@scalio-cloud/ui 0.54.0 → 0.56.0
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/README.md +32 -8
- package/nav.css +3 -0
- package/package.json +1 -1
- package/react/actions.js +78 -7
- package/react/agents.js +358 -0
- package/react/index.js +1 -1
- package/react/nav.js +8 -3
- package/react/roles.js +2 -2
- package/react/users.js +3 -2
package/README.md
CHANGED
|
@@ -240,18 +240,21 @@ Pages that belong together under one menu item keep their own addresses: the ite
|
|
|
240
240
|
on top. An app with two work areas (Nexus Identity and HR) puts `<WorkspaceSwitcher options value onSelect />`
|
|
241
241
|
into the sidebar's `top`.
|
|
242
242
|
|
|
243
|
-
**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
243
|
+
**Main action of the page** (from 0.55.0, Markus 2026-11-10): the one blue button above Übersicht is always the main
|
|
244
|
+
action of the page you are on. A page declares it with `<MainAction>`; without one the sidebar shows the app's
|
|
245
|
+
`primaryAction` (the main action of the start page). Leaving the page brings the start page's action back. On phones
|
|
246
|
+
(no sidebar) `MainAction` renders a blue button in place. A page never shows its main action a second time, and no
|
|
247
|
+
buttons sit below Übersicht.
|
|
248
248
|
|
|
249
249
|
```jsx
|
|
250
|
-
<
|
|
250
|
+
<MainAction label="Kunde" icon={Plus} onSelect={() => setOpen(true)} testId="customer-add" />
|
|
251
|
+
<MainAction label="Blueprint" icon={Plus} to="/blueprints/new" link={Link} testId="new-blueprint-btn" />
|
|
251
252
|
```
|
|
252
253
|
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
Further page actions (Feststellungen, Versionen vergleichen, Zurück) stay in the page header and are not blue;
|
|
255
|
+
`<PageActions>` renders them in place. `UserAdmin` («Benutzer hinzufügen») and `RoleAdmin` («Rolle») use
|
|
256
|
+
`MainAction` themselves. `<Sidebar pageActions />` and `<ActionSlot />` (0.18.0 to 0.53.x) still do nothing.
|
|
257
|
+
Labels without "Neu"/"New": the + icon says it ("+ Kontakt", not "+ Neuer Kontakt").
|
|
255
258
|
|
|
256
259
|
## Page templates (React, from 0.33.0)
|
|
257
260
|
|
|
@@ -549,6 +552,27 @@ const updates = saasUpdatesApi(api); // once, outside the component
|
|
|
549
552
|
The banner is blue (orange for a security update); people without admin role only see when the update is planned.
|
|
550
553
|
«Später» hides it for this version until the next browser session.
|
|
551
554
|
|
|
555
|
+
## Scalio Agent: Einstellungen → Scalio Agent (React)
|
|
556
|
+
|
|
557
|
+
Since 0.56.0 (scalio-docs ADR 0107, `interfaces/agent-v2.md`) every app that uses the Scalio Agent shows the same
|
|
558
|
+
block. Server side: scalio-platform 0.31.0 `agent.AgentHub.router` (`/api/agent/v2/admin/*`). The admin creates a
|
|
559
|
+
one-time enrollment code (shown once, with the silent install command for this app), sees every agent with status,
|
|
560
|
+
roles and worker states, switches roles per agent, restarts, stops or starts a worker, blocks or removes an agent, and
|
|
561
|
+
sees the last tasks without their data.
|
|
562
|
+
|
|
563
|
+
```jsx
|
|
564
|
+
import { AgentsPanel, agentsApi } from "@scalio-cloud/ui/react";
|
|
565
|
+
|
|
566
|
+
const agents = agentsApi(api); // once, outside the component
|
|
567
|
+
<AgentsPanel client={agents} lang={lang} downloadUrl="/api/agent/download"
|
|
568
|
+
notify={(m, tone) => toast[tone === "error" ? "error" : "success"](m)} />
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
`appUrl` (default the page's origin) goes into the install command; `refreshMs` (default 15000, 0 = off) reloads the
|
|
572
|
+
list. Test IDs: `agents-panel`, `agents-code-create`, `agents-code-value`, `agents-code-command`, `agent-<id>`,
|
|
573
|
+
`agent-role-<id>-<role>`, `agent-worker-state-<id>-<worker>`, `agent-worker-restart|stop|start-<id>-<worker>`,
|
|
574
|
+
`agent-block-<id>`, `agent-remove-<id>`, `agents-tasks`.
|
|
575
|
+
|
|
552
576
|
## Benachrichtigungen: E-Mail-Versand und E-Mail-Vorlagen (React)
|
|
553
577
|
|
|
554
578
|
Since 0.29.0 (ADR 0069 W5) every app sends mail the same way. The server side is scalio-platform 0.8.0 `mail`
|
package/nav.css
CHANGED
|
@@ -882,3 +882,6 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
|
|
|
882
882
|
.scalio-progress-step.is-active, .scalio-progress-step.is-done { color: hsl(var(--foreground)); }
|
|
883
883
|
.scalio-progress-step.is-done .scalio-icon { color: #059669; }
|
|
884
884
|
.scalio-progress-dot { width: 0.875rem; height: 0.875rem; border: 2px solid hsl(var(--border)); border-radius: 999px; }
|
|
885
|
+
/* Main action of a page (react/actions.js MainAction): in the sidebar as .scalio-nav-cta; on phones in place. */
|
|
886
|
+
.scalio-nav-cta:disabled { opacity: 0.6; cursor: default; }
|
|
887
|
+
.scalio-main-action-inline { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; margin-top: 0; text-decoration: none; }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.56.0",
|
|
4
4
|
"description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
|
|
5
5
|
"license": "SEE LICENSE IN README.md",
|
|
6
6
|
"private": false,
|
package/react/actions.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// Page actions (UISPEC section 2
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
2
|
+
// Page actions (UISPEC section 2).
|
|
3
|
+
// - Main action (from 0.55.0, Markus 2026-11-10): the one blue button above Übersicht in the sidebar is always the
|
|
4
|
+
// main action of the page you are on («+ Kunde», «+ Umgebung», «Export hochladen», «+ Benutzer hinzufügen»). A
|
|
5
|
+
// page declares it with <MainAction label icon to|onSelect />; without one the sidebar shows the app's
|
|
6
|
+
// primaryAction (the main action of the start page). On phones (no sidebar) MainAction renders a blue button in
|
|
7
|
+
// place. A page never shows its main action a second time.
|
|
8
|
+
// - Further actions (Feststellungen, Versionen vergleichen, Zurück) stay in the page header, never blue.
|
|
9
|
+
// <PageActions> renders them in place; ActionSlot renders nothing (0.18.0 to 0.53.x moved them into the sidebar).
|
|
8
10
|
const React = require("react");
|
|
9
11
|
const h = React.createElement;
|
|
10
12
|
|
|
@@ -53,6 +55,75 @@ function useDesktop() {
|
|
|
53
55
|
return desktop;
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
// Main action of the current page. A small stack: the last mounted MainAction wins, unmounting restores the one below.
|
|
59
|
+
let mainStack = [];
|
|
60
|
+
const mainListeners = new Set();
|
|
61
|
+
let mainSnapshot = null;
|
|
62
|
+
function emitMain() {
|
|
63
|
+
mainSnapshot = mainStack.length ? mainStack[mainStack.length - 1].action : null;
|
|
64
|
+
mainListeners.forEach((fn) => fn());
|
|
65
|
+
}
|
|
66
|
+
function subscribeMain(fn) {
|
|
67
|
+
mainListeners.add(fn);
|
|
68
|
+
return () => mainListeners.delete(fn);
|
|
69
|
+
}
|
|
70
|
+
const getMain = () => mainSnapshot;
|
|
71
|
+
|
|
72
|
+
// The page's main action, or null (the sidebar then shows the app's primaryAction).
|
|
73
|
+
function useMainAction() {
|
|
74
|
+
return React.useSyncExternalStore(subscribeMain, getMain, () => null);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Desktop sidebars that show the main action. MainAction renders nothing in place while one is mounted on a desktop.
|
|
78
|
+
let sidebars = 0;
|
|
79
|
+
const sidebarListeners = new Set();
|
|
80
|
+
function subscribeSidebars(fn) {
|
|
81
|
+
sidebarListeners.add(fn);
|
|
82
|
+
return () => sidebarListeners.delete(fn);
|
|
83
|
+
}
|
|
84
|
+
function useSidebarHost(on) {
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (!on) return undefined;
|
|
87
|
+
sidebars += 1;
|
|
88
|
+
sidebarListeners.forEach((fn) => fn());
|
|
89
|
+
return () => {
|
|
90
|
+
sidebars -= 1;
|
|
91
|
+
sidebarListeners.forEach((fn) => fn());
|
|
92
|
+
};
|
|
93
|
+
}, [on]);
|
|
94
|
+
}
|
|
95
|
+
function useHasSidebar() {
|
|
96
|
+
return React.useSyncExternalStore(subscribeSidebars, () => sidebars > 0, () => false);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// <MainAction label="Kunde" icon={Plus} to="/customers/new" /> or onSelect={open}. testId names the button.
|
|
100
|
+
function MainAction(props) {
|
|
101
|
+
const { label, icon, to, onSelect, testId, disabled, link } = props;
|
|
102
|
+
const ref = React.useRef(props);
|
|
103
|
+
ref.current = props;
|
|
104
|
+
React.useLayoutEffect(() => {
|
|
105
|
+
const entry = {
|
|
106
|
+
action: { label, icon, to, testId, disabled: !!disabled, onSelect: onSelect ? () => ref.current.onSelect && ref.current.onSelect() : undefined },
|
|
107
|
+
};
|
|
108
|
+
mainStack = mainStack.concat([entry]);
|
|
109
|
+
emitMain();
|
|
110
|
+
return () => {
|
|
111
|
+
mainStack = mainStack.filter((e) => e !== entry);
|
|
112
|
+
emitMain();
|
|
113
|
+
};
|
|
114
|
+
}, [label, icon, to, testId, disabled, !!onSelect]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
115
|
+
const hasSidebar = useHasSidebar();
|
|
116
|
+
const desktop = useDesktop();
|
|
117
|
+
if (hasSidebar && desktop) return null;
|
|
118
|
+
const Icon = icon;
|
|
119
|
+
const content = [Icon ? h(Icon, { key: "i", className: "scalio-icon", "aria-hidden": "true" }) : null, h("span", { key: "l" }, label)];
|
|
120
|
+
const cls = "scalio-btn-primary scalio-main-action-inline";
|
|
121
|
+
if (to && link) return h(link, { to, className: cls, "data-testid": testId || "main-action" }, content);
|
|
122
|
+
if (to) return h("a", { href: to, className: cls, "data-testid": testId || "main-action" }, content);
|
|
123
|
+
return h("button", { type: "button", className: cls, disabled: !!disabled,
|
|
124
|
+
onClick: () => onSelect && onSelect(), "data-testid": testId || "main-action" }, content);
|
|
125
|
+
}
|
|
126
|
+
|
|
56
127
|
// Kept for older apps: renders nothing (no page actions in the sidebar since 0.54.0).
|
|
57
128
|
function ActionSlot() {
|
|
58
129
|
setActionSlot(null);
|
|
@@ -66,4 +137,4 @@ function PageActions({ children }) {
|
|
|
66
137
|
return h(React.Fragment, null, children);
|
|
67
138
|
}
|
|
68
139
|
|
|
69
|
-
module.exports = { PageActions, ActionSlot, useActionSlot, useDesktop, setActionSlot };
|
|
140
|
+
module.exports = { PageActions, ActionSlot, useActionSlot, useDesktop, setActionSlot, MainAction, useMainAction, useSidebarHost };
|
package/react/agents.js
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Scalio Agent in the app (scalio-docs ADR 0107, interfaces/agent-v2.md): AgentsPanel in Einstellungen -> Scalio Agent
|
|
3
|
+
// for admins. Backend: scalio-platform `agent.AgentHub.router` (GET /agent/v2/admin/agents, PATCH /agents/{id},
|
|
4
|
+
// POST /agents/{id}/block|unblock, DELETE /agents/{id}, POST /agents/{id}/workers/{worker}/{restart|stop|start},
|
|
5
|
+
// POST|GET /agent/v2/admin/codes, DELETE /codes/{id}, GET /agent/v2/admin/tasks).
|
|
6
|
+
// Shows every agent of this instance with its roles and worker states, creates one-time enrollment codes (the
|
|
7
|
+
// code is shown once) and lists the last tasks without their data.
|
|
8
|
+
const React = require("react");
|
|
9
|
+
const h = React.createElement;
|
|
10
|
+
const Icons = require("./icons");
|
|
11
|
+
const { StatusBadge } = require("./blocks");
|
|
12
|
+
const { SettingsSection, SettingsField: Field } = require("./settings");
|
|
13
|
+
const { askConfirm } = require("./dialog");
|
|
14
|
+
|
|
15
|
+
const LABELS = {
|
|
16
|
+
de: {
|
|
17
|
+
title: "Scalio Agent",
|
|
18
|
+
hint: "Der Scalio Agent läuft als Windows-Dienst in Ihrem Netz und erledigt Aufgaben, die nur dort gehen (z. B. Active Directory). Er baut nur ausgehende Verbindungen auf. Sie können ihn auf mehreren Servern installieren und pro Server die Rollen wählen.",
|
|
19
|
+
download: "Agent herunterladen (MSI)",
|
|
20
|
+
newCode: "Registrierungscode erzeugen",
|
|
21
|
+
codeRoles: "Rollen für den neuen Agent",
|
|
22
|
+
codeNote: "Notiz (z. B. Servername)",
|
|
23
|
+
codeTitle: "Registrierungscode",
|
|
24
|
+
codeOnce: "Der Code wird nur jetzt angezeigt. Er gilt 24 Stunden und nur für einen Server.",
|
|
25
|
+
codeCommand: "Stille Installation",
|
|
26
|
+
copy: "Kopieren",
|
|
27
|
+
copied: "Kopiert.",
|
|
28
|
+
close: "Schliessen",
|
|
29
|
+
openCodes: "Offene Codes",
|
|
30
|
+
codeExpires: "gültig bis {at}",
|
|
31
|
+
revoke: "Widerrufen",
|
|
32
|
+
agents: "Agents",
|
|
33
|
+
none: "Noch kein Agent registriert. Erzeugen Sie einen Code und installieren Sie den Agent auf einem Server.",
|
|
34
|
+
name: "Name",
|
|
35
|
+
host: "Server",
|
|
36
|
+
version: "Version",
|
|
37
|
+
status: "Status",
|
|
38
|
+
lastSeen: "Letzter Kontakt",
|
|
39
|
+
roles: "Rollen",
|
|
40
|
+
workers: "Worker",
|
|
41
|
+
online: "online",
|
|
42
|
+
offline: "offline",
|
|
43
|
+
blocked: "gesperrt",
|
|
44
|
+
never: "nie",
|
|
45
|
+
notOnHost: "Server kann diese Rolle nicht",
|
|
46
|
+
restart: "Neu starten",
|
|
47
|
+
stop: "Anhalten",
|
|
48
|
+
start: "Starten",
|
|
49
|
+
block: "Sperren",
|
|
50
|
+
unblock: "Entsperren",
|
|
51
|
+
remove: "Entfernen",
|
|
52
|
+
removeConfirm: "Agent «{name}» entfernen? Er bekommt keine Aufträge mehr und muss sich mit einem neuen Code registrieren.",
|
|
53
|
+
blockConfirm: "Agent «{name}» sperren? Er bekommt sofort keine Aufträge mehr.",
|
|
54
|
+
stopConfirm: "Worker «{worker}» auf «{name}» anhalten? Aufträge für diese Rolle übernimmt dann ein anderer Agent mit derselben Rolle, sonst warten sie.",
|
|
55
|
+
sent: "Auftrag an den Agent geschickt.",
|
|
56
|
+
saved: "Gespeichert.",
|
|
57
|
+
tasks: "Letzte Aufträge",
|
|
58
|
+
noTasks: "Noch keine Aufträge.",
|
|
59
|
+
task: "Aktion",
|
|
60
|
+
agent: "Agent",
|
|
61
|
+
created: "Erstellt",
|
|
62
|
+
message: "Meldung",
|
|
63
|
+
states: { starting: "startet", running: "läuft", stopped: "angehalten", crashed: "abgestürzt, startet neu", disabled: "abgeschaltet nach Abstürzen", unavailable: "nicht verfügbar" },
|
|
64
|
+
taskStates: { queued: "wartet", claimed: "läuft", finished: "fertig", error: "Fehler" },
|
|
65
|
+
restarts: "{n} Neustarts",
|
|
66
|
+
},
|
|
67
|
+
en: {
|
|
68
|
+
title: "Scalio Agent",
|
|
69
|
+
hint: "The Scalio Agent runs as a Windows service in your network and does work that is only possible there (e.g. Active Directory). It only opens outgoing connections. You can install it on several servers and choose the roles per server.",
|
|
70
|
+
download: "Download the agent (MSI)",
|
|
71
|
+
newCode: "Create enrollment code",
|
|
72
|
+
codeRoles: "Roles of the new agent",
|
|
73
|
+
codeNote: "Note (e.g. server name)",
|
|
74
|
+
codeTitle: "Enrollment code",
|
|
75
|
+
codeOnce: "The code is shown only now. It is valid for 24 hours and for one server.",
|
|
76
|
+
codeCommand: "Silent installation",
|
|
77
|
+
copy: "Copy",
|
|
78
|
+
copied: "Copied.",
|
|
79
|
+
close: "Close",
|
|
80
|
+
openCodes: "Open codes",
|
|
81
|
+
codeExpires: "valid until {at}",
|
|
82
|
+
revoke: "Revoke",
|
|
83
|
+
agents: "Agents",
|
|
84
|
+
none: "No agent enrolled yet. Create a code and install the agent on a server.",
|
|
85
|
+
name: "Name",
|
|
86
|
+
host: "Server",
|
|
87
|
+
version: "Version",
|
|
88
|
+
status: "Status",
|
|
89
|
+
lastSeen: "Last contact",
|
|
90
|
+
roles: "Roles",
|
|
91
|
+
workers: "Workers",
|
|
92
|
+
online: "online",
|
|
93
|
+
offline: "offline",
|
|
94
|
+
blocked: "blocked",
|
|
95
|
+
never: "never",
|
|
96
|
+
notOnHost: "this server cannot run the role",
|
|
97
|
+
restart: "Restart",
|
|
98
|
+
stop: "Stop",
|
|
99
|
+
start: "Start",
|
|
100
|
+
block: "Block",
|
|
101
|
+
unblock: "Unblock",
|
|
102
|
+
remove: "Remove",
|
|
103
|
+
removeConfirm: "Remove agent «{name}»? It gets no more tasks and has to enroll again with a new code.",
|
|
104
|
+
blockConfirm: "Block agent «{name}»? It gets no more tasks at once.",
|
|
105
|
+
stopConfirm: "Stop worker «{worker}» on «{name}»? Another agent with the same role takes its tasks, otherwise they wait.",
|
|
106
|
+
sent: "Sent to the agent.",
|
|
107
|
+
saved: "Saved.",
|
|
108
|
+
tasks: "Last tasks",
|
|
109
|
+
noTasks: "No tasks yet.",
|
|
110
|
+
task: "Action",
|
|
111
|
+
agent: "Agent",
|
|
112
|
+
created: "Created",
|
|
113
|
+
message: "Message",
|
|
114
|
+
states: { starting: "starting", running: "running", stopped: "stopped", crashed: "crashed, restarting", disabled: "switched off after crashes", unavailable: "not available" },
|
|
115
|
+
taskStates: { queued: "waiting", claimed: "running", finished: "done", error: "error" },
|
|
116
|
+
restarts: "{n} restarts",
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const STATE_TONE = { starting: "running", running: "ok", stopped: "neutral", crashed: "warn", disabled: "error", unavailable: "neutral" };
|
|
121
|
+
const TASK_TONE = { queued: "neutral", claimed: "running", finished: "ok", error: "error" };
|
|
122
|
+
|
|
123
|
+
function labels(lang, overrides) {
|
|
124
|
+
return Object.assign({}, LABELS[lang === "en" ? "en" : "de"], overrides || {});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function fill(text, vars) {
|
|
128
|
+
return Object.keys(vars || {}).reduce((s, k) => s.split(`{${k}}`).join(vars[k] == null ? "" : vars[k]), text);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function when(iso, lang) {
|
|
132
|
+
if (!iso) return "";
|
|
133
|
+
const d = new Date(iso);
|
|
134
|
+
if (Number.isNaN(d.getTime())) return iso;
|
|
135
|
+
return d.toLocaleString(lang === "en" ? "en-GB" : "de-CH", { dateStyle: "medium", timeStyle: "short" });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function errorText(err) {
|
|
139
|
+
const d = err && err.response && err.response.data && err.response.data.detail;
|
|
140
|
+
if (typeof d === "string") return d;
|
|
141
|
+
return (err && err.message) || String(err);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// api: axios instance with the app's base URL (/api).
|
|
145
|
+
function agentsApi(api, base) {
|
|
146
|
+
const b = base || "/agent/v2/admin";
|
|
147
|
+
return {
|
|
148
|
+
list: () => api.get(`${b}/agents`).then((r) => r.data),
|
|
149
|
+
update: (id, body) => api.patch(`${b}/agents/${id}`, body).then((r) => r.data),
|
|
150
|
+
block: (id, on) => api.post(`${b}/agents/${id}/${on ? "block" : "unblock"}`, {}).then((r) => r.data),
|
|
151
|
+
remove: (id) => api.delete(`${b}/agents/${id}`).then((r) => r.data),
|
|
152
|
+
control: (id, worker, action) => api.post(`${b}/agents/${id}/workers/${worker}/${action}`, {}).then((r) => r.data),
|
|
153
|
+
codes: () => api.get(`${b}/codes`).then((r) => r.data),
|
|
154
|
+
createCode: (body) => api.post(`${b}/codes`, body || {}).then((r) => r.data),
|
|
155
|
+
revokeCode: (id) => api.delete(`${b}/codes/${id}`).then((r) => r.data),
|
|
156
|
+
tasks: (limit) => api.get(`${b}/tasks?limit=${limit || 20}`).then((r) => r.data),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// The silent install command for a code: the app's own address is the connection URL.
|
|
161
|
+
function installCommand(url, code) {
|
|
162
|
+
return `msiexec /i ScalioAgent.msi ENROLL_URL=${url} ENROLL_CODE=${code} /qn`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function statusOf(agent) {
|
|
166
|
+
if (agent.blocked) return "blocked";
|
|
167
|
+
return agent.online ? "online" : "offline";
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Props: client (agentsApi), lang, labels, appUrl (address the agent connects to, default window.location.origin),
|
|
171
|
+
// downloadUrl (MSI), notify(message, tone), formatError(err), refreshMs (default 15000, 0 = off), copy(text).
|
|
172
|
+
function AgentsPanel(props) {
|
|
173
|
+
const L = labels(props.lang, props.labels);
|
|
174
|
+
const fmtErr = props.formatError || errorText;
|
|
175
|
+
const [data, setData] = React.useState(null);
|
|
176
|
+
const [codes, setCodes] = React.useState([]);
|
|
177
|
+
const [tasks, setTasks] = React.useState([]);
|
|
178
|
+
const [error, setError] = React.useState("");
|
|
179
|
+
const [busy, setBusy] = React.useState(false);
|
|
180
|
+
const [codeRoles, setCodeRoles] = React.useState(null);
|
|
181
|
+
const [note, setNote] = React.useState("");
|
|
182
|
+
const [shown, setShown] = React.useState(null); // {code, expires_at} right after «Code erzeugen»
|
|
183
|
+
|
|
184
|
+
const load = React.useCallback(async () => {
|
|
185
|
+
try {
|
|
186
|
+
const [d, c, t] = await Promise.all([props.client.list(), props.client.codes(), props.client.tasks(20)]);
|
|
187
|
+
setData(d);
|
|
188
|
+
setCodes(c || []);
|
|
189
|
+
setTasks(t || []);
|
|
190
|
+
setError("");
|
|
191
|
+
} catch (e) {
|
|
192
|
+
setError(fmtErr(e));
|
|
193
|
+
}
|
|
194
|
+
}, [props.client]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
195
|
+
|
|
196
|
+
React.useEffect(() => {
|
|
197
|
+
load();
|
|
198
|
+
const ms = props.refreshMs == null ? 15000 : props.refreshMs;
|
|
199
|
+
if (!ms) return undefined;
|
|
200
|
+
const t = setInterval(load, ms);
|
|
201
|
+
return () => clearInterval(t);
|
|
202
|
+
}, [load, props.refreshMs]);
|
|
203
|
+
|
|
204
|
+
const offered = (data && data.roles) || [];
|
|
205
|
+
const selectedRoles = codeRoles || offered.map((r) => r.name);
|
|
206
|
+
|
|
207
|
+
const run = async (fn, okText) => {
|
|
208
|
+
setBusy(true);
|
|
209
|
+
try {
|
|
210
|
+
const res = await fn();
|
|
211
|
+
if (okText && props.notify) props.notify(okText, "ok");
|
|
212
|
+
await load();
|
|
213
|
+
setBusy(false);
|
|
214
|
+
return res;
|
|
215
|
+
} catch (e) {
|
|
216
|
+
const t = fmtErr(e);
|
|
217
|
+
setError(t);
|
|
218
|
+
if (props.notify) props.notify(t, "error");
|
|
219
|
+
setBusy(false);
|
|
220
|
+
return null;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const createCode = async () => {
|
|
225
|
+
const res = await run(() => props.client.createCode({ roles: selectedRoles, note }));
|
|
226
|
+
if (res && res.code) { setShown(res); setNote(""); }
|
|
227
|
+
};
|
|
228
|
+
const copy = (text) => {
|
|
229
|
+
try {
|
|
230
|
+
if (props.copy) props.copy(text);
|
|
231
|
+
else if (typeof navigator !== "undefined" && navigator.clipboard) navigator.clipboard.writeText(text);
|
|
232
|
+
if (props.notify) props.notify(L.copied, "ok");
|
|
233
|
+
} catch (e) { /* clipboard blocked */ }
|
|
234
|
+
};
|
|
235
|
+
const confirmThen = async (text, confirmLabel, fn, okText) => {
|
|
236
|
+
if (!(await askConfirm({ title: L.title, text, confirmLabel, lang: props.lang, danger: true }))) return;
|
|
237
|
+
await run(fn, okText);
|
|
238
|
+
};
|
|
239
|
+
const appUrl = props.appUrl || (typeof window !== "undefined" ? window.location.origin : "");
|
|
240
|
+
|
|
241
|
+
const rows = [];
|
|
242
|
+
rows.push(h("div", { key: "acts", className: "scalio-settings-section-footer", style: { justifyContent: "flex-start", flexWrap: "wrap", gap: "0.5rem" } },
|
|
243
|
+
props.downloadUrl ? h("a", { className: "scalio-btn", href: props.downloadUrl, "data-testid": "agents-download" },
|
|
244
|
+
h(Icons.Download, { className: "scalio-icon" }), L.download) : null));
|
|
245
|
+
|
|
246
|
+
// new code
|
|
247
|
+
rows.push(h(Field, { key: "code", label: L.newCode, testId: "agents-new-code" },
|
|
248
|
+
offered.length > 1 ? h("div", { style: { display: "flex", flexWrap: "wrap", gap: "0.75rem" } },
|
|
249
|
+
h("span", { className: "scalio-settings-text" }, `${L.codeRoles}:`),
|
|
250
|
+
offered.map((r) => h("label", { key: r.name, className: "scalio-settings-check" },
|
|
251
|
+
h("input", { type: "checkbox", checked: selectedRoles.includes(r.name), disabled: busy, "data-testid": `agents-code-role-${r.name}`,
|
|
252
|
+
onChange: () => setCodeRoles(selectedRoles.includes(r.name) ? selectedRoles.filter((x) => x !== r.name) : selectedRoles.concat([r.name])) }),
|
|
253
|
+
h("span", null, r.label || r.name)))) : null,
|
|
254
|
+
h("div", { style: { display: "flex", gap: "0.5rem", marginTop: "0.5rem", flexWrap: "wrap" } },
|
|
255
|
+
h("input", { className: "scalio-input", placeholder: L.codeNote, "aria-label": L.codeNote, value: note, maxLength: 200, disabled: busy,
|
|
256
|
+
"data-testid": "agents-code-note", onChange: (e) => setNote(e.target.value) }),
|
|
257
|
+
h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy, "data-testid": "agents-code-create", onClick: createCode },
|
|
258
|
+
h(Icons.KeyRound, { className: "scalio-icon" }), L.newCode))));
|
|
259
|
+
|
|
260
|
+
if (shown) {
|
|
261
|
+
const cmd = installCommand(appUrl, shown.code);
|
|
262
|
+
rows.push(h("div", { key: "shown", className: "scalio-notice is-info", role: "status", "data-testid": "agents-code-shown" },
|
|
263
|
+
h("div", { className: "scalio-notice-body" },
|
|
264
|
+
h("div", { className: "scalio-notice-title" }, L.codeTitle),
|
|
265
|
+
h("div", { className: "scalio-notice-text" },
|
|
266
|
+
h("code", { "data-testid": "agents-code-value", style: { fontSize: "1.1em" } }, shown.code), " ",
|
|
267
|
+
h("button", { type: "button", className: "scalio-btn is-ghost", "data-testid": "agents-code-copy", onClick: () => copy(shown.code) },
|
|
268
|
+
h(Icons.Copy, { className: "scalio-icon" }), L.copy),
|
|
269
|
+
h("div", null, L.codeOnce),
|
|
270
|
+
h("div", { style: { marginTop: "0.5rem" } }, `${L.codeCommand}:`),
|
|
271
|
+
h("pre", { style: { whiteSpace: "pre-wrap", wordBreak: "break-all" }, "data-testid": "agents-code-command" }, cmd),
|
|
272
|
+
h("button", { type: "button", className: "scalio-btn is-ghost", "data-testid": "agents-code-command-copy", onClick: () => copy(cmd) },
|
|
273
|
+
h(Icons.Copy, { className: "scalio-icon" }), L.copy),
|
|
274
|
+
h("button", { type: "button", className: "scalio-btn", "data-testid": "agents-code-close", onClick: () => setShown(null) }, L.close)))));
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (codes.length) {
|
|
278
|
+
rows.push(h(Field, { key: "codes", label: L.openCodes },
|
|
279
|
+
h("ul", { className: "scalio-settings-text", "data-testid": "agents-codes" },
|
|
280
|
+
codes.map((c) => h("li", { key: c.id, "data-testid": `agents-code-${c.id}` },
|
|
281
|
+
[c.note, (c.roles || []).join(", "), fill(L.codeExpires, { at: when(c.expires_at, props.lang) })].filter(Boolean).join(" · "), " ",
|
|
282
|
+
h("button", { type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agents-code-revoke-${c.id}`,
|
|
283
|
+
onClick: () => run(() => props.client.revokeCode(c.id)) }, L.revoke))))));
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// agents
|
|
287
|
+
const agents = (data && data.agents) || [];
|
|
288
|
+
const roleLabel = (name) => (offered.find((r) => r.name === name) || {}).label || name;
|
|
289
|
+
const setRoles = (a, roles) => run(() => props.client.update(a.id, { roles }), L.saved);
|
|
290
|
+
const agentRow = (a) => {
|
|
291
|
+
const st = statusOf(a);
|
|
292
|
+
const can = new Set(((a.capabilities || {}).workers) || []);
|
|
293
|
+
const states = {};
|
|
294
|
+
(a.workers || []).forEach((w) => { states[w.name] = w; });
|
|
295
|
+
return h("tr", { key: a.id, "data-testid": `agent-${a.id}` },
|
|
296
|
+
h("td", null, h("div", { className: "font-medium" }, a.name || a.hostname), a.domain ? h("div", { className: "scalio-settings-text" }, a.domain) : null),
|
|
297
|
+
h("td", null, a.hostname || "", a.os ? h("div", { className: "scalio-settings-text" }, a.os) : null),
|
|
298
|
+
h("td", null, a.version || "–"),
|
|
299
|
+
h("td", null, h(StatusBadge, { tone: st === "online" ? "ok" : st === "blocked" ? "error" : "warn", testId: `agent-status-${a.id}` }, L[st]),
|
|
300
|
+
h("div", { className: "scalio-settings-text" }, a.last_seen ? when(a.last_seen, props.lang) : L.never)),
|
|
301
|
+
h("td", null, offered.map((r) => h("label", { key: r.name, className: "scalio-settings-check", title: can.has(r.name) ? "" : L.notOnHost },
|
|
302
|
+
h("input", { type: "checkbox", checked: (a.roles || []).includes(r.name), disabled: busy || a.blocked, "data-testid": `agent-role-${a.id}-${r.name}`,
|
|
303
|
+
onChange: () => setRoles(a, (a.roles || []).includes(r.name) ? a.roles.filter((x) => x !== r.name) : (a.roles || []).concat([r.name])) }),
|
|
304
|
+
h("span", null, r.label || r.name, can.has(r.name) ? "" : " ⚠")))),
|
|
305
|
+
h("td", null, (a.roles || []).map((name) => {
|
|
306
|
+
const w = states[name] || { name, state: can.has(name) ? "starting" : "unavailable" };
|
|
307
|
+
const stopped = w.state === "stopped" || w.state === "disabled";
|
|
308
|
+
return h("div", { key: name, style: { display: "flex", alignItems: "center", gap: "0.35rem", flexWrap: "wrap", marginBottom: "0.25rem" }, "data-testid": `agent-worker-${a.id}-${name}` },
|
|
309
|
+
h("span", null, roleLabel(name)),
|
|
310
|
+
h(StatusBadge, { tone: STATE_TONE[w.state] || "neutral", testId: `agent-worker-state-${a.id}-${name}` }, (L.states || {})[w.state] || w.state),
|
|
311
|
+
w.restarts ? h("span", { className: "scalio-settings-text" }, fill(L.restarts, { n: w.restarts })) : null,
|
|
312
|
+
w.last_error ? h("span", { className: "scalio-settings-text", title: w.last_error }, h(Icons.Alert, { className: "scalio-icon" })) : null,
|
|
313
|
+
a.online && can.has(name) ? [
|
|
314
|
+
h("button", { key: "r", type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agent-worker-restart-${a.id}-${name}`,
|
|
315
|
+
onClick: () => run(() => props.client.control(a.id, name, "restart"), L.sent) }, h(Icons.RotateCcw, { className: "scalio-icon" }), L.restart),
|
|
316
|
+
stopped
|
|
317
|
+
? h("button", { key: "s", type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agent-worker-start-${a.id}-${name}`,
|
|
318
|
+
onClick: () => run(() => props.client.control(a.id, name, "start"), L.sent) }, L.start)
|
|
319
|
+
: h("button", { key: "s", type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agent-worker-stop-${a.id}-${name}`,
|
|
320
|
+
onClick: () => confirmThen(fill(L.stopConfirm, { worker: roleLabel(name), name: a.name }), L.stop, () => props.client.control(a.id, name, "stop"), L.sent) }, L.stop),
|
|
321
|
+
] : null);
|
|
322
|
+
})),
|
|
323
|
+
h("td", null,
|
|
324
|
+
h("button", { type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agent-block-${a.id}`,
|
|
325
|
+
onClick: () => a.blocked
|
|
326
|
+
? run(() => props.client.block(a.id, false), L.saved)
|
|
327
|
+
: confirmThen(fill(L.blockConfirm, { name: a.name }), L.block, () => props.client.block(a.id, true), L.saved) }, a.blocked ? L.unblock : L.block),
|
|
328
|
+
h("button", { type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agent-remove-${a.id}`,
|
|
329
|
+
onClick: () => confirmThen(fill(L.removeConfirm, { name: a.name }), L.remove, () => props.client.remove(a.id), L.saved) },
|
|
330
|
+
h(Icons.Trash, { className: "scalio-icon" }), L.remove)));
|
|
331
|
+
};
|
|
332
|
+
rows.push(h(Field, { key: "agents", label: L.agents },
|
|
333
|
+
!data ? null : agents.length === 0
|
|
334
|
+
? h("p", { className: "scalio-settings-text", "data-testid": "agents-none" }, L.none)
|
|
335
|
+
: h("div", { style: { overflowX: "auto" } },
|
|
336
|
+
h("table", { className: "scalio-users-table", "data-testid": "agents-table" },
|
|
337
|
+
h("thead", null, h("tr", null, [L.name, L.host, L.version, L.status, L.roles, L.workers, ""].map((t, i) => h("th", { key: i }, t)))),
|
|
338
|
+
h("tbody", null, agents.map(agentRow))))));
|
|
339
|
+
|
|
340
|
+
// tasks
|
|
341
|
+
const nameOf = (id) => (agents.find((a) => a.id === id) || {}).name || "";
|
|
342
|
+
rows.push(h(Field, { key: "tasks", label: L.tasks },
|
|
343
|
+
tasks.length === 0 ? h("p", { className: "scalio-settings-text", "data-testid": "agents-no-tasks" }, L.noTasks)
|
|
344
|
+
: h("div", { style: { overflowX: "auto" } },
|
|
345
|
+
h("table", { className: "scalio-users-table", "data-testid": "agents-tasks" },
|
|
346
|
+
h("thead", null, h("tr", null, [L.task, L.agent, L.status, L.created, L.message].map((t, i) => h("th", { key: i }, t)))),
|
|
347
|
+
h("tbody", null, tasks.map((t) => h("tr", { key: t.id, "data-testid": `agents-task-${t.id}` },
|
|
348
|
+
h("td", null, `${t.worker ? `${t.worker} · ` : ""}${t.action || ""}`),
|
|
349
|
+
h("td", null, nameOf(t.agent_id)),
|
|
350
|
+
h("td", null, h(StatusBadge, { tone: TASK_TONE[t.status] || "neutral" }, (L.taskStates || {})[t.status] || t.status || "")),
|
|
351
|
+
h("td", null, when(t.created_at, props.lang)),
|
|
352
|
+
h("td", null, t.message || ""))))))));
|
|
353
|
+
|
|
354
|
+
if (error) rows.push(h("div", { key: "err", className: "scalio-notice is-error", role: "alert", "data-testid": "agents-error" }, error));
|
|
355
|
+
return h(SettingsSection, { id: "agent", title: L.title, description: L.hint, testId: "agents-panel" }, rows);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
module.exports = { AgentsPanel, agentsApi, agentInstallCommand: installCommand, AGENT_LABELS: LABELS };
|
package/react/index.js
CHANGED
|
@@ -378,6 +378,6 @@ module.exports = {
|
|
|
378
378
|
TEST_IDS,
|
|
379
379
|
initials,
|
|
380
380
|
};
|
|
381
|
-
Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"));
|
|
381
|
+
Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"));
|
|
382
382
|
// After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
|
|
383
383
|
Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
|
package/react/nav.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const h = React.createElement;
|
|
7
7
|
const Icons = require("./icons");
|
|
8
|
+
const { useMainAction, useSidebarHost } = require("./actions");
|
|
8
9
|
const { labelsFor } = require("./labels");
|
|
9
10
|
|
|
10
11
|
function cx() {
|
|
@@ -71,6 +72,7 @@ function PrimaryAction({ action, link, onNavigate, testIdPrefix }) {
|
|
|
71
72
|
type: "button",
|
|
72
73
|
className: "scalio-nav-cta",
|
|
73
74
|
"data-testid": testId,
|
|
75
|
+
disabled: action.disabled || undefined,
|
|
74
76
|
onClick: () => {
|
|
75
77
|
if (onNavigate) onNavigate();
|
|
76
78
|
if (action.onSelect) action.onSelect();
|
|
@@ -101,8 +103,9 @@ function SearchButton({ search, lang, labels, testIdPrefix, onNavigate }) {
|
|
|
101
103
|
|
|
102
104
|
// Sidebar. variant "desktop" shows from 768px, "drawer" is the same content inside NavDrawer.
|
|
103
105
|
// link: the router's NavLink (gets to, end, className(fn), onClick); without it plain <a> + activePath.
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
+
// One button in the sidebar, above Übersicht: the main action of the current page (<MainAction>, react/actions.js),
|
|
107
|
+
// else primaryAction, the main action of the start page (Markus 2026-11-10). No buttons below Übersicht.
|
|
108
|
+
// pageActions is still accepted for older apps but does nothing: further page actions stay in the page header.
|
|
106
109
|
function Sidebar(props) {
|
|
107
110
|
const {
|
|
108
111
|
nav, link, activePath, top, search, primaryAction, footer, version, commit, lang, labels,
|
|
@@ -112,6 +115,8 @@ function Sidebar(props) {
|
|
|
112
115
|
const L = labelsFor(lang, labels);
|
|
113
116
|
const sections = visibleSections(nav);
|
|
114
117
|
const rest = sections;
|
|
118
|
+
const pageMain = useMainAction();
|
|
119
|
+
useSidebarHost(variant !== "drawer");
|
|
115
120
|
const section = (sec, i) =>
|
|
116
121
|
h(
|
|
117
122
|
"div",
|
|
@@ -128,7 +133,7 @@ function Sidebar(props) {
|
|
|
128
133
|
},
|
|
129
134
|
top ? h("div", { className: "scalio-sidebar-top" }, top) : null,
|
|
130
135
|
h(SearchButton, { search, lang, labels, testIdPrefix: prefix, onNavigate }),
|
|
131
|
-
h(PrimaryAction, { action: primaryAction, link, onNavigate, testIdPrefix: prefix }),
|
|
136
|
+
h(PrimaryAction, { action: pageMain || primaryAction, link, onNavigate, testIdPrefix: prefix }),
|
|
132
137
|
h("div", { className: "scalio-sidebar-scroll" }, rest.map(section)),
|
|
133
138
|
footer || version
|
|
134
139
|
? h(
|
package/react/roles.js
CHANGED
|
@@ -9,6 +9,7 @@ const React = require("react");
|
|
|
9
9
|
const { askConfirm } = require("./dialog");
|
|
10
10
|
const h = React.createElement;
|
|
11
11
|
const Icons = require("./icons");
|
|
12
|
+
const { MainAction } = require("./actions");
|
|
12
13
|
|
|
13
14
|
const TEXT = {
|
|
14
15
|
de: {
|
|
@@ -370,8 +371,7 @@ function RoleAdmin(props) {
|
|
|
370
371
|
return h("div", { className: "scalio-users scalio-roles", "data-testid": props.testId || "role-admin" },
|
|
371
372
|
h("div", { className: "scalio-users-bar" },
|
|
372
373
|
h("p", { className: "scalio-users-hint" }, own.length ? L.readOnly : L.empty),
|
|
373
|
-
canEdit ? h(
|
|
374
|
-
h(Icons.Plus, { className: "scalio-icon" }), L.add) : null),
|
|
374
|
+
canEdit ? h(MainAction, { label: L.add, icon: Icons.Plus, onSelect: () => openAdd(null), disabled: busy, testId: "role-add" }) : null),
|
|
375
375
|
h("div", { className: "scalio-users-table-wrap" },
|
|
376
376
|
h("table", { className: "scalio-users-table scalio-roles-table", "data-testid": "roles-table" },
|
|
377
377
|
h("thead", null, head), h("tbody", null, body))),
|
package/react/users.js
CHANGED
|
@@ -8,6 +8,7 @@ const React = require("react");
|
|
|
8
8
|
const { askConfirm } = require("./dialog");
|
|
9
9
|
const h = React.createElement;
|
|
10
10
|
const Icons = require("./icons");
|
|
11
|
+
const { MainAction } = require("./actions");
|
|
11
12
|
const { labelsFor } = require("./labels");
|
|
12
13
|
|
|
13
14
|
function cx() {
|
|
@@ -270,8 +271,8 @@ function UserAdmin(props) {
|
|
|
270
271
|
{ className: "scalio-users-bar" },
|
|
271
272
|
h("input", { className: "scalio-input scalio-users-search", type: "search", value: query, placeholder: L.search, "aria-label": L.search,
|
|
272
273
|
onChange: (e) => setQuery(e.target.value), "data-testid": "users-search" }),
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
// Main action of the page: the blue button above Übersicht (inline on phones or without a sidebar).
|
|
275
|
+
h(MainAction, { label: L.add, icon: Icons.Plus, onSelect: openCreate, testId: "user-add" })
|
|
275
276
|
);
|
|
276
277
|
|
|
277
278
|
const table = shown.length
|