diff --git a/frontend/src/components/monitoring/MonitoringOverview.jsx b/frontend/src/components/monitoring/MonitoringOverview.jsx index a822a756..7e2ea6a1 100644 --- a/frontend/src/components/monitoring/MonitoringOverview.jsx +++ b/frontend/src/components/monitoring/MonitoringOverview.jsx @@ -8,7 +8,7 @@ import { formatBytes } from '@/utils/formatBytes'; import { AreaChart, MetricCard, Pill, Sparkline } from '@/components/ds'; import { Button } from '@/components/ui/button'; import { Skeleton } from '../Skeleton'; -import { LiveChecks, MonitorKpi, MonitorsList } from './MonitorsSummary'; +import { LiveChecks, MonitorKpi, MonitorsList, MonitorsNotice } from './MonitorsSummary'; import { OverviewBoard, OverviewSection } from '@/components/detail/OverviewBoard'; import DiskReclaimModal from './DiskReclaimModal'; import { HOST_SCOPE, useScopeMetrics, trendOf } from './useMonitorScope'; @@ -61,6 +61,9 @@ const MONITOR_KPI_BLOCKS = [ { metric: 'degraded', labelKey: 'app.monitorsSummary.degraded', label: 'Degraded' }, ]; +// Board rows for the "nothing is watched yet" notice: a line and a button. +const NOTICE_ROWS = 3; + // Board rows for the monitor list and the live check feed: five rows of each // without scrolling. const LIST_BLOCK_ROWS = 9; @@ -228,6 +231,12 @@ export default function MonitoringOverview({ {/* 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. */} + {/* Only renders while nothing is watched (or the list failed to + load), so it leaves the layout once a monitor exists. */} + + + + {MONITOR_KPI_BLOCKS.map((block) => ( diff --git a/frontend/src/components/monitoring/MonitorsSummary.jsx b/frontend/src/components/monitoring/MonitorsSummary.jsx index 2a106a8e..428fe39a 100644 --- a/frontend/src/components/monitoring/MonitorsSummary.jsx +++ b/frontend/src/components/monitoring/MonitorsSummary.jsx @@ -86,15 +86,17 @@ export function MonitorKpi({ summary, metric }) { ); } -// The watched monitors. Also where "nothing is watched yet" -// and a failed load are said, since this is the block that would list them. -export function MonitorsList({ summary }) { +// What the monitor blocks say when there is nothing to list: no monitor exists +// yet, or the request failed. Its own short block, so an empty page is one +// line and a button rather than a tall empty list. +export function MonitorsNotice({ summary }) { const { t } = useTranslation(); const navigate = useNavigate(); const { monitors, loadError, load } = summary; + if (monitors.length) return null; // A failed fetch with nothing loaded is not "nothing is being watched". - if (loadError && !monitors.length) { + if (loadError) { return (
-
-
-

{t('app.monitorsSummary.monitors', 'Monitors')}

- {t('app.monitorsSummary.nothingIsBeingWatchedYet', 'Nothing is being watched yet')} -
- + return ( +
+
+
+

{t('app.monitorsSummary.monitors', 'Monitors')}

+ {t('app.monitorsSummary.nothingIsBeingWatchedYet', 'Nothing is being watched yet')}
-

- {t('app.monitorsSummary.everythingBelowDescribesTheMachinesServerkitShort', 'Below: the servers ServerKit runs on.')} {t('app.monitorsSummary.everythingBelowDescribesTheMachinesServerkit', 'Everything below describes the servers ServerKit runs on. Add a monitor to watch a website, an API endpoint, a database port or a WordPress site and get an incident when it stops answering.')} -

-
- ); - } + +
+

+ {t('app.monitorsSummary.everythingBelowDescribesTheMachinesServerkitShort', 'Below: the servers ServerKit runs on.')} {t('app.monitorsSummary.everythingBelowDescribesTheMachinesServerkit', 'Everything below describes the servers ServerKit runs on. Add a monitor to watch a website, an API endpoint, a database port or a WordPress site and get an incident when it stops answering.')} +

+
+ ); +} + +// The watched monitors. +export function MonitorsList({ summary }) { + const { t } = useTranslation(); + const { monitors } = summary; + if (!monitors.length) return null; return (
diff --git a/frontend/src/styles/components/_dashboard-widgets.scss b/frontend/src/styles/components/_dashboard-widgets.scss index 5d032369..b0b2866d 100644 --- a/frontend/src/styles/components/_dashboard-widgets.scss +++ b/frontend/src/styles/components/_dashboard-widgets.scss @@ -27,6 +27,8 @@ // SCSS only needs them for the responsive stack-down below. $skw-grid-gap: 12px; $skw-stack-row-h: 260px; +// A bare tile (one KPI) in the stacked layout: two to a row, this tall. +$skw-stack-tile-h: 96px; // Inspector panel width + the gutter the page reserves for it while open. @@ -1600,7 +1602,9 @@ $skw-z-tv: 200; height: auto !important; min-height: 0 !important; display: flex; - flex-direction: column; + // Wrapping rows rather than a column: a full-width widget still takes + // a row to itself, and KPI tiles can share one. + flex-flow: row wrap; gap: $skw-grid-gap; &__ghost { display: none; } @@ -1614,6 +1618,14 @@ $skw-z-tv: 200; height: $skw-stack-row-h !important; transition: none; } + + // A KPI tile does not need a chart's height or the whole width: two + // sit side by side, as tall as a count and its label. + > .skw-frame--bare { + width: calc(50% - #{$skw-grid-gap} / 2) !important; + height: auto !important; + min-height: $skw-stack-tile-h; + } } // Dragging and resizing are pointer-precision gestures; neither survives