clavarium 0.2.315-next.1 → 0.2.317-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 +6 -6
- package/package.json +2 -2
- package/server/settingswords.mjs +33 -0
- package/server/talk.mjs +4 -3
- package/web/app.js +262 -32
- package/web/index.html +334 -283
- package/web/style.css +65 -14
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.317-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.317-next.1",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
|
13
13
|
"@xterm/xterm": "^6.0.0",
|
|
14
14
|
"clavarium-binder": "0.1.60-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.2-next.2",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.66-next.1",
|
|
17
17
|
"clavarium-tether": "0.1.0-next.49",
|
|
18
18
|
"mammoth": "1.13.0",
|
|
19
19
|
"mermaid": "11.17.2",
|
|
@@ -787,9 +787,9 @@
|
|
|
787
787
|
}
|
|
788
788
|
},
|
|
789
789
|
"node_modules/clavarium-parley": {
|
|
790
|
-
"version": "0.17.
|
|
791
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
792
|
-
"integrity": "sha512-
|
|
790
|
+
"version": "0.17.66-next.1",
|
|
791
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.66-next.1.tgz",
|
|
792
|
+
"integrity": "sha512-dSvtC4uYpTT87AMufUEwa8LBVsQ6peNBah72AEp6yhj6OCNGoxiHmLUPKop/Q7QZBqBO38ZGzAMgqt+KIpRDDQ==",
|
|
793
793
|
"license": "MIT",
|
|
794
794
|
"bin": {
|
|
795
795
|
"parley": "bin/parley.mjs",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.317-next.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "A conversation is a VM with a terminal in it. Everything else is a folder.",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@xterm/xterm": "^6.0.0",
|
|
47
47
|
"clavarium-binder": "0.1.60-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.2-next.2",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
49
|
+
"clavarium-parley": "0.17.66-next.1",
|
|
50
50
|
"clavarium-tether": "0.1.0-next.49",
|
|
51
51
|
"mammoth": "1.13.0",
|
|
52
52
|
"mermaid": "11.17.2",
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* THE WORDS OF THE SETTINGS PAGES in French (settings redesign, 05-11); English is in the page (web/index.html,
|
|
2
|
+
web/app.js, uiSaid). Served with the chat screen's words (/api/talk/words, talk.mjs), as Features' are, so the
|
|
3
|
+
owner's own words may replace any of them. French says « vous ». One short line each. */
|
|
4
|
+
export const SETTINGS_WORDS_FR = {
|
|
5
|
+
'set-tab-general': 'Général', 'set-tab-device': 'Cet appareil', 'set-tab-resources': 'Ressources', 'set-tab-access': 'Accès',
|
|
6
|
+
'set-tab-chat': 'Chat et voix', 'set-tab-automatic': 'Automatique', 'set-tab-diagnostics': 'Diagnostics', 'set-tab-advanced': 'Avancé',
|
|
7
|
+
'set-ch-general': 'Général', 'set-ch-machine': 'Machine', 'set-ch-access': 'Accès', 'set-ch-sharing': 'Partage', 'set-ch-chat': 'Chat',
|
|
8
|
+
'set-ch-wakeups': 'Réveils', 'set-ch-answerer': 'Répondeur', 'set-ch-health': 'Santé', 'set-ch-advanced': 'Avancé',
|
|
9
|
+
'set-ch-s-general': 'Général', 'set-ch-s-about': 'À propos', 'set-ch-s-screen': 'Écran', 'set-ch-s-alerts': 'Alertes',
|
|
10
|
+
'set-ch-s-resources': 'Ressources', 'set-ch-s-operators': 'Administrateurs', 'set-ch-s-network': 'Réseau', 'set-ch-s-remote-screen': 'Écran à distance',
|
|
11
|
+
'set-ch-s-words': 'Écran du chat', 'set-ch-s-dictation': 'Dictée', 'set-ch-s-shortcuts': 'Raccourcis', 'set-ch-s-thread': 'Événements du chat',
|
|
12
|
+
'set-ch-s-updates': 'Mises à jour', 'set-ch-s-binders': 'Classeurs', 'set-ch-s-events': 'Activité', 'set-ch-s-logs': 'Journaux',
|
|
13
|
+
'set-ch-s-usage': 'Usage', 'set-ch-s-backup': 'Sauvegarde', 'set-ch-s-advanced': 'Avancé',
|
|
14
|
+
'set-check-updates': 'Chercher une mise à jour', 'set-activity': 'Activité', 'set-restart-dots': 'Redémarrer…', 'set-terminal': 'Terminal',
|
|
15
|
+
'set-search': 'Chercher', 'set-why': 'Pourquoi',
|
|
16
|
+
'set-memory': 'Mémoire', 'set-disk': 'Disque', 'set-cpu': 'Processeur',
|
|
17
|
+
'set-free-of': '{free} libres sur {total}', 'set-left-of': '{free} restants sur {total}', 'set-highest': 'au plus {n} % en 1 h',
|
|
18
|
+
'set-core': '1 cœur', 'set-cores': '{n} cœurs',
|
|
19
|
+
'set-update-out': '{v} est sortie', 'set-up-to-date': 'À jour · {v}', 'set-wifi-on': 'Wi-Fi · {name}', 'set-wifi-off': 'Wi-Fi non utilisé', 'set-cable': 'Câble',
|
|
20
|
+
'set-not-well': 'ne va pas bien', 'set-box-away': '{name} hors ligne',
|
|
21
|
+
'set-just-now': 'à l\'instant', 'set-min-ago': 'il y a {n} min', 'set-h-ago': 'il y a {n} h', 'set-days-ago': 'il y a {n} jours',
|
|
22
|
+
'set-on': 'Activé', 'set-off': 'Désactivé', 'set-none': 'Aucun', 'set-changed': '{n} modifiés', 'set-as-given': 'Comme livrés',
|
|
23
|
+
'set-lang-device': 'La langue de chaque appareil', 'set-res-now': 'Mémoire {m} % · disque {d} %',
|
|
24
|
+
'set-binders-max': 'Les agents en font {n} au plus', 'set-admin-1': '1 administrateur', 'set-admins': '{n} administrateurs',
|
|
25
|
+
'set-backup-now': 'Exporter · importer', 'set-git-key': '1 clé git', 'set-git-keys': '{n} clés git', 'set-restart': 'redémarrer',
|
|
26
|
+
'set-logs-now': 'Clavarium, machines, système',
|
|
27
|
+
'set-dict-backup': 'Secours en service', 'set-dict-expired': 'Clé expirée', 'set-dict-with-backup': 'avec secours', 'set-dict-server': 'réglée sur le serveur',
|
|
28
|
+
'set-attached': '{n} joints', 'set-secret': '1 secret', 'set-secrets': '{n} secrets', 'set-offline': 'hors ligne',
|
|
29
|
+
'set-device': '1 appareil', 'set-devices': '{n} appareils', 'set-no-device': 'Aucun appareil', 'set-chat': 'Chat',
|
|
30
|
+
'set-wakeups-on': '{on} sur {n} actifs', 'set-asleep': 'Endormie', 'set-not-looked': 'Pas encore regardée',
|
|
31
|
+
'set-running-well': 'En marche · rien d\'anormal', 'set-conv-advanced': 'Archiver · remettre à neuf · supprimer',
|
|
32
|
+
};
|
|
33
|
+
export const settingsWords = (lang) => (String(lang ?? '').toLowerCase().split('-')[0] === 'fr' ? { ...SETTINGS_WORDS_FR } : {});
|
package/server/talk.mjs
CHANGED
|
@@ -63,6 +63,7 @@ import { randomUUID, createHash } from 'node:crypto';
|
|
|
63
63
|
import { mkdirSync, lstatSync, rmSync, readFileSync, writeFileSync, readdirSync } from 'node:fs';
|
|
64
64
|
import { install, Parley, WAKE, reread, texts, fill, LANGUAGES, SHOWN_MAX, FILES_MAX } from 'clavarium-parley/host';
|
|
65
65
|
import { featureWords } from './features.mjs';
|
|
66
|
+
import { settingsWords } from './settingswords.mjs';
|
|
66
67
|
import { importFile } from './files.mjs';
|
|
67
68
|
import { KEYS } from 'clavarium-parley/ui';
|
|
68
69
|
import { Refusal, SESSION } from './conversations.mjs';
|
|
@@ -268,9 +269,9 @@ export class Talk {
|
|
|
268
269
|
const lang = s.lang === 'device' ? String(device ?? 'en') : s.lang;
|
|
269
270
|
const words = texts(lang, s.own);
|
|
270
271
|
this.#lastLang = words.lang;
|
|
271
|
-
/* The words of Features (features.mjs) for this language, the owner's own over them as over the others. */
|
|
272
|
-
const more = featureWords(words.lang);
|
|
273
|
-
for (const [key, value] of Object.entries(s.own ?? {})) if (key.startsWith('features-') && typeof value === 'string') more[key] = value.slice(0, 500);
|
|
272
|
+
/* The words of Features (features.mjs) and of the settings pages (settingswords.mjs) for this language, the owner's own over them as over the others. */
|
|
273
|
+
const more = { ...featureWords(words.lang), ...settingsWords(words.lang) };
|
|
274
|
+
for (const [key, value] of Object.entries(s.own ?? {})) if ((key.startsWith('features-') || key.startsWith('set-')) && typeof value === 'string') more[key] = value.slice(0, 500);
|
|
274
275
|
return { ...more, ...words };
|
|
275
276
|
}
|
|
276
277
|
|
package/web/app.js
CHANGED
|
@@ -437,14 +437,15 @@
|
|
|
437
437
|
const chapters = [...sheet.querySelectorAll('details.chapter')];
|
|
438
438
|
return chapters.length ? chapters : [...sheet.querySelectorAll(':scope > :not(header.topbar):not(.panel-top)')].filter((e) => e.querySelector(':scope > .panel-top'));
|
|
439
439
|
};
|
|
440
|
-
const wasOpen = new Map();
|
|
440
|
+
const wasOpen = new Map(); const wasHidden = new Map();
|
|
441
441
|
const norm = (t) => String(t).toLowerCase().normalize('NFD').replace(/[̀-ͯ]/g, '');
|
|
442
442
|
field.addEventListener('input', () => {
|
|
443
443
|
const q = norm(field.value.trim());
|
|
444
444
|
sheet.dataset.searching = q ? 'on' : '';
|
|
445
445
|
for (const it of items()) {
|
|
446
|
-
if (!q) { it.hidden =
|
|
447
|
-
|
|
446
|
+
if (!q) { it.hidden = wasHidden.get(it) ?? it.hidden; wasHidden.delete(it); for (const row of it.querySelectorAll('.search-out')) row.classList.remove('search-out'); if (it.tagName === 'DETAILS' && wasOpen.has(it)) { it.open = wasOpen.get(it); wasOpen.delete(it); } continue; }
|
|
447
|
+
if (!wasHidden.has(it)) wasHidden.set(it, it.hidden);
|
|
448
|
+
const hit = !wasHidden.get(it) && norm(it.textContent).includes(q);
|
|
448
449
|
it.hidden = !hit;
|
|
449
450
|
/* Within a chapter whose title does not say it: only its rows that do. */
|
|
450
451
|
const head = it.querySelector(':scope > summary, :scope > .panel-top');
|
|
@@ -993,11 +994,10 @@
|
|
|
993
994
|
if (noTerminal()) $('files-open').hidden = deviceShared.length === 0;
|
|
994
995
|
$('sleep').hidden = !usable || c.asleep === true;
|
|
995
996
|
$('restart').hidden = DEVICE || !usable;
|
|
996
|
-
/*
|
|
997
|
-
$('quick-sleep').hidden = !usable || c.asleep === true;
|
|
998
|
-
$('quick-restart').hidden = DEVICE || !usable;
|
|
997
|
+
/* At hand, on top of its settings: wake when asleep, else restart, sleep, its terminal. */
|
|
999
998
|
$('quick-wake').hidden = !c || c.asleep !== true;
|
|
1000
|
-
$('
|
|
999
|
+
$('hand-terminal').hidden = !usable || noTerminal();
|
|
1000
|
+
$('panel-actions').hidden = DEVICE || !c;
|
|
1001
1001
|
/* Its own sheet is there as soon as it exists: archiving one that failed is done from it. */
|
|
1002
1002
|
$('folders').hidden = DEVICE || !c;
|
|
1003
1003
|
}
|
|
@@ -2297,6 +2297,7 @@
|
|
|
2297
2297
|
row.append(label, fixedUse(), off); handed.append(row);
|
|
2298
2298
|
}
|
|
2299
2299
|
$('access-secrets-empty').hidden = handed.children.length > 0;
|
|
2300
|
+
paintConvStates(here);
|
|
2300
2301
|
/* What can still be attached, for the picker. */
|
|
2301
2302
|
const picker = $('attach-rows'); picker.replaceChildren();
|
|
2302
2303
|
$('attach-title').textContent = `Attach to "${current}"`;
|
|
@@ -2319,11 +2320,13 @@
|
|
|
2319
2320
|
/* Where the tool works, and the way to the other place. */
|
|
2320
2321
|
const kept = here?.work === 'kept';
|
|
2321
2322
|
$('work-box').hidden = DEVICE || !here;
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2323
|
+
/* One short line; the why behind its ⓘ. */
|
|
2324
|
+
$('work-now-text').textContent = kept ? 'Kept here · shown in Files' : 'On the disk of its machine';
|
|
2325
|
+
$('work-now-why').textContent = kept
|
|
2326
|
+
? 'Its files outlive the machine. It has a fixed size, and refuses symbolic links that point upwards or outside: a code project that installs packages belongs on the disk of its machine.'
|
|
2327
|
+
: 'Faster for a large code project, but its files are not shown in Files and go with the machine.';
|
|
2325
2328
|
$('work-moved').textContent = here?.moved ?? ''; $('work-moved').hidden = !here?.moved;
|
|
2326
|
-
$('work-move').textContent = kept ? 'Move
|
|
2329
|
+
$('work-move').textContent = kept ? 'Move to its machine\'s disk...' : 'Keep it here...';
|
|
2327
2330
|
$('work-move').onclick = () => {
|
|
2328
2331
|
const to = kept ? 'disk' : 'kept';
|
|
2329
2332
|
/* The question is asked over the terminal, not under this panel. */
|
|
@@ -2365,7 +2368,7 @@
|
|
|
2365
2368
|
const markAttention = () => { clearTimeout(marking); marking = setTimeout(() => {
|
|
2366
2369
|
for (const chapter of document.querySelectorAll('details.chapter')) chapter.toggleAttribute('data-attention', asksForYou(chapter));
|
|
2367
2370
|
/* And on its category, in the side list of Settings. */
|
|
2368
|
-
for (const b of document.querySelectorAll('
|
|
2371
|
+
for (const b of document.querySelectorAll('.settings-tabs button[data-group]')) b.toggleAttribute('data-attention', Boolean(b.closest('.sheet')?.querySelector(`.settings-group[data-group="${b.dataset.group}"] details.chapter[data-attention]`)));
|
|
2369
2372
|
}, 150); };
|
|
2370
2373
|
new MutationObserver(markAttention).observe(document.body, { subtree: true, childList: true, attributes: true, attributeFilter: ['hidden', 'data-tone', 'class'] });
|
|
2371
2374
|
/* Reached by a link (or a button that leads to it): opened, and said for a moment. */
|
|
@@ -2373,6 +2376,9 @@
|
|
|
2373
2376
|
const openChapter = (key, { show = true } = {}) => {
|
|
2374
2377
|
const chapter = document.querySelector(`details.chapter[data-chapter="${key}"]`);
|
|
2375
2378
|
if (!chapter) return chapter;
|
|
2379
|
+
/* In a tab not shown: that tab first. */
|
|
2380
|
+
const group = chapter.closest('.settings-group.tab-off');
|
|
2381
|
+
if (group) group.closest('.sheet')?.showTab?.(group.dataset.group);
|
|
2376
2382
|
chapter.open = true;
|
|
2377
2383
|
if (show) {
|
|
2378
2384
|
for (const other of document.querySelectorAll('details.chapter.reached')) other.classList.remove('reached');
|
|
@@ -2643,8 +2649,8 @@
|
|
|
2643
2649
|
$('machine-size-wait').textContent = waiting; $('machine-size-wait').hidden = !waiting;
|
|
2644
2650
|
/* Asleep: chosen now, applied as it wakes -- it is not woken for it. */
|
|
2645
2651
|
$('machine-size-hint').textContent = here?.asleep === true
|
|
2646
|
-
? 'Asleep:
|
|
2647
|
-
: 'Restarts
|
|
2652
|
+
? 'Asleep: applied when it wakes · a disk only grows'
|
|
2653
|
+
: 'Restarts it · a disk only grows';
|
|
2648
2654
|
$('machine-later-text').textContent = here?.sizeAtWake ? `Will be applied when it wakes: ${laterWords(here.sizeAtWake)}` : '';
|
|
2649
2655
|
$('machine-later').hidden = !here?.sizeAtWake;
|
|
2650
2656
|
$('machine-size-apply').textContent = here?.asleep === true ? 'Keep for its wake' : 'Apply...';
|
|
@@ -2654,6 +2660,49 @@
|
|
|
2654
2660
|
/* Whether its tool asks before acting -- for a tool that can be given every right in its machine. */
|
|
2655
2661
|
$('rights-box').hidden = DEVICE || !here?.rights;
|
|
2656
2662
|
for (const b of $('ask-first').children) b.setAttribute('aria-pressed', String((b.dataset.on === 'true') === (here?.askFirst === true)));
|
|
2663
|
+
void paintConvHand(here);
|
|
2664
|
+
paintConvStates(here);
|
|
2665
|
+
}
|
|
2666
|
+
/* A CONVERSATION'S AT HAND: its machine's three tiles, from its health (memory, disk) and its last hour
|
|
2667
|
+
(/api/history, read at most every 30 s). */
|
|
2668
|
+
const convHandAt = { of: '', at: 0, h: null };
|
|
2669
|
+
async function paintConvHand(here) {
|
|
2670
|
+
const box = $('panel-tiles');
|
|
2671
|
+
if (DEVICE || !here || here.asleep || here.phase !== 'ready') { box.hidden = true; return; }
|
|
2672
|
+
if (convHandAt.of !== here.name || Date.now() - convHandAt.at > 30_000) { convHandAt.of = here.name; convHandAt.at = Date.now(); convHandAt.h = await handHistory(here.name); }
|
|
2673
|
+
if (current !== here.name) return;
|
|
2674
|
+
const h = convHandAt.h; const health = here.health;
|
|
2675
|
+
const tiles = [];
|
|
2676
|
+
const mem = health?.memory;
|
|
2677
|
+
const memUsed = mem?.totalMb ? 100 - (mem.availableMb / mem.totalMb) * 100 : lastOf(h?.memory);
|
|
2678
|
+
if (memUsed !== null && memUsed !== undefined) tiles.push(handTile(uiSaid('set-memory', 'Memory'), memUsed, mem ? uiSaid('set-free-of', '{free} free of {total}', { free: GB(mem.availableMb), total: GB(mem.totalMb) }) : '', h?.memory, levelAt(memUsed)));
|
|
2679
|
+
const diskLeft = health?.disks?.['/']?.availableMb;
|
|
2680
|
+
const diskUsed = lastOf(h?.disk) ?? (diskLeft !== undefined && here.diskGb ? 100 - (diskLeft / (here.diskGb * 1024)) * 100 : null);
|
|
2681
|
+
if (diskUsed !== null) tiles.push(handTile(uiSaid('set-disk', 'Disk'), diskUsed, diskLeft !== undefined ? uiSaid('set-left-of', '{free} left of {total}', { free: GB(diskLeft), total: `${here.diskGb} GB` }) : `${here.diskGb} GB`, h?.disk, levelAt(diskUsed)));
|
|
2682
|
+
const cpu = lastOf(h?.cpu);
|
|
2683
|
+
if (h) tiles.push(handTile(uiSaid('set-cpu', 'CPU'), cpu, uiSaid(here.cpus === 1 ? 'set-core' : 'set-cores', here.cpus === 1 ? '1 core' : '{n} cores', { n: here.cpus ?? 1 }), h.cpu, levelAt(cpu ?? 0)));
|
|
2684
|
+
for (const t of tiles) t.addEventListener('click', () => { openChapter('machine')?.scrollIntoView({ block: 'start' }); });
|
|
2685
|
+
box.replaceChildren(...tiles); box.hidden = tiles.length === 0;
|
|
2686
|
+
}
|
|
2687
|
+
/* What each folded chapter of a conversation says: its state now. */
|
|
2688
|
+
function paintConvStates(here) {
|
|
2689
|
+
if (DEVICE || !here) return;
|
|
2690
|
+
const join = (...parts) => parts.filter(Boolean).join(' · ');
|
|
2691
|
+
chapterNow('general', join(here.title || here.name, here.group, here.toolLabel ?? here.tool));
|
|
2692
|
+
chapterNow('machine', join(sizeWords(here.memoryMb), uiSaid(here.cpus === 1 ? 'set-core' : 'set-cores', here.cpus === 1 ? '1 core' : '{n} cores', { n: here.cpus ?? 1 }), here.diskGb ? `${here.diskGb} GB` : ''));
|
|
2693
|
+
const attached = (here.resources ?? []).length; const secrets = $('access-secrets').children.length;
|
|
2694
|
+
chapterNow('access', join(uiSaid('set-attached', '{n} attached', { n: attached }), secrets ? uiSaid(secrets === 1 ? 'set-secret' : 'set-secrets', secrets === 1 ? '1 secret' : '{n} secrets', { n: secrets }) : '', here.offline ? uiSaid('set-offline', 'offline') : ''));
|
|
2695
|
+
const shared = $('share-here').children.length;
|
|
2696
|
+
chapterNow('sharing', shared ? uiSaid(shared === 1 ? 'set-device' : 'set-devices', shared === 1 ? '1 device' : '{n} devices', { n: shared }) : uiSaid('set-no-device', 'No device'));
|
|
2697
|
+
const chatOn = levelsWord('talk-on');
|
|
2698
|
+
chapterNow('chat', join(chatOn ? `${uiSaid('set-chat', 'Chat')} ${chatOn.toLowerCase()}` : '', here.chatName ? `“${here.chatName}”` : ''));
|
|
2699
|
+
const w = here.wakeups?.items ?? [];
|
|
2700
|
+
chapterNow('wakeups', w.length ? uiSaid('set-wakeups-on', '{on} of {n} on', { on: w.filter((x) => x.on).length, n: w.length }) : uiSaid('set-none', 'None'));
|
|
2701
|
+
chapterNow('answerer', here.answerer ? (here.answerer.on ? uiSaid('set-on', 'On') : uiSaid('set-off', 'Off')) : '');
|
|
2702
|
+
const hl = here.health;
|
|
2703
|
+
const wrong = (hl?.problems ?? []).filter((p) => p.level === 'warn' || p.level === 'bad');
|
|
2704
|
+
chapterNow('health', here.asleep ? uiSaid('set-asleep', 'Asleep') : !hl ? uiSaid('set-not-looked', 'Not looked at yet') : join(wrong.length ? wrong[0].text : hl.state === 'Running' ? uiSaid('set-running-well', 'Running · nothing wrong') : hl.state, hl.at ? agoSaid(hl.at) : ''));
|
|
2705
|
+
chapterNow('advanced', uiSaid('set-conv-advanced', 'Archive · reset · delete'));
|
|
2657
2706
|
}
|
|
2658
2707
|
for (const b of $('ask-first').children) {
|
|
2659
2708
|
b.addEventListener('click', async () => {
|
|
@@ -3171,7 +3220,7 @@
|
|
|
3171
3220
|
if (talk.on) $('talk-declare').textContent = talk.tools
|
|
3172
3221
|
? `Then "Ask the tool to use it": it is told to talk to you here, in ${languageName(deviceLang())}.`
|
|
3173
3222
|
: 'The tools folder (/tools) is not in place yet: the tool cannot be asked.';
|
|
3174
|
-
if (!talk.on && talk.possible === false) $('talk-about').textContent = 'Needs its work folder kept here (it works on its machine\'s disk)';
|
|
3223
|
+
if (!talk.on && talk.possible === false) { $('talk-about').textContent = 'Needs its work folder kept here (it works on its machine\'s disk)'; $('talk-about').hidden = false; }
|
|
3175
3224
|
}
|
|
3176
3225
|
for (const b of $('talk-on').children) {
|
|
3177
3226
|
b.addEventListener('click', async () => {
|
|
@@ -3447,7 +3496,7 @@
|
|
|
3447
3496
|
const row = document.createElement('div'); row.className = 'wakeup'; row.dataset.kind = w.kind;
|
|
3448
3497
|
const what = document.createElement('b'); what.textContent = wakeupSays(w);
|
|
3449
3498
|
const said = document.createElement('p'); said.className = 'hint'; said.textContent = `Typed: ${w.message}`;
|
|
3450
|
-
const last = document.createElement('p'); last.className = 'hint wakeup-last'; last.textContent = w.last ? `Last
|
|
3499
|
+
const last = document.createElement('p'); last.className = 'hint wakeup-last'; last.textContent = w.last ? `Last: ${agoSaid(w.last.at)} · ${w.last.what}` : 'Not yet.'; last.title = w.last ? new Date(w.last.at).toLocaleString() : '';
|
|
3451
3500
|
const acts = document.createElement('div'); acts.className = 'row';
|
|
3452
3501
|
acts.append(modes([['on', 'On'], ['off', 'Off']], w.on ? 'on' : 'off', async (value) => { await post(`${API}/conversations/${encodeURIComponent(current)}/wakeups/${w.id}`, { on: value === 'on' }); await refresh(); paintWakeups(); }, `This wake-up: ${wakeupSays(w)}`));
|
|
3453
3502
|
const remove = document.createElement('button'); remove.type = 'button'; remove.textContent = 'Remove';
|
|
@@ -3535,6 +3584,8 @@
|
|
|
3535
3584
|
const about = platformSaid.answerer;
|
|
3536
3585
|
const mine = conversations.find((x) => x.name === current)?.answerer;
|
|
3537
3586
|
$('answerer-fields').hidden = !about || !mine;
|
|
3587
|
+
/* None set on this installation: its chapter hidden (an empty section is hidden). */
|
|
3588
|
+
$('chapter-answerer').hidden = !about;
|
|
3538
3589
|
if (!about || !mine) { $('answerer-about').textContent = 'While you are away, several models can answer the simple questions of the tool. None is set on this installation (CLAVARIUM_ANSWERER_URL, CLAVARIUM_ANSWERER_MODELS).'; return; }
|
|
3539
3590
|
$('answerer-about').textContent = `While you are away, ${about.models.length > 1 ? `${about.models.length} models answer the simple questions of the tool, when they ALL give the same answer` : 'one model answers the simple questions of the tool'}; otherwise you are asked. Turned on, THE SCREEN OF THIS CONVERSATION IS SENT to: ${about.models.join(', ')}.`;
|
|
3540
3591
|
/* What is being written is not painted over by a refresh. */
|
|
@@ -3601,7 +3652,9 @@
|
|
|
3601
3652
|
await refresh();
|
|
3602
3653
|
await paintPanel();
|
|
3603
3654
|
$('attach-picker').hidden = !picking;
|
|
3604
|
-
|
|
3655
|
+
/* The folders button shows the folders: their chapter opened, in its tab. */
|
|
3656
|
+
openChapter('access', { show: !picking });
|
|
3657
|
+
if (picking) $('attach-picker').scrollIntoView({ block: 'nearest' });
|
|
3605
3658
|
}
|
|
3606
3659
|
$('folders').addEventListener('click', () => { void openAccess(false); });
|
|
3607
3660
|
$('attach-open').addEventListener('click', () => { openChapter('access'); $('attach-picker').hidden = false; $('attach-picker').scrollIntoView({ block: 'nearest' }); });
|
|
@@ -5377,14 +5430,14 @@
|
|
|
5377
5430
|
enterPlace('salon-new', push);
|
|
5378
5431
|
$('salon-new-title').textContent = editing ? editing.name : 'New room';
|
|
5379
5432
|
$('salon-new-create').textContent = editing ? 'Save' : 'Create';
|
|
5380
|
-
$('salon-new-remove-card').hidden = !editing;
|
|
5433
|
+
$('salon-new-remove-card').hidden = $('salon-new-advanced-head').hidden = !editing;
|
|
5381
5434
|
$('salon-new-remove').hidden = false; $('salon-new-remove-card').querySelector('.confirm')?.remove();
|
|
5382
5435
|
$('salon-new-error').hidden = true; $('salon-new-name').value = editing?.name ?? ''; $('salon-new-search').value = '';
|
|
5383
5436
|
salonIn = new Set(editing ? editing.members.filter((m) => m.kind === 'ai').map((m) => m.ref) : []);
|
|
5384
5437
|
salonHost = editing?.members.find((m) => m.host)?.ref ?? '';
|
|
5385
5438
|
salonBoxes = new Set(editing ? editing.members.filter((m) => m.kind === 'box').map((m) => m.ref) : []);
|
|
5386
5439
|
try { const x = await fetch(`${API}/boxes`); salonBoxList = x.ok ? await x.json() : []; } catch { salonBoxList = []; }
|
|
5387
|
-
$('salon-new-boxes-card').hidden = salonBoxList.length === 0;
|
|
5440
|
+
$('salon-new-boxes-card').hidden = $('salon-new-voice-head').hidden = salonBoxList.length === 0;
|
|
5388
5441
|
paintSalonMembers();
|
|
5389
5442
|
$('salon-new-name').focus();
|
|
5390
5443
|
}
|
|
@@ -6056,17 +6109,189 @@
|
|
|
6056
6109
|
catch (error) { $('operators-error').textContent = error.message; $('operators-error').hidden = false; }
|
|
6057
6110
|
await paintOperators();
|
|
6058
6111
|
});
|
|
6059
|
-
/* THE
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
const
|
|
6065
|
-
const
|
|
6066
|
-
const
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6112
|
+
/* THE TABS OF A SETTINGS PAGE (settings redesign, 05-11): its groups -- General, (This device,) Resources, Access,
|
|
6113
|
+
Chat & voice, Automatic, Diagnostics, Advanced: the same names in the same order on every settings page -- one
|
|
6114
|
+
shown at a time. The one last shown is kept on this device. A tab whose group has nothing to show is hidden,
|
|
6115
|
+
the order of the others unchanged. While a search is typed, every group is searched and shown (CSS). */
|
|
6116
|
+
function settingsTabs(sheet) {
|
|
6117
|
+
const nav = sheet?.querySelector('.settings-tabs'); if (!nav) return;
|
|
6118
|
+
const buttons = [...nav.querySelectorAll('button[data-group]')];
|
|
6119
|
+
const groupOf = (key) => sheet.querySelector(`.settings-group[data-group="${key}"]`);
|
|
6120
|
+
const kept = `clavarium-tab-${sheet.id}`;
|
|
6121
|
+
const show = (key, { keep = true } = {}) => {
|
|
6122
|
+
for (const b of buttons) { const on = b.dataset.group === key; b.setAttribute('aria-selected', String(on)); b.tabIndex = on ? 0 : -1; }
|
|
6123
|
+
for (const g of sheet.querySelectorAll('.settings-group[data-group]')) g.classList.toggle('tab-off', g.dataset.group !== key);
|
|
6124
|
+
sheet.dataset.tab = key;
|
|
6125
|
+
if (keep) try { localStorage.setItem(kept, key); } catch { /* a private window */ }
|
|
6126
|
+
const b = buttons.find((x) => x.dataset.group === key);
|
|
6127
|
+
if (b && nav.scrollWidth > nav.clientWidth) nav.scrollLeft = Math.max(0, b.offsetLeft - (nav.clientWidth - b.offsetWidth) / 2);
|
|
6128
|
+
};
|
|
6129
|
+
/* Hidden: a tab whose chapters are all hidden (Usage, Administrators on this machine alone...). */
|
|
6130
|
+
const refresh = () => {
|
|
6131
|
+
if (sheet.dataset.searching === 'on') return;
|
|
6132
|
+
for (const b of buttons) { const g = groupOf(b.dataset.group); b.hidden = !g || ![...g.querySelectorAll('details.chapter')].some((d) => !d.hidden); }
|
|
6133
|
+
if (buttons.find((b) => b.dataset.group === sheet.dataset.tab)?.hidden) show(buttons.find((b) => !b.hidden)?.dataset.group ?? buttons[0].dataset.group, { keep: false });
|
|
6134
|
+
};
|
|
6135
|
+
for (const b of buttons) b.addEventListener('click', () => { show(b.dataset.group); b.focus(); });
|
|
6136
|
+
nav.addEventListener('keydown', (event) => {
|
|
6137
|
+
const shown = buttons.filter((b) => !b.hidden); const at = shown.findIndex((b) => b.dataset.group === sheet.dataset.tab);
|
|
6138
|
+
const to = { ArrowRight: at + 1, ArrowLeft: at - 1, Home: 0, End: shown.length - 1 }[event.key];
|
|
6139
|
+
if (to === undefined || !shown.length) return;
|
|
6140
|
+
event.preventDefault(); const b = shown[(to + shown.length) % shown.length]; show(b.dataset.group); b.focus();
|
|
6141
|
+
});
|
|
6142
|
+
let first = buttons[0].dataset.group;
|
|
6143
|
+
try { const k = localStorage.getItem(kept); if (buttons.some((b) => b.dataset.group === k)) first = k; } catch { /* as above */ }
|
|
6144
|
+
show(first, { keep: false });
|
|
6145
|
+
sheet.showTab = show; sheet.refreshTabs = refresh;
|
|
6146
|
+
new MutationObserver(() => refresh()).observe(sheet, { subtree: true, attributes: true, attributeFilter: ['hidden'] });
|
|
6147
|
+
refresh();
|
|
6148
|
+
}
|
|
6149
|
+
for (const id of ['settings', 'panel']) settingsTabs($(id));
|
|
6150
|
+
|
|
6151
|
+
/* THE WORDS OF THE SETTINGS PAGES in the screen's language (server/settingswords.mjs, served with the chat's,
|
|
6152
|
+
uiSaid): an element marked data-said="key" keeps its English as the fallback. */
|
|
6153
|
+
function saySettings() {
|
|
6154
|
+
for (const e of document.querySelectorAll('[data-said]')) { e.dataset.en ??= e.textContent; e.textContent = uiSaid(e.dataset.said, e.dataset.en); }
|
|
6155
|
+
for (const b of document.querySelectorAll('button.tip-btn')) b.setAttribute('aria-label', uiSaid('set-why', 'Why'));
|
|
6156
|
+
const s = document.querySelector('#settings .settings-search'); if (s) s.placeholder = uiSaid('set-search', 'Search');
|
|
6157
|
+
const p = document.querySelector('#panel .settings-search'); if (p) p.placeholder = uiSaid('set-search', 'Search');
|
|
6158
|
+
}
|
|
6159
|
+
void readWords().then(saySettings).catch(() => {});
|
|
6160
|
+
|
|
6161
|
+
/* "WHY", BEHIND AN ⓘ (settings redesign, step 3): a row says what it is in one short line; the why behind
|
|
6162
|
+
the ⓘ beside its name, one click away. Any element .tip (hidden) gets its button. */
|
|
6163
|
+
function wireTips(root = document) {
|
|
6164
|
+
for (const tip of root.querySelectorAll('.tip')) {
|
|
6165
|
+
if (tip.dataset.wired) continue; tip.dataset.wired = '1'; tip.hidden = true;
|
|
6166
|
+
const b = document.createElement('button'); b.type = 'button'; b.className = 'tip-btn'; b.textContent = 'ⓘ';
|
|
6167
|
+
b.setAttribute('aria-label', uiSaid('set-why', 'Why')); b.setAttribute('aria-expanded', 'false');
|
|
6168
|
+
b.addEventListener('click', (event) => { event.preventDefault(); event.stopPropagation(); tip.hidden = !tip.hidden; b.setAttribute('aria-expanded', String(!tip.hidden)); });
|
|
6169
|
+
/* Beside the row's name, on its line. */
|
|
6170
|
+
const name = tip.closest('.set-what')?.querySelector(':scope > :is(b, span, label)');
|
|
6171
|
+
if (name) { const line = document.createElement('span'); line.className = 'with-tip'; name.before(line); line.append(name, b); continue; }
|
|
6172
|
+
/* A paragraph of its own: beside the heading or the line above it, else on a line of its own. */
|
|
6173
|
+
let above = tip.previousElementSibling; while (above?.hidden) above = above.previousElementSibling;
|
|
6174
|
+
if (above) { const head = above.querySelector(':scope > b'); if (head) head.after(b); else above.append(b); }
|
|
6175
|
+
else { const line = document.createElement('div'); line.className = 'tip-head'; line.append(b); tip.before(line); }
|
|
6176
|
+
}
|
|
6177
|
+
}
|
|
6178
|
+
wireTips();
|
|
6179
|
+
|
|
6180
|
+
/* WHAT A FOLDED CHAPTER SAYS (settings redesign, step 1): its state now, in a few words, where a description
|
|
6181
|
+
was -- often enough not to open it. */
|
|
6182
|
+
function chapterNow(key, text) {
|
|
6183
|
+
const about = document.querySelector(`details.chapter[data-chapter="${key}"] > summary .chapter-about`);
|
|
6184
|
+
if (about && text !== undefined && text !== null) about.textContent = text;
|
|
6185
|
+
}
|
|
6186
|
+
const agoSaid = (t) => { const m = Math.max(0, Math.round((Date.now() - new Date(t).getTime()) / 60_000)); return m < 1 ? uiSaid('set-just-now', 'just now') : m < 60 ? uiSaid('set-min-ago', '{n} min ago', { n: m }) : m < 48 * 60 ? uiSaid('set-h-ago', '{n} h ago', { n: Math.round(m / 60) }) : uiSaid('set-days-ago', '{n} days ago', { n: Math.round(m / 1440) }); };
|
|
6187
|
+
|
|
6188
|
+
/* AT HAND: three tiles -- memory, disk, CPU -- each its share now, a bar, the last hour in a small line, and
|
|
6189
|
+
what is left in words; a click opens Resources. From what is read already (/api/server, a machine's health,
|
|
6190
|
+
/api/history): no new call to the server. */
|
|
6191
|
+
const levelAt = (p, high = false) => (p >= 95 ? 'bad' : p >= 85 || high ? 'warn' : 'ok');
|
|
6192
|
+
function handTile(label, percent, sub, values, level, reservePercent) {
|
|
6193
|
+
const t = el('button', 'tile'); t.type = 'button'; t.dataset.level = level;
|
|
6194
|
+
const k = el('span', 'tile-k'); k.append(el('b', '', label), el('span', 'tile-n', percent === null ? '—' : `${Math.round(percent)} %`));
|
|
6195
|
+
const bar = el('span', 'tile-bar'); const fill = el('i'); fill.style.width = `${Math.max(0, Math.min(100, percent ?? 0))}%`; bar.append(fill);
|
|
6196
|
+
if (Number.isFinite(reservePercent) && reservePercent > 0 && reservePercent < 100) { const u = el('u'); u.style.width = `${reservePercent}%`; bar.append(u); }
|
|
6197
|
+
t.append(k, bar);
|
|
6198
|
+
const known = (values ?? []).map((v, i) => [i, v]).filter(([, v]) => v !== null && v !== undefined);
|
|
6199
|
+
if (known.length > 1) {
|
|
6200
|
+
const n = values.length - 1; let d = '';
|
|
6201
|
+
for (const [i, v] of known) d += `${d ? 'L' : 'M'}${((i / n) * 100).toFixed(1)},${(22 - (v / 100) * 20).toFixed(1)}`;
|
|
6202
|
+
const svg = svgEl('svg', { viewBox: '0 0 100 22', preserveAspectRatio: 'none', class: 'tile-spark', 'aria-hidden': 'true' });
|
|
6203
|
+
svg.append(svgEl('path', { d, 'vector-effect': 'non-scaling-stroke' })); t.append(svg);
|
|
6204
|
+
}
|
|
6205
|
+
t.append(el('span', 'tile-sub', sub));
|
|
6206
|
+
t.setAttribute('aria-label', `${label}: ${percent === null ? '—' : `${Math.round(percent)} %`}, ${sub}`);
|
|
6207
|
+
return t;
|
|
6208
|
+
}
|
|
6209
|
+
const lastOf = (values) => { for (let i = (values?.length ?? 0) - 1; i >= 0; i -= 1) if (values[i] !== null && values[i] !== undefined) return values[i]; return null; };
|
|
6210
|
+
const handHistory = async (of) => (of ? fetch(`${API}/history?of=${encodeURIComponent(of)}&span=1h`).then((x) => (x.ok ? x.json() : null)).catch(() => null) : null);
|
|
6211
|
+
/* A chip: a dot of its state and a word -- only when it says something. */
|
|
6212
|
+
const handChip = (tone, text, go) => { const c = el(go ? 'button' : 'span', 'hand-chip', text); c.dataset.tone = tone; if (go) { c.type = 'button'; c.addEventListener('click', go); } return c; };
|
|
6213
|
+
|
|
6214
|
+
/* The server's: under the top bar of Settings. */
|
|
6215
|
+
let lastServer = null;
|
|
6216
|
+
async function paintSettingsHand(r = lastServer) {
|
|
6217
|
+
if (DEVICE) return;
|
|
6218
|
+
lastServer = r;
|
|
6219
|
+
$('settings-hand').hidden = false;
|
|
6220
|
+
const h = await handHistory('server');
|
|
6221
|
+
const tiles = [];
|
|
6222
|
+
const go = () => { openChapter('s-resources')?.scrollIntoView({ block: 'start' }); };
|
|
6223
|
+
if (r?.memory) { const m = r.memory; tiles.push(handTile(uiSaid('set-memory', 'Memory'), m.usedPercent, uiSaid('set-free-of', '{free} free of {total}', { free: GB(m.freeMb), total: GB(m.totalMb) }), h?.memory, levelAt(m.usedPercent, r.high?.memory), r.reserve?.memoryMb && m.totalMb ? (r.reserve.memoryMb / m.totalMb) * 100 : null)); }
|
|
6224
|
+
const disk = r?.disk?.disks?.find((d) => d.holds?.includes('machines')) ?? r?.disk?.disks?.[0];
|
|
6225
|
+
if (disk) tiles.push(handTile(uiSaid('set-disk', 'Disk'), disk.usedPercent, uiSaid('set-free-of', '{free} free of {total}', { free: GB(disk.freeMb), total: GB(disk.sizeMb) }), h?.disk, levelAt(disk.usedPercent, r.high?.disk), r.reserve?.diskMb && disk.sizeMb ? (r.reserve.diskMb / disk.sizeMb) * 100 : null));
|
|
6226
|
+
const cpu = lastOf(h?.cpu);
|
|
6227
|
+
if (h) { const most = Math.max(0, ...(h.cpu ?? []).filter((v) => v !== null)); tiles.push(handTile(uiSaid('set-cpu', 'CPU'), cpu, uiSaid('set-highest', 'highest {n} % in 1 h', { n: Math.round(most) }), h.cpu, levelAt(cpu ?? 0))); }
|
|
6228
|
+
for (const t of tiles) t.addEventListener('click', go);
|
|
6229
|
+
$('settings-tiles').replaceChildren(...tiles); $('settings-tiles').hidden = tiles.length === 0;
|
|
6230
|
+
paintSettingsFacts();
|
|
6231
|
+
}
|
|
6232
|
+
/* Its chips: the version, a conversation that is not well, a voice box away. */
|
|
6233
|
+
let handWifi = null;
|
|
6234
|
+
function paintSettingsFacts() {
|
|
6235
|
+
const chips = [];
|
|
6236
|
+
const u = lastUpdates;
|
|
6237
|
+
if (u?.installed) {
|
|
6238
|
+
if (u.available) chips.push(handChip('warn', uiSaid('set-update-out', '{v} is out', { v: u.available.version ?? u.available }), () => { openChapter('s-updates')?.scrollIntoView({ block: 'start' }); }));
|
|
6239
|
+
else if (u.version) chips.push(handChip('ok', uiSaid('set-up-to-date', 'Up to date · {v}', { v: u.version })));
|
|
6240
|
+
}
|
|
6241
|
+
if (handWifi?.using?.ssid) chips.push(handChip('ok', uiSaid('set-wifi-on', 'Wi-Fi · {name}', { name: handWifi.using.ssid })));
|
|
6242
|
+
for (const c of conversations.filter((x) => (x.health?.problems ?? []).some((p) => p.level === 'warn' || p.level === 'bad'))) {
|
|
6243
|
+
const bad = c.health.problems.some((p) => p.level === 'bad');
|
|
6244
|
+
chips.push(handChip(bad ? 'bad' : 'warn', `${c.title || c.name} · ${uiSaid('set-not-well', 'not well')}`, () => select(c.name, { step: true })));
|
|
6245
|
+
}
|
|
6246
|
+
for (const b of (handBoxes ?? []).filter((x) => x.online === false)) chips.push(handChip('off', uiSaid('set-box-away', '{name} offline', { name: b.name })));
|
|
6247
|
+
$('settings-facts').replaceChildren(...chips); $('settings-facts').hidden = chips.length === 0;
|
|
6248
|
+
}
|
|
6249
|
+
let handBoxes = null;
|
|
6250
|
+
$('hand-check').addEventListener('click', () => { const sheet = $('settings'); sheet.showTab?.('automatic'); openChapter('s-updates'); $('updates-check').click(); $('settings-updates-top').scrollIntoView({ block: 'start' }); });
|
|
6251
|
+
$('hand-activity').addEventListener('click', () => { openChapter('s-events')?.scrollIntoView({ block: 'start' }); });
|
|
6252
|
+
$('hand-restart').addEventListener('click', () => { openChapter('s-advanced'); $('server-restarts').scrollIntoView({ block: 'center' }); });
|
|
6253
|
+
/* THE STATE OF EACH FOLDED CHAPTER OF SETTINGS, read from what its own painting left (and three small looks:
|
|
6254
|
+
network, remote screen, the last thing that happened). Painted again when a chapter is folded. */
|
|
6255
|
+
const optionText = (id) => { const s = $(id); return s?.selectedOptions?.[0]?.textContent?.replace(/\s*\(.*\)$/, '') ?? ''; };
|
|
6256
|
+
const levelsWord = (id) => [...($(id)?.children ?? [])].find((b) => b.getAttribute('aria-pressed') === 'true')?.textContent ?? '';
|
|
6257
|
+
async function paintSettingsStates() {
|
|
6258
|
+
if (DEVICE) return;
|
|
6259
|
+
const join = (...parts) => parts.filter(Boolean).join(' · ');
|
|
6260
|
+
chapterNow('s-screen', join(levelsWord('theme'), document.querySelector('#settings-text .text-now')?.textContent));
|
|
6261
|
+
const alerts = $('alerts-state').textContent.trim();
|
|
6262
|
+
chapterNow('s-alerts', alerts.length <= 30 ? alerts : alerts.split(/[.,:;]/)[0]);
|
|
6263
|
+
chapterNow('s-words', join(optionText('words-lang') === 'The language of each device' ? uiSaid('set-lang-device', 'Each device\'s language') : optionText('words-lang'), optionText('chat-window')));
|
|
6264
|
+
const levels = [...document.querySelectorAll('#thread-levels select')].filter((x) => [...x.options].some((o) => /\(default\)/.test(o.textContent)));
|
|
6265
|
+
const changed = levels.filter((x) => !/\(default\)/.test(x.selectedOptions[0]?.textContent ?? '')).length;
|
|
6266
|
+
chapterNow('s-thread', changed ? uiSaid('set-changed', '{n} changed', { n: changed }) : uiSaid('set-as-given', 'As given'));
|
|
6267
|
+
const shortcuts = [...document.querySelectorAll('#settings-shortcuts .list-item b')].map((b) => b.textContent);
|
|
6268
|
+
chapterNow('s-shortcuts', shortcuts.length ? shortcuts.slice(0, 3).join(' · ') + (shortcuts.length > 3 ? ` +${shortcuts.length - 3}` : '') : uiSaid('set-none', 'None'));
|
|
6269
|
+
if ($('binders-agent-lists').value !== '') chapterNow('s-binders', uiSaid('set-binders-max', 'Agents make up to {n}', { n: $('binders-agent-lists').value }));
|
|
6270
|
+
const admins = $('operators-rows').children.length;
|
|
6271
|
+
chapterNow('s-operators', admins ? uiSaid(admins === 1 ? 'set-admin-1' : 'set-admins', admins === 1 ? '1 administrator' : '{n} administrators', { n: admins }) : '');
|
|
6272
|
+
chapterNow('s-backup', uiSaid('set-backup-now', 'Export · import'));
|
|
6273
|
+
const shelf = $('shelf-state').textContent.split(' · ')[0];
|
|
6274
|
+
const keys = $('git-hosts').children.length;
|
|
6275
|
+
chapterNow('s-advanced', join(shelf, uiSaid(keys === 1 ? 'set-git-key' : 'set-git-keys', keys === 1 ? '1 git key' : '{n} git keys', { n: keys }), uiSaid('set-restart', 'restart')));
|
|
6276
|
+
chapterNow('s-about', $('settings-about').textContent);
|
|
6277
|
+
chapterNow('s-logs', uiSaid('set-logs-now', 'Clavarium, machines, system'));
|
|
6278
|
+
const u = lastUpdates;
|
|
6279
|
+
if (u?.installed) chapterNow('s-updates', join(u.available ? uiSaid('set-update-out', '{v} is out', { v: u.available.version ?? u.available }) : uiSaid('set-up-to-date', 'Up to date · {v}', { v: u.version }), optionText('updates-channel').split(' ')[0], optionText('updates-mode').split(',')[0]));
|
|
6280
|
+
else if (u) chapterNow('s-updates', u.version ? `Clavarium ${u.version}` : '');
|
|
6281
|
+
const [wifi, mesh, events] = await Promise.all([
|
|
6282
|
+
fetch(`${API}/wifi`).then((r) => (r.ok ? r.json() : null)).catch(() => null),
|
|
6283
|
+
fetch(`${API}/meshcentral`).then((r) => (r.ok ? r.json() : null)).catch(() => null),
|
|
6284
|
+
fetch(`${API}/events?limit=1`).then((r) => (r.ok ? r.json() : null)).catch(() => null),
|
|
6285
|
+
]);
|
|
6286
|
+
handWifi = wifi;
|
|
6287
|
+
if (wifi) chapterNow('s-network', wifi.using?.ssid ? uiSaid('set-wifi-on', 'Wi-Fi · {name}', { name: wifi.using.ssid }) : (wifi.links ?? []).some((l) => l.kind === 'cable' && l.address) ? uiSaid('set-cable', 'Cable') : uiSaid('set-wifi-off', 'Wi-Fi not in use'));
|
|
6288
|
+
if (mesh) chapterNow('s-remote-screen', mesh.running ? uiSaid('set-on', 'On') : uiSaid('set-off', 'Off'));
|
|
6289
|
+
const last = Array.isArray(events) ? events[0] : null;
|
|
6290
|
+
if (last) chapterNow('s-events', `${agoSaid(last.at)} · ${String(last.text).slice(0, 60)}`);
|
|
6291
|
+
handBoxes = await fetch(`${API}/boxes`).then((r) => (r.ok ? r.json() : null)).catch(() => null);
|
|
6292
|
+
paintSettingsFacts();
|
|
6293
|
+
}
|
|
6294
|
+
for (const d of document.querySelectorAll('#settings details.chapter')) d.addEventListener('toggle', () => { if (!d.open) void paintSettingsStates(); });
|
|
6070
6295
|
async function openSettings({ push = true } = {}) {
|
|
6071
6296
|
enterPlace('settings', push);
|
|
6072
6297
|
void paintSettingsFeatures().catch(() => {});
|
|
@@ -6100,6 +6325,7 @@
|
|
|
6100
6325
|
if ($('settings-mesh-top').open) void paintScreen();
|
|
6101
6326
|
if ($('settings-usage-top').open) void paintUsage();
|
|
6102
6327
|
await Promise.all([paintHosts(), paintShelf(), paintServer(), paintUpdates()]);
|
|
6328
|
+
await paintSettingsStates();
|
|
6103
6329
|
}
|
|
6104
6330
|
|
|
6105
6331
|
/* ---------- Dictation, in Settings: two engines, main and backup (server/voice.mjs, dictation-engines.mjs) ---------- */
|
|
@@ -6172,6 +6398,8 @@
|
|
|
6172
6398
|
if (about.source === 'settings' && about.down) { $('settings-dictation').textContent = `${about.down} down · backup in use`; $('settings-dictation').dataset.tone = 'warn'; }
|
|
6173
6399
|
/* Its key past its expiry day: not used (voice.mjs); said in red, a dot on the chapter. */
|
|
6174
6400
|
if (about.source === 'settings' && about.secretExpired) { $('settings-dictation').textContent = 'Key expired: replace it in Assets > Secrets'; $('settings-dictation').dataset.tone = 'bad'; }
|
|
6401
|
+
chapterNow('s-dictation', about.source === 'settings' ? (about.down ? uiSaid('set-dict-backup', 'Backup in use') : about.secretExpired ? uiSaid('set-dict-expired', 'Key expired') : `${uiSaid('set-on', 'On')}${main?.provider ? ` · ${short(main.provider)}` : ''}${backup ? ` · ${uiSaid('set-dict-with-backup', 'with backup')}` : ''}`)
|
|
6402
|
+
: about.source === 'env' ? `${uiSaid('set-on', 'On')} · ${uiSaid('set-dict-server', 'set on the server')}` : uiSaid('set-off', 'Off'));
|
|
6175
6403
|
if (about.secretMissing) dictationSay(`The secret "${about.secret}" is gone: choose another key.`);
|
|
6176
6404
|
else if (backup?.secretMissing) dictationSay(`Backup: the secret "${backup.secret}" is gone: choose another key.`);
|
|
6177
6405
|
if (about.down) dq('main', 'dot').dataset.down = ''; else delete dq('main', 'dot').dataset.down;
|
|
@@ -6295,6 +6523,7 @@
|
|
|
6295
6523
|
if (!about) return;
|
|
6296
6524
|
$('instance-name').placeholder = about.defaultName;
|
|
6297
6525
|
if (document.activeElement !== $('instance-name')) $('instance-name').value = about.given ? about.name : '';
|
|
6526
|
+
chapterNow('s-general', about.name);
|
|
6298
6527
|
}
|
|
6299
6528
|
$('instance-form').addEventListener('submit', async (event) => {
|
|
6300
6529
|
event.preventDefault();
|
|
@@ -7256,7 +7485,9 @@
|
|
|
7256
7485
|
clearTimeout(serverTimer);
|
|
7257
7486
|
const r = await fetch(`${API}/server`).then((x) => (x.ok ? x.json() : null)).catch(() => null);
|
|
7258
7487
|
$('settings-server-top').hidden = !r; $('settings-server').hidden = !r; $('settings-usage-top').hidden = !r || !USAGE_SHOWN;
|
|
7488
|
+
void paintSettingsHand(r);
|
|
7259
7489
|
if (!r) return;
|
|
7490
|
+
if (r.memory) chapterNow('s-resources', uiSaid('set-res-now', 'Memory {m} % · disk {d} %', { m: Math.round(r.memory.usedPercent), d: Math.round((r.disk?.disks?.[0]?.usedPercent) ?? 0) }));
|
|
7260
7491
|
void paintCurves($('server-curves'));
|
|
7261
7492
|
/* The two settings of each: a fixed amount and a share; the larger is kept free. */
|
|
7262
7493
|
const set = r.settings ?? { ...r.reserve, diskPercent: 0, memoryPercent: 0 };
|
|
@@ -10103,8 +10334,7 @@
|
|
|
10103
10334
|
}
|
|
10104
10335
|
$('sleep').addEventListener('click', () => void sleepMachine());
|
|
10105
10336
|
/* The quick actions at the top of the panel do the same as the Machine chapter's. */
|
|
10106
|
-
$('
|
|
10107
|
-
$('quick-restart').addEventListener('click', () => { leavePanel(); void restartMachine(false); });
|
|
10337
|
+
$('hand-terminal').addEventListener('click', () => { leavePanel(); seeTerminal(); });
|
|
10108
10338
|
$('quick-wake').addEventListener('click', () => { leavePanel(); seeTerminal(); });
|
|
10109
10339
|
async function rebuild() {
|
|
10110
10340
|
const name = current;
|