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];
|
||||
|
||||
// Irregular i18n key fragments shared by the type selector's label
|
||||
// (pages.common.monitors.monitorTypes.<fragment>) and description
|
||||
// (pages.createMonitor.form.type.<fragment>Description) keys.
|
||||
export const monitorTypeLabelKey: Record<SelectableMonitorType, string> = {
|
||||
// (pages.common.monitors.monitorTypes.<fragment>), its description
|
||||
// (pages.createMonitor.form.type.<fragment>Description), and status page
|
||||
// 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",
|
||||
ping: "optionPing",
|
||||
docker: "optionDocker",
|
||||
@@ -46,6 +49,8 @@ export const monitorTypeLabelKey: Record<SelectableMonitorType, string> = {
|
||||
grpc: "optionGrpc",
|
||||
websocket: "optionWebSocket",
|
||||
dns: "optionDns",
|
||||
hardware: "optionHardware",
|
||||
pagespeed: "optionPagespeed",
|
||||
};
|
||||
|
||||
export const MonitorIntervalOptions = [
|
||||
|
||||
@@ -1,24 +1,13 @@
|
||||
import { monitorTypeLabelKey } from "@/Types/Monitor";
|
||||
import type { Monitor, MonitorType } from "@/Types/Monitor";
|
||||
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 = (
|
||||
type: MonitorType,
|
||||
t: (key: string) => string
|
||||
): string => {
|
||||
const key = MONITOR_TYPE_KEYS[type];
|
||||
return key ? t(key) : type;
|
||||
const fragment = monitorTypeLabelKey[type];
|
||||
return fragment ? t(`pages.common.monitors.monitorTypes.${fragment}`) : type;
|
||||
};
|
||||
|
||||
export const STATUS_PAGE_THEMES = [
|
||||
|
||||
Reference in new issue
Block a user