mirror of
https://github.com/jhd3197/ServerKit.git
synced 2026-12-01 20:55:16 +09:00
Keep KPI tiles compact when the board stacks
Below tablet width every block stacks full width at a chart's height, which turned each one-number tile into a tall empty card. Tiles now sit two to a row at their own height. The "nothing is watched yet" notice is its own short block, so a page with no monitors is a line and a button instead of a tall empty list beside the host tiles.
This commit is contained in:
1 parent
4ba740a12d
commit
8453631d99
3 files changed
+51
-23
No files matched your search
@@ -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. */}
|
||||
<OverviewSection id="monitor-notice" title={t('app.monitoringOverview.monitors', 'Monitors')} replaces="monitors" w={12} h={NOTICE_ROWS}>
|
||||
<MonitorsNotice summary={monitorsSummary} />
|
||||
</OverviewSection>
|
||||
|
||||
{MONITOR_KPI_BLOCKS.map((block) => (
|
||||
<OverviewSection key={block.metric} id={`monitor-${block.metric}`} title={translateLabel(t, block)} tile replaces="monitors" w={3} h={KPI_TILE_ROWS}>
|
||||
<MonitorKpi summary={monitorsSummary} metric={block.metric} />
|
||||
|
||||
@@ -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 (
|
||||
<section className="monitoring-panel mon-nomonitors">
|
||||
<ErrorState
|
||||
@@ -107,24 +109,29 @@ export function MonitorsList({ summary }) {
|
||||
);
|
||||
}
|
||||
|
||||
if (!monitors.length) {
|
||||
return (
|
||||
<section className="monitoring-panel mon-nomonitors">
|
||||
<div className="monitoring-panel__header">
|
||||
<div>
|
||||
<h3>{t('app.monitorsSummary.monitors', 'Monitors')}</h3>
|
||||
<span className="mon-panel-sub">{t('app.monitorsSummary.nothingIsBeingWatchedYet', 'Nothing is being watched yet')}</span>
|
||||
</div>
|
||||
<Button size="sm" onClick={() => navigate('/monitoring/monitors')}>
|
||||
<Plus size={14} /> {t('app.monitorsSummary.addMonitor', 'New monitor')}
|
||||
</Button>
|
||||
return (
|
||||
<section className="monitoring-panel mon-nomonitors">
|
||||
<div className="monitoring-panel__header">
|
||||
<div>
|
||||
<h3>{t('app.monitorsSummary.monitors', 'Monitors')}</h3>
|
||||
<span className="mon-panel-sub">{t('app.monitorsSummary.nothingIsBeingWatchedYet', 'Nothing is being watched yet')}</span>
|
||||
</div>
|
||||
<p className="mon-panel-hint">
|
||||
{t('app.monitorsSummary.everythingBelowDescribesTheMachinesServerkitShort', 'Below: the servers ServerKit runs on.')} <InfoTip>{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.')}</InfoTip>
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
<Button size="sm" onClick={() => navigate('/monitoring/monitors')}>
|
||||
<Plus size={14} /> {t('app.monitorsSummary.addMonitor', 'New monitor')}
|
||||
</Button>
|
||||
</div>
|
||||
<p className="mon-panel-hint">
|
||||
{t('app.monitorsSummary.everythingBelowDescribesTheMachinesServerkitShort', 'Below: the servers ServerKit runs on.')} <InfoTip>{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.')}</InfoTip>
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
// The watched monitors.
|
||||
export function MonitorsList({ summary }) {
|
||||
const { t } = useTranslation();
|
||||
const { monitors } = summary;
|
||||
if (!monitors.length) return null;
|
||||
|
||||
return (
|
||||
<section className="monitoring-panel">
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user