fix monitor types
This commit is contained in:
1 parent
7f68d23566
commit
a7fb235c56
2 files changed
+11
-17
No files matched your search
@@ -35,9 +35,12 @@ export const SelectableMonitorTypes = [
|
|||||||
export type SelectableMonitorType = (typeof SelectableMonitorTypes)[number];
|
export type SelectableMonitorType = (typeof SelectableMonitorTypes)[number];
|
||||||
|
|
||||||
// Irregular i18n key fragments shared by the type selector's label
|
// Irregular i18n key fragments shared by the type selector's label
|
||||||
// (pages.common.monitors.monitorTypes.<fragment>) and description
|
// (pages.common.monitors.monitorTypes.<fragment>), its description
|
||||||
// (pages.createMonitor.form.type.<fragment>Description) keys.
|
// (pages.createMonitor.form.type.<fragment>Description), and status page
|
||||||
export const monitorTypeLabelKey: Record<SelectableMonitorType, string> = {
|
// type labels (via getMonitorTypeLabel). Covers every type with a label;
|
||||||
|
// only selectable types have description keys.
|
||||||
|
export const monitorTypeLabelKey: Record<SelectableMonitorType, string> &
|
||||||
|
Partial<Record<MonitorType, string>> = {
|
||||||
http: "optionHttp",
|
http: "optionHttp",
|
||||||
ping: "optionPing",
|
ping: "optionPing",
|
||||||
docker: "optionDocker",
|
docker: "optionDocker",
|
||||||
@@ -46,6 +49,8 @@ export const monitorTypeLabelKey: Record<SelectableMonitorType, string> = {
|
|||||||
grpc: "optionGrpc",
|
grpc: "optionGrpc",
|
||||||
websocket: "optionWebSocket",
|
websocket: "optionWebSocket",
|
||||||
dns: "optionDns",
|
dns: "optionDns",
|
||||||
|
hardware: "optionHardware",
|
||||||
|
pagespeed: "optionPagespeed",
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MonitorIntervalOptions = [
|
export const MonitorIntervalOptions = [
|
||||||
|
|||||||
@@ -1,24 +1,13 @@
|
|||||||
|
import { monitorTypeLabelKey } from "@/Types/Monitor";
|
||||||
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
||||||
export type MonitorDisplayType = "uptime" | "infrastructure";
|
export type MonitorDisplayType = "uptime" | "infrastructure";
|
||||||
|
|
||||||
export const MONITOR_TYPE_KEYS: Partial<Record<MonitorType, string>> = {
|
|
||||||
http: "pages.common.monitors.monitorTypes.optionHttp",
|
|
||||||
ping: "pages.common.monitors.monitorTypes.optionPing",
|
|
||||||
docker: "pages.common.monitors.monitorTypes.optionDocker",
|
|
||||||
port: "pages.common.monitors.monitorTypes.optionPort",
|
|
||||||
game: "pages.common.monitors.monitorTypes.optionGame",
|
|
||||||
grpc: "pages.common.monitors.monitorTypes.optionGrpc",
|
|
||||||
websocket: "pages.common.monitors.monitorTypes.optionWebSocket",
|
|
||||||
hardware: "pages.common.monitors.monitorTypes.optionHardware",
|
|
||||||
pagespeed: "pages.common.monitors.monitorTypes.optionPagespeed",
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getMonitorTypeLabel = (
|
export const getMonitorTypeLabel = (
|
||||||
type: MonitorType,
|
type: MonitorType,
|
||||||
t: (key: string) => string
|
t: (key: string) => string
|
||||||
): string => {
|
): string => {
|
||||||
const key = MONITOR_TYPE_KEYS[type];
|
const fragment = monitorTypeLabelKey[type];
|
||||||
return key ? t(key) : type;
|
return fragment ? t(`pages.common.monitors.monitorTypes.${fragment}`) : type;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const STATUS_PAGE_THEMES = [
|
export const STATUS_PAGE_THEMES = [
|
||||||
|
|||||||
Reference in new issue
Block a user