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.

3.2 KB
Raw Blame
import { Component, Show } from 'solid-js';
import { HistoryLockPlanLink } from './HistoryLockPlanLink';
import { LoadingSpinner } from './LoadingSpinner';
import type { HistoryChartState } from './useHistoryChartState';

interface HistoryChartOverlayProps {
  chart: HistoryChartState;
  hideLock?: boolean;
}

export const HistoryChartOverlay: Component<HistoryChartOverlayProps> = (props) => {
  return (
    <>
      <Show
        when={!props.chart.loading() && props.chart.data().length === 0 && !props.chart.error()}
      >
        <div class="absolute inset-0 flex items-center justify-center bg-surface">
          <div class="text-center">
            <div class="text-slate-400 mb-2">
              <svg
                xmlns="http://www.w3.org/2000/svg"
                width="32"
                height="32"
                viewBox="0 0 24 24"
                fill="none"
                stroke="currentColor"
                stroke-width="2"
                stroke-linecap="round"
                stroke-linejoin="round"
                class="mx-auto"
              >
                <path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" />
                <path d="M3 3v5h5" />
                <path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16" />
                <path d="M16 16l5 5" />
                <path d="M21 21v-5h-5" />
              </svg>
            </div>
            <p class="text-sm text-slate-500">No history samples in this time range.</p>
          </div>
        </div>
      </Show>

      <Show when={props.chart.loading()}>
        <div class="absolute inset-0 flex items-center justify-center bg-surface -[1px]">
          <LoadingSpinner size="xl" tone="info" label="Loading history" />
        </div>
      </Show>

      <Show when={props.chart.error()}>
        <div class="absolute inset-0 flex items-center justify-center">
          <p role="alert" class="px-3 text-center text-sm text-red-500">
            {props.chart.error()}
          </p>
        </div>
      </Show>

      <Show when={props.chart.isLocked() && !props.hideLock}>
        <div class="absolute inset-0 z-10 flex flex-col items-center justify-center bg-surface rounded-md">
          <div class="bg-indigo-500 rounded-full p-3 shadow-xs mb-3">
            <svg
              xmlns="http://www.w3.org/2000/svg"
              width="24"
              height="24"
              viewBox="0 0 24 24"
              fill="none"
              stroke="white"
              stroke-width="2"
              stroke-linecap="round"
              stroke-linejoin="round"
            >
              <rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect>
              <path d="M7 11V7a5 5 0 0 1 10 0v4"></path>
            </svg>
          </div>
          <h3 class="text-lg font-bold text-base-content mb-1">
            {props.chart.lockDays()}-Day History
          </h3>
          <p class="text-sm text-muted text-center max-w-[220px] mb-4">
            Historical data beyond {props.chart.lockDays()} days requires a higher license plan.
          </p>
          <HistoryLockPlanLink class="text-sm font-medium text-blue-600 hover:underline dark:text-blue-400" />
        </div>
      </Show>
    </>
  );
};