clavarium 0.2.68-next.1 → 0.2.71-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/api.mjs +18 -1
- package/server/groups.mjs +120 -0
- package/server/main.mjs +6 -3
- package/web/app.js +222 -15
- package/web/index.html +1 -1
- package/web/links.js +4 -4
- package/web/style.css +23 -0
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clavarium",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.71-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.71-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.8-next.1",
|
|
15
15
|
"clavarium-docket": "0.1.1",
|
|
16
|
-
"clavarium-parley": "0.17.
|
|
16
|
+
"clavarium-parley": "0.17.10-next.1",
|
|
17
17
|
"clavarium-tether": "0.1.0-next.10",
|
|
18
18
|
"mermaid": "11.17.2",
|
|
19
19
|
"node-pty": "^1.1.0",
|
|
@@ -742,9 +742,9 @@
|
|
|
742
742
|
}
|
|
743
743
|
},
|
|
744
744
|
"node_modules/clavarium-parley": {
|
|
745
|
-
"version": "0.17.
|
|
746
|
-
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.
|
|
747
|
-
"integrity": "sha512-
|
|
745
|
+
"version": "0.17.10-next.1",
|
|
746
|
+
"resolved": "https://registry.npmjs.org/clavarium-parley/-/clavarium-parley-0.17.10-next.1.tgz",
|
|
747
|
+
"integrity": "sha512-a4mZ29EFeBV6P+cumehzJ3VmVWcswklv2L5XAC0Oo+kJQ6k09komHlz2uZZVRRQZFhgC0I6G+avFAYq5zsophA==",
|
|
748
748
|
"license": "MIT",
|
|
749
749
|
"bin": {
|
|
750
750
|
"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.71-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.8-next.1",
|
|
48
48
|
"clavarium-docket": "0.1.1",
|
|
49
|
-
"clavarium-parley": "0.17.
|
|
49
|
+
"clavarium-parley": "0.17.10-next.1",
|
|
50
50
|
"clavarium-tether": "0.1.0-next.10",
|
|
51
51
|
"mermaid": "11.17.2",
|
|
52
52
|
"node-pty": "^1.1.0",
|
package/server/api.mjs
CHANGED
|
@@ -78,6 +78,11 @@
|
|
|
78
78
|
* POST /api/secrets/<NAME>/replace {value?, expires?}: in place, its name and grants kept; '' removes the expiry
|
|
79
79
|
* POST /api/secrets/<NAME>/remove
|
|
80
80
|
* POST /api/secrets/<NAME>/rename {name}: its value and where it is handed go with it
|
|
81
|
+
* GET /api/asset-groups the owner's asset groups: [{id, label, members}]
|
|
82
|
+
* POST /api/asset-groups {label}: a new, empty group
|
|
83
|
+
* POST /api/asset-groups/place {asset, group}: put an asset in a group (group null to take it out)
|
|
84
|
+
* POST /api/asset-groups/<id>/rename {label}
|
|
85
|
+
* POST /api/asset-groups/<id>/remove
|
|
81
86
|
* GET /api/conversations/<name>/health-react POST the same {on?, message?, command?}: what it does when its machine is short
|
|
82
87
|
* GET /api/machines/places GET /api/machines/moving POST /api/machines/move {to}: all the machines to another disk
|
|
83
88
|
* POST /api/machines/forget-old: the copy a move left behind, removed
|
|
@@ -146,7 +151,7 @@ function readBody(request, max = BODY_MAX) {
|
|
|
146
151
|
}
|
|
147
152
|
|
|
148
153
|
/* Returns true when the request was an API request (answered here). */
|
|
149
|
-
export async function handleApi(request, response, conversations, headers, resources, originOk = sameOrigin, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts) {
|
|
154
|
+
export async function handleApi(request, response, conversations, headers, resources, originOk = sameOrigin, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups) {
|
|
150
155
|
const { pathname } = new URL(request.url ?? '/', 'http://local');
|
|
151
156
|
if (!pathname.startsWith('/api/')) return false;
|
|
152
157
|
let send = (status, body) => {
|
|
@@ -240,6 +245,10 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
240
245
|
if (pathname === '/api/resources' && resources) return send(200, resources.list()), true;
|
|
241
246
|
if (pathname === '/api/shortcuts' && shortcuts) return send(200, shortcuts.list()), true;
|
|
242
247
|
if (pathname === '/api/secrets' && secrets) return send(200, secrets.list()), true;
|
|
248
|
+
/* The owner's asset groups (groups.mjs): a label and the asset ids each
|
|
249
|
+
holds. Distinct from /api/groups/* above, which are the conversation
|
|
250
|
+
list's folders. */
|
|
251
|
+
if (pathname === '/api/asset-groups' && groups) return send(200, groups.list()), true;
|
|
243
252
|
if (pathname === '/api/mailboxes' && mailboxes) return send(200, mailboxes.list()), true;
|
|
244
253
|
/* Which providers and kinds an account can be connected for here. */
|
|
245
254
|
if (pathname === '/api/accounts' && accounts) return send(200, { supported: accounts.supported() }), true;
|
|
@@ -428,6 +437,14 @@ export async function handleApi(request, response, conversations, headers, resou
|
|
|
428
437
|
if (tetherOp && tethers) { const r = await tethers.act(tetherOp[1], body, ''); if (!r.ok) throw new Refusal(400, r.text); return send(200, r.data ?? { ok: true }), true; }
|
|
429
438
|
if (pathname === '/api/shortcuts' && shortcuts) return send(201, shortcuts.add(body)), true;
|
|
430
439
|
if (pathname === '/api/secrets' && secrets) { const made = secrets.set(body); setup?.secretAdded(made.name); return send(201, made), true; }
|
|
440
|
+
/* Asset groups (groups.mjs): a folder-style tidy-up, not a right. */
|
|
441
|
+
if (pathname === '/api/asset-groups' && groups) return send(201, groups.create(body.label)), true;
|
|
442
|
+
if (pathname === '/api/asset-groups/place' && groups) return send(200, groups.place(body.asset, body.group ?? null)), true;
|
|
443
|
+
const groupOp = /^\/api\/asset-groups\/([0-9a-f]{12})\/(rename|remove)$/.exec(pathname);
|
|
444
|
+
if (groupOp && groups) {
|
|
445
|
+
if (groupOp[2] === 'rename') return send(200, groups.rename(groupOp[1], body.label)), true;
|
|
446
|
+
return groups.remove(groupOp[1]), send(200, { ok: true }), true;
|
|
447
|
+
}
|
|
431
448
|
const reactSet = /^\/api\/conversations\/([^/]+)\/health-react$/.exec(pathname);
|
|
432
449
|
if (reactSet && reacting) { const n = decodeURIComponent(reactSet[1]); if (!conversations.list().some((c) => c.name === n)) throw new Refusal(404, 'No such conversation.'); return send(200, reacting.set(n, body)), true; }
|
|
433
450
|
if (pathname === '/api/machines/move' && machinesMove) return send(202, await machinesMove.move(String(body.to ?? ''))), true;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/* GROUPS OF ASSETS: a folder-style tidy-up, for the owner's convenience.
|
|
2
|
+
*
|
|
3
|
+
* The owner may have many assets -- folders, git repositories, mailboxes,
|
|
4
|
+
* secrets, connexions. A GROUP is a named box they drop some of them into,
|
|
5
|
+
* to calm the three places assets are shown (the Assets list, a
|
|
6
|
+
* conversation's panel, the access map) and to hand a whole box to a
|
|
7
|
+
* conversation at once.
|
|
8
|
+
*
|
|
9
|
+
* WHAT A GROUP IS NOT: a right. The table of rights (grants.mjs, and the
|
|
10
|
+
* Tether levels) stays the ONE truth of who may do what. A group is only a
|
|
11
|
+
* label an asset carries. "Give the group" is a shortcut that gives each of
|
|
12
|
+
* its assets, one by one, each at a sensible default for its own type -- it
|
|
13
|
+
* is never a line of its own in the rights table, and there is no
|
|
14
|
+
* inheritance. So a group may hold assets of mixed types, and taking a right
|
|
15
|
+
* back is still done on the one asset.
|
|
16
|
+
*
|
|
17
|
+
* THE MODEL IS A FOLDER: an asset sits in AT MOST ONE group; placing it in a
|
|
18
|
+
* group takes it out of any other. Assets with no group ("loose") and
|
|
19
|
+
* grouped assets live side by side. A group emptied of its assets is still a
|
|
20
|
+
* group until it is removed.
|
|
21
|
+
*
|
|
22
|
+
* A MEMBER is an asset id, the same string the rest of the server uses:
|
|
23
|
+
* "folder:reports", "git:site", "mailbox:news", "secret:MODEL_KEY",
|
|
24
|
+
* "connexion:<id>". This store does not police what an id points at (assets
|
|
25
|
+
* come and go, and a Tether connexion is not in grants.mjs), so it keeps ids
|
|
26
|
+
* as given; a view resolves them against the assets that exist and ignores
|
|
27
|
+
* the rest. `forget(asset)` drops a member whose asset is gone.
|
|
28
|
+
*/
|
|
29
|
+
import { randomBytes } from 'node:crypto';
|
|
30
|
+
import { Refusal } from './conversations.mjs';
|
|
31
|
+
import { titleProblem } from './names.mjs';
|
|
32
|
+
|
|
33
|
+
export const LABEL_MAX = 40;
|
|
34
|
+
/* An id a browser cannot forge into something else: short, random, lower. */
|
|
35
|
+
const ID = /^[0-9a-f]{12}$/;
|
|
36
|
+
/* A member is "<type>:<name>" -- a type of a few lower letters, then a name
|
|
37
|
+
with no space or control character. Kept loose on purpose (see above). */
|
|
38
|
+
const MEMBER = /^[a-z]{2,16}:[^\s\u0000-\u001f]{1,64}$/;
|
|
39
|
+
|
|
40
|
+
export function labelProblem(value) {
|
|
41
|
+
const problem = titleProblem(value);
|
|
42
|
+
if (problem) return problem.replace('A name', 'A group name').replace('Give a name.', 'Give the group a name.');
|
|
43
|
+
if ([...value].length > LABEL_MAX) return `A group name is ${LABEL_MAX} characters at most.`;
|
|
44
|
+
return '';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const isMember = (asset) => typeof asset === 'string' && MEMBER.test(asset);
|
|
48
|
+
|
|
49
|
+
export class Groups {
|
|
50
|
+
#store;
|
|
51
|
+
|
|
52
|
+
constructor({ store }) { this.#store = store; }
|
|
53
|
+
|
|
54
|
+
/* [{ id, label, members: [asset...] }], in the order they were made. */
|
|
55
|
+
list() {
|
|
56
|
+
return this.#store.all().map((g) => ({ id: g.name, label: g.label, members: [...(g.members ?? [])] }));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* The group an asset is in, or null. */
|
|
60
|
+
groupOf(asset) {
|
|
61
|
+
const g = this.#store.all().find((x) => (x.members ?? []).includes(asset));
|
|
62
|
+
return g ? g.name : null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* A new, empty group. */
|
|
66
|
+
create(label) {
|
|
67
|
+
const problem = labelProblem(label);
|
|
68
|
+
if (problem) throw new Refusal(400, problem);
|
|
69
|
+
let id; do { id = randomBytes(6).toString('hex'); } while (this.#store.get(id));
|
|
70
|
+
this.#store.put({ name: id, label, members: [] });
|
|
71
|
+
return { id, label, members: [] };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
rename(id, label) {
|
|
75
|
+
const group = this.#require(id);
|
|
76
|
+
const problem = labelProblem(label);
|
|
77
|
+
if (problem) throw new Refusal(400, problem);
|
|
78
|
+
this.#store.put({ ...group, label });
|
|
79
|
+
return { id, label, members: [...(group.members ?? [])] };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
remove(id) {
|
|
83
|
+
this.#require(id);
|
|
84
|
+
this.#store.remove(id);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/* Put an asset in a group, or take it out (group null). A folder move:
|
|
88
|
+
the asset leaves whatever other group it was in. */
|
|
89
|
+
place(asset, group) {
|
|
90
|
+
if (!isMember(asset)) throw new Refusal(400, 'Not an asset: a type and a name, such as "folder:reports".');
|
|
91
|
+
if (group !== null && group !== undefined) this.#require(group);
|
|
92
|
+
for (const g of this.#store.all()) {
|
|
93
|
+
const has = (g.members ?? []).includes(asset);
|
|
94
|
+
if (g.name === group) { if (!has) this.#store.put({ ...g, members: [...(g.members ?? []), asset] }); }
|
|
95
|
+
else if (has) this.#store.put({ ...g, members: (g.members ?? []).filter((a) => a !== asset) });
|
|
96
|
+
}
|
|
97
|
+
return { asset, group: group ?? null };
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Drop a member everywhere its asset appears (the asset was removed). */
|
|
101
|
+
forget(asset) {
|
|
102
|
+
for (const g of this.#store.all()) {
|
|
103
|
+
if ((g.members ?? []).includes(asset)) this.#store.put({ ...g, members: (g.members ?? []).filter((a) => a !== asset) });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/* An asset renamed keeps its place under its new id. */
|
|
108
|
+
renamed(from, to) {
|
|
109
|
+
for (const g of this.#store.all()) {
|
|
110
|
+
if ((g.members ?? []).includes(from)) this.#store.put({ ...g, members: (g.members ?? []).map((a) => (a === from ? to : a)).filter((a, i, all) => all.indexOf(a) === i) });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
#require(id) {
|
|
115
|
+
if (typeof id !== 'string' || !ID.test(id)) throw new Refusal(400, 'Not a group.');
|
|
116
|
+
const group = this.#store.get(id);
|
|
117
|
+
if (!group) throw new Refusal(404, 'No such group.');
|
|
118
|
+
return group;
|
|
119
|
+
}
|
|
120
|
+
}
|
package/server/main.mjs
CHANGED
|
@@ -48,6 +48,7 @@ import { Guide, commonText } from './guide.mjs';
|
|
|
48
48
|
import { SignInMailboxes } from './signin.mjs';
|
|
49
49
|
import { Mailboxes, recentMessages } from './mailbox.mjs';
|
|
50
50
|
import { Grants } from './grants.mjs';
|
|
51
|
+
import { Groups } from './groups.mjs';
|
|
51
52
|
import { GitReview } from './gitpush.mjs';
|
|
52
53
|
import { GitAccess } from './gitaccess.mjs';
|
|
53
54
|
import { GitChecks } from './gitchecks.mjs';
|
|
@@ -157,7 +158,7 @@ const withoutTmux = (env) => Object.fromEntries(Object.entries(env).filter(([key
|
|
|
157
158
|
|
|
158
159
|
const REFUSED = 'This Clavarium belongs to someone else: your account is not one of its operators.\n';
|
|
159
160
|
|
|
160
|
-
function serve(port, conversations, resources, { gate = () => 'local', originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, repair, capacity, updates, instance = new Instance(), certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts } = {}) {
|
|
161
|
+
function serve(port, conversations, resources, { gate = () => 'local', originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, repair, capacity, updates, instance = new Instance(), certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups } = {}) {
|
|
161
162
|
/* Its manifest carries the name of this Clavarium, or the one a device chose (instance.mjs). */
|
|
162
163
|
const sendManifest = (response, url) => response.writeHead(200, { ...HEADERS, 'content-type': 'application/manifest+json' }).end(instance.manifest(new URL(url ?? '/', 'http://local').searchParams.get('name') ?? undefined));
|
|
163
164
|
const sendFile = async (response, file) => {
|
|
@@ -200,7 +201,7 @@ function serve(port, conversations, resources, { gate = () => 'local', originOk,
|
|
|
200
201
|
response.writeHead(403, { ...HEADERS, 'content-type': 'text/plain; charset=utf-8' }).end(REFUSED);
|
|
201
202
|
return;
|
|
202
203
|
}
|
|
203
|
-
if (conversations && await handleApi(request, response, conversations, HEADERS, resources, originOk, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts)) return;
|
|
204
|
+
if (conversations && await handleApi(request, response, conversations, HEADERS, resources, originOk, shortcuts, voice, sharing, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, repair, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, bundles, wifi, binders, meshcentral, tethers, accounts, groups)) return;
|
|
204
205
|
if (pathname === '/manifest.webmanifest' && request.method === 'GET') { sendManifest(response, request.url); return; }
|
|
205
206
|
const file = FILES[pathname];
|
|
206
207
|
if (!file || (request.method !== 'GET' && request.method !== 'HEAD')) {
|
|
@@ -251,6 +252,8 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
251
252
|
const all = conversations ?? new Conversations({ store: new Store(`${dataDir}/conversations.json`), layout: new JsonFile(`${dataDir}/layout.json`, {}), vms, tools, ...(stopDelayMs === undefined ? {} : { stopDelayMs }) });
|
|
252
253
|
/* Who may do what with what: ONE table, shared by everything below. */
|
|
253
254
|
const grants = new Grants(new Store(`${dataDir}/grants.json`));
|
|
255
|
+
/* Folder-style boxes the owner drops assets into, to tidy the views and hand a whole box at once (groups.mjs). */
|
|
256
|
+
const groups = new Groups({ store: new Store(`${dataDir}/groups.json`) });
|
|
254
257
|
/* What happened, in one dated list (events.mjs): the owner's actions, and what the server did by itself. */
|
|
255
258
|
const events = new Events({ file: `${dataDir}/events.log` });
|
|
256
259
|
const vault = new Vault(vaultKey ?? `${dataDir}/vault.key`);
|
|
@@ -531,7 +534,7 @@ export async function startHome({ port, host, dataDir, mntDir = dataDir, gitRese
|
|
|
531
534
|
void team.refresh().catch((error) => console.error(`operators: ${error.message}`));
|
|
532
535
|
const watching = setInterval(() => { void team.watch().catch(() => {}); }, 60_000); watching.unref?.();
|
|
533
536
|
}
|
|
534
|
-
const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, binders, meshcentral, tethers, accounts, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
|
|
537
|
+
const { server, listening } = serve(port, all, folders, { gate, originOk, shortcuts, voice, sharing, door, secrets, network, signin, mailboxes, gitReview, platform, answerer, wakeups, alerts, talk, gitAccess, gitKeeper, shelf, health, setup, guide, capacity, updates, instance, certificate, team, reacting, machinesMove, serverLogs, history, events, wifi, binders, meshcentral, tethers, accounts, groups, bundles: new Bundles({ dir: `${dataDir}/imports`, folder: (name) => folders.folder(name) }), repair: (name) => repairTerminal(name) });
|
|
535
538
|
server.on('close', () => { closing = true; stopBinders(); stopTethers(); clearInterval(historyTimer); history.save(); stopVmWatch(); stopShelf(); stopHealth(); stopUpdates(); stopWatch(); clearInterval(mailTimer); clearInterval(expiryTimer); clearInterval(answerTimer); clearInterval(wakeTimer); clearInterval(docketTimer); dockets.stop(); clearInterval(gitTimer); talk.stop(); });
|
|
536
539
|
let closing = false;
|
|
537
540
|
bridge = attachBridge(server, {
|
package/web/app.js
CHANGED
|
@@ -3195,6 +3195,20 @@
|
|
|
3195
3195
|
return svg;
|
|
3196
3196
|
}
|
|
3197
3197
|
const roundPlus = (label, onclick) => { const b = el('button', 'as-add', '+'); b.type = 'button'; b.setAttribute('aria-label', label); b.title = label; b.addEventListener('click', onclick); return b; };
|
|
3198
|
+
/* One row, used by both the by-type and the by-group views. The icon
|
|
3199
|
+
follows the item's own kind (a group mixes kinds). */
|
|
3200
|
+
function assetRow(item, { chosen, choose }) {
|
|
3201
|
+
const row = el('button', 'as-row'); row.type = 'button'; row.dataset.asset = item.key; row.dataset.name = item.name;
|
|
3202
|
+
if (item.key === chosen) row.setAttribute('aria-current', 'true');
|
|
3203
|
+
const name = el('b', '', item.name);
|
|
3204
|
+
if (item.badge) { const badge = el('span', `as-badge${item.badgeTone ? ` ${item.badgeTone}` : ''}`, item.badge); if (item.badgeTitle) badge.title = item.badgeTitle; name.append(badge); }
|
|
3205
|
+
const sub = el('small', item.tone ? `as-sub ${item.tone}` : 'as-sub', item.sub ?? '');
|
|
3206
|
+
if (item.dot) { sub.classList.add('status-line'); sub.dataset.tone = item.dot; }
|
|
3207
|
+
const words = el('span', 'as-words'); words.append(name, sub);
|
|
3208
|
+
row.append(kindIcon(item.kind), words);
|
|
3209
|
+
row.addEventListener('click', () => choose(item.key));
|
|
3210
|
+
return row;
|
|
3211
|
+
}
|
|
3198
3212
|
/* The rows, by kind. items: [{key, kind, name, sub, badge, badgeTitle, tone}]. */
|
|
3199
3213
|
function paintAsList(holder, items, { chosen, choose, add, empty }) {
|
|
3200
3214
|
holder.replaceChildren();
|
|
@@ -3206,22 +3220,197 @@
|
|
|
3206
3220
|
if (add) head.append(roundPlus(`Add ${{ git: 'a repository', folder: 'a folder', mailbox: 'a mailbox', agenda: 'a calendar', contacts: 'an address book', acces: 'an access', secret: 'a secret', list: LISTS_WORD.a }[kind]}`, () => add(kind)));
|
|
3207
3221
|
section.append(head);
|
|
3208
3222
|
if (mine.length === 0) section.append(el('p', 'hint as-none', 'None yet'));
|
|
3209
|
-
for (const item of mine) {
|
|
3210
|
-
const row = el('button', 'as-row'); row.type = 'button'; row.dataset.asset = item.key; row.dataset.name = item.name;
|
|
3211
|
-
if (item.key === chosen) row.setAttribute('aria-current', 'true');
|
|
3212
|
-
const name = el('b', '', item.name);
|
|
3213
|
-
if (item.badge) { const badge = el('span', `as-badge${item.badgeTone ? ` ${item.badgeTone}` : ''}`, item.badge); if (item.badgeTitle) badge.title = item.badgeTitle; name.append(badge); }
|
|
3214
|
-
const sub = el('small', item.tone ? `as-sub ${item.tone}` : 'as-sub', item.sub ?? '');
|
|
3215
|
-
if (item.dot) { sub.classList.add('status-line'); sub.dataset.tone = item.dot; }
|
|
3216
|
-
const words = el('span', 'as-words'); words.append(name, sub);
|
|
3217
|
-
row.append(kindIcon(kind), words);
|
|
3218
|
-
row.addEventListener('click', () => choose(item.key));
|
|
3219
|
-
section.append(row);
|
|
3220
|
-
}
|
|
3223
|
+
for (const item of mine) section.append(assetRow(item, { chosen, choose }));
|
|
3221
3224
|
holder.append(section);
|
|
3222
3225
|
}
|
|
3223
3226
|
if (items.length === 0 && empty) holder.append(el('p', 'hint', empty));
|
|
3224
3227
|
}
|
|
3228
|
+
/* The group an asset is in, or '' for none. */
|
|
3229
|
+
const groupOf = (key, groups) => groups.find((g) => (g.members ?? []).includes(key))?.id ?? '';
|
|
3230
|
+
/* Groups the owner has folded shut in the by-group view (a convenience). */
|
|
3231
|
+
const groupsFolded = (() => { try { const v = JSON.parse(localStorage.getItem('clavarium-groups-folded') ?? '[]'); return new Set(Array.isArray(v) ? v : []); } catch { return new Set(); } })();
|
|
3232
|
+
const keepGroupsFolded = () => { try { localStorage.setItem('clavarium-groups-folded', JSON.stringify([...groupsFolded])); } catch { /* a private window */ } };
|
|
3233
|
+
/* The rows, by the owner's groups: a foldable section per group, then the
|
|
3234
|
+
loose ones. A group's name opens its own detail (rename, remove, give the
|
|
3235
|
+
whole group); the chevron folds it; "+" makes a new one. An asset is put
|
|
3236
|
+
into a group from the asset's own detail. */
|
|
3237
|
+
function paintAsGroups(holder, items, groups, { chosen, choose, empty }) {
|
|
3238
|
+
holder.replaceChildren();
|
|
3239
|
+
const byKey = new Map(items.map((i) => [i.key, i]));
|
|
3240
|
+
const addBar = el('div', 'as-group-new');
|
|
3241
|
+
if (groupAdding) {
|
|
3242
|
+
const form = el('form', 'as-group-form'); form.autocomplete = 'off';
|
|
3243
|
+
const input = el('input'); input.placeholder = 'Group name'; input.maxLength = 40; input.setAttribute('aria-label', 'New group name');
|
|
3244
|
+
const make = el('button', 'primary', 'Add'); make.type = 'submit';
|
|
3245
|
+
const cancel = el('button', '', 'Cancel'); cancel.type = 'button'; cancel.addEventListener('click', () => { groupAdding = false; void paintAssets(); });
|
|
3246
|
+
form.append(input, make, cancel);
|
|
3247
|
+
form.addEventListener('submit', async (event) => {
|
|
3248
|
+
event.preventDefault(); $('assets-error').hidden = true;
|
|
3249
|
+
try { const made = await post(`${API}/asset-groups`, { label: input.value.trim() }); groupAdding = false; assetOpen = `group:${made.id}`; remember(); }
|
|
3250
|
+
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3251
|
+
void paintAssets();
|
|
3252
|
+
});
|
|
3253
|
+
addBar.append(form);
|
|
3254
|
+
holder.append(addBar);
|
|
3255
|
+
queueMicrotask(() => input.focus());
|
|
3256
|
+
} else {
|
|
3257
|
+
addBar.append(roundPlus('New group', () => { groupAdding = true; void paintAssets(); }), el('span', 'hint', 'New group'));
|
|
3258
|
+
holder.append(addBar);
|
|
3259
|
+
}
|
|
3260
|
+
const section = (head, rows, none, { foldable } = {}) => {
|
|
3261
|
+
const s = el('section', 'as-kind as-group'); s.append(head);
|
|
3262
|
+
if (!foldable || !head.dataset.folded) {
|
|
3263
|
+
if (rows.length === 0) s.append(el('p', 'hint as-none', none));
|
|
3264
|
+
for (const item of rows) s.append(assetRow(item, { chosen, choose }));
|
|
3265
|
+
}
|
|
3266
|
+
holder.append(s);
|
|
3267
|
+
};
|
|
3268
|
+
for (const g of groups) {
|
|
3269
|
+
const members = (g.members ?? []).map((k) => byKey.get(k)).filter(Boolean);
|
|
3270
|
+
const folded = groupsFolded.has(g.id);
|
|
3271
|
+
const head = el('div', 'as-kind-head as-group-head'); if (folded) head.dataset.folded = 'true';
|
|
3272
|
+
const chev = el('button', 'as-chev'); chev.type = 'button'; chev.setAttribute('aria-label', folded ? 'Unfold' : 'Fold'); chev.setAttribute('aria-expanded', String(!folded));
|
|
3273
|
+
chev.append(el('span', '', folded ? '▸' : '▾'));
|
|
3274
|
+
chev.addEventListener('click', () => { if (folded) groupsFolded.delete(g.id); else groupsFolded.add(g.id); keepGroupsFolded(); void paintAssets(); });
|
|
3275
|
+
const label = el('button', 'as-group-name'); label.type = 'button';
|
|
3276
|
+
if (`group:${g.id}` === chosen) label.setAttribute('aria-current', 'true');
|
|
3277
|
+
label.append(el('h3', '', g.label), el('span', 'as-badge count', String(members.length)));
|
|
3278
|
+
label.title = 'Open the group (give it, rename it)';
|
|
3279
|
+
label.addEventListener('click', () => choose(`group:${g.id}`));
|
|
3280
|
+
head.append(chev, label);
|
|
3281
|
+
section(head, members, 'Empty. Open an asset to put it here.', { foldable: true });
|
|
3282
|
+
}
|
|
3283
|
+
const grouped = new Set(groups.flatMap((g) => g.members ?? []));
|
|
3284
|
+
const loose = items.filter((i) => !grouped.has(i.key));
|
|
3285
|
+
const looseHead = el('div', 'as-kind-head'); looseHead.append(el('h3', '', 'No group'));
|
|
3286
|
+
section(looseHead, loose, groups.length ? 'Every asset is in a group.' : 'Make a group above, then open an asset to put it in it.');
|
|
3287
|
+
if (items.length === 0 && empty) holder.append(el('p', 'hint', empty));
|
|
3288
|
+
}
|
|
3289
|
+
/* Give the whole group to a conversation: none / read / write, turned into
|
|
3290
|
+
the right default FOR EACH member's type. A shortcut over the per-asset
|
|
3291
|
+
grants -- those stay the truth, and each asset keeps its own right after. */
|
|
3292
|
+
const GROUP_LEVELS = [['none', 'None'], ['read', 'Read'], ['write', 'Write']];
|
|
3293
|
+
function memberGrantValue(item, level) {
|
|
3294
|
+
if (item.target) return { none: 'none', read: 'watch', write: 'frame' }[level];
|
|
3295
|
+
if (item.kind === 'secret') return level === 'none' ? 'off' : 'use';
|
|
3296
|
+
if (item.kind === 'mailbox') return level === 'none' ? 'none' : 'read'; // a mailbox has only read
|
|
3297
|
+
return level; // folder, git, list: none/read/write line up
|
|
3298
|
+
}
|
|
3299
|
+
async function applyMemberGrant(item, conversationName, value) {
|
|
3300
|
+
if (item.target) return grantTarget(item.target.id, conversationName, value);
|
|
3301
|
+
if (item.kind === 'secret') return handTo(conversationName, item.name, value === 'use', 'assets-error');
|
|
3302
|
+
if (item.kind === 'list') return grantList(item.list.id, conversationName, value);
|
|
3303
|
+
return attachTo(conversationName, item.name, value, 'assets-error');
|
|
3304
|
+
}
|
|
3305
|
+
/* The group's single level for a conversation, read back from its members:
|
|
3306
|
+
none if all are off, write if any member is given write, else read. */
|
|
3307
|
+
function groupLevelFor(members, conversationName) {
|
|
3308
|
+
let any = false; let write = false;
|
|
3309
|
+
for (const item of members) {
|
|
3310
|
+
const v = memberCurrent(item, conversationName);
|
|
3311
|
+
if (!['none', 'off'].includes(v)) any = true;
|
|
3312
|
+
if (['write', 'rw', 'frame', 'free'].includes(v)) write = true;
|
|
3313
|
+
}
|
|
3314
|
+
return write ? 'write' : any ? 'read' : 'none';
|
|
3315
|
+
}
|
|
3316
|
+
function memberCurrent(item, conversationName) {
|
|
3317
|
+
const id = `conversation:${conversationName}`;
|
|
3318
|
+
if (item.target) return item.target.grants?.[id]?.level ?? 'none';
|
|
3319
|
+
if (item.kind === 'secret') return item.secret.conversations.includes(conversationName) ? 'use' : 'off';
|
|
3320
|
+
if (item.kind === 'list') return item.list.grants?.[id] ?? 'none';
|
|
3321
|
+
return item.resource?.attachments?.[conversationName] ?? 'none';
|
|
3322
|
+
}
|
|
3323
|
+
/* The toggle above the rows: by type (default) or by the owner's groups. */
|
|
3324
|
+
function paintAssetsView() {
|
|
3325
|
+
const bar = $('assets-view'); if (!bar) return;
|
|
3326
|
+
bar.replaceChildren();
|
|
3327
|
+
for (const [by, label] of [['type', 'By type'], ['group', 'By group']]) {
|
|
3328
|
+
const b = el('button', '', label); b.type = 'button'; b.dataset.by = by;
|
|
3329
|
+
b.setAttribute('aria-pressed', String(assetsBy === by));
|
|
3330
|
+
b.addEventListener('click', () => { if (assetsBy === by) return; assetsBy = by; keepAssetsBy(); groupAdding = false; void paintAssets(); });
|
|
3331
|
+
bar.append(b);
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
/* In an asset's detail: which group it is in. Moving it is a folder move
|
|
3335
|
+
(it leaves any other group). New groups are made in the by-group view. */
|
|
3336
|
+
function groupPicker(chosen, groups) {
|
|
3337
|
+
const wrap = el('div', 'as-group-of'); wrap.append(el('span', 'as-group-of-label', 'Group'));
|
|
3338
|
+
if (!groups.length) { wrap.append(el('small', 'hint', 'Make one in “By group”.')); return wrap; }
|
|
3339
|
+
const sel = el('select'); sel.setAttribute('aria-label', `Group for ${chosen.name}`);
|
|
3340
|
+
const none = el('option', '', 'No group'); none.value = ''; sel.append(none);
|
|
3341
|
+
const inId = groupOf(chosen.key, groups);
|
|
3342
|
+
for (const g of groups) { const o = el('option', '', g.label); o.value = g.id; if (g.id === inId) o.selected = true; sel.append(o); }
|
|
3343
|
+
if (!inId) none.selected = true;
|
|
3344
|
+
sel.addEventListener('change', async () => {
|
|
3345
|
+
$('assets-error').hidden = true;
|
|
3346
|
+
try { await post(`${API}/asset-groups/place`, { asset: chosen.key, group: sel.value || null }); }
|
|
3347
|
+
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3348
|
+
void paintAssets();
|
|
3349
|
+
});
|
|
3350
|
+
wrap.append(sel);
|
|
3351
|
+
return wrap;
|
|
3352
|
+
}
|
|
3353
|
+
/* A group's own detail: rename it, remove it (the assets stay), give the
|
|
3354
|
+
whole group to a conversation at a level, and its members (each opens). */
|
|
3355
|
+
function groupDetail(detail, group, items, back) {
|
|
3356
|
+
const members = (group.members ?? []).map((k) => items.find((i) => i.key === k)).filter(Boolean);
|
|
3357
|
+
const top = el('div', 'as-title');
|
|
3358
|
+
const all = el('button', 'as-link as-back', '‹ Assets'); all.type = 'button'; all.addEventListener('click', () => { if (!nav.close('asset')) back(); });
|
|
3359
|
+
const h = el('h2'); h.append(el('span', '', group.label), el('span', 'as-badge count', String(members.length)));
|
|
3360
|
+
top.append(all, h);
|
|
3361
|
+
detail.append(top);
|
|
3362
|
+
/* Rename and remove. Removing a group drops the grouping only; every asset,
|
|
3363
|
+
and every right it was given, stays exactly as it was. */
|
|
3364
|
+
const form = el('form', 'set-row'); form.autocomplete = 'off';
|
|
3365
|
+
const name = el('input'); name.value = group.label; name.maxLength = 40; name.setAttribute('aria-label', 'Group name');
|
|
3366
|
+
const go = el('button', '', 'Rename'); go.type = 'submit';
|
|
3367
|
+
const what = el('div', 'set-what'); what.append(el('span', '', 'Name'));
|
|
3368
|
+
const control = el('div', 'set-control'); control.append(name, go);
|
|
3369
|
+
form.append(what, control);
|
|
3370
|
+
form.addEventListener('submit', async (event) => {
|
|
3371
|
+
event.preventDefault(); $('assets-error').hidden = true;
|
|
3372
|
+
try { await post(`${API}/asset-groups/${group.id}/rename`, { label: name.value.trim() }); }
|
|
3373
|
+
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3374
|
+
void paintAssets();
|
|
3375
|
+
});
|
|
3376
|
+
const del = el('button', 'as-danger', 'Remove the group'); del.type = 'button'; del.title = 'The assets stay; only the group is removed.';
|
|
3377
|
+
del.addEventListener('click', async () => {
|
|
3378
|
+
$('assets-error').hidden = true;
|
|
3379
|
+
try { await post(`${API}/asset-groups/${group.id}/remove`, {}); assetOpen = ''; remember(); }
|
|
3380
|
+
catch (error) { $('assets-error').textContent = error.message; $('assets-error').hidden = false; }
|
|
3381
|
+
void paintAssets();
|
|
3382
|
+
});
|
|
3383
|
+
const box = el('div', 'set-rows as-block'); box.append(form, del);
|
|
3384
|
+
detail.append(box);
|
|
3385
|
+
/* Give the whole group. none / read / write turned into each type's own
|
|
3386
|
+
default; each asset keeps its own right after (set one by one above). */
|
|
3387
|
+
const ready = conversations.filter((c) => c.phase === 'ready');
|
|
3388
|
+
const give = async (c, level) => {
|
|
3389
|
+
for (const item of members) { try { await applyMemberGrant(item, c.name, memberGrantValue(item, level)); } catch { /* error shown by the grant; keep going */ } }
|
|
3390
|
+
await paintAssets();
|
|
3391
|
+
};
|
|
3392
|
+
const row = (c) => {
|
|
3393
|
+
const line = el('div', 'given-row'); line.dataset.conversation = c.name;
|
|
3394
|
+
line.append(el('span', '', shownName(c)), modes(GROUP_LEVELS, groupLevelFor(members, c.name), (v) => give(c, v), `Give ${group.label} to ${c.name}`));
|
|
3395
|
+
return line;
|
|
3396
|
+
};
|
|
3397
|
+
const using = ready.filter((c) => groupLevelFor(members, c.name) !== 'none');
|
|
3398
|
+
const others = ready.filter((c) => groupLevelFor(members, c.name) === 'none');
|
|
3399
|
+
const givenBox = el('div', 'as-users'); const picker = el('div', 'as-users as-picker'); picker.hidden = true;
|
|
3400
|
+
for (const c of using) givenBox.append(row(c));
|
|
3401
|
+
if (using.length === 0) givenBox.append(el('p', 'hint', members.length ? 'No conversation has the group.' : 'The group is empty.'));
|
|
3402
|
+
for (const c of others) picker.append(row(c));
|
|
3403
|
+
if (others.length === 0) picker.append(el('p', 'hint', ready.length ? 'Every conversation has it.' : 'No conversation is ready.'));
|
|
3404
|
+
detail.append(chapter('Give the group to a conversation', roundPlus('Give the group to a conversation', () => { picker.hidden = !picker.hidden; })), givenBox, picker);
|
|
3405
|
+
const note = el('p', 'as-assoc hint');
|
|
3406
|
+
note.append(el('b', '', 'Per type'), document.createTextNode(': repositories and folders read or write, a mailbox reads, a secret is used, a connexion is given at the matching level. Each asset keeps its own right, set one by one.'));
|
|
3407
|
+
detail.append(note);
|
|
3408
|
+
/* The members, each opens its own detail. */
|
|
3409
|
+
const rowsBox = el('div', 'as-group-members');
|
|
3410
|
+
for (const item of members) rowsBox.append(assetRow(item, { chosen: '', choose: (key) => { placeAssetStep(); assetOpen = key; remember(); void paintAssets(); } }));
|
|
3411
|
+
if (members.length === 0) rowsBox.append(el('p', 'hint', 'Open an asset and pick this group to put it here.'));
|
|
3412
|
+
detail.append(chapter('Assets in the group'), rowsBox);
|
|
3413
|
+
}
|
|
3225
3414
|
/* The top of a detail: "All assets" (a phone), the icon, the name, a badge. */
|
|
3226
3415
|
function asTitle(item, back) {
|
|
3227
3416
|
const top = el('div', 'as-title');
|
|
@@ -3815,6 +4004,13 @@
|
|
|
3815
4004
|
|
|
3816
4005
|
/* ---- the server's ---- */
|
|
3817
4006
|
let assetOpen = ''; let assetsAdding = ''; let assetsQuery = ''; let remoteShown = ''; let remoteEditing = false; let listOpen = ''; let listsSig = '';
|
|
4007
|
+
/* How the Assets list is arranged: by type (the categories, the default) or
|
|
4008
|
+
by the owner's groups. A per-viewer convenience, kept in the browser. */
|
|
4009
|
+
let assetsBy = 'type';
|
|
4010
|
+
try { if (localStorage.getItem('clavarium-assets-by') === 'group') assetsBy = 'group'; } catch { /* a private window */ }
|
|
4011
|
+
const keepAssetsBy = () => { try { localStorage.setItem('clavarium-assets-by', assetsBy); } catch { /* as above */ } };
|
|
4012
|
+
/* The "+ New group" inline form being shown in the by-group view. */
|
|
4013
|
+
let groupAdding = false;
|
|
3818
4014
|
/* A binder opened in Assets: its screen, the card of the address (a reload); a card, a step (binderSteps). */
|
|
3819
4015
|
let assetsView = null; let assetsAt = null;
|
|
3820
4016
|
const assetsSteps = binderSteps(() => assetsView, { address: () => remember() });
|
|
@@ -3853,7 +4049,7 @@
|
|
|
3853
4049
|
}
|
|
3854
4050
|
async function paintAssets() {
|
|
3855
4051
|
if (place !== 'assets' || DEVICE) return;
|
|
3856
|
-
const [all, boxes, secrets, keys, lists, tether] = await Promise.all([getJson('/resources', []), getJson('/mailboxes', []), getJson('/secrets', []), getJson('/git-keys', []), binderCall('lists', {}), getJson('/tether', {}), readDevices()]);
|
|
4052
|
+
const [all, boxes, secrets, keys, lists, tether, assetGroups] = await Promise.all([getJson('/resources', []), getJson('/mailboxes', []), getJson('/secrets', []), getJson('/git-keys', []), binderCall('lists', {}), getJson('/tether', {}), getJson('/asset-groups', []), readDevices()]);
|
|
3857
4053
|
if (place !== 'assets') return;
|
|
3858
4054
|
paintKeys(keys);
|
|
3859
4055
|
markSecrets(secrets);
|
|
@@ -3885,8 +4081,17 @@
|
|
|
3885
4081
|
}
|
|
3886
4082
|
const shown = assetsQuery ? items.filter((i) => i.name.includes(assetsQuery.toLowerCase()) || i.name.toLowerCase().includes(assetsQuery.toLowerCase())) : items;
|
|
3887
4083
|
const chosen = assetsAdding ? null : items.find((i) => i.key === assetOpen) ?? null;
|
|
3888
|
-
|
|
3889
|
-
|
|
4084
|
+
/* A group can be the open thing too (its own detail: give it, rename it). */
|
|
4085
|
+
const chosenGroup = !assetsAdding && !chosen && assetOpen.startsWith('group:') ? assetGroups.find((g) => `group:${g.id}` === assetOpen) ?? null : null;
|
|
4086
|
+
$('assets-as').dataset.open = chosen || chosenGroup || assetsAdding ? 'detail' : 'list';
|
|
4087
|
+
/* The "by type / by group" toggle sits above the rows (built once, kept). */
|
|
4088
|
+
paintAssetsView();
|
|
4089
|
+
const choose = (key) => { placeAssetStep(); assetOpen = key; assetsAdding = ''; remoteEditing = false; remember(); void paintAssets(); };
|
|
4090
|
+
if (assetsBy === 'group') {
|
|
4091
|
+
paintAsGroups($('assets-rows'), shown, assetGroups, { chosen: chosen?.key ?? (chosenGroup ? `group:${chosenGroup.id}` : ''), choose, empty: assetsQuery ? 'Nothing by that name.' : '' });
|
|
4092
|
+
} else {
|
|
4093
|
+
paintAsList($('assets-rows'), shown, { chosen: chosen?.key, choose, add: (kind) => { placeAssetStep(); assetsAdding = kind; void paintAssets(); }, empty: assetsQuery ? 'Nothing by that name.' : '' });
|
|
4094
|
+
}
|
|
3890
4095
|
const detail = $('assets-detail');
|
|
3891
4096
|
/* The forms go back to where they wait before the detail is drawn again. */
|
|
3892
4097
|
for (const form of detail.querySelectorAll('.as-form, #gitview-remote-box')) $('assets-forms').append(form);
|
|
@@ -3923,8 +4128,10 @@
|
|
|
3923
4128
|
focusField(form.querySelector('input:not([type=radio])'));
|
|
3924
4129
|
return;
|
|
3925
4130
|
}
|
|
4131
|
+
if (chosenGroup) { groupDetail(detail, chosenGroup, items, back); return; }
|
|
3926
4132
|
if (!chosen) { if (items.length) detail.append(noAssetChosen()); return; }
|
|
3927
4133
|
detail.append(asTitle(chosen, back));
|
|
4134
|
+
detail.append(groupPicker(chosen, assetGroups));
|
|
3928
4135
|
const ready = conversations.filter((c) => c.phase === 'ready');
|
|
3929
4136
|
const r = chosen.resource;
|
|
3930
4137
|
/* State, in a line. */
|
package/web/index.html
CHANGED
|
@@ -458,7 +458,7 @@
|
|
|
458
458
|
<div class="panel-top"><b>Assets</b><button type="button" id="assets-close" class="as-link place-back">‹ Conversations</button></div>
|
|
459
459
|
<p id="assets-error" class="error" role="alert" hidden></p>
|
|
460
460
|
<div class="as" id="assets-as">
|
|
461
|
-
<div class="as-list"><input type="search" id="assets-search" placeholder="Search assets" aria-label="Search assets" spellcheck="false" autocomplete="off"><div id="assets-rows"></div></div>
|
|
461
|
+
<div class="as-list"><div class="as-view" id="assets-view" role="group" aria-label="Arrange assets"></div><input type="search" id="assets-search" placeholder="Search assets" aria-label="Search assets" spellcheck="false" autocomplete="off"><div id="assets-rows"></div></div>
|
|
462
462
|
<div class="as-detail" id="assets-detail"></div>
|
|
463
463
|
</div>
|
|
464
464
|
<div id="assets-forms" hidden>
|
package/web/links.js
CHANGED
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
/* An icon of that set, or, until it is there, nothing in its place. */
|
|
29
29
|
const ic = (name, cls = 'lk-svg') => window.clavariumIcons?.icon(name, cls) ?? null;
|
|
30
30
|
const kindIcon = (kind) => h('span', { class: 'lk-ic', 'aria-hidden': 'true' }, ic(KIND_ICON[kind]));
|
|
31
|
-
const KIND_WORD = { device: 'device', conversation: 'conversation', folder: 'folder', git: 'repository', mailbox: 'mailbox', secret: 'secret' };
|
|
32
|
-
const COLUMN = { device: 'device', conversation: 'conversation', folder: 'asset', git: 'asset', mailbox: 'asset', secret: 'asset' };
|
|
31
|
+
const KIND_WORD = { device: 'device', conversation: 'conversation', folder: 'folder', git: 'repository', mailbox: 'mailbox', agenda: 'calendar', contacts: 'address book', secret: 'secret' };
|
|
32
|
+
const COLUMN = { device: 'device', conversation: 'conversation', folder: 'asset', git: 'asset', mailbox: 'asset', agenda: 'asset', contacts: 'asset', secret: 'asset' };
|
|
33
33
|
const TITLES = { device: 'Devices', conversation: 'Conversations', asset: 'Assets' };
|
|
34
34
|
const VIEWS = {
|
|
35
35
|
devices: { cols: [['device'], ['conversation', 'asset']], sources: ['device'] },
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
if (k === 'chat' && !l.rights.includes('w')) return 'chat, read only';
|
|
92
92
|
return WORDS[k].toLowerCase();
|
|
93
93
|
};
|
|
94
|
-
const allowed = (a, b) => !a.pending && !b.pending && ((a.kind === 'device' && ['conversation', 'folder', 'git', 'mailbox'].includes(b.kind)) || (a.kind === 'conversation' && ['folder', 'git', 'mailbox', 'secret'].includes(b.kind)));
|
|
94
|
+
const allowed = (a, b) => !a.pending && !b.pending && ((a.kind === 'device' && ['conversation', 'folder', 'git', 'mailbox'].includes(b.kind)) || (a.kind === 'conversation' && ['folder', 'git', 'mailbox', 'agenda', 'contacts', 'secret'].includes(b.kind)));
|
|
95
95
|
const inView = (n) => VIEWS[view].cols.flat().includes(COLUMN[n.kind]);
|
|
96
96
|
const shown = (l) => VIEWS[view].sources.includes(node(l.from)?.kind) && inView(node(l.to));
|
|
97
97
|
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
times, puts each box at the average place of what it is linked to; the order
|
|
162
162
|
that crossed least is kept. What is linked to nothing goes last, by name. */
|
|
163
163
|
function layout() {
|
|
164
|
-
const ASSETS = ['folder', 'git', 'mailbox', 'secret'];
|
|
164
|
+
const ASSETS = ['folder', 'git', 'mailbox', 'agenda', 'contacts', 'secret'];
|
|
165
165
|
const base = (k) => graph.nodes.filter((n) => COLUMN[n.kind] === k).sort((a, b) => (ASSETS.indexOf(a.kind) - ASSETS.indexOf(b.kind)) || a.name.localeCompare(b.name));
|
|
166
166
|
let cols = VIEWS[view].cols.map((ks) => ks.map(base));
|
|
167
167
|
const colOf = new Map(); cols.forEach((gs, ci) => gs.flat().forEach((n) => colOf.set(n.id, ci)));
|
package/web/style.css
CHANGED
|
@@ -1106,6 +1106,29 @@ header .ic, #folders .ic { width: 18px; height: 18px; fill: none; stroke: curren
|
|
|
1106
1106
|
/* The detail scrolls as a whole: nothing in it is squeezed (a branch diagram cut, its buttons over it) when a folder's files open below. */
|
|
1107
1107
|
.as-detail > * { flex-shrink: 0; }
|
|
1108
1108
|
#assets-search { width: 100%; padding: 9px 12px; border-radius: 9px; margin-bottom: 4px; }
|
|
1109
|
+
/* By type / by group toggle, above the rows. */
|
|
1110
|
+
.as-view { display: flex; margin-bottom: 6px; }
|
|
1111
|
+
.as-view button { flex: 1 1 0; border-radius: 0; margin-left: -1px; font-size: .8125rem; padding: 7px 8px; }
|
|
1112
|
+
.as-view button:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
|
|
1113
|
+
.as-view button:last-child { border-radius: 0 8px 8px 0; }
|
|
1114
|
+
.as-view button[aria-pressed="true"] { border-color: var(--brass); color: var(--brass-ink); background: rgba(210, 169, 78, .16); position: relative; z-index: 1; }
|
|
1115
|
+
/* The by-group view: make-a-group bar, a group's name button, its inline editor. */
|
|
1116
|
+
.as-group-new { display: flex; align-items: center; gap: 6px; margin: 2px 0 4px; }
|
|
1117
|
+
.as-group-new .hint { color: var(--ink2); }
|
|
1118
|
+
.as-group-head { gap: 2px; }
|
|
1119
|
+
.as-chev { flex: 0 0 auto; width: 24px; height: 28px; min-width: 0 !important; min-height: 0 !important; padding: 0; background: transparent; border: 0; color: var(--ink2); font-size: .8rem; }
|
|
1120
|
+
.as-group-name { display: flex; align-items: center; gap: 6px; flex: 1 1 auto; justify-content: flex-start; text-align: left; background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; }
|
|
1121
|
+
.as-group-name:hover { border-color: var(--line); }
|
|
1122
|
+
.as-group-name[aria-current="true"] { background: var(--panel); border-color: var(--line); }
|
|
1123
|
+
.as-group-members { display: flex; flex-direction: column; gap: 2px; }
|
|
1124
|
+
.as-group-form { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; }
|
|
1125
|
+
.as-group-form input { flex: 1 1 8rem; min-width: 0; padding: 6px 9px; border-radius: 8px; }
|
|
1126
|
+
.as-group-form button { font-size: .8125rem; }
|
|
1127
|
+
.as-danger, button.as-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
|
|
1128
|
+
/* The group selector in an asset's detail. */
|
|
1129
|
+
.as-group-of { display: flex; align-items: center; gap: 10px; }
|
|
1130
|
+
.as-group-of-label { font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
|
|
1131
|
+
.as-group-of select { padding: 6px 9px; border-radius: 8px; }
|
|
1109
1132
|
.as-kind { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
|
|
1110
1133
|
.as-kind-head, .as-chapter { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
1111
1134
|
.as-kind-head h3 { margin: 0; padding: 4px 6px; font-size: .6875rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
|