Files
MikrotikManager/lib/dashboard-source-state.ts
T

13 lines
778 B
TypeScript

export const DASHBOARD_SOURCES = {
servers: "Серверы", probes: "Пробы", bgp: "BGP", gre: "GRE",
wg: "WireGuard", vxlan: "VXLAN", traffic: "Трафик",
internetPath: "Internet path", events: "События",
} as const
export type DashboardSource = keyof typeof DASHBOARD_SOURCES
export type DashboardSources = Partial<Record<DashboardSource, { receivedAt: number | null; error: string | null; sampledAt?: string }>>
export function updateDashboardSource(previous: DashboardSources, source: DashboardSource, error: string | null, now: number, sampledAt?: string): DashboardSources {
return { ...previous, [source]: { receivedAt: error ? previous[source]?.receivedAt ?? null : now, error, sampledAt: error ? previous[source]?.sampledAt : sampledAt } }
}