@scalio-cloud/ui 0.55.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 +21 -0
- package/package.json +1 -1
- package/react/agents.js +358 -0
- package/react/index.js +1 -1
package/README.md
CHANGED
|
@@ -552,6 +552,27 @@ const updates = saasUpdatesApi(api); // once, outside the component
|
|
|
552
552
|
The banner is blue (orange for a security update); people without admin role only see when the update is planned.
|
|
553
553
|
«Später» hides it for this version until the next browser session.
|
|
554
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
|
+
|
|
555
576
|
## Benachrichtigungen: E-Mail-Versand und E-Mail-Vorlagen (React)
|
|
556
577
|
|
|
557
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/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/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"));
|