Skip to content

armgit / Pulse

Public Imported from GitHub
0

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.

1013 B
Raw Blame
import type { SourceType } from '@/types/resource';

export interface SourceTypePresentation {
  label: string;
  badgeClasses: string;
}

const SOURCE_TYPE_PRESENTATION: Record<SourceType, SourceTypePresentation> = {
  agent: {
    label: 'Agent',
    badgeClasses: 'bg-emerald-100 text-emerald-700 dark:bg-emerald-900/25 dark:text-emerald-400',
  },
  api: {
    label: 'API',
    badgeClasses: 'bg-blue-100 text-blue-700 dark:bg-blue-900/25 dark:text-blue-400',
  },
  hybrid: {
    label: 'Hybrid',
    badgeClasses: 'bg-teal-100 text-teal-700 dark:bg-teal-900/25 dark:text-teal-400',
  },
};

export const getSourceTypePresentation = (
  sourceType?: SourceType | string | null,
): SourceTypePresentation | null => {
  if (!sourceType) return null;
  return SOURCE_TYPE_PRESENTATION[sourceType as SourceType] || null;
};

export const getSourceTypeLabel = (sourceType?: SourceType | string | null): string | null =>
  getSourceTypePresentation(sourceType)?.label || (sourceType ? String(sourceType) : null);