diff --git a/backend/app/services/dashboard_service.py b/backend/app/services/dashboard_service.py index e319a0b8..fb2949b5 100644 --- a/backend/app/services/dashboard_service.py +++ b/backend/app/services/dashboard_service.py @@ -49,13 +49,17 @@ GRID_COLS = 12 # JSON per board. MAX_WIDGETS_PER_BOARD = 100 -# A board can also hold the Overview layout a user saved for one kind of -# detail page (every server page shares the user's server layout, the page's -# own server being the board's variable). It is an ordinary board row whose -# slug names the kind, so it reuses the same storage, validation and -# ownership rules; it is just never listed among the dashboard tabs. +# A board can also hold the Overview layout a user saved for a page: one kind +# of detail page (every server page shares the user's server layout, the +# page's own server being the board's variable) or a single overview page +# (Monitoring, Backups). It is an ordinary board row whose slug names the +# page, so it reuses the same storage, validation and ownership rules; it is +# just never listed among the dashboard tabs. ENTITY_SCOPE_PREFIX = 'entity:' -ENTITY_SCOPES = ('entity:server', 'entity:service') +ENTITY_SCOPES = ( + 'entity:server', 'entity:service', + 'entity:monitoring', 'entity:backups', +) DEFAULT_BOARDS = [ diff --git a/backend/tests/test_dashboards.py b/backend/tests/test_dashboards.py index e0c15366..6cc9ba81 100644 --- a/backend/tests/test_dashboards.py +++ b/backend/tests/test_dashboards.py @@ -485,11 +485,21 @@ def test_overview_layout_is_stored_but_is_not_a_dashboard_tab(client, auth_heade assert scoped[0]['widgets'] == [_widget()] -def test_overview_layout_is_empty_until_saved(client, auth_headers): - resp = client.get('/api/v1/dashboards?scope=entity:service', headers=auth_headers) +@pytest.mark.parametrize('scope', [ + 'entity:server', 'entity:service', 'entity:monitoring', 'entity:backups', +]) +def test_overview_layout_is_empty_until_saved(client, auth_headers, scope): + resp = client.get(f'/api/v1/dashboards?scope={scope}', headers=auth_headers) assert resp.status_code == 200 assert resp.get_json()['boards'] == [] + saved = client.post('/api/v1/dashboards', headers=auth_headers, json={ + 'name': 'Overview', 'scope': scope, 'widgets': [_widget()], + }) + assert saved.status_code == 201 + again = client.get(f'/api/v1/dashboards?scope={scope}', headers=auth_headers).get_json()['boards'] + assert [board['slug'] for board in again] == [scope] + def test_saving_an_overview_layout_again_replaces_it(client, auth_headers): first = client.post('/api/v1/dashboards', headers=auth_headers, json={ diff --git a/frontend/src/components/backups/BackupsOverview.jsx b/frontend/src/components/backups/BackupsOverview.jsx index 92a36172..b1ba0e59 100644 --- a/frontend/src/components/backups/BackupsOverview.jsx +++ b/frontend/src/components/backups/BackupsOverview.jsx @@ -10,6 +10,7 @@ import { formatBytes } from '@/utils/formatBytes'; import { KpiBand, MetricCard, Pill, DataTable, DataTableFooter } from '@/components/ds'; import EmptyState from '../EmptyState'; import InfoTip from '../InfoTip'; +import { OverviewBoard, OverviewSection } from '@/components/detail/OverviewBoard'; import { useTranslation } from 'react-i18next'; import { formatDuration, formatNumber } from '@/utils/intl'; @@ -100,6 +101,9 @@ const LATEST_COLUMNS = [ // reliably it has been running, where the bytes live, and what happened lately. // The archive table lives on its own Snapshots section — this page answers // "is my data safe?", not "show me every file". +// Dashboard widget types the Backups overview can carry besides its blocks. +const BACKUPS_WIDGET_TYPES = ['note']; + export default function BackupsOverview({ stats, storageConfig, costSummary, schedules = [], backups = [], onGo, storageWarning = false, }) { @@ -254,6 +258,8 @@ export default function BackupsOverview({ return (
+ + + -
+
@@ -342,7 +349,9 @@ export default function BackupsOverview({ ))}
+
+

{t('app.backupsOverview.recentActivity', 'Recent activity')}

@@ -378,9 +387,9 @@ export default function BackupsOverview({
)}
-
+ -
+

{t('app.backupsOverview.storageDestinations', 'Storage destinations')}

@@ -420,7 +429,9 @@ export default function BackupsOverview({

)}
+
+

{t('app.backupsOverview.latestSnapshots', 'Latest backups')}

