ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(dashboard): one control row, and the clock becomes a widget
Juan Denis500a21761896
diff --git a/backend/tests/test_dashboards.py b/backend/tests/test_dashboards.pyindex 2c5b9680..564eceeb 100644--- a/backend/tests/test_dashboards.py+++ b/backend/tests/test_dashboards.py@@ -323,6 +323,7 @@ RENDERER_CFG_KEYS = {'feed': {'required': set(), 'known': {'limit', 'title'}},'actions': {'required': {'items'}, 'known': {'items', 'title'}},'specs': {'required': {'resource'}, 'known': {'resource', 'title'}},+ 'clock': {'required': set(), 'known': {'timezone', 'showDate', 'showSeconds', 'title'}},'note': {'required': set(), 'known': {'text', 'title'}},}diff --git a/frontend/src/components/dashboard/widgets/registry.js b/frontend/src/components/dashboard/widgets/registry.jsindex 568320a4..b2d60f1d 100644--- a/frontend/src/components/dashboard/widgets/registry.js+++ b/frontend/src/components/dashboard/widgets/registry.js@@ -13,6 +13,7 @@ import {BarChart3,CheckCircle2,CircleDashed,+ Clock,Cpu,FileText,History,@@ -218,6 +219,22 @@ export const CORE_WIDGET_TYPES = [resource: '$server',},},+ {+ id: 'clock',+ name: 'Clock',+ icon: Clock,+ cat: 'Utility',+ desc: 'Current time, for a wall display or a second timezone',+ w: 3,+ h: 2,+ min: [2, 2],+ defaultCfg: {+ title: '',+ timezone: '',+ showDate: true,+ showSeconds: true,+ },+ },{id: 'note',name: 'Text note',diff --git a/frontend/src/components/dashboard/widgets/renderers.jsx b/frontend/src/components/dashboard/widgets/renderers.jsxindex 46937784..0f2b50d7 100644--- a/frontend/src/components/dashboard/widgets/renderers.jsx+++ b/frontend/src/components/dashboard/widgets/renderers.jsx@@ -6,7 +6,7 @@* may throw: `WidgetBody` wraps each one in a boundary so one bad widget can* never take the grid down with it.*/-import { Component, useEffect, useId, useMemo, useRef } from 'react';+import { Component, useEffect, useId, useMemo, useRef, useState } from 'react';import {Activity,Archive,@@ -760,6 +760,53 @@ function WNote({ cfg }) {/* --------------------------------------------------------------- dispatch */+/* ------------------------------------------------------------------- clock */++/**+ * Wall clock. Ticks locally rather than polling: the time between two server+ * samples is not interesting, and a widget that re-fetches every second to+ * print a number the browser already knows would be silly.+ *+ * `cfg.timezone` is an IANA name; empty means this browser's zone.+ */+function WClock({ cfg }) {+ const [now, setNow] = useState(() => new Date());++ useEffect(() => {+ const id = setInterval(() => setNow(new Date()), 1000);+ return () => clearInterval(id);+ }, []);++ const zone = cfg.timezone || undefined;+ let time;+ let date;+ let label;+ try {+ time = new Intl.DateTimeFormat('en-GB', {+ hour: '2-digit',+ minute: '2-digit',+ ...(cfg.showSeconds === false ? {} : { second: '2-digit' }),+ hour12: false,+ timeZone: zone,+ }).format(now);+ date = new Intl.DateTimeFormat('en-GB', {+ weekday: 'short', day: 'numeric', month: 'short', timeZone: zone,+ }).format(now);+ label = zone || Intl.DateTimeFormat().resolvedOptions().timeZone || '';+ } catch {+ // An invalid IANA name should not blank the widget.+ return <Empty>{`Unknown timezone “${cfg.timezone}”.`}</Empty>;+ }++ return (+ <div className="skw-clock">+ <div className="skw-clock__time mono">{time}</div>+ {cfg.showDate !== false && <div className="skw-clock__date">{date}</div>}+ <div className="skw-clock__zone mono">{label.replace(/_/g, ' ')}</div>+ </div>+ );+}+const CORE_RENDERERS = {stat: WStat,timeseries: WTimeseries,@@ -773,6 +820,7 @@ const CORE_RENDERERS = {feed: WFeed,actions: WActions,specs: WSpecs,+ clock: WClock,note: WNote,};diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsxindex e2c90e58..bd5db654 100644--- a/frontend/src/pages/Dashboard.jsx+++ b/frontend/src/pages/Dashboard.jsx@@ -32,15 +32,6 @@ const REFRESH_OPTIONS = [{ label: '1m', value: 60 },];-function formatUptime(seconds) {- if (!seconds) return { days: 0, hours: 0, minutes: 0 };- return {- days: Math.floor(seconds / 86400),- hours: Math.floor((seconds % 86400) / 3600),- minutes: Math.floor((seconds % 3600) / 60),- };-}-const Dashboard = () => {const navigate = useNavigate();const { isAdmin } = useAuth();@@ -292,11 +283,13 @@ const Dashboard = () => {};// ---- derived display ---------------------------------------------------+ // IP, kernel and uptime used to live in a header strip above the board.+ // That strip is gone — the controls are one row now — and those facts are+ // the Host details widget, which can be placed, sized and pointed at+ // whichever server you like. The clock is its own widget for the same+ // reason. Only what the bar itself still needs is derived here.const activeSysInfo = isRemote ? remoteSystemInfo : systemInfo;const hostname = metrics?.system?.hostname || activeSysInfo?.hostname || 'server';- const kernelVersion = metrics?.system?.kernel || activeSysInfo?.kernel || '-';- const ipAddress = metrics?.system?.ip_address || activeSysInfo?.ip_address || '-';- const uptime = formatUptime(localUptime ?? metrics?.system?.uptime_seconds);const isConnected = isRemote ? !!remoteMetrics : !!localMetrics;const displayTime = localTime? localTime.toLocaleTimeString('en-GB', { hour12: false })@@ -345,84 +338,6 @@ const Dashboard = () => {// the page no longer reserves a right-hand gutter for it.return (<div className="page-container dashboard-page">- {/* Host identity — which machine the board's $server variable points at */}- <div className="top-bar">- <div className="server-identity">- {/* A chevron that opens a menu of one is just noise — most- installs manage a single host, so show the name plainly- until there is actually something to switch to. */}- {servers.length < 2 ? (- <span className="srv-switch srv-switch--static">- <span className="srv-switch__name">{hostname}</span>- </span>- ) : (- <Popover open={serverMenuOpen} onOpenChange={setServerMenuOpen}>- <PopoverTrigger asChild>- <button- type="button"- className={`srv-switch${serverMenuOpen ? ' srv-switch--open' : ''}`}- aria-label="Switch server"- >- <span className="srv-switch__name">{hostname}</span>- <ChevronDown size={18} className="srv-switch__chev" aria-hidden="true" />- </button>- </PopoverTrigger>- <PopoverContent align="start" sideOffset={7} className="env-menu">- <div className="env-menu__head">Connected servers · {servers.length}</div>- {servers.map((server) => {- const online = server.status === 'online';- return (- <button- type="button"- key={server.id}- className="env-opt"- onClick={() => { handleServerChange(server.id); setServerMenuOpen(false); }}- >- <span- className={`env-opt__dot env-opt__dot--${online ? 'online' : 'offline'}`}- aria-hidden="true"- ></span>- <span className="env-opt__body">- <span className="env-opt__name">{server.name}</span>- <span className="env-opt__meta">- {server.group_name || (server.is_local ? 'local' : server.id)}- {' · '}- {online ? 'online' : 'offline'}- </span>- </span>- {server.id === selectedServer.id && (- <span className="env-opt__check" aria-hidden="true"><Check size={15} /></span>- )}- </button>- );- })}- </PopoverContent>- </Popover>- )}- <div className="server-details">- <span className={`conn-status conn-status--${isConnected ? 'live' : 'down'}`} role="status">- <span className="conn-status__dot" aria-hidden="true"></span>- {isConnected ? 'Live' : 'Reconnecting'}- </span>- <span className="detail-separator">·</span>- <span>IP: {ipAddress}</span>- <span className="detail-separator">·</span>- <span>KERNEL: {kernelVersion}</span>- <span className="detail-separator">·</span>- <span>- UPTIME: {uptime.days}d {String(uptime.hours).padStart(2, '0')}h{' '}- {String(uptime.minutes).padStart(2, '0')}m- </span>- </div>- </div>- <div className="top-bar-right">- <div className="clock-widget">- <span className="clock-time">{displayTime}</span>- <span className="clock-zone">{metrics?.time?.timezone_id || 'UTC'}</span>- </div>- </div>- </div>-{/* Extension slot: widgets contributed to the top of the dashboard */}<PluginSlot name="dashboard.top" />@@ -482,6 +397,59 @@ const Dashboard = () => {</div><div className="skw-bar__ctl">+ {/* Which machine the board's $server variable points at.+ A chevron opening a menu of one is noise, so with a+ single host this is a plain readout. */}+ {servers.length < 2 ? (+ <span className="skw-varpick skw-varpick--static">+ <span className="skw-varpick__k mono">server</span>+ <span className="skw-varpick__v">{hostname}</span>+ </span>+ ) : (+ <Popover open={serverMenuOpen} onOpenChange={setServerMenuOpen}>+ <PopoverTrigger asChild>+ <button+ type="button"+ className={`skw-varpick${serverMenuOpen ? ' is-open' : ''}`}+ aria-label="Switch server"+ >+ <span className="skw-varpick__k mono">server</span>+ <span className="skw-varpick__v">{selectedServer.name || hostname}</span>+ <ChevronDown size={13} aria-hidden="true" />+ </button>+ </PopoverTrigger>+ <PopoverContent align="start" sideOffset={7} className="env-menu">+ <div className="env-menu__head">Dashboard variable · $server</div>+ {servers.map((server) => {+ const online = server.status === 'online';+ return (+ <button+ type="button"+ key={server.id}+ className="env-opt"+ onClick={() => { handleServerChange(server.id); setServerMenuOpen(false); }}+ >+ <span+ className={`env-opt__dot env-opt__dot--${online ? 'online' : 'offline'}`}+ aria-hidden="true"+ ></span>+ <span className="env-opt__body">+ <span className="env-opt__name">{server.name}</span>+ <span className="env-opt__meta">+ {server.group_name || (server.is_local ? 'local' : server.id)}+ {' · '}+ {online ? 'online' : 'offline'}+ </span>+ </span>+ {server.id === selectedServer.id && (+ <span className="env-opt__check" aria-hidden="true"><Check size={15} /></span>+ )}+ </button>+ );+ })}+ </PopoverContent>+ </Popover>+ )}<SegControloptions={RANGES.map(([value, label]) => ({ value, label }))}value={range}diff --git a/frontend/src/styles/components/_dashboard-widgets.scss b/frontend/src/styles/components/_dashboard-widgets.scssindex a1c6c5c4..742cf99d 100644--- a/frontend/src/styles/components/_dashboard-widgets.scss+++ b/frontend/src/styles/components/_dashboard-widgets.scss@@ -150,6 +150,18 @@ $skw-z-tv: 200;background: var(--surface-3);}+ // Static variant: one server, so there is nothing to pick. Reads as a+ // label rather than a dead button.+ &--static {+ cursor: default;+ border-style: dashed;++ &:hover {+ border-color: var(--border);+ background: var(--surface-2);+ }+ }+&__k {color: var(--text-ghost);font-size: 10px;@@ -526,10 +538,15 @@ $skw-z-tv: 200;min-height: 0;display: flex;flex-direction: column;- justify-content: center;+ // Top-aligned, NOT centred. Once the spark row became flexible it competed+ // with the value for height, and centring pushed the number up out of the+ // tile — the reading is the point of this widget, so it is pinned first and+ // the chart gets whatever is left.+ justify-content: flex-start;padding: 12px 13px;&__value {+ flex: 0 0 auto;color: var(--text);font-size: 28px;font-weight: 700;@@ -544,6 +561,7 @@ $skw-z-tv: 200;}&__meta {+ flex: 0 0 auto;display: flex;align-items: center;gap: 9px;@@ -570,15 +588,18 @@ $skw-z-tv: 200;// taller stat widget grows its trend line instead of banking dead// space under the value. `min-height: 0` lets it shrink in a 2-row// tile without pushing the meta row out.- margin-top: auto;+ margin-top: 8px;margin-left: -2px;margin-right: -2px;line-height: 0;- flex: 1 1 auto;- min-height: 34px;+ // Grows into leftover height but never demands any: a hard min-height+ // here is what previously overflowed the tile and clipped the value.+ flex: 1 1 0;+ min-height: 0;display: flex;+ overflow: hidden;- > svg { flex: 1; }+ > svg { flex: 1; min-height: 0; }}}@@ -1516,3 +1537,42 @@ $skw-z-tv: 200;.skw-empty-board { padding: 40px 16px; }.skw-tpl { grid-template-columns: 1fr; }}++// ============================================================+// CLOCK — the wall time, as a widget.+// ============================================================+// The dashboard used to carry a fixed clock in its header. That header is gone+// (one control row now), so the time is opt-in: add it if you want it, put it+// on a second timezone if that's what you need.+.skw-clock {+ flex: 1;+ min-height: 0;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ gap: 2px;+ padding: 10px 12px;+ text-align: center;++ &__time {+ color: var(--text);+ font-size: 30px;+ font-weight: 600;+ line-height: 1.05;+ letter-spacing: 0.01em;+ font-variant-numeric: tabular-nums;+ }++ &__date {+ color: var(--text-dim);+ font-size: 12.5px;+ }++ &__zone {+ color: var(--text-ghost);+ font-size: 10.5px;+ text-transform: uppercase;+ letter-spacing: 0.05em;+ }+}