clavarium 0.2.150-next.1 → 0.2.151-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/server/api.mjs +15 -1
- package/server/history.mjs +40 -0
- package/web/app.js +240 -1
- package/web/index.html +31 -0
- package/web/style.css +112 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.151-next.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "clavarium",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.151-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/package.json
CHANGED
package/server/api.mjs
CHANGED
|
@@ -97,6 +97,8 @@
|
|
|
97
97
|
* GET /api/meshcentral: the remote screen (MeshCentral); POST /api/meshcentral/enable (turned on, in the background) /disable
|
|
98
98
|
* GET /api/events?kind=&conversation=&q=&before=&limit= what happened, newest first
|
|
99
99
|
* GET /api/history?of=server|<name>&span=1h|24h|7d the curves of memory, CPU and disk (and the reserve, for the server)
|
|
100
|
+
* GET /api/history/all?span=1h|24h|7d Settings, Usage: the server and every machine (asleep too) on one time axis,
|
|
101
|
+
* in GB and cores: {t, capacity, server, itself, machines: [{name, alloc, asleep, ...}]}
|
|
100
102
|
* GET /api/server/logs?source=&span= what the server's programs said POST /api/server/restart
|
|
101
103
|
* GET /api/operators who may sign in POST /api/operators {email} -> {email, password}: shown once
|
|
102
104
|
* POST /api/operators/<email>/password -> {email, password} POST /api/operators/<email>/disable|enable|remove
|
|
@@ -128,7 +130,7 @@
|
|
|
128
130
|
* Origin header is compared, and the body must be JSON, which a form on
|
|
129
131
|
* another site cannot send. */
|
|
130
132
|
import { sameOrigin } from './bridge.mjs';
|
|
131
|
-
import { Refusal } from './conversations.mjs';
|
|
133
|
+
import { Refusal, DISK_GB } from './conversations.mjs';
|
|
132
134
|
import { VmUnknown } from './vm.mjs';
|
|
133
135
|
import { list, download, importFile, page, PAGE_HEADERS, changeRoute, IMAGE_HEADERS } from './files.mjs';
|
|
134
136
|
import { WORK_TAB } from './resources.mjs';
|
|
@@ -296,6 +298,18 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
296
298
|
}
|
|
297
299
|
return send(200, curves), true;
|
|
298
300
|
}
|
|
301
|
+
if (pathname === '/api/history/all' && history) {
|
|
302
|
+
const a = capacity ? await capacity.about().catch(() => null) : null;
|
|
303
|
+
const room = capacity ? await capacity.room().catch(() => null) : null;
|
|
304
|
+
/* What each machine's disk takes on this server, measured now and then (known asleep too). */
|
|
305
|
+
const held = new Map((a?.usage?.machines?.each ?? []).map((x) => [x.name, x.mb]));
|
|
306
|
+
const machines = conversations.list().filter((c) => ['ready', 'restarting', 'moving'].includes(c.phase)).map((c) => ({
|
|
307
|
+
name: c.name, memoryMb: c.memoryMb, cores: c.cpus ?? 1, asleep: c.asleep === true,
|
|
308
|
+
/* Its disk as its machine sees it when known, else the size it was given. */
|
|
309
|
+
diskMb: health?.of(c.name)?.disks?.['/']?.sizeMb ?? (c.diskGb ?? DISK_GB) * 1024, hostDiskMb: held.get(c.name),
|
|
310
|
+
}));
|
|
311
|
+
return send(200, history.together(query.get('span') ?? '1h', machines, { memoryMb: a?.memory?.totalMb, cores: room?.cpu?.cores, diskMb: a?.disk?.sizeMb })), true;
|
|
312
|
+
}
|
|
299
313
|
if (pathname === '/api/server/logs' && serverLogs) return send(200, await serverLogs.read(query.get('source') ?? 'clavarium', query.get('span') ?? '1')), true;
|
|
300
314
|
if (pathname === '/api/machines/disks' && machinesMove) return send(200, await machinesMove.disks()), true;
|
|
301
315
|
if (pathname === '/api/machines/places' && machinesMove) return send(200, await machinesMove.places()), true;
|
package/server/history.mjs
CHANGED
|
@@ -12,6 +12,12 @@
|
|
|
12
12
|
* health }] (health: health.mjs's last record, or null)
|
|
13
13
|
* series(of, span) { t: [ms...], <measure>: [percent or null...], marks: [ms...] }
|
|
14
14
|
* of: 'server' or a conversation's name; span: '1h' '24h' '7d'
|
|
15
|
+
* together(span, machines, server) Settings, Usage: the server and every machine on ONE
|
|
16
|
+
* time axis, in gigabytes and cores (percent x what each was given):
|
|
17
|
+
* { span, t, capacity: {memoryGb, cores, diskGb}, server: {memory, cpu, disk},
|
|
18
|
+
* itself: {...}, machines: [{ name, alloc, asleep, since, memory, cpu, disk, marks }] }
|
|
19
|
+
* machines [{ name, memoryMb, cores, diskMb, hostDiskMb?, asleep? }],
|
|
20
|
+
* server { memoryMb, cores, diskMb }
|
|
15
21
|
*
|
|
16
22
|
* Kept: every minute for a day, then fifteen-minute blocks (their highest value:
|
|
17
23
|
* a peak stays seen) for a week. A few hundred kilobytes in a file of its own,
|
|
@@ -106,6 +112,40 @@ export class History {
|
|
|
106
112
|
return out;
|
|
107
113
|
}
|
|
108
114
|
|
|
115
|
+
/* Who takes what, side by side: every curve on the server's own times (a machine is looked at in
|
|
116
|
+
the same look as the server, so its times are the same ones), and in gigabytes and cores rather
|
|
117
|
+
than in percent -- a stack of shares of different sizes says nothing. "This server itself" is
|
|
118
|
+
what the server uses beyond its machines: the system, Clavarium, the files. */
|
|
119
|
+
together(span, machines = [], server = {}) {
|
|
120
|
+
const s = this.series('server', span);
|
|
121
|
+
const gb = (mb) => (Number.isFinite(mb) && mb > 0 ? Math.round((mb / 1024) * 100) / 100 : null);
|
|
122
|
+
const abs = (v, all) => (v === null || v === undefined || all === null ? null : Math.round((v / 100) * all * 1000) / 1000);
|
|
123
|
+
const capacity = { memoryGb: gb(server.memoryMb), cores: server.cores || null, diskGb: gb(server.diskMb) };
|
|
124
|
+
const out = { span: s.span, from: s.from, to: s.to, t: s.t, capacity, server: {}, itself: {}, machines: [] };
|
|
125
|
+
for (const m of MEASURES) out.server[m] = s[m].map((v) => abs(v, m === 'cpu' ? capacity.cores : capacity[`${m}Gb`]));
|
|
126
|
+
for (const x of machines) {
|
|
127
|
+
const own = this.series(x.name, span);
|
|
128
|
+
const at = new Map(own.t.map((t, i) => [t, i]));
|
|
129
|
+
const alloc = { memoryGb: gb(x.memoryMb), cores: x.cores || 1, diskGb: gb(x.diskMb) };
|
|
130
|
+
const first = own.t[0] ?? Infinity;
|
|
131
|
+
/* Asleep (or not looked inside), its disk is still taken: what it holds on this server's disk, from its first look on. */
|
|
132
|
+
const held = gb(x.hostDiskMb);
|
|
133
|
+
const curve = (m, all) => s.t.map((t) => { const i = at.get(t); const v = i === undefined ? null : abs(own[m][i], all); return v === null && m === 'disk' && held !== null && t >= first ? held : v; });
|
|
134
|
+
out.machines.push({ name: x.name, alloc, asleep: Boolean(x.asleep), since: x.asleep ? this.lastSeen(x.name) : null, memory: curve('memory', alloc.memoryGb), cpu: curve('cpu', alloc.cores), disk: curve('disk', alloc.diskGb), marks: own.marks });
|
|
135
|
+
}
|
|
136
|
+
/* The server itself: its total less its machines, never below nothing (the two are not read at the same instant). */
|
|
137
|
+
for (const m of MEASURES) out.itself[m] = out.server[m].map((v, i) => (v === null ? null : Math.max(0, Math.round((v - out.machines.reduce((a, x) => a + (x[m][i] ?? 0), 0)) * 1000) / 1000)));
|
|
138
|
+
return out;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/* When a machine was last seen running (its memory known), over the whole week kept; null if never. */
|
|
142
|
+
lastSeen(of) {
|
|
143
|
+
const k = this.#keys.get(of); if (!k) return null;
|
|
144
|
+
const rows = [...k.blocks, ...(k.block ? [k.block] : []), ...k.minutes];
|
|
145
|
+
let last = null; for (const r of rows) if (r[1] !== null && (last === null || r[0] > last)) last = r[0];
|
|
146
|
+
return last;
|
|
147
|
+
}
|
|
148
|
+
|
|
109
149
|
forget(name) { this.#keys.delete(name); }
|
|
110
150
|
|
|
111
151
|
save() {
|
package/web/app.js
CHANGED
|
@@ -5309,6 +5309,7 @@
|
|
|
5309
5309
|
void paintInstance();
|
|
5310
5310
|
if ($('settings-wifi-top').open) void paintWifi();
|
|
5311
5311
|
if ($('settings-mesh-top').open) void paintScreen();
|
|
5312
|
+
if ($('settings-usage-top').open) void paintUsage();
|
|
5312
5313
|
await Promise.all([paintHosts(), paintShelf(), paintServer(), paintUpdates()]);
|
|
5313
5314
|
}
|
|
5314
5315
|
|
|
@@ -6103,10 +6104,248 @@
|
|
|
6103
6104
|
}
|
|
6104
6105
|
/* Kept current while in sight: a new look a minute. */
|
|
6105
6106
|
setInterval(() => { for (const box of document.querySelectorAll('.curves')) if (box.offsetParent !== null) void paintCurves(box, { force: true }); }, 60_000);
|
|
6107
|
+
/* SETTINGS, USAGE (server/history.mjs together(); GET /api/history/all): who takes the memory, the CPU
|
|
6108
|
+
and the disk -- each machine and this server itself, in GB and cores, now (three tiles) and over time
|
|
6109
|
+
(one stacked chart), then ranked. One colour per conversation, given by the order of the names: a
|
|
6110
|
+
conversation keeps its colour whatever its rank, and from one span or measure to the next. */
|
|
6111
|
+
const USAGE_WORD = { memory: 'Memory', cpu: 'CPU', disk: 'Disk' };
|
|
6112
|
+
const USAGE_SPAN = { '1h': '1 h', '24h': '24 h', '7d': '7 days' };
|
|
6113
|
+
const usage = { r: null, measure: 'memory', span: '24h', focus: null };
|
|
6114
|
+
const uEsc = (s) => String(s).replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`);
|
|
6115
|
+
const uKey = (m) => (m === 'cpu' ? 'cores' : `${m}Gb`);
|
|
6116
|
+
const uFix = (v, d) => (Math.round(v * 10 ** d) / 10 ** d).toFixed(d);
|
|
6117
|
+
const uFmt = (m, v) => (m === 'cpu' ? `${uFix(v, 1)} ${uFix(v, 1) === '1.0' ? 'core' : 'cores'}` : `${uFix(v, m === 'disk' && v >= 10 ? 0 : 1)} GB`);
|
|
6118
|
+
const uAlloc = (m, v) => (m === 'cpu' ? `${v} ${v === 1 ? 'core' : 'cores'}` : `${uFix(v, Number.isInteger(v) ? 0 : 1)} GB`);
|
|
6119
|
+
const uAgo = (ms) => { const m = Math.round(ms / 60_000); return m < 1 ? 'just now' : m < 60 ? `${m} min` : m < 48 * 60 ? `${Math.round(m / 60)} h` : `${Math.round(m / 1440)} days`; };
|
|
6120
|
+
const uWhen = (t) => new Date(t).toLocaleString([], usage.span === '7d' ? { weekday: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' } : { hour: '2-digit', minute: '2-digit' });
|
|
6121
|
+
/* Six colours, then the same six hatched; past twelve, the rest is one "others" (never a colour reused silently). */
|
|
6122
|
+
const uFill = (x) => (x.hatch ? `repeating-linear-gradient(135deg, var(--${x.c}) 0 3px, transparent 3px 5px)` : `var(--${x.c})`);
|
|
6123
|
+
function usageWho(r) {
|
|
6124
|
+
const all = [...r.machines].sort((a, b) => a.name.localeCompare(b.name));
|
|
6125
|
+
const many = all.length > 12; const shown = many ? all.slice(0, 11) : all;
|
|
6126
|
+
const who = shown.map((x, i) => ({ ...x, key: x.name, c: `s${(i % 6) + 1}`, hatch: i >= 6 }));
|
|
6127
|
+
if (many) {
|
|
6128
|
+
const rest = all.slice(11);
|
|
6129
|
+
const sum = (m) => r.t.map((_, i) => (rest.some((x) => x[m][i] !== null) ? rest.reduce((a, x) => a + (x[m][i] ?? 0), 0) : null));
|
|
6130
|
+
const alloc = (k) => rest.reduce((a, x) => a + (x.alloc[k] ?? 0), 0);
|
|
6131
|
+
who.push({ name: `${rest.length} others`, key: '__others', c: 's0', hatch: true, asleep: rest.every((x) => x.asleep), since: null, alloc: { memoryGb: alloc('memoryGb'), cores: alloc('cores'), diskGb: alloc('diskGb') }, memory: sum('memory'), cpu: sum('cpu'), disk: sum('disk'), marks: rest.flatMap((x) => x.marks) });
|
|
6132
|
+
}
|
|
6133
|
+
return who;
|
|
6134
|
+
}
|
|
6135
|
+
const uAsleep = (x, m) => x.asleep && m !== 'disk';
|
|
6136
|
+
const uLast = (r, m) => { for (let i = r.t.length - 1; i >= 0; i -= 1) if (r.server[m][i] !== null) return i; return -1; };
|
|
6137
|
+
const uCap = (r, m) => r.capacity[uKey(m)] ?? Math.max(1, ...r.server[m].filter((v) => v !== null));
|
|
6138
|
+
function paintUsageTiles(r, who) {
|
|
6139
|
+
const box = $('usage-tiles'); box.replaceChildren();
|
|
6140
|
+
for (const m of ['memory', 'cpu', 'disk']) {
|
|
6141
|
+
const i = uLast(r, m); const cap = uCap(r, m);
|
|
6142
|
+
const parts = who.map((x) => ({ x, v: i < 0 ? 0 : x[m][i] ?? 0 }));
|
|
6143
|
+
const itself = i < 0 ? 0 : r.itself[m][i] ?? 0;
|
|
6144
|
+
const used = i < 0 ? 0 : r.server[m][i];
|
|
6145
|
+
const top = [...parts].sort((a, b) => b.v - a.v)[0];
|
|
6146
|
+
const b = el('button', 'u-tile'); b.type = 'button'; b.setAttribute('aria-pressed', String(usage.measure === m));
|
|
6147
|
+
const seg = (name, v, fill, faded) => `<span title="${uEsc(name)} · ${uFmt(m, v)}" style="width:${(v / cap) * 100}%;background:${fill}${faded ? ';opacity:.25' : ''}"></span>`;
|
|
6148
|
+
b.innerHTML = `<div class="u-tile-head"><span class="u-tile-what">${USAGE_WORD[m]}</span><span class="u-tile-pct u-num">${i < 0 ? '' : `${Math.round((used / cap) * 100)} %`}</span></div>
|
|
6149
|
+
<div class="u-tile-big u-num">${i < 0 ? '—' : uFmt(m, used)} <small>of ${uAlloc(m, cap)}</small></div>
|
|
6150
|
+
<div class="u-stack" aria-hidden="true">${parts.filter((p) => p.v > 0).map((p) => seg(p.x.name, p.v, uFill(p.x), usage.focus && usage.focus !== p.x.key)).join('')}${itself > 0 ? seg('This server itself', itself, 'var(--s0)', Boolean(usage.focus)) : ''}</div>
|
|
6151
|
+
<div class="u-tile-foot"><span>Free ${i < 0 ? '—' : uFmt(m, Math.max(0, cap - used))}</span><span>${top?.v > 0 ? `Most: ${uEsc(top.x.name)}` : ''}</span></div>`;
|
|
6152
|
+
b.addEventListener('click', () => { usage.measure = m; paintUsageAll(); });
|
|
6153
|
+
box.append(b);
|
|
6154
|
+
}
|
|
6155
|
+
}
|
|
6156
|
+
function paintUsageLegend(who) {
|
|
6157
|
+
$('usage-legend').replaceChildren(...who.map((x) => {
|
|
6158
|
+
const b = el('button', `u-chip${x.asleep ? ' asleep' : ''}`); b.type = 'button'; b.setAttribute('aria-pressed', String(usage.focus === x.key));
|
|
6159
|
+
const sw = el('i'); sw.style.background = uFill(x);
|
|
6160
|
+
b.append(sw, document.createTextNode(x.name)); if (x.asleep) b.append(document.createTextNode(' '), el('span', 'u-z', 'asleep'));
|
|
6161
|
+
b.addEventListener('click', () => usageFocus(x.key));
|
|
6162
|
+
return b;
|
|
6163
|
+
}));
|
|
6164
|
+
}
|
|
6165
|
+
function uNiceStep(max, ticks) { const raw = max / ticks; const p = 10 ** Math.floor(Math.log10(raw)); for (const k of [1, 2, 2.5, 5, 10]) if (k * p >= raw) return k * p; return 10 * p; }
|
|
6166
|
+
let usageGeo = null;
|
|
6167
|
+
function paintUsageChart(r, who) {
|
|
6168
|
+
const svg = $('usage-svg'); svg.replaceChildren(); $('usage-tip').hidden = true;
|
|
6169
|
+
const m = usage.measure; const N = r.t.length;
|
|
6170
|
+
const W = $('usage-plot').clientWidth || 600; usageWidth = W; const phone = W < 560; const H = phone ? 230 : 300;
|
|
6171
|
+
const M = { l: phone ? 34 : 44, r: phone ? 6 : 128, t: 14, b: 24 };
|
|
6172
|
+
svg.setAttribute('viewBox', `0 0 ${W} ${H}`); svg.setAttribute('height', H);
|
|
6173
|
+
$('usage-chart-title').textContent = `${USAGE_WORD[m]} over time`;
|
|
6174
|
+
$('usage-k-oom').hidden = m !== 'memory';
|
|
6175
|
+
const cap = uCap(r, m);
|
|
6176
|
+
/* The machines in their fixed order, bottom to top; the server itself on top. */
|
|
6177
|
+
const layers = [...who.map((x) => ({ key: x.key, x, v: x[m] })), { key: '__sys', x: { c: 's0', name: 'This server itself' }, v: r.itself[m] }];
|
|
6178
|
+
const tops = []; let acc = new Array(N).fill(0);
|
|
6179
|
+
for (const L of layers) { const lo = acc; const hi = lo.map((a, i) => a + (L.v[i] ?? 0)); tops.push({ ...L, lo, hi }); acc = hi; }
|
|
6180
|
+
const ymax = Math.max(cap, ...acc) * 1.06;
|
|
6181
|
+
const step = uNiceStep(ymax, phone ? 4 : 5);
|
|
6182
|
+
const t0 = r.from; const t1 = r.to; const pw = W - M.l - M.r;
|
|
6183
|
+
const x = (t) => M.l + ((t - t0) / Math.max(1, t1 - t0)) * pw;
|
|
6184
|
+
const y = (v) => H - M.b - (v / ymax) * (H - M.t - M.b);
|
|
6185
|
+
for (let v = 0; v <= ymax; v += step) { svg.append(svgEl('line', { class: v === 0 ? 'u-base' : 'u-gridline', x1: M.l, x2: W - M.r, y1: y(v), y2: y(v) })); const tx = svgEl('text', { x: M.l - 6, y: y(v) + 4, 'text-anchor': 'end' }); tx.textContent = String(Math.round(v * 10) / 10); svg.append(tx); }
|
|
6186
|
+
const unit = svgEl('text', { x: M.l - 6, y: M.t - 4, 'text-anchor': 'end' }); unit.textContent = m === 'cpu' ? 'cores' : 'GB'; svg.append(unit);
|
|
6187
|
+
/* Time ticks: midnights over a week, round hours (or ten minutes) else. */
|
|
6188
|
+
const tickStep = usage.span === '7d' ? 24 * 3600_000 : usage.span === '1h' ? (phone ? 15 : 10) * 60_000 : (phone ? 6 : 3) * 3600_000;
|
|
6189
|
+
const first = new Date(t0); if (usage.span === '7d') first.setHours(24, 0, 0, 0); else first.setTime(Math.ceil(t0 / tickStep) * tickStep);
|
|
6190
|
+
for (let t = first.getTime(); t <= t1; t += tickStep) {
|
|
6191
|
+
if (x(t) < M.l + 14 || x(t) > W - M.r - 14) continue;
|
|
6192
|
+
const e = svgEl('text', { x: x(t), y: H - 6, 'text-anchor': 'middle' }); e.textContent = new Date(t).toLocaleString([], usage.span === '7d' ? { weekday: 'short', day: 'numeric' } : { hour: '2-digit', minute: '2-digit' }); svg.append(e);
|
|
6193
|
+
}
|
|
6194
|
+
/* Hatched fills, for the seventh conversation on. */
|
|
6195
|
+
const defs = svgEl('defs', {}); svg.append(defs);
|
|
6196
|
+
const fillOf = (L) => { if (!L.x.hatch) return `fill:var(--${L.x.c})`; const id = `u-h-${L.x.c}`; if (!defs.querySelector(`#${id}`)) { const p = svgEl('pattern', { id, width: 5, height: 5, patternUnits: 'userSpaceOnUse', patternTransform: 'rotate(45)' }); p.append(svgEl('rect', { width: 3, height: 5, style: `fill:var(--${L.x.c})` })); defs.append(p); } return `fill:url(#${id})`; };
|
|
6197
|
+
/* A gap in the looks (the server was down) is a gap in the chart: one shape per run of looks. */
|
|
6198
|
+
const gap = 3 * (usage.span === '7d' ? 15 * 60_000 : 60_000);
|
|
6199
|
+
const runs = []; let run = null;
|
|
6200
|
+
r.t.forEach((t, i) => { if (r.server[m][i] === null) { run = null; return; } if (!run || t - r.t[i - 1] > gap) { run = []; runs.push(run); } run.push(i); });
|
|
6201
|
+
const g = svgEl('g', {}); svg.append(g);
|
|
6202
|
+
for (const L of tops) {
|
|
6203
|
+
const faded = usage.focus && usage.focus !== L.key; const focused = usage.focus === L.key;
|
|
6204
|
+
for (const ix of runs) {
|
|
6205
|
+
let d = ix.map((i, k) => `${k ? 'L' : 'M'}${x(r.t[i]).toFixed(1)},${y(L.hi[i]).toFixed(1)}`).join('');
|
|
6206
|
+
const top = d;
|
|
6207
|
+
d += [...ix].reverse().map((i) => `L${x(r.t[i]).toFixed(1)},${y(L.lo[i]).toFixed(1)}`).join('');
|
|
6208
|
+
g.append(svgEl('path', { d: `${d}Z`, class: `u-band${faded ? ' u-faded' : ''}`, style: fillOf(L), 'fill-opacity': focused ? 0.95 : L.key === '__sys' ? 0.55 : 0.78 }));
|
|
6209
|
+
if (!faded && L.key !== '__sys') g.append(svgEl('path', { d: top, class: 'u-band-top', style: `stroke:var(--${L.x.c})${L.x.hatch ? ';stroke-dasharray:4 2' : ''}` }));
|
|
6210
|
+
}
|
|
6211
|
+
}
|
|
6212
|
+
svg.append(svgEl('line', { class: 'u-cap', x1: M.l, x2: W - M.r, y1: y(cap), y2: y(cap) }));
|
|
6213
|
+
const capWord = svgEl('text', { x: M.l + 6, y: y(cap) - 6 }); capWord.textContent = `Capacity · ${uAlloc(m, Math.round(cap * 10) / 10)}`; svg.append(capWord);
|
|
6214
|
+
/* Memory full: a red mark on the band of its conversation. */
|
|
6215
|
+
if (m === 'memory') for (const L of tops) for (const at of L.x.marks ?? []) {
|
|
6216
|
+
if (usage.focus && usage.focus !== L.key) continue;
|
|
6217
|
+
const i = r.t.findIndex((t) => t >= at); if (i < 0) continue;
|
|
6218
|
+
svg.append(svgEl('circle', { class: 'u-oom', cx: x(r.t[i]), cy: y(L.hi[i]), r: 5 }));
|
|
6219
|
+
if (!phone) { const end = x(r.t[i]) > W - M.r - 50; const w = svgEl('text', { x: end ? x(r.t[i]) + 4 : x(r.t[i]), y: y(L.hi[i]) - 10, 'text-anchor': end ? 'end' : 'middle', class: 'u-oom-word' }); w.textContent = 'memory full'; svg.append(w); }
|
|
6220
|
+
}
|
|
6221
|
+
/* Names at the right end, for bands thick enough; pushed apart so none overlaps. */
|
|
6222
|
+
const last = runs.at(-1)?.at(-1);
|
|
6223
|
+
if (!phone && last !== undefined) {
|
|
6224
|
+
const words = [];
|
|
6225
|
+
for (const L of tops) { const h = y(L.lo[last]) - y(L.hi[last]); if (L.key === '__sys' || h >= 7) words.push({ L, y: (y(L.lo[last]) + y(L.hi[last])) / 2, text: L.key === '__sys' ? 'server' : L.x.name.length > 18 ? `${L.x.name.slice(0, 17)}…` : L.x.name }); }
|
|
6226
|
+
words.sort((a, b) => b.y - a.y);
|
|
6227
|
+
for (let k = 1; k < words.length; k += 1) if (words[k - 1].y - words[k].y < 14) words[k].y = words[k - 1].y - 14;
|
|
6228
|
+
for (const w of words) { const e = svgEl('text', { x: W - M.r + 8, y: w.y + 4, class: `u-direct${w.L.key === '__sys' || (usage.focus && usage.focus !== w.L.key) ? ' dim' : ''}` }); e.textContent = w.text; svg.append(e); }
|
|
6229
|
+
}
|
|
6230
|
+
const cross = svgEl('line', { class: 'u-cross', y1: M.t, y2: H - M.b, visibility: 'hidden' }); svg.append(cross);
|
|
6231
|
+
const hit = svgEl('rect', { x: M.l, y: 0, width: Math.max(0, pw), height: H, fill: 'transparent' }); svg.append(hit);
|
|
6232
|
+
usageGeo = { x, y, W, H, M, tops, cross, ymax, pw, t0, t1 };
|
|
6233
|
+
svg.setAttribute('aria-label', `${USAGE_WORD[m]} per conversation, ${USAGE_SPAN[usage.span]}. The table below gives the same figures.`);
|
|
6234
|
+
hit.addEventListener('pointermove', usageHover); hit.addEventListener('pointerdown', usageHover);
|
|
6235
|
+
hit.addEventListener('pointerleave', () => { $('usage-tip').hidden = true; cross.setAttribute('visibility', 'hidden'); });
|
|
6236
|
+
hit.addEventListener('click', (event) => { const p = usagePick(event); if (!p) return; const L = usageGeo.tops.find((q) => q.key !== '__sys' && p.v >= q.lo[p.i] && p.v <= q.hi[p.i] && q.hi[p.i] > q.lo[p.i]); usageFocus(L ? L.key : null); });
|
|
6237
|
+
}
|
|
6238
|
+
function usagePick(event) {
|
|
6239
|
+
const r = usage.r; if (!r?.t.length || !usageGeo) return null;
|
|
6240
|
+
const at = $('usage-svg').getBoundingClientRect(); const px = event.clientX - at.left; const py = event.clientY - at.top;
|
|
6241
|
+
const { M, H, ymax, pw, t0, t1 } = usageGeo;
|
|
6242
|
+
const t = t0 + ((px - M.l) / pw) * (t1 - t0);
|
|
6243
|
+
let i = 0; r.t.forEach((u, k) => { if (Math.abs(u - t) < Math.abs(r.t[i] - t)) i = k; });
|
|
6244
|
+
return { i, px, v: ((H - M.b - py) / (H - M.t - M.b)) * ymax };
|
|
6245
|
+
}
|
|
6246
|
+
function usageHover(event) {
|
|
6247
|
+
const p = usagePick(event); if (!p) return;
|
|
6248
|
+
const r = usage.r; const m = usage.measure; const { i, px } = p; const { x, tops, cross, W } = usageGeo;
|
|
6249
|
+
const tip = $('usage-tip');
|
|
6250
|
+
if (r.server[m][i] === null) { tip.hidden = true; cross.setAttribute('visibility', 'hidden'); return; }
|
|
6251
|
+
cross.setAttribute('x1', x(r.t[i])); cross.setAttribute('x2', x(r.t[i])); cross.setAttribute('visibility', 'visible');
|
|
6252
|
+
const rows = [...tops].reverse().map((L) => {
|
|
6253
|
+
const zz = L.key !== '__sys' && L.v[i] === null;
|
|
6254
|
+
return `<div class="u-tip-row${zz ? ' asleep' : ''}${usage.focus === L.key ? ' focus' : ''}"><i class="u-sw" style="background:${L.key === '__sys' ? 'var(--s0)' : uFill(L.x)}"></i><span>${L.key === '__sys' ? 'this server itself' : uEsc(L.x.name)}</span><b>${zz ? 'asleep' : uFmt(m, L.v[i] ?? 0)}</b></div>`;
|
|
6255
|
+
}).join('');
|
|
6256
|
+
const near = usage.span === '7d' ? 15 * 60_000 : 2 * 60_000;
|
|
6257
|
+
const oom = m === 'memory' ? tops.find((L) => (L.x.marks ?? []).some((at) => Math.abs(at - r.t[i]) <= near)) : null;
|
|
6258
|
+
tip.innerHTML = `<div class="u-tip-when">${uWhen(r.t[i])}${usage.span === '7d' ? ' <span class="hint">(peak of 15 min)</span>' : ''}</div>${rows}<div class="u-tip-total"><span>Total</span><b>${uFmt(m, r.server[m][i])} / ${uAlloc(m, Math.round(uCap(r, m) * 10) / 10)}</b></div>${oom ? `<div class="u-tip-oom">▲ ${uEsc(oom.x.name)}: memory full</div>` : ''}`;
|
|
6259
|
+
tip.hidden = false;
|
|
6260
|
+
if (getComputedStyle(tip).position === 'static') return;
|
|
6261
|
+
const tw = tip.offsetWidth;
|
|
6262
|
+
let left = px + 14; if (left + tw > W) left = px - tw - 14; if (left < 0) left = Math.max(0, Math.min(W - tw, px - tw / 2));
|
|
6263
|
+
tip.style.left = `${left}px`;
|
|
6264
|
+
}
|
|
6265
|
+
function usageFacts(r, x, m) {
|
|
6266
|
+
const a = x[m]; const A = x.alloc[uKey(m)] || 1; const pct = a.map((v) => (v === null ? null : (v / A) * 100));
|
|
6267
|
+
const i = uLast(r, m); const now = i < 0 ? null : a[i];
|
|
6268
|
+
let pk = -1; let pi = 0; pct.forEach((v, k) => { if (v !== null && v > pk) { pk = v; pi = k; } });
|
|
6269
|
+
const known = pct.filter((v) => v !== null);
|
|
6270
|
+
const high = known.filter((v) => v >= 95).length;
|
|
6271
|
+
const over80 = known.length ? known.filter((v) => v >= 80).length / known.length : 0;
|
|
6272
|
+
const ooms = m === 'memory' ? (x.marks ?? []).filter((t) => t >= r.from).length : 0;
|
|
6273
|
+
let note = ''; let alert = false;
|
|
6274
|
+
if (uAsleep(x, m)) note = x.since ? `asleep for ${uAgo(r.to - x.since)}` : 'asleep';
|
|
6275
|
+
else if (ooms) { note = `${high ? 'reached 95 % · ' : ''}memory full ${ooms === 1 ? 'once' : `${ooms} times`}`; alert = true; }
|
|
6276
|
+
else if (high) { note = m === 'cpu' ? 'used all its cores' : 'reached 95 %'; alert = m !== 'cpu'; }
|
|
6277
|
+
else if (over80 > 0.2) note = 'often above 80 %';
|
|
6278
|
+
else if (pk >= 0 && pk < 30 && m !== 'disk') note = 'roomy: little used';
|
|
6279
|
+
return { now, nowP: now === null ? null : (now / A) * 100, pk, pkA: pk >= 0 ? a[pi] : 0, pkT: r.t[pi], note, alert, A };
|
|
6280
|
+
}
|
|
6281
|
+
function usageSpark(r, x, m, wide) {
|
|
6282
|
+
const a = x[m]; const lim = x.alloc[uKey(m)] || 1; const W = wide ? 340 : 120; const H = wide ? 34 : 30;
|
|
6283
|
+
const sx = (t) => ((t - r.from) / Math.max(1, r.to - r.from)) * W; const sy = (v) => H - 2 - (Math.min(v, lim) / lim) * (H - 4);
|
|
6284
|
+
let d = ''; let pen = false;
|
|
6285
|
+
a.forEach((v, i) => { if (v === null) { pen = false; return; } d += `${pen ? 'L' : 'M'}${sx(r.t[i]).toFixed(1)},${sy(v).toFixed(1)}`; pen = true; });
|
|
6286
|
+
const marks = m === 'memory' ? (x.marks ?? []).map((at) => { const i = r.t.findIndex((t) => t >= at); return i < 0 || a[i] === null ? '' : `<circle class="u-oom" cx="${sx(r.t[i])}" cy="${sy(a[i])}" r="3.2"/>`; }).join('') : '';
|
|
6287
|
+
const zz = uAsleep(x, m) ? `<line x1="${Math.max(0, sx(x.since ?? r.from))}" x2="${W}" y1="${H - 2}" y2="${H - 2}" stroke="var(--ink2)" stroke-dasharray="2 3" vector-effect="non-scaling-stroke"/>` : '';
|
|
6288
|
+
return `<svg class="u-spark" viewBox="0 0 ${W} ${H}" preserveAspectRatio="none" aria-hidden="true"><line class="u-lim" x1="0" x2="${W}" y1="2" y2="2" vector-effect="non-scaling-stroke"/><path d="${d}" fill="none" stroke="var(--${x.c})" stroke-width="1.75"${x.hatch ? ' stroke-dasharray="4 2"' : ''} vector-effect="non-scaling-stroke" stroke-linejoin="round"/>${zz}${marks}</svg>`;
|
|
6289
|
+
}
|
|
6290
|
+
function paintUsageList(r, who) {
|
|
6291
|
+
const m = usage.measure; const span = USAGE_SPAN[usage.span];
|
|
6292
|
+
$('usage-list-title').textContent = `${USAGE_WORD[m]} per conversation`;
|
|
6293
|
+
const rows = who.map((x) => ({ x, f: usageFacts(r, x, m) })).sort((a, b) => uAsleep(a.x, m) - uAsleep(b.x, m) || (b.f.now ?? -1) - (a.f.now ?? -1));
|
|
6294
|
+
const name = (x) => `<span class="u-who"><i class="u-sw" style="background:${uFill(x)}"></i>${uEsc(x.name)}${uAsleep(x, m) ? ' <span class="u-zz">asleep</span>' : ''}</span>`;
|
|
6295
|
+
const quiet = (x, f) => uAsleep(x, m) || f.now === null;
|
|
6296
|
+
$('usage-rank').innerHTML = `<thead><tr><th>Conversation</th><th class="r">Now</th><th class="r">Peak · ${span}</th><th>Over ${span}</th><th class="r">Given</th><th>Note</th></tr></thead><tbody>${
|
|
6297
|
+
rows.map(({ x, f }) => `<tr data-k="${uEsc(x.key)}" class="${uAsleep(x, m) ? 'asleep' : ''}" aria-selected="${usage.focus === x.key}" tabindex="0">
|
|
6298
|
+
<td>${name(x)}</td>
|
|
6299
|
+
<td class="r u-num">${quiet(x, f) ? '—' : `<span class="u-big">${uFmt(m, f.now)}</span><span class="u-sub">${Math.round(f.nowP)} % of given</span>`}</td>
|
|
6300
|
+
<td class="r u-num">${f.pk < 0 ? '—' : `${uFmt(m, f.pkA)}<span class="u-sub">${Math.round(f.pk)} % · ${uAgo(r.to - f.pkT)} ago</span>`}</td>
|
|
6301
|
+
<td>${usageSpark(r, x, m, false)}</td>
|
|
6302
|
+
<td class="r u-num">${uAlloc(m, f.A)}</td>
|
|
6303
|
+
<td><span class="u-note${f.alert ? ' alert' : ''}">${f.note}</span></td></tr>`).join('')}</tbody>`;
|
|
6304
|
+
$('usage-cards').innerHTML = rows.map(({ x, f }) => `<div role="button" tabindex="0" class="u-card${uAsleep(x, m) ? ' asleep' : ''}" data-k="${uEsc(x.key)}" aria-selected="${usage.focus === x.key}">
|
|
6305
|
+
${name(x)}
|
|
6306
|
+
<span class="u-now u-num">${quiet(x, f) ? '—' : `<span class="u-big">${uFmt(m, f.now)}</span> <span class="hint">${Math.round(f.nowP)} %</span>`}</span>
|
|
6307
|
+
${usageSpark(r, x, m, true)}
|
|
6308
|
+
<span class="u-facts u-num"><span>Peak ${f.pk < 0 ? '—' : `${uFmt(m, f.pkA)} (${Math.round(f.pk)} %)`}</span><span>Given ${uAlloc(m, f.A)}</span></span>
|
|
6309
|
+
${f.note ? `<span class="u-note${f.alert ? ' alert' : ''}">${f.note}</span>` : ''}</div>`).join('');
|
|
6310
|
+
for (const row of document.querySelectorAll('#usage-rank tbody tr, #usage-cards .u-card')) {
|
|
6311
|
+
row.addEventListener('click', () => usageFocus(row.dataset.k));
|
|
6312
|
+
row.addEventListener('keydown', (event) => { if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); usageFocus(row.dataset.k); } });
|
|
6313
|
+
}
|
|
6314
|
+
}
|
|
6315
|
+
function paintUsageAll() {
|
|
6316
|
+
const r = usage.r; if (!r) return;
|
|
6317
|
+
for (const b of $('usage-measure').children) b.setAttribute('aria-pressed', String(b.dataset.m === usage.measure));
|
|
6318
|
+
for (const b of $('usage-span').children) b.setAttribute('aria-pressed', String(b.dataset.span === usage.span));
|
|
6319
|
+
const who = usageWho(r);
|
|
6320
|
+
paintUsageTiles(r, who); paintUsageLegend(who); paintUsageChart(r, who); paintUsageList(r, who);
|
|
6321
|
+
}
|
|
6322
|
+
/* A second touch on the same one, or on nothing, shows them all again. */
|
|
6323
|
+
const usageFocus = (key) => { usage.focus = usage.focus === key || !key ? null : key; paintUsageAll(); };
|
|
6324
|
+
async function paintUsage() {
|
|
6325
|
+
const span = usage.span;
|
|
6326
|
+
const r = await fetch(`${API}/history/all?span=${span}`).then((x) => (x.ok ? x.json() : null)).catch(() => null);
|
|
6327
|
+
if (span !== usage.span) return;
|
|
6328
|
+
$('usage-none').hidden = Boolean(r?.t?.length);
|
|
6329
|
+
$('usage-none').textContent = r ? 'Nothing measured yet: a look is taken every minute.' : 'Usage cannot be read just now.';
|
|
6330
|
+
for (const id of ['usage-tiles', 'usage-legend']) $(id).hidden = !r?.t?.length;
|
|
6331
|
+
$('usage').querySelector('.u-chart').hidden = !r?.t?.length; $('usage-rank').parentElement.hidden = !r?.t?.length;
|
|
6332
|
+
if (!r?.t?.length) return;
|
|
6333
|
+
usage.r = r;
|
|
6334
|
+
if (usage.focus && !usageWho(r).some((x) => x.key === usage.focus)) usage.focus = null;
|
|
6335
|
+
paintUsageAll();
|
|
6336
|
+
}
|
|
6337
|
+
$('usage-measure').addEventListener('click', (event) => { const b = event.target.closest('button[data-m]'); if (!b) return; usage.measure = b.dataset.m; paintUsageAll(); });
|
|
6338
|
+
$('usage-span').addEventListener('click', (event) => { const b = event.target.closest('button[data-span]'); if (!b) return; usage.span = b.dataset.span; for (const x of $('usage-span').children) x.setAttribute('aria-pressed', String(x === b)); void paintUsage(); });
|
|
6339
|
+
$('settings-usage-top').addEventListener('toggle', () => { if ($('settings-usage-top').open) void paintUsage(); });
|
|
6340
|
+
/* Drawn again when its width changes only: a phone's bar of address, folding in a scroll, is a resize too. */
|
|
6341
|
+
let usageResize; let usageWidth = 0;
|
|
6342
|
+
addEventListener('resize', () => { clearTimeout(usageResize); usageResize = setTimeout(() => { const w = $('usage-plot').clientWidth; if (w !== usageWidth && $('settings-usage-top').open && $('usage').offsetParent !== null) paintUsageAll(); }, 80); });
|
|
6343
|
+
/* Kept current while in sight: a new look a minute. */
|
|
6344
|
+
setInterval(() => { if ($('settings-usage-top').open && $('usage').offsetParent !== null) void paintUsage(); }, 60_000);
|
|
6106
6345
|
async function paintServer() {
|
|
6107
6346
|
clearTimeout(serverTimer);
|
|
6108
6347
|
const r = await fetch(`${API}/server`).then((x) => (x.ok ? x.json() : null)).catch(() => null);
|
|
6109
|
-
$('settings-server-top').hidden = !r; $('settings-server').hidden = !r;
|
|
6348
|
+
$('settings-server-top').hidden = !r; $('settings-server').hidden = !r; $('settings-usage-top').hidden = !r;
|
|
6110
6349
|
if (!r) return;
|
|
6111
6350
|
void paintCurves($('server-curves'));
|
|
6112
6351
|
/* The two settings of each: a fixed amount and a share; the larger is kept free. */
|
package/web/index.html
CHANGED
|
@@ -855,6 +855,37 @@
|
|
|
855
855
|
(server/updates.mjs; the updater, as root: deploy/updater.mjs). -->
|
|
856
856
|
</div>
|
|
857
857
|
</details>
|
|
858
|
+
<!-- USAGE: who takes the memory, the CPU and the disk -- each machine and this server itself,
|
|
859
|
+
now and over time, in GB and cores (server/history.mjs together(); GET /api/history/all). -->
|
|
860
|
+
<details class="chapter" id="settings-usage-top" data-chapter="s-usage">
|
|
861
|
+
<summary><span class="chapter-title">Usage</span><span class="chapter-about">Who takes the memory, the CPU and the disk.</span></summary>
|
|
862
|
+
<div class="chapter-body">
|
|
863
|
+
<div id="usage" class="usage">
|
|
864
|
+
<p id="usage-none" class="hint" hidden>Nothing measured yet.</p>
|
|
865
|
+
<div class="u-tiles" id="usage-tiles" role="group" aria-label="Measure"></div>
|
|
866
|
+
<div class="u-legend" id="usage-legend" role="group" aria-label="Conversations"></div>
|
|
867
|
+
<section class="u-chart">
|
|
868
|
+
<div class="u-toolbar">
|
|
869
|
+
<h4 id="usage-chart-title">Memory over time</h4>
|
|
870
|
+
<span class="u-sp"></span>
|
|
871
|
+
<div class="levels" id="usage-measure" role="group" aria-label="Measure"><button type="button" data-m="memory" aria-pressed="true">Memory</button><button type="button" data-m="cpu" aria-pressed="false">CPU</button><button type="button" data-m="disk" aria-pressed="false">Disk</button></div>
|
|
872
|
+
<div class="levels" id="usage-span" role="group" aria-label="Over"><button type="button" data-span="1h" aria-pressed="false">1 h</button><button type="button" data-span="24h" aria-pressed="true">24 h</button><button type="button" data-span="7d" aria-pressed="false">7 days</button></div>
|
|
873
|
+
</div>
|
|
874
|
+
<div class="u-plot" id="usage-plot"><svg id="usage-svg" role="img"></svg><div class="u-tip" id="usage-tip" hidden></div></div>
|
|
875
|
+
<div class="u-foot">
|
|
876
|
+
<span class="u-k"><span class="u-k-cap"></span>Server capacity</span>
|
|
877
|
+
<span class="u-k"><i class="u-sw" style="background:var(--s0)"></i>This server itself</span>
|
|
878
|
+
<span class="u-k" id="usage-k-oom"><span class="u-k-oom"></span>Memory full (a program stopped)</span>
|
|
879
|
+
</div>
|
|
880
|
+
</section>
|
|
881
|
+
<section>
|
|
882
|
+
<div class="u-list-head"><h4 id="usage-list-title">Memory per conversation</h4><p class="hint">Tap a row to see it alone in the chart.</p></div>
|
|
883
|
+
<table class="u-rank" id="usage-rank"></table>
|
|
884
|
+
<div class="u-cards" id="usage-cards"></div>
|
|
885
|
+
</section>
|
|
886
|
+
</div>
|
|
887
|
+
</div>
|
|
888
|
+
</details>
|
|
858
889
|
<details class="chapter" id="settings-ch-backup" data-chapter="s-backup">
|
|
859
890
|
<summary><span class="chapter-title">Backup</span><span class="chapter-about">Export, import, full backup.</span></summary>
|
|
860
891
|
<div class="chapter-body">
|
package/web/style.css
CHANGED
|
@@ -1470,6 +1470,118 @@ select.pill { appearance: auto; }
|
|
|
1470
1470
|
.curve-foot { display: flex; justify-content: space-between; font-size: .6875rem; color: var(--ink2); margin-top: 2px; }
|
|
1471
1471
|
.curve-legend { display: block; margin-top: 2px; font-size: .6875rem; }
|
|
1472
1472
|
|
|
1473
|
+
/* Settings, Usage: who takes the memory, the CPU and the disk. One fixed colour per conversation
|
|
1474
|
+
(a validated categorical order, a step per theme): the colour follows the conversation, never its rank.
|
|
1475
|
+
--s0 is "this server itself", recessive on purpose. */
|
|
1476
|
+
:root { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s0: #5b6878; --u-grid: rgba(163, 177, 194, .14); }
|
|
1477
|
+
:root[data-theme="light"] { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s0: #a4adb8; --u-grid: rgba(79, 93, 109, .14); }
|
|
1478
|
+
.usage { display: flex; flex-direction: column; gap: 14px; }
|
|
1479
|
+
.usage h4 { margin: 0; font-size: .9375rem; }
|
|
1480
|
+
.usage .u-num { font-variant-numeric: tabular-nums; }
|
|
1481
|
+
/* Now: three tiles, each a stacked bar of who takes what; a tile is also the measure switch. */
|
|
1482
|
+
.u-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
|
|
1483
|
+
.u-tile { text-align: left; font-weight: 400; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 9px; background: var(--panel); min-width: 0; }
|
|
1484
|
+
.u-tile[aria-pressed="true"] { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); }
|
|
1485
|
+
.u-tile-head { display: flex; align-items: baseline; gap: 8px; }
|
|
1486
|
+
.u-tile-what { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink2); }
|
|
1487
|
+
.u-tile-pct { margin-left: auto; font-size: .75rem; color: var(--ink2); }
|
|
1488
|
+
.u-tile-big { font-size: 1.375rem; font-weight: 700; line-height: 1.1; }
|
|
1489
|
+
.u-tile-big small { font-size: .8125rem; font-weight: 400; color: var(--ink2); }
|
|
1490
|
+
.u-stack { display: flex; gap: 2px; height: 12px; border-radius: 4px; background: var(--u-grid); overflow: hidden; }
|
|
1491
|
+
.u-stack span { display: block; height: 100%; min-width: 2px; }
|
|
1492
|
+
.u-stack span:first-child { border-radius: 4px 0 0 4px; }
|
|
1493
|
+
.u-tile-foot { display: flex; justify-content: space-between; gap: 8px; font-size: .75rem; color: var(--ink2); min-width: 0; }
|
|
1494
|
+
.u-tile-foot span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1495
|
+
/* The legend, shared by the tiles and the chart: a chip singles its conversation out. */
|
|
1496
|
+
.u-legend { display: flex; flex-wrap: wrap; gap: 4px 6px; }
|
|
1497
|
+
.u-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 7px; font-weight: 500; border-radius: 999px; background: transparent; }
|
|
1498
|
+
.u-chip i, .u-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
|
|
1499
|
+
.u-chip[aria-pressed="true"] { border-color: var(--brass); background: rgba(210, 169, 78, .14); }
|
|
1500
|
+
.u-chip.asleep { color: var(--ink2); }
|
|
1501
|
+
.u-chip .u-z { font-size: .6875rem; color: var(--ink2); font-weight: 400; }
|
|
1502
|
+
/* Asleep: an empty dashed swatch, everywhere. */
|
|
1503
|
+
:is(.u-chip.asleep i, .u-tip-row.asleep .u-sw, .u-rank tr.asleep .u-sw, .u-card.asleep .u-sw) { background: transparent !important; border: 1.5px dashed var(--ink2); }
|
|
1504
|
+
/* Over time. */
|
|
1505
|
+
.u-chart { border: 1px solid var(--line); border-radius: 9px; background: var(--panel); padding: 10px 12px 8px; }
|
|
1506
|
+
.u-toolbar { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 8px; }
|
|
1507
|
+
.u-toolbar .u-sp { flex: 1; }
|
|
1508
|
+
.u-toolbar .levels button { padding: 4px 12px; }
|
|
1509
|
+
.u-plot { position: relative; touch-action: pan-y; }
|
|
1510
|
+
.u-plot svg { display: block; width: 100%; overflow: visible; }
|
|
1511
|
+
.u-plot text { font-family: var(--sans); font-size: 11px; fill: var(--ink2); font-variant-numeric: tabular-nums; }
|
|
1512
|
+
.u-plot .u-gridline { stroke: var(--u-grid); stroke-width: 1; }
|
|
1513
|
+
.u-plot .u-base { stroke: var(--line); stroke-width: 1; }
|
|
1514
|
+
.u-plot .u-cap { stroke: var(--ink2); stroke-width: 1.25; stroke-dasharray: 5 4; fill: none; }
|
|
1515
|
+
.u-plot .u-band { stroke: var(--panel); stroke-width: 1; stroke-linejoin: round; transition: opacity .15s; }
|
|
1516
|
+
.u-plot .u-band-top { fill: none; stroke-width: 1.5; stroke-linejoin: round; }
|
|
1517
|
+
.u-plot .u-faded { opacity: .18; }
|
|
1518
|
+
.u-plot .u-cross { stroke: var(--ink); stroke-width: 1; opacity: .55; }
|
|
1519
|
+
.u-plot .u-oom { fill: var(--danger); stroke: var(--panel); stroke-width: 2; }
|
|
1520
|
+
.u-plot .u-oom-word { fill: var(--danger); font-weight: 600; }
|
|
1521
|
+
.u-plot .u-direct { font-size: 11.5px; fill: var(--ink); font-weight: 600; }
|
|
1522
|
+
.u-plot .u-direct.dim { fill: var(--ink2); font-weight: 400; }
|
|
1523
|
+
.u-tip { position: absolute; top: 4px; z-index: 2; min-width: 190px; padding: 7px 9px; border-radius: 8px; background: var(--bar); border: 1px solid var(--line); box-shadow: 0 6px 20px rgba(0, 0, 0, .28); font-size: .75rem; pointer-events: none; }
|
|
1524
|
+
.u-tip-when { font-weight: 700; margin-bottom: 4px; }
|
|
1525
|
+
.u-tip-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 7px; align-items: center; line-height: 1.55; }
|
|
1526
|
+
.u-tip-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1527
|
+
.u-tip-row b { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
|
|
1528
|
+
.u-tip-row.focus { font-weight: 700; }
|
|
1529
|
+
.u-tip-row.asleep { color: var(--ink2); }
|
|
1530
|
+
.u-tip-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; display: flex; justify-content: space-between; color: var(--ink2); }
|
|
1531
|
+
.u-tip-total b { color: var(--ink); font-variant-numeric: tabular-nums; }
|
|
1532
|
+
.u-tip-oom { color: var(--danger); font-weight: 600; margin-top: 3px; }
|
|
1533
|
+
.u-foot { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 4px; font-size: .75rem; color: var(--ink2); }
|
|
1534
|
+
.u-k { display: inline-flex; align-items: center; gap: 6px; }
|
|
1535
|
+
.u-k-cap { width: 18px; border-top: 1.5px dashed var(--ink2); }
|
|
1536
|
+
.u-k-oom { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); }
|
|
1537
|
+
/* Per conversation: a ranked table (cards on a phone). */
|
|
1538
|
+
.u-list-head { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; margin-bottom: 6px; }
|
|
1539
|
+
.u-list-head .hint { margin: 0; }
|
|
1540
|
+
table.u-rank { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
|
|
1541
|
+
.u-rank th { text-align: left; font-size: .6875rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink2); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
|
|
1542
|
+
.u-rank td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
|
|
1543
|
+
.u-rank tr:last-child td { border-bottom: 0; }
|
|
1544
|
+
.u-rank .r { text-align: right; }
|
|
1545
|
+
.u-rank tbody tr { cursor: pointer; }
|
|
1546
|
+
.u-rank tbody tr:hover { background: rgba(210, 169, 78, .06); }
|
|
1547
|
+
.u-rank tbody tr[aria-selected="true"] { background: rgba(210, 169, 78, .13); box-shadow: inset 3px 0 0 var(--brass); }
|
|
1548
|
+
.u-rank tbody tr.asleep td { color: var(--ink2); }
|
|
1549
|
+
.u-who { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; white-space: nowrap; }
|
|
1550
|
+
.u-zz { font-size: .6875rem; font-weight: 600; color: var(--ink2); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; white-space: nowrap; }
|
|
1551
|
+
.u-big { font-weight: 700; }
|
|
1552
|
+
.u-sub { display: block; font-size: .6875rem; color: var(--ink2); white-space: nowrap; }
|
|
1553
|
+
.u-note { font-size: .75rem; color: var(--ink2); }
|
|
1554
|
+
.u-note.alert { color: var(--danger); font-weight: 600; }
|
|
1555
|
+
.u-note.alert::before { content: "\25B2 "; font-size: .625rem; vertical-align: 1px; }
|
|
1556
|
+
svg.u-spark { display: block; width: 120px; height: 30px; overflow: visible; }
|
|
1557
|
+
svg.u-spark .u-lim { stroke: var(--line); stroke-dasharray: 2 3; }
|
|
1558
|
+
svg.u-spark .u-oom { fill: var(--danger); stroke: var(--panel); stroke-width: 1.5; }
|
|
1559
|
+
.u-cards { display: none; }
|
|
1560
|
+
@media (max-width: 700px) {
|
|
1561
|
+
.u-tiles { grid-template-columns: minmax(0, 1fr); gap: 6px; }
|
|
1562
|
+
.u-tile { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "what big pct" "bar bar bar"; align-items: baseline; gap: 4px 10px; padding: 8px 10px; }
|
|
1563
|
+
.u-tile-head { display: contents; }
|
|
1564
|
+
.u-tile-what { grid-area: what; }
|
|
1565
|
+
.u-tile-pct { grid-area: pct; }
|
|
1566
|
+
.u-tile-big { grid-area: big; font-size: 1.0625rem; }
|
|
1567
|
+
.u-stack { grid-area: bar; }
|
|
1568
|
+
.u-tile-foot { display: none; }
|
|
1569
|
+
.u-chart { padding: 8px 8px 6px; margin: 0 -4px; }
|
|
1570
|
+
.u-toolbar h4 { flex-basis: 100%; }
|
|
1571
|
+
.u-toolbar .u-sp { display: none; }
|
|
1572
|
+
.u-toolbar .levels button { padding: 4px 10px; }
|
|
1573
|
+
.u-tip { position: static; margin-top: 6px; box-shadow: none; min-width: 0; }
|
|
1574
|
+
table.u-rank { display: none; }
|
|
1575
|
+
.u-cards { display: grid; gap: 8px; }
|
|
1576
|
+
.u-card { cursor: pointer; border: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 10px 12px; border-radius: 9px; background: var(--panel); }
|
|
1577
|
+
.u-card[aria-selected="true"] { border-color: var(--brass); box-shadow: inset 3px 0 0 var(--brass); }
|
|
1578
|
+
.u-card .u-now { text-align: right; white-space: nowrap; }
|
|
1579
|
+
.u-card svg.u-spark { grid-column: 1 / -1; width: 100%; height: 34px; }
|
|
1580
|
+
.u-card .u-facts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .75rem; color: var(--ink2); }
|
|
1581
|
+
.u-card .u-note { grid-column: 1 / -1; }
|
|
1582
|
+
.u-card.asleep { color: var(--ink2); }
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1473
1585
|
/* Settings, What happened: one line each -- when, what kind, what; who when it is not said. */
|
|
1474
1586
|
.events-pick { flex-wrap: wrap; gap: 8px 12px; align-items: center; }
|
|
1475
1587
|
.events-pick input[type=search] { flex: 1 1 10rem; min-width: 0; }
|