@@ -447,7 +458,8 @@ export default function BackupsOverview({ /> )}
-
+ +
); } diff --git a/frontend/src/components/detail/OverviewBoard.jsx b/frontend/src/components/detail/OverviewBoard.jsx index a60ba9fc..8867b875 100644 --- a/frontend/src/components/detail/OverviewBoard.jsx +++ b/frontend/src/components/detail/OverviewBoard.jsx @@ -1,7 +1,7 @@ import { Children, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { createPortal } from 'react-dom'; import { useNavigate, useSearchParams } from 'react-router-dom'; -import { Grid2x2, History, LayoutGrid, Plus } from 'lucide-react'; +import { Grid2x2, History, LayoutGrid, Plus, SlidersHorizontal } from 'lucide-react'; import { useTranslation } from 'react-i18next'; import api from '@/services/api'; import { useAuth } from '@/contexts/useAuth'; @@ -91,12 +91,17 @@ function SectionWidget({ widget, ctx }) { const NO_WIDGET_TYPES = []; const NO_LEADING_WIDGETS = []; +// kind what the layout is for: 'server' / 'service' (one layout shared +// by every page of that kind) or a page such as 'monitoring' +// shared true when `kind` covers many pages, so editing says so +// serverVar what dashboard widgets bound to `$server` should read // widgetTypes ids of dashboard widget types offered on this board // leading dashboard widgets placed ahead of the sections in the default // layout: [{ type, w, h, cfg }], h in board rows // Pass both as module-level constants: they define the board, they are not state. export function OverviewBoard({ - kind, entityId, entityLabel, widgetTypes = NO_WIDGET_TYPES, leading = NO_LEADING_WIDGETS, children, + kind, entityId, entityLabel, shared = false, serverVar, + widgetTypes = NO_WIDGET_TYPES, leading = NO_LEADING_WIDGETS, children, }) { const sections = Children.toArray(children).filter(isValidElement).map((child) => child.props); return ( @@ -105,6 +110,8 @@ export function OverviewBoard({ kind={kind} entityId={entityId} entityLabel={entityLabel} + shared={shared} + serverVar={serverVar} widgetTypeIds={widgetTypes} leading={leading} sections={sections} @@ -112,7 +119,7 @@ export function OverviewBoard({ ); } -function OverviewBoardInner({ kind, entityId, entityLabel, widgetTypeIds, leading, sections }) { +function OverviewBoardInner({ kind, entityId, entityLabel, shared, serverVar, widgetTypeIds, leading, sections }) { const { t } = useTranslation(); const toast = useToast(); const navigate = useNavigate(); @@ -365,8 +372,8 @@ function OverviewBoardInner({ kind, entityId, entityLabel, widgetTypeIds, leadin const ctx = useMemo(() => ({ range: BOARD_RANGE, tick, - // Dashboard widgets bound to `$server` read this page's server. - serverVar: kind === 'server' ? entityId : undefined, + // What dashboard widgets bound to `$server` read on this page. + serverVar, isAdmin, navigate, types, @@ -375,12 +382,12 @@ function OverviewBoardInner({ kind, entityId, entityLabel, widgetTypeIds, leadin adoptVersion, releaseSection, emptyLabel: t('app.overviewBoard.nothingToShow', 'Nothing to show here right now.'), - }), [tick, kind, entityId, isAdmin, navigate, types, adoptVersion, releaseSection, t]); + }), [tick, kind, entityId, serverVar, isAdmin, navigate, types, adoptVersion, releaseSection, t]); // Page blocks already on the board are not offered again. const placedSections = new Set(widgets.filter(isSectionWidget).map((widget) => widget.cfg?.section)); const libraryTypes = types.filter((type) => !type.section || !placedSections.has(type.section)); - const resources = kind === 'server' ? [{ id: entityId, label: entityLabel || String(entityId), kind: 'server' }] : []; + const resources = serverVar ? [{ id: serverVar, label: entityLabel || String(serverVar), kind: 'server' }] : []; return (
@@ -399,7 +406,9 @@ function OverviewBoardInner({ kind, entityId, entityLabel, widgetTypeIds, leadin
-
)} @@ -417,6 +426,15 @@ function OverviewBoardInner({ kind, entityId, entityLabel, widgetTypeIds, leadin /> )} + {/* A quiet way in, under the blocks it rearranges. */} + {!edit && board !== undefined && ( +
+ +
+ )} + {edit && } {edit && libraryOpen && ( diff --git a/frontend/src/components/monitoring/MonitoringOverview.jsx b/frontend/src/components/monitoring/MonitoringOverview.jsx index 168ab1c5..d8564ca5 100644 --- a/frontend/src/components/monitoring/MonitoringOverview.jsx +++ b/frontend/src/components/monitoring/MonitoringOverview.jsx @@ -9,6 +9,7 @@ import { AreaChart, KpiBand, MetricCard, Pill, Sparkline } from '@/components/ds import { Button } from '@/components/ui/button'; import { Skeleton } from '../Skeleton'; import MonitorsSummary from './MonitorsSummary'; +import { OverviewBoard, OverviewSection } from '@/components/detail/OverviewBoard'; import DiskReclaimModal from './DiskReclaimModal'; import { HOST_SCOPE, useScopeMetrics, trendOf } from './useMonitorScope'; import { useTranslation } from 'react-i18next'; @@ -45,6 +46,9 @@ function last(series) { // the Host health grid below is how you switch between them. That grid is what // the standalone Fleet Monitor page used to be — a heatmap you had to leave // this page to read, for numbers that belong next to these ones. +// Dashboard widget types the Monitoring overview can carry besides its blocks. +const MONITORING_WIDGET_TYPES = ['stat', 'gauge', 'timeseries', 'specs', 'note']; + export default function MonitoringOverview({ scope, isHost, scopeLabel, status, activeAlerts = [], speedTest, speedTestRunning, onRunSpeedTest, @@ -195,16 +199,21 @@ export default function MonitoringOverview({ return (
+ {/* Monitors first: "is the site up" is the question this page is for, and everything below describes the machines ServerKit runs on rather than the things it is watching. */} - - -
-

{t('app.monitoringOverview.hostHealth', 'Host health')}

- {scopeLabel} -
+ + + + {/* The shared DS tile, not a monitoring-only copy of it — same geometry as every other KPI strip in the panel, plus the sparkline slot this page needed. */} @@ -258,8 +267,9 @@ export default function MonitoringOverview({ ); })} + -
+
@@ -283,7 +293,9 @@ export default function MonitoringOverview({
+
+
@@ -303,16 +315,13 @@ export default function MonitoringOverview({ />
-
+ {/* The fleet, inline. Clicking a card re-scopes everything above it, which is the whole reason this replaced a separate page. */} + {!fleetLoaded && (
-
-

{t('app.monitoringOverview.allHosts', 'All hosts')}

- -
@@ -320,12 +329,9 @@ export default function MonitoringOverview({ )} {fleet.length > 0 && ( <> -
-

{t('app.monitoringOverview.allHosts', 'All hosts')}

- - {online}/{fleet.length} {t('app.monitoringOverview.onlineClickACardToRe', 'online · click a card to re-scope')} - -
+

+ {online}/{fleet.length} {t('app.monitoringOverview.onlineClickACardToRe', 'online · click a card to re-scope')} +

{/* Always the panel host's own numbers, never the scoped ones — a card in this strip has to keep @@ -359,8 +365,9 @@ export default function MonitoringOverview({
)} + -
+

{t('app.monitoringOverview.activeAlerts', 'Active alerts')}

@@ -385,7 +392,9 @@ export default function MonitoringOverview({
)}
+
+

{t('app.monitoringOverview.speedTest', 'Speed test')}

@@ -429,7 +438,8 @@ export default function MonitoringOverview({

)}
-
+ + setReclaimOpen(false)} />
diff --git a/frontend/src/components/serverdetail/ServerOverviewTab.jsx b/frontend/src/components/serverdetail/ServerOverviewTab.jsx index 2002811c..d8775652 100644 --- a/frontend/src/components/serverdetail/ServerOverviewTab.jsx +++ b/frontend/src/components/serverdetail/ServerOverviewTab.jsx @@ -113,8 +113,10 @@ const ServerOverviewTab = ({ server, metrics, systemInfo, onRefreshServer }) => )} diff --git a/frontend/src/components/service-detail/OverviewTab.jsx b/frontend/src/components/service-detail/OverviewTab.jsx index 93800c61..0ce6110b 100644 --- a/frontend/src/components/service-detail/OverviewTab.jsx +++ b/frontend/src/components/service-detail/OverviewTab.jsx @@ -118,7 +118,7 @@ const OverviewTab = ({ app, deployConfig }) => { return (
- +

{t('app.overviewTab.serviceInfo', 'Service info')}

diff --git a/frontend/src/i18n/locales/en.json b/frontend/src/i18n/locales/en.json index 2bdff220..a07a6c04 100644 --- a/frontend/src/i18n/locales/en.json +++ b/frontend/src/i18n/locales/en.json @@ -768,6 +768,7 @@ "acrossDestinations_one": "across 1 destination", "acrossDestinations_other": "across {{count}} destinations", "allSnapshots": "All backups", + "atAGlance": "At a glance", "backupActivity": "Backup activity", "backupCompleted": "Backup completed ·", "backupFailed": "Couldn't back up ·", @@ -4113,6 +4114,7 @@ "memoryDisk": "Memory and disk", "memoryUsage": "Memory usage", "monitor": "Monitor {{name}}", + "monitors": "Monitors", "noHistoryYetForThisHost": "No history yet for this host. Samples are collected on the monitoring interval.", "noSpeedTestYetRunOne": "No speed test yet. Run one to measure this server's connection.", "nothingIsOverItsLimitRight": "Nothing is over its limit right now.", @@ -4396,6 +4398,7 @@ "discardMessage": "Your saved overview layout stays as it was.", "discardTitle": "Discard layout changes?", "editHint": "Drag headers to move · drag the corner to resize · this layout applies to every {{kind}} page for your account", + "editHintPage": "Drag headers to move · drag the corner to resize · saved to your account", "editLayout": "Edit overview layout", "nothingToShow": "Nothing to show here right now.", "restoreDefault": "Restore default layout", @@ -7340,6 +7343,7 @@ "searchPackages": "Search packages…", "searchRightMostTheTabStrip": ", search right-most. The tab strip is the heading, so there is no title to repeat.", "secondary": "Secondary", + "sections": "Style guide sections", "securityTabContent": "Security tab content.", "selectDropdown": "Select dropdown", "selectTextarea": "Select and textarea", diff --git a/frontend/src/styles/components/_detail-page.scss b/frontend/src/styles/components/_detail-page.scss index a11646c9..ac307afa 100644 --- a/frontend/src/styles/components/_detail-page.scss +++ b/frontend/src/styles/components/_detail-page.scss @@ -172,6 +172,30 @@ .skw-barbtn { height: $control-md; } } + + // "Edit overview layout", under the blocks. + &__foot { + display: flex; + justify-content: flex-end; + margin-block-start: $space-3; + } + + &__edit { + display: inline-flex; + align-items: center; + gap: $space-tight; + height: $control-sm; + padding: 0 $space-2; + border: 0; + border-radius: $radius-control; + background: transparent; + color: var(--text-ghost); + font-size: $text-xs; + font-family: inherit; + cursor: pointer; + + &:hover { color: var(--text); background: var(--surface-2); } + } } // A page block inside a widget frame: it fills the frame and scrolls when the @@ -194,7 +218,9 @@ // drops its own. &__host { > .overview-tab__card, - > .scheduled-tasks-card { + > .scheduled-tasks-card, + > .monitoring-panel, + > .bk-panel { padding: 0; border: 0; border-radius: 0; @@ -204,7 +230,17 @@ .overview-tab__card > .overview-tab__card-title, .overview-tab__card-header-row > .overview-tab__card-title, .system-status-card__title > h3, - .scheduled-tasks-card__header { display: none; } + .scheduled-tasks-card__header, + > .monitoring-panel > .monitoring-panel__header h3, + > .bk-panel > .bk-panel__head h3 { display: none; } + + // With the title gone, what is left of a panel's head (a count, a + // link, a button) sits on the right, where it sat beside the title. + > .monitoring-panel > .monitoring-panel__header > h3 + *, + > .bk-panel > .bk-panel__head > h3 + * { margin-inline-start: auto; } + // A head that held nothing but its title goes with it. + > .bk-panel > .bk-panel__head:not(:has(> :not(h3))), + > .monitoring-panel > .monitoring-panel__header:not(:has(> :not(h3))) { display: none; } // A header row keeps its action (Attach, a state pill) on the right. .overview-tab__card-header-row { justify-content: flex-end; } @@ -215,6 +251,15 @@ } } +// Monitoring styles its panels under its own page class, which outranks the +// plain reset above; scoping to the board puts the reset back on top. +.sk-overview-board .sk-overview-section__host > .monitoring-panel { + padding: 0; + border: 0; + border-radius: 0; + background: none; +} + // Settings shell: grouped left nav + content column. .sk-detail-settings { display: grid; diff --git a/frontend/tests/layout-baselines/monitoring-1440.png b/frontend/tests/layout-baselines/monitoring-1440.png index 6da9022d..90dd17ab 100644 Binary files a/frontend/tests/layout-baselines/monitoring-1440.png and b/frontend/tests/layout-baselines/monitoring-1440.png differ diff --git a/frontend/tests/layout-baselines/monitoring-390.png b/frontend/tests/layout-baselines/monitoring-390.png index a9b6f311..d6feb89b 100644 Binary files a/frontend/tests/layout-baselines/monitoring-390.png and b/frontend/tests/layout-baselines/monitoring-390.png differ diff --git a/frontend/tests/layout-baselines/monitoring-768.png b/frontend/tests/layout-baselines/monitoring-768.png index 5517fa2f..910b1d73 100644 Binary files a/frontend/tests/layout-baselines/monitoring-768.png and b/frontend/tests/layout-baselines/monitoring-768.png differ