mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-21 23:56:39 +00:00
d7d8f9bfe8
* feat(dashboard): replace 24h charts with Configuration Status and Recent Activity The 24-hour CPU/Memory area charts summed per-container metrics normalized to each container's CPU quota, producing numbers that bore no honest relationship to host load. The live ResourceGauges strip already shows accurate host-level stats, making the historical charts both inaccurate and redundant. This commit replaces that row with two side-by-side cards: - **Configuration Status**: aggregates every toggleable feature on the active node (notification agents, alert rules, routing rules, auto-heal, auto-update, webhooks, scheduled tasks, MFA, SSO, vulnerability scanning, cloud backup, and alert thresholds) into a single at-a-glance card. Tier-locked rows display an upgrade indicator instead of a value. Each row is clickable and navigates to the relevant settings section. Data refreshes every 60 s and immediately on state-invalidate events. - **Recent Activity**: lists the ten most recent notification-history events for the active node (deployments, image updates, auto-heal actions, scan findings, cloud backup events, system notices) with category icons and relative timestamps. Refreshes every 30 s. New backend endpoints: - GET /api/dashboard/configuration - per-node feature status with locked/ requiredTier markers so the frontend renders upgrade chips without extra calls. The endpoint sits after authGate and before the remote proxy so remote-node requests are transparently forwarded. - GET /api/dashboard/recent-activity?limit=N - thin wrapper over DatabaseService.getNotificationHistory. - GET /api/fleet/configuration - fleet-wide fan-out using the same Promise.allSettled dead-node-tolerant pattern as /fleet/overview. Exposed as the new "Status" tab on the Fleet page (after Snapshots). Shared utilities: - visibilityInterval and formatCount extracted to frontend/src/lib/utils.ts so the three polling hooks and two components share a single copy. * docs(dashboard): fix stale alt text referencing removed historical charts
67 lines
1.8 KiB
TypeScript
67 lines
1.8 KiB
TypeScript
import { useNodes } from '@/context/NodeContext';
|
|
import type { NotificationItem } from './dashboard/types';
|
|
import type { SectionId } from './settings/types';
|
|
import {
|
|
HealthStatusBar,
|
|
ResourceGauges,
|
|
StackHealthTable,
|
|
ConfigurationStatus,
|
|
RecentActivity,
|
|
RecentAlerts,
|
|
useDashboardData,
|
|
} from './dashboard';
|
|
|
|
interface HomeDashboardProps {
|
|
onNavigateToStack?: (stackFile: string) => void;
|
|
notifications: NotificationItem[];
|
|
onClearNotifications: () => void | Promise<void>;
|
|
onOpenSettings?: (section: SectionId) => void;
|
|
}
|
|
|
|
const NOOP = () => {};
|
|
|
|
export default function HomeDashboard({ onNavigateToStack, notifications, onClearNotifications, onOpenSettings }: HomeDashboardProps) {
|
|
const { activeNode, nodes } = useNodes();
|
|
const data = useDashboardData();
|
|
const activeNodeName = activeNode?.name || 'Local';
|
|
|
|
return (
|
|
<div className="flex-1 p-6 space-y-4">
|
|
<HealthStatusBar
|
|
stats={data.stats}
|
|
systemStats={data.systemStats}
|
|
notifications={notifications}
|
|
activeNodeName={activeNodeName}
|
|
nodeCount={data.nodeCount}
|
|
lastSyncAt={data.lastSyncAt}
|
|
/>
|
|
|
|
<ResourceGauges
|
|
systemStats={data.systemStats}
|
|
cpuHistory={data.cpuHistory}
|
|
netHistory={data.netHistory}
|
|
historyEndAt={data.historyEndAt}
|
|
/>
|
|
|
|
<StackHealthTable
|
|
stackStatuses={data.stackStatuses}
|
|
metrics={data.metrics}
|
|
stackCpuSeries={data.stackCpuSeries}
|
|
activeNodeName={activeNodeName}
|
|
onNavigateToStack={onNavigateToStack ?? NOOP}
|
|
/>
|
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-4">
|
|
<ConfigurationStatus onOpenSettings={onOpenSettings} />
|
|
<RecentActivity />
|
|
</div>
|
|
|
|
<RecentAlerts
|
|
notifications={notifications}
|
|
nodes={nodes}
|
|
onCleared={onClearNotifications}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|