Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
import type { StatusIndicatorVariant } from '@/utils/status';
import type { RelayConfig, RelayStatus } from '@/api/relay';
export interface RelayConnectionPresentation {
variant: StatusIndicatorVariant;
label: string;
pulse: boolean;
}
const RELAY_MISSING_TOKEN_ERROR =
/\b(?:no license token available|license token provider not configured)\b/i;
export const RELAY_READONLY_NOTICE_CLASS =
'border border-blue-200 text-xs text-blue-800 dark:border-blue-800 dark:text-blue-200';
export const RELAY_PRIMARY_BUTTON_CLASS =
'min-h-10 sm:min-h-10 px-3 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md disabled:opacity-50';
export const RELAY_PRIMARY_LINK_CLASS =
'w-full sm:w-auto min-h-10 text-center sm:min-h-9 px-5 py-2.5 text-sm font-semibold bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors';
export const RELAY_SECONDARY_BUTTON_CLASS =
'min-h-10 sm:min-h-10 px-3 py-2 text-sm font-medium text-base-content bg-surface-hover hover:bg-surface-hover rounded-md disabled:opacity-50';
export const RELAY_INLINE_ACTION_CLASS =
'text-sm text-indigo-500 hover:underline disabled:opacity-50';
export const RELAY_INFO_TITLE_CLASS = 'text-sm font-medium text-base-content';
export const RELAY_INFO_MESSAGE_CLASS = 'text-xs text-muted mt-1';
export const RELAY_LAST_ERROR_CLASS =
'mt-2 text-xs text-red-600 dark:text-red-400 bg-red-50 dark:bg-red-900/25 rounded-sm px-2 py-1';
export const RELAY_CODE_BLOCK_CLASS =
'block text-xs font-mono text-base-content bg-surface-alt rounded-sm px-3 py-2 select-all break-all';
export const RELAY_QR_IMAGE_CLASS = 'rounded-md border border-border p-2';
export const RELAY_DIAGNOSTICS_WRAP_CLASS = 'space-y-2';
export const RELAY_DIAGNOSTICS_TITLE_CLASS = 'text-xs font-semibold text-base-content';
export const RELAY_SETTINGS_DESCRIPTION =
'Connect paired Pulse Mobile devices to this instance. Pulse Mobile is being retired on 31 March 2027, and paired phones keep working until then.';
export const RELAY_LICENSE_REQUIRED_MESSAGE =
'Pulse Mobile is being retired on 31 March 2027 and is no longer part of new plans. For alerts on your phone, add an ntfy, Gotify, or Pushover destination under Alerts.';
export const RELAY_PAIRING_AVAILABILITY_TITLE = 'Pair Pulse Mobile';
export const RELAY_PAIRING_AVAILABILITY_MESSAGE =
'Install the Pulse Mobile app on your phone, then scan a QR code or open a deep link here to securely link it to this Pulse instance. Paired devices receive alert push notifications over an end-to-end encrypted connection until Pulse Mobile is retired on 31 March 2027.';
export const RELAY_ENABLE_HELP_TEXT =
'Open a secure outbound connection so paired Pulse Mobile devices can reach this instance from anywhere. No inbound ports needed.';
export const RELAY_ACTIVATION_REQUIRED_LABEL = 'Activation required';
export const RELAY_ACTIVATION_REQUIRED_MESSAGE =
'Pulse Mobile connections are on, but this instance does not have an active Relay token. Refresh your plan, or turn Pulse Mobile connections off before pairing phones.';
export const RELAY_PAIRING_APP_AVAILABILITY_TEXT =
'Pulse Mobile stays available for iOS and Android until 31 March 2027. To get the install links, enter your activation key on';
export const RELAY_PAIRING_APP_DOWNLOAD_LINK_LABEL = 'your download page';
export function getRelayDiagnosticClass(severity: 'warning' | 'error'): string {
return severity === 'error'
? 'rounded-sm px-2 py-1 text-xs bg-red-50 dark:bg-red-900/25 text-red-700 dark:text-red-300'
: 'rounded-sm px-2 py-1 text-xs bg-amber-50 dark:bg-amber-900/25 text-amber-700 dark:text-amber-300';
}
export function getRelayConnectionPresentation(
config?: RelayConfig | null,
status?: RelayStatus | null,
): RelayConnectionPresentation {
if (!config?.enabled) {
return {
variant: 'muted',
label: 'Not enabled',
pulse: false,
};
}
if (status?.connected) {
return {
variant: 'success',
label: 'Connected',
pulse: true,
};
}
if (isRelayMissingTokenError(status?.last_error)) {
return {
variant: 'danger',
label: RELAY_ACTIVATION_REQUIRED_LABEL,
pulse: false,
};
}
return {
variant: 'danger',
label: 'Disconnected',
pulse: false,
};
}
export function getRelayStatusErrorMessage(status?: RelayStatus | null): string | null {
const error = status?.last_error?.trim();
if (!error) {
return null;
}
if (isRelayMissingTokenError(error)) {
return RELAY_ACTIVATION_REQUIRED_MESSAGE;
}
return error;
}
function isRelayMissingTokenError(error?: string | null): boolean {
return RELAY_MISSING_TOKEN_ERROR.test(error ?? '');
}