Skip to content

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.

feat(dashboard): a real editor, and widgets that say what they are

Juan Denis563e6c980daf
diff --git a/backend/app/services/dashboard_service.py b/backend/app/services/dashboard_service.py
index ac2a1e7a..6bb95423 100644
--- a/backend/app/services/dashboard_service.py
+++ b/backend/app/services/dashboard_service.py
@@ -13,18 +13,20 @@ the same ones at runtime):
floating rows or holes above a widget.
* Every widget respects its type's minimum size from the widget registry.
-``cfg`` is free-form per widget type and the backend never interprets it — it is
-stored and handed back verbatim. The shapes used here mirror the widget table in
+``cfg`` is free-form per widget type and the backend does not interpret it —
+it is stored and handed back verbatim. The one exception is ``_repair_board``,
+which rewrites config keys that no renderer reads any more (see below); it never
+invents config the user did not set. The shapes used here mirror the widget table in
the plan contract:
* ``stat`` ``{metric, agg, resource, thresholds}``
-* ``timeseries`` ``{metrics: [...], resource}``
+* ``timeseries`` ``{series: [{resource, metric}, ...], legend, fill}``
* ``gauge`` ``{metric, resource, thresholds}``
-* ``topn`` ``{metric, source, limit}``
+* ``topn`` ``{metric, limit}``
* ``table`` ``{source: 'apps'|'servers'|'containers'|'deploys', limit}``
-* ``logs`` ``{resource, lines}``
+* ``logs`` ``{source, path, containerId, level, lines}``
* ``deploys`` / ``alerts`` / ``status`` / ``feed`` ``{limit, …}``
-* ``actions`` ``{actions: [...]}``
+* ``actions`` ``{items: [...]}`` (keys the renderer can route)
* ``specs`` ``{resource}``
``resource: '$server'`` is the server variable the dashboard topbar binds, so a
@@ -169,14 +171,105 @@ def seed_defaults(user_id):
return created
+# Widget configs that early boards were seeded with, mapped to the keys the
+# renderers actually read. Fixing DEFAULT_BOARDS only helps users who have never
+# opened the dashboard — everyone else already has rows in the database, and
+# seeding never runs again for them. So repair on read.
+#
+# Each entry: (old key, new key, converter). A converter of None copies through.
+_CFG_RENAMES = {
+ # `metrics: ['cpu','ram']` -> `series: [{resource, metric}, ...]`
+ 'timeseries': [('metrics', 'series',
+ lambda v, cfg: [{'resource': cfg.get('resource', '$server'),
+ 'metric': m} for m in v if isinstance(m, str)])],
+ # `actions: [...]` -> `items: [...]`
+ 'actions': [('actions', 'items', None)],
+}
+
+# Shortcut keys the quick-actions widget can resolve (ACTIONS in renderers.jsx).
+# Early boards seeded 'new-app'/'deploy'/'backup', none of which route anywhere.
+_QUICK_ACTIONS = {
+ 'servers', 'services', 'docker', 'terminal', 'deploys', 'databases',
+ 'backups', 'monitoring', 'domains', 'files', 'security', 'jobs',
+}
+_QUICK_ACTION_ALIASES = {'new-app': 'services', 'deploy': 'deploys', 'backup': 'backups'}
+_DEFAULT_QUICK_ACTIONS = ['services', 'docker', 'terminal', 'backups']
+
+
+
+
+
+def _repair_widget_cfg(widget):
+ """Bring one stored widget's cfg up to the current renderer contract.
+
+ Returns True when something changed. Deliberately conservative: it renames
+ known-dead keys and drops unroutable shortcuts, and never touches config the
+ renderers understand.
+ """
+ if not isinstance(widget, dict):
+ return False
+ cfg = widget.get('cfg')
+ if not isinstance(cfg, dict):
+ return False
+
+ changed = False
+ for old, new, convert in _CFG_RENAMES.get(widget.get('type'), []):
+ if old in cfg and new not in cfg:
+ value = cfg.pop(old)
+ cfg[new] = convert(value, cfg) if convert else value
+ changed = True
+
+ if widget.get('type') == 'actions':
+ items = cfg.get('items')
+ mapped = [_QUICK_ACTION_ALIASES.get(i, i)
+ for i in (items or []) if isinstance(i, str)]
+ kept = [i for i in dict.fromkeys(mapped) if i in _QUICK_ACTIONS]
+ # An empty shortcut list renders "No actions selected", which is a
+ # useless thing to greet someone with. If nothing survived (or nothing
+ # was ever set), fall back to the shipped four.
+ if not kept:
+ kept = _DEFAULT_QUICK_ACTIONS[:]
+ if kept != items:
+ cfg['items'] = kept
+ changed = True
+
+ return changed
+
+
+def _repair_board(board):
+ """Bring one board's stored widgets up to the current renderer contract.
+
+ Works on a deep copy on purpose. A JSON column mutated in place looks
+ unchanged to SQLAlchemy, so no UPDATE is emitted — and the commit then
+ expires the instance, which reloads the ORIGINAL rows and silently undoes
+ the repair. Copying first is what makes the change both detected and kept.
+ """
+ widgets = copy.deepcopy(board.widgets or [])
+ # Only dead config is rewritten. A missing `title` is NOT repaired here —
+ # writing a title into config the user never set would break the promise
+ # that a widget's cfg round-trips verbatim. The frame derives a display
+ # title instead (deriveWidgetTitle in the frontend registry).
+ changed = any([_repair_widget_cfg(w) for w in widgets])
+
+ if not changed:
+ return False
+ board.widgets = widgets
+ return True
+
+
def get_boards_for_user(user_id):
"""Every board owned by this user, seeding the shipped defaults on the
- first read for a user who has none."""
+ first read for a user who has none, and repairing configs that predate the
+ current renderer contract."""
boards = (DashboardBoard.query
.filter_by(user_id=user_id)
.order_by(DashboardBoard.position, DashboardBoard.id)
.all())
if boards:
+ # Not `any(...)`: it short-circuits, so only the first repairable board
+ # would ever be fixed.
+ if [_repair_board(b) for b in boards].count(True):
+ db.session.commit()
return boards
seed_defaults(user_id)
return (DashboardBoard.query
diff --git a/backend/tests/test_dashboards.py b/backend/tests/test_dashboards.py
index 81c4908a..2c5b9680 100644
--- a/backend/tests/test_dashboards.py
+++ b/backend/tests/test_dashboards.py
@@ -371,3 +371,95 @@ def test_seeded_quick_actions_all_resolve():
assert not unknown, (
f"{board['slug']}/{widget['i']}: unroutable shortcuts {sorted(unknown)}"
)
+
+
+# ── repairing boards that predate the current renderer contract ──────────────
+def test_legacy_board_is_repaired_on_read(app, client, auth_headers):
+ """Fixing DEFAULT_BOARDS only helps users who have never opened the
+ dashboard — seeding never runs again for anyone else. Boards already in the
+ database carried `metrics`/`actions` keys nothing reads and no titles at
+ all, so every tile read "Stat" and the chart and shortcuts rendered empty.
+ """
+ from app import db as _db
+ from app.models.dashboard import DashboardBoard
+ from app.models import User
+
+ user = User.query.filter_by(username='testadmin').first() or User.query.first()
+ legacy = DashboardBoard(
+ user_id=user.id, slug='overview', name='Overview', icon='grid', position=0,
+ widgets=[
+ {'i': 'w1', 'type': 'stat', 'x': 0, 'y': 0, 'w': 3, 'h': 2,
+ 'cfg': {'metric': 'cpu', 'resource': '$server'}},
+ {'i': 'w5', 'type': 'timeseries', 'x': 0, 'y': 2, 'w': 8, 'h': 4,
+ 'cfg': {'metrics': ['cpu', 'ram'], 'resource': '$server'}},
+ {'i': 'w6', 'type': 'actions', 'x': 8, 'y': 2, 'w': 4, 'h': 2,
+ 'cfg': {'actions': ['new-app', 'deploy', 'terminal', 'backup']}},
+ ])
+ _db.session.add(legacy)
+ _db.session.commit()
+
+ boards = client.get('/api/v1/dashboards', headers=auth_headers).get_json()['boards']
+ board = next(b for b in boards if b['slug'] == 'overview')
+ by_id = {w['i']: w for w in board['widgets']}
+
+ # timeseries: metrics -> series, as [{resource, metric}]
+ ts = by_id['w5']['cfg']
+ assert 'metrics' not in ts
+ assert ts['series'] == [{'resource': '$server', 'metric': 'cpu'},
+ {'resource': '$server', 'metric': 'ram'}]
+
+ # actions: actions -> items, aliased to keys that actually route
+ items = by_id['w6']['cfg']['items']
+ assert 'actions' not in by_id['w6']['cfg']
+ assert items and all(i in {'servers', 'services', 'docker', 'terminal', 'deploys',
+ 'databases', 'backups', 'monitoring', 'domains',
+ 'files', 'security', 'jobs'} for i in items)
+
+ # Titles are NOT written into stored config — that would break the
+ # verbatim round-trip promise. The frame derives a display title instead.
+ assert 'title' not in by_id['w1']['cfg']
+
+ # and the repair is persisted, not recomputed on every read
+ stored = DashboardBoard.query.get(legacy.id)
+ assert 'series' in stored.widgets[1]['cfg']
+
+
+def test_quick_actions_never_render_empty(app, client, auth_headers):
+ """An empty shortcut list shows "No actions selected", which is a useless
+ thing to greet someone with — fall back to the shipped four."""
+ from app import db as _db
+ from app.models.dashboard import DashboardBoard
+ from app.models import User
+
+ user = User.query.filter_by(username='testadmin').first() or User.query.first()
+ board = DashboardBoard(
+ user_id=user.id, slug=None, name='Custom', icon='grid', position=9,
+ widgets=[{'i': 'a1', 'type': 'actions', 'x': 0, 'y': 0, 'w': 3, 'h': 2,
+ 'cfg': {'items': ['nope', 'also-nope']}}])
+ _db.session.add(board)
+ _db.session.commit()
+
+ boards = client.get('/api/v1/dashboards', headers=auth_headers).get_json()['boards']
+ custom = next(b for b in boards if b['name'] == 'Custom')
+ assert custom['widgets'][0]['cfg']['items'], 'unroutable shortcuts left the widget empty'
+
+
+def test_repair_leaves_a_current_board_untouched(app, client, auth_headers):
+ """The repair must be a no-op for config the renderers already understand."""
+ from app import db as _db
+ from app.models.dashboard import DashboardBoard
+ from app.models import User
+
+ user = User.query.filter_by(username='testadmin').first() or User.query.first()
+ cfg = {'title': 'Mine', 'series': [{'resource': 'local', 'metric': 'cpu'}],
+ 'legend': True, 'fill': False}
+ board = DashboardBoard(
+ user_id=user.id, slug=None, name='Current', icon='grid', position=8,
+ widgets=[{'i': 't1', 'type': 'timeseries', 'x': 0, 'y': 0, 'w': 8, 'h': 4,
+ 'cfg': dict(cfg)}])
+ _db.session.add(board)
+ _db.session.commit()
+
+ boards = client.get('/api/v1/dashboards', headers=auth_headers).get_json()['boards']
+ current = next(b for b in boards if b['name'] == 'Current')
+ assert current['widgets'][0]['cfg'] == cfg
diff --git a/frontend/src/components/dashboard/grid/WidgetEditor.jsx b/frontend/src/components/dashboard/grid/WidgetEditor.jsx
new file mode 100644
index 00000000..aa671e58
--- /dev/null
+++ b/frontend/src/components/dashboard/grid/WidgetEditor.jsx
@@ -0,0 +1,587 @@
+import { useMemo } from 'react';
+import {
+ Copy, LayoutGrid, Minus, Plus, Trash2,
+} from 'lucide-react';
+import { Drawer, SegControl } from '@/components/ds';
+import { Switch } from '@/components/ui/switch';
+import {
+ AGGREGATIONS, getMetric, metricsForResource, metricsForSource,
+} from '../widgets/metrics';
+// Single source of truth for shortcut targets: what a user can pick here is
+// exactly what the renderer can draw. WidgetBody is what the board itself
+// draws with, so the preview cannot drift from the real thing.
+import { QUICK_ACTION_OPTIONS, WidgetBody } from '../widgets/renderers';
+import { deriveWidgetTitle } from '../widgets/registry';
+import { GRID_COLS, GRID_GAP, GRID_ROW } from './layout';
+
+// Tallest a widget may be dragged/stepped to. Twelve columns wide is the board;
+// height is only bounded so a stepper can't run away.
+const MAX_ROWS = 20;
+const FALLBACK_MIN = [2, 2];
+// Log widgets count lines, everything else counts rows — different granularity.
+const LINE_STEP = 20;
+const LINE_MIN = 20;
+const ROW_MIN = 2;
+
+// One grid column plus its gutter on a typical ~1300px board. The preview
+// reproduces that step (rather than a fraction of the stage) so a 4-wide widget
+// looks 4-wide instead of shrinking to fit a 700px drawer column; anything
+// wider than the stage is capped by `max-width` in the stylesheet.
+const PREVIEW_STEP = 109;
+
+const TABLE_SOURCES = [
+ ['services', 'Services'],
+ ['servers', 'Servers'],
+ ['containers', 'Containers'],
+ ['deploys', 'Deploys'],
+];
+const TOPN_DIMENSIONS = [['servers', 'Servers'], ['services', 'Services']];
+const LOG_LEVELS = [['all', 'All'], ['out', 'Info'], ['warn', 'Warn'], ['err', 'Error']];
+const SEVERITIES = [['all', 'All'], ['critical', 'Critical'], ['high', 'High'], ['low', 'Low']];
+
+// Types that point at one machine, so they get the resource picker.
+const RESOURCE_TYPES = ['stat', 'gauge', 'specs'];
+// Every core type except `status`, which draws the whole fleet and so has
+// nothing to configure beyond its title and size.
+const CONFIGURABLE_TYPES = [
+ 'stat', 'timeseries', 'gauge', 'topn', 'table', 'logs',
+ 'deploys', 'alerts', 'feed', 'actions', 'specs', 'note',
+];
+
+const clamp = (value, low, high) => Math.max(low, Math.min(high, value));
+const toOptions = (pairs) => pairs.map(([value, label]) => ({ value, label }));
+
+// A metric saved before the resource changed is kept in the list, flagged,
+// rather than silently swapped out from under the operator.
+function asOptions(catalog, selected) {
+ const options = catalog.map((metric) => [metric.id, metric.label]);
+ if (selected && !catalog.some((metric) => metric.id === selected)) {
+ options.push([selected, `${getMetric(selected).label} · unavailable here`]);
+ }
+ return options;
+}
+
+/**
+ * Metric dropdown options for a resource. metrics.js is explicit that config
+ * UIs must build this from the resource's own catalog, so a dead option
+ * (network on the local host, load average on an agent) never reaches a user.
+ * The `$server` variable can resolve either way, so it gets the union.
+ */
+function metricOptionsFor(resource, selected) {
+ const catalog = !resource || resource === '$server'
+ ? [...new Set([...metricsForSource('local'), ...metricsForSource('server')])]
+ : metricsForResource(resource);
+ return asOptions(catalog, selected);
+}
+
+/** Top N ranks servers/services, never the panel host. */
+function topnMetricOptions(selected) {
+ return asOptions(metricsForSource('server'), selected);
+}
+
+const iconOf = (type) => {
+ const candidate = type?.icon;
+ const usable = typeof candidate === 'function' || (candidate && typeof candidate === 'object');
+ return usable ? candidate : LayoutGrid;
+};
+
+/**
+ * One labelled setting. `inline` puts the control beside the caption instead of
+ * under it, which is how a bare switch reads best.
+ */
+function Field({ label, hint, inline, children }) {
+ return (
+ <div className={`skwe-edit__row${inline ? ' skwe-edit__row--inline' : ''}`}>
+ {/* A <span>, not a <label>: every control below carries its own
+ aria-label, so the caption is presentation only and must not
+ claim an association it does not have. */}
+ <span className="skwe-edit__label">{label}</span>
+ <div className="skwe-edit__control">{children}</div>
+ {hint && <p className="skwe-edit__hint">{hint}</p>}
+ </div>
+ );
+}
+
+function Group({ title, children }) {
+ return (
+ <div className="skwe-edit__group">
+ <div className="skwe-edit__grouphead">{title}</div>
+ {children}
+ </div>
+ );
+}
+
+function Select({ value, onChange, options, label }) {
+ return (
+ <select
+ className="skwe-edit__select"
+ value={value ?? ''}
+ aria-label={label}
+ onChange={(event) => onChange(event.target.value)}
+ >
+ {options.map(([optionValue, optionLabel]) => (
+ <option key={optionValue} value={optionValue}>{optionLabel}</option>
+ ))}
+ </select>
+ );
+}
+
+function Stepper({ label, value, onStep, suffix }) {
+ return (
+ <div className="skwe-stepper">
+ <button
+ type="button"
+ className="skwe-stepper__btn"
+ title={`Decrease ${label}`}
+ aria-label={`Decrease ${label}`}
+ onClick={() => onStep(-1)}
+ >
+ <Minus size={13} aria-hidden="true" />
+ </button>
+ <span className="skwe-stepper__val mono">{value}{suffix ? ` ${suffix}` : ''}</span>
+ <button
+ type="button"
+ className="skwe-stepper__btn"
+ title={`Increase ${label}`}
+ aria-label={`Increase ${label}`}
+ onClick={() => onStep(1)}
+ >
+ <Plus size={13} aria-hidden="true" />
+ </button>
+ </div>
+ );
+}
+
+/**
+ * Wide configuration drawer for the selected widget: the real widget rendered
+ * live on the left, its settings on the right. Every field writes straight
+ * through `onChange` with a whole new widget instance — the board owns the list
+ * and decides when to persist — so the preview updates on the same keystroke
+ * the board does.
+ *
+ * Built on the shared ds/Drawer (a Radix dialog) rather than a hand-rolled
+ * fixed panel. That buys escape-to-close, scrim-to-close, focus trapping and
+ * listener teardown from the primitive, and it is also why the floating AI
+ * bubble steps aside: `_ai-assistant.scss` already hides `.sk-ai-bubble` while
+ * any `[role=dialog][data-state=open]` is mounted. The old inspector was a bare
+ * <aside>, which is exactly why the bubble sat on top of its footer.
+ */
+export function WidgetEditor({
+ widget,
+ type,
+ resources = [],
+ ctx,
+ onChange,
+ onClose,
+ onDuplicate,
+ onRemove,
+}) {
+ const resourceOptions = useMemo(() => [
+ ['$server', 'Dashboard variable'],
+ ...resources.map((resource) => [
+ resource.id,
+ resource.kind ? `${resource.label} · ${resource.kind}` : resource.label,
+ ]),
+ ], [resources]);
+
+ if (!widget) return null;
+
+ const cfg = widget.cfg || {};
+ const kind = widget.type;
+ const [minW, minH] = type?.min || FALLBACK_MIN;
+ const Icon = iconOf(type);
+ const title = deriveWidgetTitle(widget, type);
+
+ // A chevron that opens a menu of one is noise: with a single connected
+ // machine the board variable and that machine are the same answer, so the
+ // picker is replaced by a plain readout of what the widget reads.
+ const multiResource = resources.length > 1;
+ const soleResourceLabel = resources[0]?.label || 'Dashboard variable';
+ // What that readout should say. A saved widget can still point at a server
+ // that has since been removed, and silently printing the surviving host
+ // would hide the problem — so say so instead.
+ const resolvedResource = (value) => {
+ if (!value || value === '$server') return soleResourceLabel;
+ return resources.find((resource) => resource.id === value)?.label || `${value} · not connected`;
+ };
+
+ const set = (key, value) => onChange?.({ ...widget, cfg: { ...cfg, [key]: value } });
+ const setSeries = (index, key, value) => set(
+ 'series',
+ (cfg.series || []).map((series, i) => (i === index ? { ...series, [key]: value } : series)),
+ );
+ const stepSize = (key, delta) => {
+ const min = key === 'w' ? minW : minH;
+ const max = key === 'w' ? GRID_COLS : MAX_ROWS;
+ onChange?.({ ...widget, [key]: clamp((widget[key] || min) + delta, min, max) });
+ };
+
+ const countsLines = kind === 'logs';
+ const countKey = countsLines ? 'lines' : 'limit';
+ const countValue = countsLines ? (cfg.lines || 60) : (cfg.limit || 6);
+ const stepCount = (direction) => {
+ const step = countsLines ? LINE_STEP : 1;
+ const floor = countsLines ? LINE_MIN : ROW_MIN;
+ set(countKey, Math.max(floor, countValue + step * direction));
+ };
+
+ // Real board geometry, so stepping the size steppers moves the preview by
+ // the same amount the board would.
+ const previewStyle = {
+ width: Math.max(1, widget.w) * PREVIEW_STEP - GRID_GAP,
+ height: Math.max(1, widget.h) * GRID_ROW + (Math.max(1, widget.h) - 1) * GRID_GAP,
+ };
+
+ return (
+ <Drawer
+ open
+ onOpenChange={(next) => { if (!next) onClose?.(); }}
+ title={title}
+ subtitle={`${type?.name || kind} · ${widget.w}×${widget.h} cells`}
+ icon={<Icon size={18} aria-hidden="true" />}
+ // ds/Drawer caps itself at 95vw, so the effective width is
+ // min(1100px, 95vw) — a hair under the 96vw asked for, and the
+ // cap is shared with every other drawer in the app.
+ width="min(1100px, 96vw)"
+ className="skwe-drawer"
+ >
+ <div className="skwe-edit">
+ <div className="skwe-edit__cols">
+ <section className="skwe-edit__preview" aria-label="Live preview">
+ <div className="skwe-edit__stage">
+ {/* Same chrome the board draws, driven by the same
+ renderer — so "preview" costs no second
+ implementation and cannot lie. */}
+ <div className="skw-frame skwe-edit__frame" style={previewStyle}>
+ <div className="skw-frame__head">
+ <span className="skw-frame__title">{title}</span>
+ </div>
+ <div className="skw-frame__body">
+ <WidgetBody widget={widget} ctx={ctx} />
+ </div>
+ </div>
+ </div>
+ {/* No pixel figure here: a widget wider than the stage
+ is capped by max-width, so quoting its board size
+ would describe something the operator isn't seeing. */}
+ <div className="skwe-edit__caption mono">
+ live preview · {widget.w}×{widget.h} of 12 columns
+ </div>
+ </section>
+
+ <section className="skwe-edit__pane" aria-label="Widget settings">
+ <Group title="Widget">
+ <Field label="Title">
+ <input
+ type="text"
+ className="skwe-edit__field"
+ aria-label="Widget title"
+ placeholder={deriveWidgetTitle({ ...widget, cfg: { ...cfg, title: '' } }, type)}
+ value={cfg.title || ''}
+ onChange={(event) => set('title', event.target.value)}
+ />
+ </Field>
+ </Group>
+
+ {CONFIGURABLE_TYPES.includes(kind) && (
+ <Group title="Data">
+ {RESOURCE_TYPES.includes(kind) && (multiResource ? (
+ <Field label="Resource">
+ <Select
+ label="Resource"
+ value={cfg.resource || '$server'}
+ onChange={(value) => set('resource', value)}
+ options={resourceOptions}
+ />
+ </Field>
+ ) : (
+ <Field label="Resource" hint="One machine is connected, so this widget reads it.">
+ <div className="skwe-edit__static mono">{resolvedResource(cfg.resource)}</div>
+ </Field>
+ ))}
+
+ {['stat', 'gauge'].includes(kind) && (
+ <Field label="Metric">
+ <Select
+ label="Metric"
+ value={cfg.metric || 'cpu'}
+ onChange={(value) => set('metric', value)}
+ options={metricOptionsFor(cfg.resource, cfg.metric || 'cpu')}
+ />
+ </Field>
+ )}
+
+ {['stat', 'gauge', 'topn'].includes(kind) && (
+ <Field label="Aggregation">
+ <SegControl
+ options={toOptions(AGGREGATIONS)}
+ value={cfg.agg || 'last'}
+ onChange={(value) => set('agg', value)}
+ />
+ </Field>
+ )}
+
+ {['stat', 'gauge'].includes(kind) && (
+ <Field label="Thresholds" hint="Value colours turn amber, then red.">
+ <div className="skwe-edit__pair">
+ {[0, 1].map((index) => (
+ <div className="skwe-edit__pairitem" key={index}>
+ <span className="skwe-edit__unit mono">{index ? 'red ≥' : 'amber ≥'}</span>
+ <input
+ type="number"
+ className="skwe-edit__field skwe-edit__field--mono"
+ aria-label={index ? 'Red threshold' : 'Amber threshold'}
+ value={(cfg.thresholds || [])[index] ?? ''}
+ onChange={(event) => {
+ const next = [...(cfg.thresholds || [null, null])];
+ next[index] = event.target.value === ''
+ ? null
+ : Number(event.target.value);
+ set('thresholds', next);
+ }}
+ />
+ </div>
+ ))}
+ </div>
+ </Field>
+ )}
+
+ {kind === 'stat' && (
+ <Field label="Sparkline" inline>
+ <Switch
+ checked={cfg.spark !== false}
+ aria-label="Show sparkline"
+ onCheckedChange={(checked) => set('spark', checked)}
+ />
+ </Field>
+ )}
+
+ {kind === 'timeseries' && (
+ <>
+ <Field label="Series">
+ <div className="skwe-edit__series">
+ {(cfg.series || []).length === 0 && (
+ <div className="skwe-edit__empty">
+ No series yet — the chart draws nothing until you add one.
+ </div>
+ )}
+ {(cfg.series || []).map((series, index) => (
+ <div
+ // Series have no stable id of their own; the index is
+ // the identity the config file itself uses.
+ key={index}
+ className={`skwe-edit__ser${multiResource ? '' : ' skwe-edit__ser--solo'}`}
+ >
+ {multiResource && (
+ <Select
+ label={`Series ${index + 1} resource`}
+ value={series.resource}
+ onChange={(value) => setSeries(index, 'resource', value)}
+ options={resourceOptions}
+ />
+ )}
+ <Select
+ label={`Series ${index + 1} metric`}
+ value={series.metric}
+ onChange={(value) => setSeries(index, 'metric', value)}
+ options={metricOptionsFor(series.resource, series.metric)}
+ />
+ <button
+ type="button"
+ className="skwe-edit__del"
+ title={`Remove series ${index + 1}`}
+ aria-label={`Remove series ${index + 1}`}
+ onClick={() => set(
+ 'series',
+ (cfg.series || []).filter((_, i) => i !== index),
+ )}
+ >
+ <Trash2 size={13} aria-hidden="true" />
+ </button>
+ </div>
+ ))}
+ <button
+ type="button"
+ className="skwe-edit__add"
+ onClick={() => set('series', [
+ ...(cfg.series || []),
+ { resource: '$server', metric: 'cpu' },
+ ])}
+ >
+ <Plus size={12} aria-hidden="true" /> Add series
+ </button>
+ </div>
+ </Field>
+ <Field label="Legend" inline>
+ <Switch
+ checked={cfg.legend !== false}
+ aria-label="Show legend"
+ onCheckedChange={(checked) => set('legend', checked)}
+ />
+ </Field>
+ <Field label="Area fill" inline>
+ <Switch
+ checked={cfg.fill !== false}
+ aria-label="Fill the area under each series"
+ onCheckedChange={(checked) => set('fill', checked)}
+ />
+ </Field>
+ </>
+ )}
+
+ {kind === 'topn' && (
+ <>
+ <Field label="Dimension">
+ <SegControl
+ options={toOptions(TOPN_DIMENSIONS)}
+ value={cfg.dim || 'servers'}
+ onChange={(value) => set('dim', value)}
+ />
+ </Field>
+ {/* Top N always ranks remote resources, so it offers the
+ server-side catalog whatever the board variable is. */}
+ <Field label="Metric">
+ <Select
+ label="Metric"
+ value={cfg.metric || 'cpu'}
+ onChange={(value) => set('metric', value)}
+ options={topnMetricOptions(cfg.metric || 'cpu')}
+ />
+ </Field>
+ </>
+ )}
+
+ {kind === 'table' && (
+ <Field label="Source">
+ <Select
+ label="Source"
+ value={cfg.source || 'services'}
+ onChange={(value) => set('source', value)}
+ options={TABLE_SOURCES}
+ />
+ </Field>
+ )}
+
+ {kind === 'logs' && (
+ <>
+ {multiResource ? (
+ <Field label="Source">
+ <Select
+ label="Log source"
+ value={cfg.source || '$server'}
+ onChange={(value) => set('source', value)}
+ options={resourceOptions}
+ />
+ </Field>
+ ) : (
+ <Field label="Source" hint="One machine is connected, so this widget tails it.">
+ <div className="skwe-edit__static mono">{resolvedResource(cfg.source)}</div>
+ </Field>
+ )}
+ <Field label="Level">
+ <SegControl
+ options={toOptions(LOG_LEVELS)}
+ value={cfg.level || 'all'}
+ onChange={(value) => set('level', value)}
+ />
+ </Field>
+ </>
+ )}
+
+ {kind === 'alerts' && (
+ <Field label="Severity">
+ <SegControl
+ options={toOptions(SEVERITIES)}
+ value={cfg.severity || 'all'}
+ onChange={(value) => set('severity', value)}
+ />
+ </Field>
+ )}
+
+ {['table', 'logs', 'deploys', 'feed'].includes(kind) && (
+ <Field label={countsLines ? 'Lines' : 'Rows'}>
+ <Stepper
+ label={countsLines ? 'lines' : 'rows'}
+ value={countValue}
+ onStep={stepCount}
+ />
+ </Field>
+ )}
+
+ {kind === 'actions' && (
+ <Field label="Shortcuts">
+ <div className="skwe-edit__checks">
+ {QUICK_ACTION_OPTIONS.map(([key, label]) => {
+ const on = (cfg.items || []).includes(key);
+ return (
+ <label className="skwe-edit__check" key={key}>
+ <input
+ type="checkbox"
+ checked={on}
+ onChange={() => set(
+ 'items',
+ on
+ ? (cfg.items || []).filter((item) => item !== key)
+ : [...(cfg.items || []), key],
+ )}
+ />
+ {label}
+ </label>
+ );
+ })}
+ </div>
+ </Field>
+ )}
+
+ {kind === 'note' && (
+ <Field label="Text" hint="**bold** and `code` are supported.">
+ <textarea
+ className="skwe-edit__textarea"
+ aria-label="Note text"
+ value={cfg.text || ''}
+ onChange={(event) => set('text', event.target.value)}
+ />
+ </Field>
+ )}
+ </Group>
+ )}
+
+ <Group title="Layout">
+ <Field label="Size" hint="Cells on the 12-column board — the preview follows.">
+ <div className="skwe-edit__pair">
+ <Stepper
+ label="width"
+ value={widget.w}
+ suffix="wide"
+ onStep={(delta) => stepSize('w', delta)}
+ />
+ <Stepper
+ label="height"
+ value={widget.h}
+ suffix="tall"
+ onStep={(delta) => stepSize('h', delta)}
+ />
+ </div>
+ </Field>
+ </Group>
+ </section>
+ </div>
+
+ <div className="skwe-edit__foot">
+ <button type="button" className="btn btn-sm" onClick={onDuplicate}>
+ <Copy size={13} aria-hidden="true" /> Duplicate
+ </button>
+ <button type="button" className="btn btn-sm btn-danger" onClick={onRemove}>
+ <Trash2 size={13} aria-hidden="true" /> Remove
+ </button>
+ <span className="skwe-edit__spacer" />
+ <button type="button" className="btn btn-sm btn-primary" onClick={onClose}>
+ Done
+ </button>
+ </div>
+ </div>
+ </Drawer>
+ );
+}
+
+export default WidgetEditor;
diff --git a/frontend/src/components/dashboard/grid/WidgetFrame.jsx b/frontend/src/components/dashboard/grid/WidgetFrame.jsx
index a31fa916..979d2c1c 100644
--- a/frontend/src/components/dashboard/grid/WidgetFrame.jsx
+++ b/frontend/src/components/dashboard/grid/WidgetFrame.jsx
@@ -3,6 +3,7 @@ import {
Copy, GripVertical, Maximize2, MoreVertical, SlidersHorizontal, Trash2,
} from 'lucide-react';
import { WidgetBody } from '../widgets/renderers';
+import { deriveWidgetTitle } from '../widgets/registry';
// Chrome around one placed widget: a header (drag handle + title + actions),
// the renderer body, and — in edit mode — the bottom-right resize grip.
@@ -38,7 +39,7 @@ export function WidgetFrame({
};
}, [menuOpen]);
- const title = widget.cfg?.title || type?.name || widget.type;
+ const title = deriveWidgetTitle(widget, type);
const fire = (action) => {
setMenuOpen(false);
onMenu?.(action, widget);
diff --git a/frontend/src/components/dashboard/grid/WidgetFullscreen.jsx b/frontend/src/components/dashboard/grid/WidgetFullscreen.jsx
index 49ef578d..cb6bb75a 100644
--- a/frontend/src/components/dashboard/grid/WidgetFullscreen.jsx
+++ b/frontend/src/components/dashboard/grid/WidgetFullscreen.jsx
@@ -1,6 +1,6 @@
import { useEffect, useRef } from 'react';
import { X } from 'lucide-react';
-import { getWidgetType, useWidgetTypes } from '../widgets/registry';
+import { deriveWidgetTitle, getWidgetType, useWidgetTypes } from '../widgets/registry';
import { WidgetBody } from '../widgets/renderers';
/**
@@ -22,7 +22,7 @@ export function WidgetFullscreen({ widget, type, ctx, onClose }) {
if (!widget) return null;
const resolved = type || getWidgetType(types, widget.type);
- const title = widget.cfg?.title || resolved?.name || widget.type;
+ const title = deriveWidgetTitle(widget, resolved);
return (
<>
diff --git a/frontend/src/components/dashboard/grid/WidgetInspector.jsx b/frontend/src/components/dashboard/grid/WidgetInspector.jsx
deleted file mode 100644
index b7029e28..00000000
--- a/frontend/src/components/dashboard/grid/WidgetInspector.jsx
+++ /dev/null
@@ -1,458 +0,0 @@
-import { useEffect, useMemo } from 'react';
-import {
- Copy, LayoutGrid, Minus, Plus, Trash2, X,
-} from 'lucide-react';
-import { SegControl } from '@/components/ds';
-import { Switch } from '@/components/ui/switch';
-import {
- AGGREGATIONS, getMetric, metricsForResource, metricsForSource,
-} from '../widgets/metrics';
-// Single source of truth for shortcut targets: what a user can pick here is
-// exactly what the renderer can draw.
-import { QUICK_ACTION_OPTIONS } from '../widgets/renderers';
-import { GRID_COLS } from './layout';
-
-// Tallest a widget may be dragged/stepped to. Twelve columns wide is the board;
-// height is only bounded so a stepper can't run away.
-const MAX_ROWS = 20;
-const FALLBACK_MIN = [2, 2];
-// Log widgets count lines, everything else counts rows — different granularity.
-const LINE_STEP = 20;
-const LINE_MIN = 20;
-const ROW_MIN = 2;
-
-
-const TABLE_SOURCES = [
- ['services', 'Services'],
- ['servers', 'Servers'],
- ['containers', 'Containers'],
- ['deploys', 'Deploys'],
-];
-const TOPN_DIMENSIONS = [['servers', 'Servers'], ['services', 'Services']];
-const LOG_LEVELS = [['all', 'All'], ['out', 'Info'], ['warn', 'Warn'], ['err', 'Error']];
-const SEVERITIES = [['all', 'All'], ['critical', 'Critical'], ['high', 'High'], ['low', 'Low']];
-
-const clamp = (value, low, high) => Math.max(low, Math.min(high, value));
-const toOptions = (pairs) => pairs.map(([value, label]) => ({ value, label }));
-
-// A metric saved before the resource changed is kept in the list, flagged,
-// rather than silently swapped out from under the operator.
-function asOptions(catalog, selected) {
- const options = catalog.map((metric) => [metric.id, metric.label]);
- if (selected && !catalog.some((metric) => metric.id === selected)) {
- options.push([selected, `${getMetric(selected).label} · unavailable here`]);
- }
- return options;
-}
-
-/**
- * Metric dropdown options for a resource. metrics.js is explicit that config
- * UIs must build this from the resource's own catalog, so a dead option
- * (network on the local host, load average on an agent) never reaches a user.
- * The `$server` variable can resolve either way, so it gets the union.
- */
-function metricOptionsFor(resource, selected) {
- const catalog = !resource || resource === '$server'
- ? [...new Set([...metricsForSource('local'), ...metricsForSource('server')])]
- : metricsForResource(resource);
- return asOptions(catalog, selected);
-}
-
-/** Top N ranks servers/services, never the panel host. */
-function topnMetricOptions(selected) {
- return asOptions(metricsForSource('server'), selected);
-}
-
-const iconOf = (type) => {
- const candidate = type?.icon;
- const usable = typeof candidate === 'function' || (candidate && typeof candidate === 'object');
- return usable ? candidate : LayoutGrid;
-};
-
-// The stylesheet targets `.skw-ins__row > label`, so the caption stays a bare
-// <label> element.
-function InspectorRow({ label, hint, children }) {
- return (
- <div className="skw-ins__row">
- <label>{label}</label>
- {children}
- {hint && <div className="skw-ins__hint">{hint}</div>}
- </div>
- );
-}
-
-function InspectorSelect({ value, onChange, options, label }) {
- return (
- <select
- className="skw-ins__select"
- value={value}
- aria-label={label}
- onChange={(event) => onChange(event.target.value)}
- >
- {options.map(([optionValue, optionLabel]) => (
- <option key={optionValue} value={optionValue}>{optionLabel}</option>
- ))}
- </select>
- );
-}
-
-// `.skw-stepper` styles its `button`/`span` children directly.
-function Stepper({ label, value, onStep, suffix }) {
- return (
- <div className="skw-stepper">
- <button
- type="button"
- title={`Decrease ${label}`}
- aria-label={`Decrease ${label}`}
- onClick={() => onStep(-1)}
- >
- <Minus size={13} />
- </button>
- <span className="mono">{value}{suffix ? ` ${suffix}` : ''}</span>
- <button
- type="button"
- title={`Increase ${label}`}
- aria-label={`Increase ${label}`}
- onClick={() => onStep(1)}
- >
- <Plus size={13} />
- </button>
- </div>
- );
-}
-
-/**
- * Right-hand configuration panel for the selected widget. Every field writes
- * straight through `onChange` with a whole new widget instance — the board owns
- * the list and decides when to persist.
- */
-export function WidgetInspector({
- widget,
- type,
- resources = [],
- onChange,
- onClose,
- onDuplicate,
- onRemove,
-}) {
- useEffect(() => {
- const onKeyDown = (event) => { if (event.key === 'Escape') onClose?.(); };
- window.addEventListener('keydown', onKeyDown);
- return () => window.removeEventListener('keydown', onKeyDown);
- }, [onClose]);
-
- const resourceOptions = useMemo(() => [
- ['$server', 'Dashboard variable'],
- ...resources.map((resource) => [
- resource.id,
- resource.kind ? `${resource.label} · ${resource.kind}` : resource.label,
- ]),
- ], [resources]);
-
- if (!widget) return null;
-
- const cfg = widget.cfg || {};
- const kind = widget.type;
- const [minW, minH] = type?.min || FALLBACK_MIN;
- const Icon = iconOf(type);
-
- const set = (key, value) => onChange?.({ ...widget, cfg: { ...cfg, [key]: value } });
- const setSeries = (index, key, value) => set(
- 'series',
- (cfg.series || []).map((series, i) => (i === index ? { ...series, [key]: value } : series)),
- );
- const stepSize = (key, delta) => {
- const min = key === 'w' ? minW : minH;
- const max = key === 'w' ? GRID_COLS : MAX_ROWS;
- onChange?.({ ...widget, [key]: clamp((widget[key] || min) + delta, min, max) });
- };
-
- const countsLines = kind === 'logs';
- const countKey = countsLines ? 'lines' : 'limit';
- const countValue = countsLines ? (cfg.lines || 60) : (cfg.limit || 6);
- const stepCount = (direction) => {
- const step = countsLines ? LINE_STEP : 1;
- const floor = countsLines ? LINE_MIN : ROW_MIN;
- set(countKey, Math.max(floor, countValue + step * direction));
- };
-
- return (
- <aside className="skw-ins" aria-label="Widget settings">
- <div className="skw-ins__head">
- <span className="skw-ins__ic"><Icon size={15} aria-hidden="true" /></span>
- <div className="skw-ins__title">
- {cfg.title || type?.name || kind}
- <div className="skw-ins__sub mono">{type?.name || kind} · {widget.w}×{widget.h}</div>
- </div>
- <button
- type="button"
- className="skw-iconbtn skw-iconbtn--bare"
- title="Close widget settings"
- aria-label="Close widget settings"
- onClick={onClose}
- >
- <X size={17} />
- </button>
- </div>
-
- <div className="skw-ins__body">
- <InspectorRow label="Title">
- <div className="skw-ins__field">
- <input
- type="text"
- aria-label="Widget title"
- value={cfg.title || ''}
- onChange={(event) => set('title', event.target.value)}
- />
- </div>
- </InspectorRow>
-
- {['stat', 'gauge', 'specs'].includes(kind) && (
- <InspectorRow label="Resource">
- <InspectorSelect
- label="Resource"
- value={cfg.resource || '$server'}
- onChange={(value) => set('resource', value)}
- options={resourceOptions}
- />
- </InspectorRow>
- )}
-
- {['stat', 'gauge'].includes(kind) && (
- <InspectorRow label="Metric">
- <InspectorSelect
- label="Metric"
- value={cfg.metric || 'cpu'}
- onChange={(value) => set('metric', value)}
- options={metricOptionsFor(cfg.resource, cfg.metric || 'cpu')}
- />
- </InspectorRow>
- )}
-
- {['stat', 'gauge', 'topn'].includes(kind) && (
- <InspectorRow label="Aggregation">
- <SegControl
- options={toOptions(AGGREGATIONS)}
- value={cfg.agg || 'last'}
- onChange={(value) => set('agg', value)}
- />
- </InspectorRow>
- )}
-
- {['stat', 'gauge'].includes(kind) && (
- <InspectorRow label="Thresholds" hint="Value colours turn amber, then red.">
- <div className="skw-ins__pair">
- {[0, 1].map((index) => (
- <div className="skw-ins__field" key={index}>
- <span className="skw-ins__prefix mono">{index ? 'red ≥' : 'amber ≥'}</span>
- <input
- type="number"
- aria-label={index ? 'Red threshold' : 'Amber threshold'}
- value={(cfg.thresholds || [])[index] ?? ''}
- onChange={(event) => {
- const next = [...(cfg.thresholds || [null, null])];
- next[index] = event.target.value === '' ? null : Number(event.target.value);
- set('thresholds', next);
- }}
- />
- </div>
- ))}
- </div>
- </InspectorRow>
- )}
-
- {kind === 'stat' && (
- <InspectorRow label="Sparkline">
- <Switch
- checked={cfg.spark !== false}
- aria-label="Show sparkline"
- onCheckedChange={(checked) => set('spark', checked)}
- />
- </InspectorRow>
- )}
-
- {kind === 'timeseries' && (
- <>
- <InspectorRow label="Series">
- <div className="skw-ins__series">
- {(cfg.series || []).map((series, index) => (
- <div className="skw-ins__ser" key={index}>
- <InspectorSelect
- label={`Series ${index + 1} resource`}
- value={series.resource}
- onChange={(value) => setSeries(index, 'resource', value)}
- options={resourceOptions}
- />
- <InspectorSelect
- label={`Series ${index + 1} metric`}
- value={series.metric}
- onChange={(value) => setSeries(index, 'metric', value)}
- options={metricOptionsFor(series.resource, series.metric)}
- />
- <button
- type="button"
- className="skw-iconbtn skw-iconbtn--bare"
- title={`Remove series ${index + 1}`}
- aria-label={`Remove series ${index + 1}`}
- onClick={() => set('series', (cfg.series || []).filter((_, i) => i !== index))}
- >
- <Trash2 size={13} />
- </button>
- </div>
- ))}
- <button
- type="button"
- className="skw-ins__add"
- onClick={() => set('series', [...(cfg.series || []), { resource: '$server', metric: 'cpu' }])}
- >
- <Plus size={12} aria-hidden="true" /> Add series
- </button>
- </div>
- </InspectorRow>
- <InspectorRow label="Legend">
- <Switch
- checked={cfg.legend !== false}
- aria-label="Show legend"
- onCheckedChange={(checked) => set('legend', checked)}
- />
- </InspectorRow>
- <InspectorRow label="Area fill">
- <Switch
- checked={cfg.fill !== false}
- aria-label="Fill the area under each series"
- onCheckedChange={(checked) => set('fill', checked)}
- />
- </InspectorRow>
- </>
- )}
-
- {kind === 'topn' && (
- <>
- <InspectorRow label="Dimension">
- <SegControl
- options={toOptions(TOPN_DIMENSIONS)}
- value={cfg.dim || 'servers'}
- onChange={(value) => set('dim', value)}
- />
- </InspectorRow>
- {/* Top N always ranks remote resources, so it offers the
- server-side catalog whatever the board variable is. */}
- <InspectorRow label="Metric">
- <InspectorSelect
- label="Metric"
- value={cfg.metric || 'cpu'}
- onChange={(value) => set('metric', value)}
- options={topnMetricOptions(cfg.metric || 'cpu')}
- />
- </InspectorRow>
- </>
- )}
-
- {kind === 'table' && (
- <InspectorRow label="Source">
- <InspectorSelect
- label="Source"
- value={cfg.source || 'services'}
- onChange={(value) => set('source', value)}
- options={TABLE_SOURCES}
- />
- </InspectorRow>
- )}
-
- {kind === 'logs' && (
- <>
- <InspectorRow label="Source">
- <InspectorSelect
- label="Log source"
- value={cfg.source || '$server'}
- onChange={(value) => set('source', value)}
- options={resourceOptions}
- />
- </InspectorRow>
- <InspectorRow label="Level">
- <SegControl
- options={toOptions(LOG_LEVELS)}
- value={cfg.level || 'all'}
- onChange={(value) => set('level', value)}
- />
- </InspectorRow>
- </>
- )}
-
- {kind === 'alerts' && (
- <InspectorRow label="Severity">
- <SegControl
- options={toOptions(SEVERITIES)}
- value={cfg.severity || 'all'}
- onChange={(value) => set('severity', value)}
- />
- </InspectorRow>
- )}
-
- {['table', 'logs', 'deploys', 'feed'].includes(kind) && (
- <InspectorRow label={countsLines ? 'Lines' : 'Rows'}>
- <Stepper
- label={countsLines ? 'lines' : 'rows'}
- value={countValue}
- onStep={stepCount}
- />
- </InspectorRow>
- )}
-
- {kind === 'actions' && (
- <InspectorRow label="Shortcuts">
- <div className="skw-ins__checks">
- {QUICK_ACTION_OPTIONS.map(([key, label]) => {
- const on = (cfg.items || []).includes(key);
- return (
- <label className="skw-ins__check" key={key}>
- <input
- type="checkbox"
- checked={on}
- onChange={() => set(
- 'items',
- on
- ? (cfg.items || []).filter((item) => item !== key)
- : [...(cfg.items || []), key],
- )}
- />
- {label}
- </label>
- );
- })}
- </div>
- </InspectorRow>
- )}
-
- {kind === 'note' && (
- <InspectorRow label="Text" hint="**bold** and `code` are supported.">
- <textarea
- className="skw-ins__textarea"
- aria-label="Note text"
- value={cfg.text || ''}
- onChange={(event) => set('text', event.target.value)}
- />
- </InspectorRow>
- )}
-
- <InspectorRow label="Size">
- <div className="skw-ins__pair">
- <Stepper label="width" value={widget.w} suffix="wide" onStep={(d) => stepSize('w', d)} />
- <Stepper label="height" value={widget.h} suffix="tall" onStep={(d) => stepSize('h', d)} />
- </div>
- </InspectorRow>
- </div>
-
- <div className="skw-ins__foot">
- <button type="button" className="btn btn-sm" onClick={onDuplicate}>
- <Copy size={13} aria-hidden="true" /> Duplicate
- </button>
- <button type="button" className="btn btn-sm btn-danger skw-ins__remove" onClick={onRemove}>
- <Trash2 size={13} aria-hidden="true" /> Remove
- </button>
- </div>
- </aside>
- );
-}
-
-export default WidgetInspector;
diff --git a/frontend/src/components/dashboard/widgets/registry.js b/frontend/src/components/dashboard/widgets/registry.js
index 02e13743..568320a4 100644
--- a/frontend/src/components/dashboard/widgets/registry.js
+++ b/frontend/src/components/dashboard/widgets/registry.js
@@ -318,3 +318,51 @@ export function getWidgetType(types, id) {
if (!Array.isArray(types) || !id) return null;
return types.find((t) => t && t.id === id) || null;
}
+
+const METRIC_TITLES = {
+ cpu: 'CPU usage',
+ ram: 'Memory',
+ disk: 'Disk',
+ load: 'Load average',
+ net_in: 'Network in',
+ net_out: 'Network out',
+};
+
+const SOURCE_TITLES = {
+ apps: 'Applications',
+ services: 'Services',
+ servers: 'Servers',
+ containers: 'Containers',
+ deploys: 'Deployments',
+};
+
+/**
+ * What to show in a widget's header.
+ *
+ * Falling straight back to the TYPE name meant a board of four different stats
+ * read "Stat" four times, which tells you nothing about any of them. So when a
+ * widget carries no explicit title, name it after what it is pointed at before
+ * giving up and using the type.
+ *
+ * This is deliberately derived at render time rather than written into the
+ * widget's stored config — config the user never set should not appear in their
+ * saved board.
+ */
+export function deriveWidgetTitle(widget, type) {
+ const cfg = widget?.cfg || {};
+ if (cfg.title) return cfg.title;
+
+ if (METRIC_TITLES[cfg.metric]) return METRIC_TITLES[cfg.metric];
+ if (SOURCE_TITLES[cfg.source]) return SOURCE_TITLES[cfg.source];
+
+ // A multi-series chart is named by its series, up to a point.
+ if (Array.isArray(cfg.series) && cfg.series.length) {
+ const names = cfg.series
+ .map((s) => METRIC_TITLES[s?.metric])
+ .filter(Boolean);
+ if (names.length === 1) return names[0];
+ if (names.length > 1) return `${names.slice(0, -1).join(', ')} & ${names[names.length - 1]}`;
+ }
+
+ return type?.name || widget?.type || 'Widget';
+}
diff --git a/frontend/src/components/dashboard/widgets/renderers.jsx b/frontend/src/components/dashboard/widgets/renderers.jsx
index 3b0723fa..4152bb12 100644
--- a/frontend/src/components/dashboard/widgets/renderers.jsx
+++ b/frontend/src/components/dashboard/widgets/renderers.jsx
@@ -439,7 +439,7 @@ function WTable({ cfg, ctx }) {
function WLogs({ cfg, ctx }) {
const bodyRef = useRef(null);
- const { lines, label, loading, error } = useLogTail(cfg, ctx.tick);
+ const { lines, label, unconfigured, loading, error } = useLogTail(cfg, ctx.tick);
const shown = cfg.level && cfg.level !== 'all'
? lines.filter((l) => l.lvl === cfg.level)
@@ -449,7 +449,13 @@ function WLogs({ cfg, ctx }) {
if (bodyRef.current) bodyRef.current.scrollTop = bodyRef.current.scrollHeight;
}, [shown.length]);
+ if (unconfigured) {
+ return <Empty>Pick a log file or container in this widget&rsquo;s settings.</Empty>;
+ }
if (loading && !lines.length) return <Loading />;
+ if (error?.elevated) {
+ return <Empty>{label || 'This log'} needs elevated access — choose another source in settings.</Empty>;
+ }
if (error) return <Failed error={error} subject="logs" />;
if (!lines.length) return <Empty>No log lines available.</Empty>;
diff --git a/frontend/src/components/dashboard/widgets/useWidgetData.js b/frontend/src/components/dashboard/widgets/useWidgetData.js
index b6e0908b..a528227d 100644
--- a/frontend/src/components/dashboard/widgets/useWidgetData.js
+++ b/frontend/src/components/dashboard/widgets/useWidgetData.js
@@ -419,15 +419,15 @@ export function useLogTail(cfg = {}, tick) {
return { label: target, lines: text.split('\n') };
}
- let path = target;
- if (!path) {
- const files = await api.getLogFiles().then((d) => (Array.isArray(d?.logs) ? d.logs : []));
- if (!files.length) return { label: '', lines: [] };
- path = files[0].path;
- }
- const result = await api.readLog(path, lineCount);
+ // Nothing configured: say so rather than guessing. This used to grab
+ // whatever `getLogFiles()` listed first, which is typically a system
+ // log the panel can't read without a password — so a freshly seeded
+ // dashboard greeted people with "sudo: a password is required".
+ if (!target) return { unconfigured: true, label: '', lines: [] };
+
+ const result = await api.readLog(target, lineCount);
if (result && result.success === false) throw new Error(result.error || 'Could not read log file');
- return { label: path, lines: Array.isArray(result?.lines) ? result.lines : [] };
+ return { label: target, lines: Array.isArray(result?.lines) ? result.lines : [] };
});
const lines = useMemo(() => (
@@ -436,7 +436,24 @@ export function useLogTail(cfg = {}, tick) {
.map(toLogLine)
), [data]);
- return { lines, label: data?.label || '', loading, error };
+ // A permission failure is a setup fact, not a crash — phrase it that way
+ // instead of leaking the shell's own words at the operator.
+ const friendly = useMemo(() => {
+ if (!error) return null;
+ const text = String(error.message || '');
+ if (/sudo|permission denied|not permitted/i.test(text)) {
+ return { ...error, message: 'this log needs elevated access', elevated: true };
+ }
+ return error;
+ }, [error]);
+
+ return {
+ lines,
+ label: data?.label || '',
+ unconfigured: !!data?.unconfigured,
+ loading,
+ error: friendly,
+ };
}
/* ------------------------------------------------------------------- specs */
diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx
index c2d3eb56..e2c90e58 100644
--- a/frontend/src/pages/Dashboard.jsx
+++ b/frontend/src/pages/Dashboard.jsx
@@ -15,7 +15,7 @@ import EmptyState from '../components/EmptyState';
import PluginSlot from '../components/PluginSlot';
import { DashGrid } from '../components/dashboard/grid/DashGrid';
import { WidgetLibrary } from '../components/dashboard/grid/WidgetLibrary';
-import { WidgetInspector } from '../components/dashboard/grid/WidgetInspector';
+import { WidgetEditor } from '../components/dashboard/grid/WidgetEditor';
import { WidgetFullscreen } from '../components/dashboard/grid/WidgetFullscreen';
import {
compact, findFreeSpot, nextWidgetId, pushDown,
@@ -341,11 +341,21 @@ const Dashboard = () => {
);
}
+ // The widget editor is a drawer over the board now, not a docked panel, so
+ // the page no longer reserves a right-hand gutter for it.
return (
- <div className={`page-container dashboard-page${edit && selectedWidget ? ' skw-ins-open' : ''}`}>
+ <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
@@ -388,6 +398,7 @@ const Dashboard = () => {
})}
</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>
@@ -573,10 +584,11 @@ const Dashboard = () => {
/>
)}
{edit && selectedWidget && (
- <WidgetInspector
+ <WidgetEditor
widget={selectedWidget}
type={selectedType}
resources={resources}
+ ctx={ctx}
onChange={updateWidget}
onClose={() => setSelectedId(null)}
onDuplicate={() => duplicateWidget(selectedWidget)}
diff --git a/frontend/src/styles/components/_dashboard-widgets.scss b/frontend/src/styles/components/_dashboard-widgets.scss
index 1c3dff41..3cceab7a 100644
--- a/frontend/src/styles/components/_dashboard-widgets.scss
+++ b/frontend/src/styles/components/_dashboard-widgets.scss
@@ -29,8 +29,6 @@ $skw-grid-gap: 12px;
$skw-stack-row-h: 260px;
// Inspector panel width + the gutter the page reserves for it while open.
-$skw-ins-w: 340px;
-$skw-ins-gutter: 352px;
// The overlay layers sit deliberately ABOVE the app's $z-* scale (which tops
// out at $z-tooltip: 60): a fullscreen widget must cover the page chrome, and
@@ -280,10 +278,6 @@ $skw-z-tv: 200;
// Page/host modifier: reserve the gutter the open inspector occupies so the
// panel never covers the widget being configured.
-.skw-ins-open {
- padding-right: $skw-ins-gutter;
- transition: padding-right 0.18s ease;
-}
// ------------------------------------------------------------
// Widget frame — the chrome every widget type shares.
@@ -1305,324 +1299,7 @@ $skw-z-tv: 200;
}
}
-// ============================================================
-// INSPECTOR — right-hand config panel for the selected widget.
-// ============================================================
-// Fixed rather than a modal: you change a setting and watch the live widget
-// react beside it, which is why the host reserves .skw-ins-open's gutter.
-.skw-ins {
- position: fixed;
- top: 0;
- right: 0;
- bottom: 0;
- z-index: $skw-z-inspector;
- width: $skw-ins-w;
- display: flex;
- flex-direction: column;
- background: var(--surface);
- border-left: 1px solid var(--border-strong);
- box-shadow: var(--shadow-lg);
- animation: skw-ins-in 0.18s cubic-bezier(0.2, 0.7, 0.3, 1);
-
- &__head {
- display: flex;
- align-items: center;
- gap: 10px;
- flex-shrink: 0;
- padding: 14px;
- border-bottom: 1px solid var(--border-soft);
- }
-
- // Widget-type glyph in the panel header — same 32px tinted box as
- // .sk-kpi__icon / .sk-drawer__ico, so the inspector reads as a drawer.
- &__ic {
- width: 32px;
- height: 32px;
- display: grid;
- place-items: center;
- flex-shrink: 0;
- border-radius: 9px;
- background: var(--accent-bg);
- color: var(--accent-bright);
- }
-
- &__title { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
-
- // Type name / instance id under the title. Mono, because it is an
- // identifier rather than prose.
- &__sub {
- margin-top: 1px;
- color: var(--text-faint);
- font-family: var(--mono);
- font-size: 11px;
- }
-
- &__body {
- flex: 1;
- min-height: 0;
- overflow: auto;
- padding: 16px 16px 26px;
- @include custom-scrollbar;
- }
-
- &__row {
- margin-bottom: 15px;
-
- > label {
- display: block;
- margin-bottom: 7px;
- color: var(--text-ghost);
- font-size: 11px;
- letter-spacing: 0.04em;
- text-transform: uppercase;
- }
-
- // Segmented controls fill the panel width instead of hugging content;
- // a 340px column has no room for a control that floats left.
- .sk-seg {
- display: flex;
- width: 100%;
-
- &__btn { flex: 1; justify-content: center; }
- }
- }
-
- &__select {
- width: 100%;
- padding: 7px 24px 7px 9px;
- border: 1px solid var(--border);
- border-radius: 7px;
- background: var(--surface-2);
- color: var(--text);
- font-family: inherit;
- font-size: 12.5px;
- cursor: pointer;
-
- &:focus {
- outline: none;
- border-color: var(--accent);
- box-shadow: 0 0 0 3px var(--accent-bg);
- }
- }
-
- // Single-line text input (widget title, unit, link target). Matched to
- // __select's metrics so a row of mixed controls sits on one baseline —
- // the app's global .form-input is sized for a full-width page form and
- // reads oversized in a 340px column.
- &__field {
- width: 100%;
- padding: 7px 9px;
- border: 1px solid var(--border);
- border-radius: 7px;
- background: var(--surface-2);
- color: var(--text);
- font-family: inherit;
- font-size: 12.5px;
- transition: border-color 0.14s, box-shadow 0.14s;
-
- &::placeholder { color: var(--text-ghost); }
-
- &:focus {
- outline: none;
- border-color: var(--accent);
- box-shadow: 0 0 0 3px var(--accent-bg);
- }
-
- // Numeric fields (thresholds, top-N) read as values, not prose.
- &--mono {
- font-family: var(--mono);
- font-size: 12px;
- font-variant-numeric: tabular-nums;
- }
- }
-
- // Free text: note body, custom query. Resizable vertically only — a
- // horizontal drag would push it out of a fixed-width panel.
- &__textarea {
- @extend .skw-ins__field;
-
- min-height: 96px;
- line-height: 1.55;
- resize: vertical;
- }
-
- // Leading unit/sigil glued to a field ("$", "%", "≥"). Rendered as a
- // sibling inside __pair rather than inside the input, so it never eats a
- // click meant for the text cursor.
- &__prefix {
- flex-shrink: 0;
- padding: 0 2px;
- color: var(--text-faint);
- font-family: var(--mono);
- font-size: 11.5px;
- }
-
- // Two controls sharing one row (amber + red thresholds, min + max).
- &__pair {
- display: flex;
- align-items: center;
- gap: 7px;
-
- > .skw-ins__field,
- > .skw-ins__select { flex: 1; min-width: 0; }
- }
-
- // Explanatory line under a control. Deliberately quieter than the label
- // above it, so a row still reads label → control → aside.
- &__hint {
- display: block;
- margin-top: 6px;
- color: var(--text-faint);
- font-size: 11px;
- line-height: 1.45;
-
- code {
- padding: 1px 4px;
- border-radius: 4px;
- background: var(--surface-3);
- font-family: var(--mono);
- font-size: 10.5px;
- }
- }
-
- // "Add series" / "Add threshold" — a full-width dashed slot rather than a
- // button, so it reads as the next empty row of the list above it.
- &__add {
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 6px;
- width: 100%;
- margin-top: 7px;
- padding: 6px 10px;
- border: 1px dashed var(--border-strong);
- border-radius: 7px;
- background: none;
- color: var(--text-faint);
- font-family: inherit;
- font-size: 11.5px;
- cursor: pointer;
- transition: 0.13s;
-
- &:hover {
- border-color: var(--accent-dim);
- color: var(--accent-bright);
- background: var(--accent-bg);
- }
- }
-
- // Row delete — the 24px third column of __ser. Stays neutral until
- // hovered; a column of red X's would shout over the settings themselves.
- &__remove {
- width: 24px;
- height: 24px;
- display: grid;
- place-items: center;
- border: none;
- border-radius: 6px;
- background: none;
- color: var(--text-ghost);
- cursor: pointer;
- transition: 0.12s;
-
- &:hover { color: var(--red); background: var(--red-bg); }
- }
-
- // Series editor: metric | aggregation | remove.
- &__series {
- display: flex;
- flex-direction: column;
- gap: 7px;
- }
-
- &__ser {
- display: grid;
- grid-template-columns: 1fr 1fr 24px;
- align-items: center;
- gap: 5px;
-
- select,
- .skw-ins__select {
- padding: 6px 22px 6px 8px;
- font-size: 11.5px;
- }
- }
-
- // Column / resource pickers. Capped and scrollable so a long list cannot
- // push the rest of the form out of reach.
- &__checks {
- display: flex;
- flex-direction: column;
- gap: 5px;
- max-height: 190px;
- overflow: auto;
- @include custom-scrollbar;
- }
-
- &__check {
- display: flex;
- align-items: center;
- gap: 9px;
- padding: 3px 2px;
- color: var(--text-dim);
- font-size: 12.5px;
- cursor: pointer;
-
- &:hover { color: var(--text); }
-
- input[type='checkbox'] {
- width: 15px;
- height: 15px;
- flex-shrink: 0;
- accent-color: var(--accent);
- cursor: pointer;
- }
- }
-
- &__foot {
- display: flex;
- align-items: center;
- gap: 8px;
- flex-shrink: 0;
- padding: 12px 14px;
- border-top: 1px solid var(--border-soft);
- }
-}
-
// Numeric stepper (widget span, top-N count, refresh seconds).
-.skw-stepper {
- display: flex;
- align-items: center;
- gap: 2px;
- padding: 2px;
- border: 1px solid var(--border);
- border-radius: 8px;
- background: var(--surface-2);
-
- button {
- width: 26px;
- height: 26px;
- display: grid;
- place-items: center;
- border: none;
- border-radius: 6px;
- background: none;
- color: var(--text-faint);
- cursor: pointer;
- transition: 0.12s;
-
- &:hover { color: #fff; background: var(--accent); }
- &:disabled { opacity: 0.4; cursor: default; background: none; color: var(--text-ghost); }
- }
-
- span {
- min-width: 58px;
- padding: 0 8px;
- color: var(--text-dim);
- font-size: 11.5px;
- text-align: center;
- }
-}
// ============================================================
// FULLSCREEN WIDGET + TV MODE
@@ -1759,10 +1436,6 @@ $skw-z-tv: 200;
// ============================================================
// ANIMATIONS (prefixed — the mock's insIn/modalIn/tickPulse are global)
// ============================================================
-@keyframes skw-ins-in {
- from { transform: translateX(18px); opacity: 0; }
- to { transform: none; opacity: 1; }
-}
@keyframes skw-modal-in {
from { transform: translateX(-50%) translateY(10px); opacity: 0; }
@@ -1779,16 +1452,6 @@ $skw-z-tv: 200;
to { opacity: 1; }
}
-// ============================================================
-// RESPONSIVE
-// ============================================================
-// The inspector's reserved gutter is 352px. Below $breakpoint-xl the content
-// column is already narrow enough that giving a third of it to the panel
-// leaves the board unreadable, so the panel starts overlaying instead.
-@include respond-to($breakpoint-xl) {
- .skw-ins-open { padding-right: 0; }
-}
-
@include respond-to($breakpoint-lg) {
// Board controls wrap under the tabs rather than fighting them for width.
.skw-bar__ctl {
@@ -1833,12 +1496,6 @@ $skw-z-tv: 200;
.skw-frame--edit .skw-frame__head,
.skw-frame.is-edit .skw-frame__head { cursor: default; }
- // Inspector becomes a full-width sheet.
- .skw-ins {
- width: 100vw;
- border-left: none;
- }
-
.skw-full {
top: 0;
width: 100vw;
diff --git a/frontend/src/styles/components/_widget-editor.scss b/frontend/src/styles/components/_widget-editor.scss
new file mode 100644
index 00000000..b7c2bef1
--- /dev/null
+++ b/frontend/src/styles/components/_widget-editor.scss
@@ -0,0 +1,458 @@
+// ============================================================
+// WIDGET EDITOR — the wide "configure this widget" drawer.
+// ============================================================
+// Replaces the 340px right-hand inspector (`.skw-ins`, deleted). Grafana's
+// shape: a live render of the real widget on the left, its settings on the
+// right, in a drawer as wide as the "Add a widget" one.
+//
+// Namespaced `skwe-` (ServerKit Widget Editor). Everything this file styles is
+// emitted by WidgetEditor.jsx and nothing else — the ONLY names it reaches for
+// outside the namespace are `.sk-drawer__body` (the shared drawer's scroll
+// region, which this panel has to hand its scrolling back to) and `.skw-frame`
+// (the board's own widget chrome, reused so the preview cannot drift from what
+// the board draws). Both are scoped under a `skwe-` ancestor.
+//
+// Colours all come from var() tokens in _theme-variables.scss, so the panel
+// reads correctly in both themes.
+// ============================================================
+
+// Settings column. Fixed, because a form column that grows with the viewport
+// just spreads three controls across a page width.
+$skwe-pane-w: 340px;
+
+// ------------------------------------------------------------
+// Drawer shell. ds/Drawer's body is a plain scroller; this panel owns three
+// regions (preview, settings, footer) that scroll independently, so the
+// scrolling has to move down a level.
+// ------------------------------------------------------------
+.skwe-drawer {
+ .sk-drawer__body {
+ display: flex;
+ flex-direction: column;
+ overflow: hidden;
+ }
+}
+
+.skwe-edit {
+ flex: 1;
+ min-height: 0;
+ display: flex;
+ flex-direction: column;
+
+ &__cols {
+ flex: 1;
+ min-height: 0;
+ display: flex;
+ align-items: stretch;
+ }
+
+ // ---------------- preview (left, flexible) ----------------
+ &__preview {
+ flex: 1 1 auto;
+ min-width: 0;
+ min-height: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 9px;
+ padding: 16px 18px;
+ border-right: 1px solid var(--border-soft);
+ }
+
+ // Stands in for the board behind the widget: same page background, plus a
+ // dot grid so the frame reads as "placed on a board" rather than floating
+ // in the drawer. Scrolls, because a 10-row widget is taller than any
+ // drawer.
+ &__stage {
+ flex: 1;
+ min-height: 0;
+ display: flex;
+ justify-content: center;
+ align-items: flex-start;
+ padding: 18px;
+ overflow: auto;
+ border: 1px solid var(--border-soft);
+ border-radius: var(--radius-lg);
+ background-color: var(--bg-body);
+ background-image: radial-gradient(circle at 1px 1px, var(--border-strong) 1px, transparent 0);
+ background-size: 24px 24px;
+ @include custom-scrollbar;
+ }
+
+ // Sits alongside `.skw-frame`; JSX sets the pixel width/height inline from
+ // the widget's own w/h, so stepping the size steppers moves this box by
+ // exactly what the board would move it.
+ &__frame {
+ flex: none;
+ max-width: 100%;
+ box-shadow: var(--shadow-lg);
+ }
+
+ &__caption {
+ flex-shrink: 0;
+ color: var(--text-faint);
+ font-size: 11px;
+ text-align: center;
+ }
+
+ // ---------------- settings (right, fixed) -----------------
+ &__pane {
+ flex: 0 0 $skwe-pane-w;
+ width: $skwe-pane-w;
+ min-height: 0;
+ overflow: auto;
+ padding: 16px 18px 26px;
+ background: var(--surface);
+ @include custom-scrollbar;
+ }
+
+ &__group {
+ margin-bottom: 22px;
+
+ &:last-child { margin-bottom: 0; }
+ }
+
+ &__grouphead {
+ margin-bottom: 13px;
+ padding-bottom: 7px;
+ border-bottom: 1px solid var(--border-soft);
+ color: var(--text-dim);
+ font-size: 11px;
+ font-weight: 600;
+ letter-spacing: 0.06em;
+ text-transform: uppercase;
+ }
+
+ &__row {
+ margin-bottom: 15px;
+
+ &:last-child { margin-bottom: 0; }
+
+ // A bare switch reads better beside its caption than under it.
+ &--inline {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+
+ .skwe-edit__label { margin-bottom: 0; }
+ .skwe-edit__control { flex: none; }
+ }
+
+ // Segmented controls fill the column instead of hugging content; a
+ // 340px column has no room for a control that floats left.
+ .sk-seg {
+ display: flex;
+ width: 100%;
+
+ &__btn { flex: 1; justify-content: center; }
+ }
+ }
+
+ &__label {
+ display: block;
+ margin-bottom: 6px;
+ color: var(--text-ghost);
+ font-size: 11px;
+ letter-spacing: 0.04em;
+ text-transform: uppercase;
+ }
+
+ &__control { min-width: 0; }
+
+ // ---------------- inputs ----------------------------------
+ // Every rule below targets the FORM ELEMENT itself, never a wrapper around
+ // it. The old inspector styled a <div> that wrapped a bare <input>, so the
+ // input kept its user-agent default and rendered as a white box on the dark
+ // panel. Adding a wrapper here is fine; leaving the control unnamed is not.
+ &__field,
+ &__select,
+ &__textarea {
+ width: 100%;
+ padding: 7px 9px;
+ border: 1px solid var(--border);
+ border-radius: 7px;
+ background: var(--surface-2);
+ color: var(--text);
+ font-family: inherit;
+ font-size: 12.5px;
+ transition: border-color 0.14s, box-shadow 0.14s;
+
+ &::placeholder { color: var(--text-ghost); }
+
+ &:focus,
+ &:focus-visible {
+ outline: none;
+ border-color: var(--accent);
+ box-shadow: 0 0 0 3px var(--accent-bg);
+ }
+ }
+
+ &__select {
+ padding-right: 24px;
+ cursor: pointer;
+
+ // Most engines inherit the control's colours into the popup list, but
+ // not all of them — name it so the options are never white-on-white.
+ option {
+ background: var(--surface-2);
+ color: var(--text);
+ }
+ }
+
+ // Numeric fields (thresholds) read as values, not prose.
+ &__field--mono {
+ font-family: var(--mono);
+ font-size: 12px;
+ font-variant-numeric: tabular-nums;
+ }
+
+ &__textarea {
+ min-height: 110px;
+ line-height: 1.55;
+ resize: vertical;
+ }
+
+ // Read-only stand-in shown where a picker would only ever offer one answer
+ // (a single connected machine). Dashed, so it does not pretend to be a
+ // control you can open.
+ &__static {
+ padding: 7px 9px;
+ border: 1px dashed var(--border);
+ border-radius: 7px;
+ background: var(--surface-2);
+ color: var(--text-dim);
+ font-size: 12px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ }
+
+ // Explanatory line under a control — quieter than the caption above it, so
+ // a row still reads caption → control → aside.
+ &__hint {
+ margin: 6px 0 0;
+ color: var(--text-faint);
+ font-size: 11px;
+ line-height: 1.45;
+ }
+
+ // Two controls sharing one row (amber + red thresholds, width + height).
+ &__pair {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+
+ > .skwe-edit__pairitem,
+ > .skwe-stepper { flex: 1; min-width: 0; }
+ }
+
+ &__pairitem {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ }
+
+ // Leading sigil glued to a field ("amber ≥"). A sibling rather than
+ // something inside the input, so it never eats a click meant for the
+ // text cursor.
+ &__unit {
+ flex: none;
+ color: var(--text-faint);
+ font-size: 11px;
+ white-space: nowrap;
+ }
+
+ // ---------------- series editor ---------------------------
+ &__series {
+ display: flex;
+ flex-direction: column;
+ gap: 7px;
+ }
+
+ &__ser {
+ display: grid;
+ grid-template-columns: 1fr 1fr 26px;
+ align-items: center;
+ gap: 6px;
+
+ // Single-machine install: the resource picker is gone, so the metric
+ // select takes the whole row.
+ &--solo { grid-template-columns: 1fr 26px; }
+
+ .skwe-edit__select {
+ padding: 6px 22px 6px 8px;
+ font-size: 11.5px;
+ }
+ }
+
+ // Row delete. Stays neutral until hovered; a column of red bins would
+ // shout over the settings themselves.
+ &__del {
+ width: 26px;
+ height: 26px;
+ display: grid;
+ place-items: center;
+ border: none;
+ border-radius: 6px;
+ background: none;
+ color: var(--text-ghost);
+ cursor: pointer;
+ transition: 0.12s;
+
+ &:hover { color: var(--red); background: var(--red-bg); }
+ &:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
+ }
+
+ // "Add series" — a full-width dashed slot rather than a button, so it
+ // reads as the next empty row of the list above it.
+ &__add {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ gap: 6px;
+ width: 100%;
+ margin-top: 2px;
+ padding: 6px 10px;
+ border: 1px dashed var(--border-strong);
+ border-radius: 7px;
+ background: none;
+ color: var(--text-faint);
+ font-family: inherit;
+ font-size: 11.5px;
+ cursor: pointer;
+ transition: 0.13s;
+
+ &:hover {
+ border-color: var(--accent-dim);
+ color: var(--accent-bright);
+ background: var(--accent-bg);
+ }
+
+ &:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
+ }
+
+ &__empty {
+ padding: 2px 0 4px;
+ color: var(--text-faint);
+ font-size: 11.5px;
+ line-height: 1.45;
+ }
+
+ // ---------------- checkbox list ---------------------------
+ // Capped and scrollable so a long shortcut list cannot push the rest of
+ // the form out of reach.
+ &__checks {
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ max-height: 210px;
+ overflow: auto;
+ @include custom-scrollbar;
+ }
+
+ &__check {
+ display: flex;
+ align-items: center;
+ gap: 9px;
+ padding: 3px 2px;
+ color: var(--text-dim);
+ font-size: 12.5px;
+ cursor: pointer;
+
+ &:hover { color: var(--text); }
+
+ input[type='checkbox'] {
+ width: 15px;
+ height: 15px;
+ flex-shrink: 0;
+ accent-color: var(--accent);
+ cursor: pointer;
+ }
+ }
+
+ // ---------------- footer ----------------------------------
+ &__foot {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-shrink: 0;
+ padding: 12px 18px;
+ border-top: 1px solid var(--border-soft);
+ background: var(--surface);
+ }
+
+ // Pushes the close affordance to the far edge, away from Remove.
+ &__spacer { flex: 1; }
+}
+
+// ------------------------------------------------------------
+// Numeric stepper (widget span, row/line count).
+// ------------------------------------------------------------
+.skwe-stepper {
+ display: flex;
+ align-items: center;
+ gap: 2px;
+ padding: 2px;
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ background: var(--surface-2);
+
+ &__btn {
+ width: 26px;
+ height: 26px;
+ flex-shrink: 0;
+ display: grid;
+ place-items: center;
+ border: none;
+ border-radius: 6px;
+ background: none;
+ color: var(--text-faint);
+ cursor: pointer;
+ transition: 0.12s;
+
+ &:hover { color: #fff; background: var(--accent); }
+ &:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
+ }
+
+ &__val {
+ flex: 1;
+ min-width: 0;
+ padding: 0 6px;
+ color: var(--text-dim);
+ font-size: 11.5px;
+ text-align: center;
+ white-space: nowrap;
+ }
+}
+
+// ------------------------------------------------------------
+// Below the lg breakpoint the drawer is too narrow for two columns, so they
+// stack: preview on top, settings under it, and the whole thing scrolls as one
+// column instead of two independent ones.
+// ------------------------------------------------------------
+@media (max-width: $breakpoint-lg) {
+ .skwe-edit {
+ &__cols {
+ flex-direction: column;
+ overflow: auto;
+ @include custom-scrollbar;
+ }
+
+ &__preview {
+ flex: none;
+ border-right: none;
+ border-bottom: 1px solid var(--border-soft);
+ }
+
+ &__stage {
+ min-height: 220px;
+ max-height: 44vh;
+ }
+
+ &__pane {
+ flex: none;
+ width: auto;
+ overflow: visible;
+ }
+ }
+}
diff --git a/frontend/src/styles/main.scss b/frontend/src/styles/main.scss
index cfe2fb7c..749fd6b5 100644
--- a/frontend/src/styles/main.scss
+++ b/frontend/src/styles/main.scss
@@ -72,6 +72,7 @@
@import 'components/_staging-banner';
@import 'components/_design-system'; // redesign shared primitives (sk-* namespace)
@import 'components/_dashboard-widgets'; // configurable dashboard grid (skw-* namespace)
+@import 'components/_widget-editor'; // wide preview+settings widget drawer (skwe-* namespace)
@import 'components/_system-notices';
@import 'components/container-status';
@import 'components/api-key-scopes';