@juice-js/observability 1.1.0-alpha.27 → 1.1.0-alpha.29

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.
Files changed (51) hide show
  1. package/fesm2022/juice-js-observability-agent.page-D6nP3YbF.mjs +1056 -0
  2. package/fesm2022/juice-js-observability-agent.page-D6nP3YbF.mjs.map +1 -0
  3. package/fesm2022/juice-js-observability-agents.page-C9WjP1nl.mjs +413 -0
  4. package/fesm2022/juice-js-observability-agents.page-C9WjP1nl.mjs.map +1 -0
  5. package/fesm2022/{juice-js-observability-alert.page-DOAX9WWa.mjs → juice-js-observability-alert.page-79qA1Wqg.mjs} +2 -2
  6. package/fesm2022/{juice-js-observability-alert.page-DOAX9WWa.mjs.map → juice-js-observability-alert.page-79qA1Wqg.mjs.map} +1 -1
  7. package/fesm2022/{juice-js-observability-alerts.page-DUXXBanH.mjs → juice-js-observability-alerts.page-DVqDxYSq.mjs} +2 -2
  8. package/fesm2022/{juice-js-observability-alerts.page-DUXXBanH.mjs.map → juice-js-observability-alerts.page-DVqDxYSq.mjs.map} +1 -1
  9. package/fesm2022/juice-js-observability-approvals.page-DXi3O9Ol.mjs +383 -0
  10. package/fesm2022/juice-js-observability-approvals.page-DXi3O9Ol.mjs.map +1 -0
  11. package/fesm2022/{juice-js-observability-incident.page-CCHEWXou.mjs → juice-js-observability-incident.page-CayeZdF_.mjs} +2 -2
  12. package/fesm2022/{juice-js-observability-incident.page-CCHEWXou.mjs.map → juice-js-observability-incident.page-CayeZdF_.mjs.map} +1 -1
  13. package/fesm2022/{juice-js-observability-incidents.page-CpNqYp2W.mjs → juice-js-observability-incidents.page-Bx7afoIh.mjs} +2 -2
  14. package/fesm2022/{juice-js-observability-incidents.page-CpNqYp2W.mjs.map → juice-js-observability-incidents.page-Bx7afoIh.mjs.map} +1 -1
  15. package/fesm2022/{juice-js-observability-load-runs.page-C2rk2bz9.mjs → juice-js-observability-load-runs.page-ByWrvCra.mjs} +2 -2
  16. package/fesm2022/{juice-js-observability-load-runs.page-C2rk2bz9.mjs.map → juice-js-observability-load-runs.page-ByWrvCra.mjs.map} +1 -1
  17. package/fesm2022/{juice-js-observability-logs.page-i76xbJLH.mjs → juice-js-observability-logs.page-DMRfXnA-.mjs} +2 -2
  18. package/fesm2022/{juice-js-observability-logs.page-i76xbJLH.mjs.map → juice-js-observability-logs.page-DMRfXnA-.mjs.map} +1 -1
  19. package/fesm2022/{juice-js-observability-metrics.page-Cq5S0yGJ.mjs → juice-js-observability-metrics.page-D3xK5mgs.mjs} +2 -2
  20. package/fesm2022/{juice-js-observability-metrics.page-Cq5S0yGJ.mjs.map → juice-js-observability-metrics.page-D3xK5mgs.mjs.map} +1 -1
  21. package/fesm2022/{juice-js-observability-notifications.page-DVYN60Me.mjs → juice-js-observability-notifications.page-BvUjV46Y.mjs} +2 -2
  22. package/fesm2022/{juice-js-observability-notifications.page-DVYN60Me.mjs.map → juice-js-observability-notifications.page-BvUjV46Y.mjs.map} +1 -1
  23. package/fesm2022/{juice-js-observability-overview.page-DXZl_fUh.mjs → juice-js-observability-overview.page-56xVtAo2.mjs} +2 -2
  24. package/fesm2022/{juice-js-observability-overview.page-DXZl_fUh.mjs.map → juice-js-observability-overview.page-56xVtAo2.mjs.map} +1 -1
  25. package/fesm2022/{juice-js-observability-resource.page-CauDE6kK.mjs → juice-js-observability-resource.page-CRSA-zpR.mjs} +2 -2
  26. package/fesm2022/{juice-js-observability-resource.page-CauDE6kK.mjs.map → juice-js-observability-resource.page-CRSA-zpR.mjs.map} +1 -1
  27. package/fesm2022/{juice-js-observability-resources.page-CukW8vVc.mjs → juice-js-observability-resources.page-BW7W5Wy2.mjs} +2 -2
  28. package/fesm2022/{juice-js-observability-resources.page-CukW8vVc.mjs.map → juice-js-observability-resources.page-BW7W5Wy2.mjs.map} +1 -1
  29. package/fesm2022/{juice-js-observability-rules.page-Df2uDVwz.mjs → juice-js-observability-rules.page-uKeK44Iz.mjs} +2 -2
  30. package/fesm2022/{juice-js-observability-rules.page-Df2uDVwz.mjs.map → juice-js-observability-rules.page-uKeK44Iz.mjs.map} +1 -1
  31. package/fesm2022/{juice-js-observability-service.page-BFXUe4mX.mjs → juice-js-observability-service.page-D7-Wbc5P.mjs} +2 -2
  32. package/fesm2022/{juice-js-observability-service.page-BFXUe4mX.mjs.map → juice-js-observability-service.page-D7-Wbc5P.mjs.map} +1 -1
  33. package/fesm2022/{juice-js-observability-services.page-B1huLe_a.mjs → juice-js-observability-services.page-CNarlAgr.mjs} +2 -2
  34. package/fesm2022/{juice-js-observability-services.page-B1huLe_a.mjs.map → juice-js-observability-services.page-CNarlAgr.mjs.map} +1 -1
  35. package/fesm2022/{juice-js-observability-silences.page-Cg53dJAy.mjs → juice-js-observability-silences.page-DBBZBZ0a.mjs} +2 -2
  36. package/fesm2022/{juice-js-observability-silences.page-Cg53dJAy.mjs.map → juice-js-observability-silences.page-DBBZBZ0a.mjs.map} +1 -1
  37. package/fesm2022/{juice-js-observability-telemetry-BftWSOaQ.mjs → juice-js-observability-telemetry-B98lekF2.mjs} +100 -90
  38. package/fesm2022/juice-js-observability-telemetry-B98lekF2.mjs.map +1 -0
  39. package/fesm2022/{juice-js-observability-timeline.page-CtU2EoDN.mjs → juice-js-observability-timeline.page-DhU78o_M.mjs} +2 -2
  40. package/fesm2022/{juice-js-observability-timeline.page-CtU2EoDN.mjs.map → juice-js-observability-timeline.page-DhU78o_M.mjs.map} +1 -1
  41. package/fesm2022/{juice-js-observability-topology.page-CUayiRVT.mjs → juice-js-observability-topology.page-CVdoBph4.mjs} +2 -2
  42. package/fesm2022/{juice-js-observability-topology.page-CUayiRVT.mjs.map → juice-js-observability-topology.page-CVdoBph4.mjs.map} +1 -1
  43. package/fesm2022/{juice-js-observability-trace.page-ByxGFLpE.mjs → juice-js-observability-trace.page-C-icZvAo.mjs} +2 -2
  44. package/fesm2022/{juice-js-observability-trace.page-ByxGFLpE.mjs.map → juice-js-observability-trace.page-C-icZvAo.mjs.map} +1 -1
  45. package/fesm2022/{juice-js-observability-traces.page-DXSDdeTH.mjs → juice-js-observability-traces.page-c8CoI2AY.mjs} +2 -2
  46. package/fesm2022/{juice-js-observability-traces.page-DXSDdeTH.mjs.map → juice-js-observability-traces.page-c8CoI2AY.mjs.map} +1 -1
  47. package/fesm2022/juice-js-observability.mjs +99 -22
  48. package/fesm2022/juice-js-observability.mjs.map +1 -1
  49. package/package.json +1 -1
  50. package/types/juice-js-observability.d.ts +119 -0
  51. package/fesm2022/juice-js-observability-telemetry-BftWSOaQ.mjs.map +0 -1
@@ -0,0 +1,1056 @@
1
+ import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
2
+ import { b as copyText, c as ContextBar, g as AgoPipe, h as apiResource, o as problemText, y as ReasonPipe } from "./juice-js-observability-telemetry-B98lekF2.mjs";
3
+ import * as i0 from "@angular/core";
4
+ import { ChangeDetectionStrategy, Component, computed, effect, inject, input, signal, untracked } from "@angular/core";
5
+ import { RouterLink } from "@angular/router";
6
+ import { DatePipe } from "@angular/common";
7
+ import * as i1 from "@angular/forms";
8
+ import { FormsModule } from "@angular/forms";
9
+ import * as i2 from "@angular/material/button";
10
+ import { MatButtonModule } from "@angular/material/button";
11
+ import { MatFormFieldModule } from "@angular/material/form-field";
12
+ import * as i5 from "@angular/material/input";
13
+ import { MatInputModule } from "@angular/material/input";
14
+ import * as i6 from "@angular/material/progress-bar";
15
+ import { MatProgressBarModule } from "@angular/material/progress-bar";
16
+ import * as i4 from "@angular/material/select";
17
+ import { MatSelectModule } from "@angular/material/select";
18
+ import * as i3 from "@angular/material/checkbox";
19
+ import { MatCheckboxModule } from "@angular/material/checkbox";
20
+ const WAITING = ["Pending", "Delivered"];
21
+ const LABELS = {
22
+ "host.summary": "Host summary",
23
+ "disk.usage": "Disk usage",
24
+ "tcp.reachability": "TCP reachability",
25
+ "agent.update": "Update the agent"
26
+ };
27
+ const PARAMETER_LABELS = {
28
+ pathPrefix: "Only under this path",
29
+ host: "Host",
30
+ port: "Port",
31
+ timeoutMs: "Wait (ms)"
32
+ };
33
+ function formatBytes(bytes) {
34
+ if (bytes === null || bytes === void 0) return "—";
35
+ const units = [
36
+ "B",
37
+ "KB",
38
+ "MB",
39
+ "GB",
40
+ "TB",
41
+ "PB"
42
+ ];
43
+ let value = bytes;
44
+ let unit = 0;
45
+ while (value >= 1024 && unit < units.length - 1) {
46
+ value /= 1024;
47
+ unit++;
48
+ }
49
+ return `${value < 10 && unit > 0 ? value.toFixed(1) : Math.round(value)} ${units[unit]}`;
50
+ }
51
+ function formatUptime(seconds) {
52
+ const days = Math.floor(seconds / 86400);
53
+ const hours = Math.floor(seconds % 86400 / 3600);
54
+ return days > 0 ? `${days} d ${hours} h` : hours > 0 ? `${hours} h ${Math.floor(seconds % 3600 / 60)} min` : `${Math.floor(seconds / 60)} min`;
55
+ }
56
+ var AgentPage = class AgentPage {
57
+ ctx = inject(ContextService);
58
+ api = inject(ApiService);
59
+ id = input.required(...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
60
+ action = signal("host.summary", ...ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []);
61
+ values = signal({}, ...ngDevMode ? [{ debugName: "values" }] : /* istanbul ignore next */ []);
62
+ issuing = signal(false, ...ngDevMode ? [{ debugName: "issuing" }] : /* istanbul ignore next */ []);
63
+ issueError = signal("", ...ngDevMode ? [{ debugName: "issueError" }] : /* istanbul ignore next */ []);
64
+ confirming = signal(false, ...ngDevMode ? [{ debugName: "confirming" }] : /* istanbul ignore next */ []);
65
+ revoking = signal(false, ...ngDevMode ? [{ debugName: "revoking" }] : /* istanbul ignore next */ []);
66
+ revokeError = signal("", ...ngDevMode ? [{ debugName: "revokeError" }] : /* istanbul ignore next */ []);
67
+ version = "";
68
+ reason = "";
69
+ requestReason = "";
70
+ issued = signal("", ...ngDevMode ? [{ debugName: "issued" }] : /* istanbul ignore next */ []);
71
+ needsApproval = computed(() => (this.selected()?.approval ?? "None") !== "None", ...ngDevMode ? [{ debugName: "needsApproval" }] : /* istanbul ignore next */ []);
72
+ requests = apiResource({
73
+ params: () => this.id(),
74
+ stream: ({ params }) => this.api.actionRequests({
75
+ agentId: params,
76
+ limit: 20
77
+ })
78
+ });
79
+ requestList = computed(() => this.requests.value()?.items ?? [], ...ngDevMode ? [{ debugName: "requestList" }] : /* istanbul ignore next */ []);
80
+ creating = signal(false, ...ngDevMode ? [{ debugName: "creating" }] : /* istanbul ignore next */ []);
81
+ reenrollError = signal("", ...ngDevMode ? [{ debugName: "reenrollError" }] : /* istanbul ignore next */ []);
82
+ token = signal(null, ...ngDevMode ? [{ debugName: "token" }] : /* istanbul ignore next */ []);
83
+ copied = signal("", ...ngDevMode ? [{ debugName: "copied" }] : /* istanbul ignore next */ []);
84
+ everyone = apiResource({
85
+ params: () => this.agent.value()?.status === "Revoked" || void 0,
86
+ stream: () => this.api.agents(true)
87
+ });
88
+ successor = computed(() => {
89
+ const revoked = this.agent.value();
90
+ if (!revoked?.revokedAt) return void 0;
91
+ return (this.everyone.value()?.items ?? []).find((a) => a.status === "Active" && a.hostname === revoked.hostname && Date.parse(a.enrolledAt) > Date.parse(revoked.revokedAt));
92
+ }, ...ngDevMode ? [{ debugName: "successor" }] : /* istanbul ignore next */ []);
93
+ actions = apiResource({
94
+ params: () => this.id(),
95
+ stream: ({ params }) => this.api.agentActions(params)
96
+ });
97
+ actionList = computed(() => this.actions.value()?.items ?? [], ...ngDevMode ? [{ debugName: "actionList" }] : /* istanbul ignore next */ []);
98
+ selected = computed(() => this.actionList().find((a) => a.name === this.action()), ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
99
+ agent = apiResource({
100
+ params: () => this.id(),
101
+ stream: ({ params }) => this.api.agent(params)
102
+ });
103
+ error = computed(() => problemText(this.agent.error()), ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
104
+ commands = apiResource({
105
+ params: () => this.id(),
106
+ stream: ({ params }) => this.api.agentCommands(params)
107
+ });
108
+ commandsError = computed(() => problemText(this.commands.error()), ...ngDevMode ? [{ debugName: "commandsError" }] : /* istanbul ignore next */ []);
109
+ packages = apiResource({
110
+ params: () => this.action() === "agent.update" || void 0,
111
+ stream: () => this.api.agentPackages()
112
+ });
113
+ older = signal(null, ...ngDevMode ? [{ debugName: "older" }] : /* istanbul ignore next */ []);
114
+ allCommands = computed(() => {
115
+ const first = this.commands.value()?.items ?? [];
116
+ const seen = new Set(first.map((c) => c.id));
117
+ return [...first, ...(this.older()?.items ?? []).filter((c) => !seen.has(c.id))];
118
+ }, ...ngDevMode ? [{ debugName: "allCommands" }] : /* istanbul ignore next */ []);
119
+ nextCursor = computed(() => this.older() ? this.older().cursor : this.commands.value()?.nextCursor ?? null, ...ngDevMode ? [{ debugName: "nextCursor" }] : /* istanbul ignore next */ []);
120
+ constructor() {
121
+ effect(() => {
122
+ const list = this.actionList();
123
+ if (list.length === 0) return;
124
+ const current = list.find((a) => a.name === untracked(this.action));
125
+ if (!current || current.permitted === false) this.choose((list.find((a) => a.permitted !== false) ?? list[0]).name);
126
+ else if (Object.keys(untracked(this.values)).length === 0) this.choose(current.name);
127
+ });
128
+ effect((onCleanup) => {
129
+ const running = this.allCommands().some((c) => this.waiting(c));
130
+ const deciding = this.requestList().some((r) => r.state === "Pending");
131
+ if (!running && !deciding) return;
132
+ const timer = setTimeout(() => {
133
+ this.commands.reload();
134
+ this.agent.reload();
135
+ this.requests.reload();
136
+ }, running ? 2e3 : 5e3);
137
+ onCleanup(() => clearTimeout(timer));
138
+ });
139
+ }
140
+ waiting(c) {
141
+ return WAITING.includes(c.state) && new Date(c.expiresAt).getTime() > Date.now();
142
+ }
143
+ describe(c) {
144
+ const p = c.parameters ?? {};
145
+ switch (c.action) {
146
+ case "disk.usage": return p["pathPrefix"] ? `under ${p["pathPrefix"]}` : "all filesystems";
147
+ case "tcp.reachability": return `${p["host"]}:${p["port"]}, wait ${p["timeoutMs"]} ms`;
148
+ case "agent.update": return `to ${p["version"]}`;
149
+ default: return Object.entries(p).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(", ");
150
+ }
151
+ }
152
+ label(name) {
153
+ return LABELS[name] ?? name;
154
+ }
155
+ title(p) {
156
+ const words = PARAMETER_LABELS[p.name] ?? p.name.replace(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase());
157
+ return p.required || p.type === "boolean" ? words : `${words} (optional)`;
158
+ }
159
+ choose(name) {
160
+ this.action.set(name);
161
+ this.issueError.set("");
162
+ const defaults = {};
163
+ for (const p of this.actionList().find((a) => a.name === name)?.parameters ?? []) if (p.default !== null) defaults[p.name] = p.type === "integer" ? Number(p.default) : p.type === "boolean" ? p.default === "true" : p.default;
164
+ else if (p.required && p.allowed?.length === 1) defaults[p.name] = p.allowed[0];
165
+ this.values.set(defaults);
166
+ }
167
+ set(name, value) {
168
+ this.values.update((v) => ({
169
+ ...v,
170
+ [name]: value
171
+ }));
172
+ }
173
+ flat(result) {
174
+ if (!result || typeof result !== "object" || Array.isArray(result)) return null;
175
+ const entries = Object.entries(result);
176
+ return entries.every(([, v]) => v === null || [
177
+ "string",
178
+ "number",
179
+ "boolean"
180
+ ].includes(typeof v)) ? entries.map(([k, v]) => [k, v === null ? "—" : String(v)]) : null;
181
+ }
182
+ summary(c) {
183
+ return c.result;
184
+ }
185
+ disk(c) {
186
+ return c.result;
187
+ }
188
+ tcp(c) {
189
+ return c.result;
190
+ }
191
+ shown = 8;
192
+ expanded = signal(/* @__PURE__ */ new Set(), ...ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []);
193
+ toggle(id) {
194
+ this.expanded.update((s) => {
195
+ const next = new Set(s);
196
+ if (!next.delete(id)) next.add(id);
197
+ return next;
198
+ });
199
+ }
200
+ fullestFirst(d, all) {
201
+ const free = (f) => f.totalBytes > 0 ? f.availableBytes / f.totalBytes : 1;
202
+ const sizable = (f) => Number(f.totalBytes >= 1024 ** 3);
203
+ const sorted = [...d.filesystems].sort((a, b) => Number(this.low(b)) - Number(this.low(a)) || sizable(b) - sizable(a) || free(a) - free(b));
204
+ return all ? sorted : sorted.slice(0, this.shown);
205
+ }
206
+ low(f) {
207
+ return f.totalBytes >= 1024 ** 3 && f.availableBytes / f.totalBytes < .1;
208
+ }
209
+ bytes(n) {
210
+ return formatBytes(n);
211
+ }
212
+ uptime(s) {
213
+ return formatUptime(s);
214
+ }
215
+ json(v) {
216
+ return JSON.stringify(v, null, 2);
217
+ }
218
+ parameters() {
219
+ if (this.action() === "agent.update") return { version: this.version };
220
+ const values = this.values();
221
+ const out = {};
222
+ for (const p of this.selected()?.parameters ?? []) {
223
+ const v = values[p.name];
224
+ if (p.type === "boolean") {
225
+ if (v === true || p.required) out[p.name] = v === true;
226
+ continue;
227
+ }
228
+ if (v === void 0 || v === null || v === "") continue;
229
+ out[p.name] = p.type === "integer" ? Number(v) : String(v).trim();
230
+ }
231
+ return out;
232
+ }
233
+ approvalText(policy) {
234
+ switch (policy) {
235
+ case "None": return "runs when asked";
236
+ case "Admin": return "needs an admin: an admin's request runs at once, an operator's waits for an admin to approve it";
237
+ default: return "needs a second person: an admin other than whoever asks approves it";
238
+ }
239
+ }
240
+ issue() {
241
+ const action = this.action();
242
+ this.issuing.set(true);
243
+ this.issueError.set("");
244
+ this.issued.set("");
245
+ const failed = (e) => {
246
+ this.issuing.set(false);
247
+ this.issueError.set(e.status === 403 ? "Asking an agent needs the operator or admin role." : problemText(e));
248
+ };
249
+ if (!this.needsApproval()) {
250
+ this.api.issueCommand(this.id(), action, this.parameters()).subscribe({
251
+ next: () => {
252
+ this.issuing.set(false);
253
+ this.commands.reload();
254
+ },
255
+ error: failed
256
+ });
257
+ return;
258
+ }
259
+ this.api.requestAction(this.id(), action, this.parameters(), this.requestReason.trim()).subscribe({
260
+ next: (r) => {
261
+ this.issuing.set(false);
262
+ this.requestReason = "";
263
+ this.issued.set(r.state === "Issued" ? "Approved by your role: running." : "Requested: it runs once approved, on the Approvals page.");
264
+ this.requests.reload();
265
+ this.commands.reload();
266
+ },
267
+ error: failed
268
+ });
269
+ }
270
+ cancelRequest(id) {
271
+ this.api.cancelRequest(id).subscribe({
272
+ next: () => this.requests.reload(),
273
+ error: (e) => this.issueError.set(problemText(e))
274
+ });
275
+ }
276
+ loadOlder() {
277
+ const cursor = this.nextCursor();
278
+ if (!cursor) return;
279
+ this.api.agentCommands(this.id(), cursor).subscribe({
280
+ next: (page) => this.older.update((o) => ({
281
+ items: [...o?.items ?? [], ...page.items],
282
+ cursor: page.nextCursor
283
+ })),
284
+ error: (e) => this.issueError.set(problemText(e))
285
+ });
286
+ }
287
+ reenroll(hostname) {
288
+ this.creating.set(true);
289
+ this.reenrollError.set("");
290
+ this.copied.set("");
291
+ this.api.createEnrollmentToken(`re-enroll ${hostname}`, 60).subscribe({
292
+ next: (t) => {
293
+ this.creating.set(false);
294
+ this.token.set(t);
295
+ },
296
+ error: (e) => {
297
+ this.creating.set(false);
298
+ this.reenrollError.set(e.status === 403 ? "Enrolling an agent needs the admin role." : problemText(e));
299
+ }
300
+ });
301
+ }
302
+ copy(text) {
303
+ copyText(text, document.querySelector("[data-testid=reenroll-token-value]")).then((done) => this.copied.set(done));
304
+ }
305
+ revoke() {
306
+ if (!this.confirming()) {
307
+ this.confirming.set(true);
308
+ return;
309
+ }
310
+ this.revoking.set(true);
311
+ this.revokeError.set("");
312
+ this.api.revokeAgent(this.id(), this.reason.trim()).subscribe({
313
+ next: () => {
314
+ this.revoking.set(false);
315
+ this.confirming.set(false);
316
+ this.agent.reload();
317
+ this.commands.reload();
318
+ },
319
+ error: (e) => {
320
+ this.revoking.set(false);
321
+ this.revokeError.set(e.status === 403 ? "Revoking an agent needs the admin role." : problemText(e));
322
+ }
323
+ });
324
+ }
325
+ static ɵfac = i0.ɵɵngDeclareFactory({
326
+ minVersion: "12.0.0",
327
+ version: "22.2.4",
328
+ ngImport: i0,
329
+ type: AgentPage,
330
+ deps: [],
331
+ target: i0.ɵɵFactoryTarget.Component
332
+ });
333
+ static ɵcmp = i0.ɵɵngDeclareComponent({
334
+ minVersion: "17.0.0",
335
+ version: "22.2.4",
336
+ type: AgentPage,
337
+ isStandalone: true,
338
+ selector: "ng-component",
339
+ inputs: { id: {
340
+ classPropertyName: "id",
341
+ publicName: "id",
342
+ isSignal: true,
343
+ isRequired: true,
344
+ transformFunction: null
345
+ } },
346
+ ngImport: i0,
347
+ template: `
348
+ <jc-context-bar>
349
+ <a [routerLink]="['agents'] | jcLink" [queryParams]="ctx.keep()" class="jc-crumb">Agents</a><span class="jc-crumb-sep">›</span>
350
+ <h1>{{ agent.value()?.hostname ?? '…' }}</h1>
351
+ </jc-context-bar>
352
+ @if (agent.isLoading() && !agent.value()) { <mat-progress-bar mode="indeterminate" /> }
353
+ @if (agent.error()) { <p class="jc-error">{{ error() }}</p> }
354
+ @if (agent.value(); as a) {
355
+ <div class="jc-summary" data-testid="agent-summary">
356
+ <span class="jc-badge" data-testid="agent-state" [class.jc-health-healthy]="a.online" [class.jc-health-offline]="!a.online && a.status === 'Active'" [class.jc-health-none]="a.status !== 'Active'">
357
+ {{ a.status !== 'Active' ? a.status : a.online ? 'Online' : 'Not calling in' }}</span>
358
+ <span>{{ a.operatingSystem }}</span>
359
+ <span>version <span class="jc-mono" data-testid="agent-version">{{ a.version }}</span></span>
360
+ <span class="jc-muted">last seen {{ a.lastSeenAt | ago }}</span>
361
+ @if (a.resourceId) { <a [routerLink]="['resources', a.resourceId] | jcLink" [queryParams]="ctx.keep()">Host resource</a> }
362
+ </div>
363
+ <p class="jc-muted jc-small">Enrolled {{ a.enrolledAt | date: 'MMM d, y, HH:mm' }} by {{ a.enrolledBy }}. Certificate valid until {{ a.certificateNotAfter | date: 'MMM d, HH:mm' }}; the agent renews it when a third is left.</p>
364
+ @if (a.status !== 'Active') {
365
+ <p class="jc-notice" data-testid="agent-revoked">Revoked {{ a.revokedAt | date: 'MMM d, y, HH:mm' }} by {{ a.revokedBy }}: {{ a.revokeReason }}. The platform refuses its certificate for good.</p>
366
+ @if (successor(); as s) {
367
+ <p data-testid="agent-successor">{{ a.hostname }} enrolled again {{ s.enrolledAt | date: 'MMM d, HH:mm' }} as <a [routerLink]="['agents', s.id] | jcLink" [queryParams]="ctx.keep()">a new agent</a>.</p>
368
+ } @else {
369
+ <section class="jc-card" data-testid="reenroll">
370
+ <h2>Bring this host back</h2>
371
+ <p class="jc-muted jc-small">The host comes back as a new agent, with a new key: this one stays revoked, with its history. It needs a new token from an admin, put on the host.</p>
372
+ <button mat-flat-button type="button" data-testid="reenroll-create" [disabled]="creating()" (click)="reenroll(a.hostname)">Create a token for {{ a.hostname }}</button>
373
+ @if (reenrollError()) { <span class="jc-error" data-testid="reenroll-error"> {{ reenrollError() }}</span> }
374
+ @if (token(); as t) {
375
+ <div class="jc-notice" data-testid="reenroll-token">
376
+ <p>Replace the token in the agent's token file (<span class="jc-mono">Agent:EnrollmentTokenFile</span>) with this one. It works once, until {{ t.expiresAt | date: 'MMM d, HH:mm' }}, and <strong>won't be shown again</strong>.</p>
377
+ <p class="jc-row"><span class="jc-mono" data-testid="reenroll-token-value">{{ t.token }}</span>
378
+ <button mat-button type="button" (click)="copy(t.token)">{{ copied() === 'copied' ? 'Copied' : copied() === 'selected' ? 'Selected: press Ctrl+C' : 'Copy' }}</button></p>
379
+ <p>The agent notices it within seconds, sets its old identity aside and enrolls again: nothing else on the host changes. An agent from before 9 November doesn't: clear its data directory's identity files and restart it.</p>
380
+ </div>
381
+ }
382
+ </section>
383
+ }
384
+ } @else {
385
+ <section class="jc-card">
386
+ <h2>Ask the agent</h2>
387
+ <form class="jc-form" data-testid="command-form" (ngSubmit)="issue()">
388
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Action</mat-label>
389
+ <mat-select name="action" data-testid="command-action" [ngModel]="action()" (ngModelChange)="choose($event)">
390
+ @for (o of actionList(); track o.name) {
391
+ <mat-option [value]="o.name" [disabled]="o.permitted === false" [attr.data-testid]="'action-' + o.name">
392
+ {{ label(o.name) }}@if (o.custom) { <span class="jc-muted"> · custom</span> }@if (o.permitted === false) { <span class="jc-muted"> · not allowed on this host</span> }
393
+ </mat-option>
394
+ }
395
+ </mat-select>
396
+ </mat-form-field>
397
+ @if (action() === 'agent.update') {
398
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-md"><mat-label>Version</mat-label>
399
+ <mat-select name="version" data-testid="command-version" [(ngModel)]="version">
400
+ @for (p of packages.value()?.items ?? []; track p.version) { <mat-option [value]="p.version">{{ p.version }}</mat-option> }
401
+ </mat-select>
402
+ </mat-form-field>
403
+ @if (packages.value()?.items?.length === 0) { <span class="jc-muted jc-small">No signed packages are offered: see Agents:PackageDirectory.</span> }
404
+ } @else {
405
+ @for (p of selected()?.parameters ?? []; track p.name) {
406
+ @if (p.type === 'boolean') {
407
+ <mat-checkbox [name]="p.name" [attr.data-testid]="'command-param-' + p.name" [ngModel]="values()[p.name] === true" (ngModelChange)="set(p.name, $event)">{{ title(p) }}</mat-checkbox>
408
+ } @else if (p.allowed?.length) {
409
+ <mat-form-field subscriptSizing="dynamic" [class.jc-field-md]="p.type !== 'string'" [class.jc-field-wide]="p.type === 'string'"><mat-label>{{ title(p) }}</mat-label>
410
+ <mat-select [name]="p.name" [attr.data-testid]="'command-param-' + p.name" [ngModel]="values()[p.name] ?? ''" (ngModelChange)="set(p.name, $event)">
411
+ @if (!p.required) { <mat-option value="">Any</mat-option> }
412
+ @for (v of p.allowed; track v) { <mat-option [value]="v">{{ v }}</mat-option> }
413
+ </mat-select>
414
+ </mat-form-field>
415
+ } @else {
416
+ <mat-form-field subscriptSizing="dynamic" [class.jc-field-sm]="p.type === 'integer'" [class.jc-field-wide]="p.type === 'string'"><mat-label>{{ title(p) }}</mat-label>
417
+ <input matInput [type]="p.type === 'integer' ? 'number' : 'text'" [name]="p.name" [attr.data-testid]="'command-param-' + p.name" [attr.min]="p.minimum" [attr.max]="p.maximum"
418
+ [attr.maxlength]="p.maxLength" [placeholder]="p.description ?? ''" [ngModel]="values()[p.name] ?? ''" (ngModelChange)="set(p.name, $event)">
419
+ </mat-form-field>
420
+ }
421
+ }
422
+ }
423
+ @if (needsApproval()) {
424
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Why (for whoever approves it)</mat-label>
425
+ <input matInput name="requestReason" data-testid="request-reason" maxlength="500" [(ngModel)]="requestReason">
426
+ </mat-form-field>
427
+ }
428
+ <div class="jc-form-actions">
429
+ <button mat-flat-button type="submit" data-testid="command-issue" [disabled]="issuing() || selected()?.permitted === false">{{ needsApproval() ? 'Request' : action() === 'agent.update' ? 'Update' : 'Run' }}</button>
430
+ @if (issueError()) { <span class="jc-error" data-testid="command-error">{{ issueError() }}</span> }
431
+ @if (issued()) { <span class="jc-muted" data-testid="command-issued">{{ issued() }}</span> }
432
+ </div>
433
+ @if (selected(); as s) {
434
+ <div class="jc-muted jc-small jc-form-actions" data-testid="command-hint">
435
+ <div>{{ s.description }} <span data-testid="command-approval">{{ s.risk }} risk: {{ approvalText(s.approval) }}.</span></div>
436
+ @if (s.limits.length) { <div data-testid="command-limits">On this host: {{ s.limits.join('; ') }}.</div> }
437
+ </div>
438
+ }
439
+ </form>
440
+ @if (actions.value(); as list) {
441
+ @if (!list.reportedAt) {
442
+ <p class="jc-notice" data-testid="actions-not-reported">This agent doesn't report what its host allows (it's older than this platform): the list shows the built-in actions, and one its host doesn't permit comes back <strong>Rejected</strong>.</p>
443
+ } @else {
444
+ <p class="jc-muted jc-small">As the agent reported {{ list.reportedAt | ago }}, when it started. Its host still checks every command.</p>
445
+ }
446
+ }
447
+ </section>
448
+ }
449
+
450
+ @if (requestList().length) {
451
+ <section class="jc-card" data-testid="requests">
452
+ <h2>Requests</h2>
453
+ <table class="jc-table">
454
+ <thead><tr><th>Asked</th><th>Action</th><th>By, and why</th><th>State</th><th>Decided</th><th></th></tr></thead>
455
+ <tbody>
456
+ @for (r of requestList(); track r.id) {
457
+ <tr [attr.data-testid]="'request-' + r.id">
458
+ <td class="jc-nowrap">{{ r.requestedAt | date: 'MMM d, HH:mm:ss' }}</td>
459
+ <td><strong>{{ r.action }}</strong><div class="jc-muted jc-small">{{ r.risk }} risk</div></td>
460
+ <td>{{ r.requestedBy }}<div class="jc-small">{{ r.reason }}</div></td>
461
+ <td class="jc-nowrap"><span class="jc-badge" [class.jc-health-degraded]="r.state === 'Pending'" [class.jc-health-healthy]="r.state === 'Issued'"
462
+ [class.jc-health-none]="r.state !== 'Pending' && r.state !== 'Issued'" data-testid="request-state">{{ r.state === 'Pending' ? 'Waiting for approval' : r.state }}</span>
463
+ @if (r.state === 'Pending') { <div class="jc-muted jc-small">until {{ r.expiresAt | date: 'HH:mm' }}</div> }</td>
464
+ <td class="jc-small">@if (r.decidedBy) { {{ r.decidedBy }}, {{ r.decidedAt | date: 'HH:mm' }} }@if (r.comment) { <div>{{ r.comment }}</div> }</td>
465
+ <td class="jc-row-actions">@if (r.state === 'Pending') { <button mat-button type="button" [attr.data-testid]="'request-cancel-' + r.id" (click)="cancelRequest(r.id)">Cancel</button> }</td>
466
+ </tr>
467
+ }
468
+ </tbody>
469
+ </table>
470
+ </section>
471
+ }
472
+
473
+ <section class="jc-card" data-testid="commands">
474
+ <h2>Commands</h2>
475
+ @if (commands.error()) { <p class="jc-error">{{ commandsError() }}</p> }
476
+ <table class="jc-table">
477
+ <thead><tr><th>Issued</th><th>Action</th><th>By</th><th>State</th><th>Answer</th></tr></thead>
478
+ <tbody>
479
+ @for (c of allCommands(); track c.id) {
480
+ <tr [attr.data-testid]="'command-' + c.id">
481
+ <td class="jc-nowrap">{{ c.issuedAt | date: 'MMM d, HH:mm:ss' }}</td>
482
+ <td><strong>{{ c.action }}</strong>@if (describe(c); as d) { <div class="jc-small jc-mono">{{ d }}</div> }</td>
483
+ <td>{{ c.issuedBy }}</td>
484
+ <td class="jc-nowrap">
485
+ <span class="jc-badge" [class.jc-health-healthy]="c.state === 'Succeeded'" [class.jc-health-unhealthy]="c.state === 'Failed' || c.state === 'Rejected'"
486
+ [class.jc-health-degraded]="waiting(c)" [class.jc-health-none]="c.state === 'Expired' || c.state === 'Cancelled'" data-testid="command-state">{{ c.state }}</span>
487
+ @if (c.durationMs !== null) { <div class="jc-muted jc-small">{{ c.durationMs }} ms</div> }
488
+ </td>
489
+ <td class="jc-small" data-testid="command-answer">
490
+ @if (c.reason) { <div [class.jc-bad]="c.state !== 'Succeeded'">{{ c.reason | reason }}</div> }
491
+ @if (c.state === 'Succeeded' && c.result) {
492
+ @switch (c.action) {
493
+ @case ('host.summary') {
494
+ @if (summary(c); as h) {
495
+ <div>{{ h.hostname }} · {{ h.operatingSystem }} {{ h.architecture }} · up {{ uptime(h.uptimeSeconds) }}</div>
496
+ <div>{{ h.processorCount }} CPUs@if (h.loadAverage) { · load {{ h.loadAverage.join(' ') }} }@if (h.memoryTotalBytes) { · memory {{ bytes(h.memoryAvailableBytes) }} of {{ bytes(h.memoryTotalBytes) }} available }</div>
497
+ }
498
+ }
499
+ @case ('disk.usage') {
500
+ @if (disk(c); as d) {
501
+ <table class="jc-kv" data-testid="disk-result">
502
+ @for (f of fullestFirst(d, expanded().has(c.id)); track f.mountPoint) {
503
+ <tr [class.jc-bad]="low(f)">
504
+ <td class="jc-mono">{{ f.mountPoint }}</td><td>{{ f.format }}</td><td class="jc-nowrap">{{ bytes(f.availableBytes) }} free of {{ bytes(f.totalBytes) }}</td>
505
+ </tr>
506
+ } @empty { <tr><td class="jc-muted">No filesystems there.</td></tr> }
507
+ </table>
508
+ @if (d.filesystems.length > shown) {
509
+ <button mat-button type="button" [attr.data-testid]="'disk-toggle-' + c.id" (click)="toggle(c.id)">
510
+ {{ expanded().has(c.id) ? 'Show the fullest ' + shown : 'Show all ' + d.filesystems.length }}</button>
511
+ }
512
+ @if (d.truncated) { <div class="jc-muted">More filesystems than the agent reports at once.</div> }
513
+ }
514
+ }
515
+ @case ('tcp.reachability') {
516
+ @if (tcp(c); as t) {
517
+ @if (t.reachable) { <div>Reachable at {{ t.address }} in {{ t.elapsedMs }} ms</div> }
518
+ @else { <div class="jc-bad">Not reachable after {{ t.elapsedMs }} ms: {{ t.error }}</div> }
519
+ }
520
+ }
521
+ @default {
522
+ @if (flat(c.result); as rows) {
523
+ <table class="jc-kv" data-testid="custom-result">@for (r of rows; track r[0]) { <tr><td>{{ r[0] }}</td><td class="jc-mono">{{ r[1] }}</td></tr> }</table>
524
+ } @else { <pre class="jc-mono" style="white-space: pre-wrap; margin: 0" data-testid="custom-result">{{ json(c.result) }}</pre> }
525
+ }
526
+ }
527
+ }
528
+ @if (waiting(c)) { <div class="jc-muted">{{ c.state === 'Pending' ? 'Waiting for the agent to call in' : 'Handed to the agent' }}, until {{ c.expiresAt | date: 'HH:mm:ss' }}</div> }
529
+ </td>
530
+ </tr>
531
+ } @empty { <tr><td colspan="5" class="jc-muted">Nothing asked yet.</td></tr> }
532
+ </tbody>
533
+ </table>
534
+ @if (nextCursor()) { <button mat-button type="button" data-testid="commands-older" (click)="loadOlder()">Older</button> }
535
+ </section>
536
+
537
+ @if (a.status === 'Active') {
538
+ <section class="jc-card">
539
+ <h2>Revoke</h2>
540
+ <p class="jc-muted jc-small">The agent stops at its next call: the platform refuses its certificate from then on, and commands still waiting are cancelled. It can't be undone; the host would enroll again with a new token.</p>
541
+ <form class="jc-form" (ngSubmit)="revoke()">
542
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Why</mat-label><input matInput name="reason" data-testid="revoke-reason" [(ngModel)]="reason" maxlength="500" (ngModelChange)="confirming.set(false)"></mat-form-field>
543
+ @if (confirming()) {
544
+ <button mat-flat-button color="warn" type="submit" data-testid="revoke-confirm" [disabled]="revoking()">Revoke {{ a.hostname }}</button>
545
+ <button mat-button type="button" (click)="confirming.set(false)">Cancel</button>
546
+ } @else {
547
+ <button mat-stroked-button type="submit" data-testid="revoke" [disabled]="!reason.trim()">Revoke</button>
548
+ }
549
+ @if (revokeError()) { <span class="jc-error" data-testid="revoke-error">{{ revokeError() }}</span> }
550
+ </form>
551
+ </section>
552
+ }
553
+ }`,
554
+ isInline: true,
555
+ dependencies: [
556
+ {
557
+ kind: "directive",
558
+ type: RouterLink,
559
+ selector: "[routerLink]",
560
+ inputs: [
561
+ "target",
562
+ "queryParams",
563
+ "fragment",
564
+ "queryParamsHandling",
565
+ "state",
566
+ "info",
567
+ "relativeTo",
568
+ "preserveFragment",
569
+ "skipLocationChange",
570
+ "replaceUrl",
571
+ "browserUrl",
572
+ "routerLink"
573
+ ]
574
+ },
575
+ {
576
+ kind: "ngmodule",
577
+ type: FormsModule
578
+ },
579
+ {
580
+ kind: "directive",
581
+ type: i1.ɵNgNoValidate,
582
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
583
+ },
584
+ {
585
+ kind: "directive",
586
+ type: i1.DefaultValueAccessor,
587
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
588
+ },
589
+ {
590
+ kind: "directive",
591
+ type: i1.NgControlStatus,
592
+ selector: "[formControlName],[ngModel],[formControl]"
593
+ },
594
+ {
595
+ kind: "directive",
596
+ type: i1.NgControlStatusGroup,
597
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
598
+ },
599
+ {
600
+ kind: "directive",
601
+ type: i1.MaxLengthValidator,
602
+ selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]",
603
+ inputs: ["maxlength"]
604
+ },
605
+ {
606
+ kind: "directive",
607
+ type: i1.NgModel,
608
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
609
+ inputs: [
610
+ "name",
611
+ "disabled",
612
+ "ngModel",
613
+ "ngModelOptions"
614
+ ],
615
+ outputs: ["ngModelChange"],
616
+ exportAs: ["ngModel"]
617
+ },
618
+ {
619
+ kind: "directive",
620
+ type: i1.NgForm,
621
+ selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
622
+ inputs: ["ngFormOptions"],
623
+ outputs: ["ngSubmit"],
624
+ exportAs: ["ngForm"]
625
+ },
626
+ {
627
+ kind: "ngmodule",
628
+ type: MatButtonModule
629
+ },
630
+ {
631
+ kind: "component",
632
+ type: i2.MatButton,
633
+ selector: " button[matButton], a[matButton], button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button], a[mat-button], a[mat-raised-button], a[mat-flat-button], a[mat-stroked-button] ",
634
+ inputs: ["matButton"],
635
+ exportAs: ["matButton", "matAnchor"]
636
+ },
637
+ {
638
+ kind: "ngmodule",
639
+ type: MatCheckboxModule
640
+ },
641
+ {
642
+ kind: "component",
643
+ type: i3.MatCheckbox,
644
+ selector: "mat-checkbox",
645
+ inputs: [
646
+ "aria-label",
647
+ "aria-labelledby",
648
+ "aria-describedby",
649
+ "aria-expanded",
650
+ "aria-controls",
651
+ "aria-owns",
652
+ "id",
653
+ "required",
654
+ "labelPosition",
655
+ "name",
656
+ "value",
657
+ "disableRipple",
658
+ "tabIndex",
659
+ "color",
660
+ "disabledInteractive",
661
+ "checked",
662
+ "disabled",
663
+ "indeterminate"
664
+ ],
665
+ outputs: ["change", "indeterminateChange"],
666
+ exportAs: ["matCheckbox"]
667
+ },
668
+ {
669
+ kind: "ngmodule",
670
+ type: MatFormFieldModule
671
+ },
672
+ {
673
+ kind: "component",
674
+ type: i4.MatFormField,
675
+ selector: "mat-form-field",
676
+ inputs: [
677
+ "hideRequiredMarker",
678
+ "color",
679
+ "floatLabel",
680
+ "appearance",
681
+ "subscriptSizing",
682
+ "hintLabel"
683
+ ],
684
+ exportAs: ["matFormField"]
685
+ },
686
+ {
687
+ kind: "directive",
688
+ type: i4.MatLabel,
689
+ selector: "mat-label"
690
+ },
691
+ {
692
+ kind: "ngmodule",
693
+ type: MatInputModule
694
+ },
695
+ {
696
+ kind: "directive",
697
+ type: i5.MatInput,
698
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
699
+ inputs: [
700
+ "disabled",
701
+ "id",
702
+ "placeholder",
703
+ "name",
704
+ "required",
705
+ "type",
706
+ "errorStateMatcher",
707
+ "aria-describedby",
708
+ "value",
709
+ "readonly",
710
+ "disabledInteractive"
711
+ ],
712
+ exportAs: ["matInput"]
713
+ },
714
+ {
715
+ kind: "ngmodule",
716
+ type: MatProgressBarModule
717
+ },
718
+ {
719
+ kind: "component",
720
+ type: i6.MatProgressBar,
721
+ selector: "mat-progress-bar",
722
+ inputs: [
723
+ "color",
724
+ "value",
725
+ "bufferValue",
726
+ "mode"
727
+ ],
728
+ outputs: ["animationEnd"],
729
+ exportAs: ["matProgressBar"]
730
+ },
731
+ {
732
+ kind: "ngmodule",
733
+ type: MatSelectModule
734
+ },
735
+ {
736
+ kind: "component",
737
+ type: i4.MatSelect,
738
+ selector: "mat-select",
739
+ inputs: [
740
+ "aria-describedby",
741
+ "panelClass",
742
+ "disabled",
743
+ "disableRipple",
744
+ "tabIndex",
745
+ "hideSingleSelectionIndicator",
746
+ "placeholder",
747
+ "required",
748
+ "multiple",
749
+ "disableOptionCentering",
750
+ "compareWith",
751
+ "value",
752
+ "aria-label",
753
+ "aria-labelledby",
754
+ "errorStateMatcher",
755
+ "typeaheadDebounceInterval",
756
+ "sortComparator",
757
+ "id",
758
+ "panelWidth",
759
+ "canSelectNullableOptions"
760
+ ],
761
+ outputs: [
762
+ "openedChange",
763
+ "opened",
764
+ "closed",
765
+ "selectionChange",
766
+ "valueChange"
767
+ ],
768
+ exportAs: ["matSelect"]
769
+ },
770
+ {
771
+ kind: "component",
772
+ type: i4.MatOption,
773
+ selector: "mat-option",
774
+ inputs: [
775
+ "value",
776
+ "id",
777
+ "disabled"
778
+ ],
779
+ outputs: ["onSelectionChange"],
780
+ exportAs: ["matOption"]
781
+ },
782
+ {
783
+ kind: "component",
784
+ type: ContextBar,
785
+ selector: "jc-context-bar"
786
+ },
787
+ {
788
+ kind: "pipe",
789
+ type: LinkPipe,
790
+ name: "jcLink"
791
+ },
792
+ {
793
+ kind: "pipe",
794
+ type: DatePipe,
795
+ name: "date"
796
+ },
797
+ {
798
+ kind: "pipe",
799
+ type: AgoPipe,
800
+ name: "ago"
801
+ },
802
+ {
803
+ kind: "pipe",
804
+ type: ReasonPipe,
805
+ name: "reason"
806
+ }
807
+ ],
808
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
809
+ });
810
+ };
811
+ i0.ɵɵngDeclareClassMetadata({
812
+ minVersion: "12.0.0",
813
+ version: "22.2.4",
814
+ ngImport: i0,
815
+ type: AgentPage,
816
+ decorators: [{
817
+ type: Component,
818
+ args: [{
819
+ changeDetection: ChangeDetectionStrategy.OnPush,
820
+ imports: [
821
+ LinkPipe,
822
+ RouterLink,
823
+ DatePipe,
824
+ FormsModule,
825
+ MatButtonModule,
826
+ MatCheckboxModule,
827
+ MatFormFieldModule,
828
+ MatInputModule,
829
+ MatProgressBarModule,
830
+ MatSelectModule,
831
+ ContextBar,
832
+ AgoPipe,
833
+ ReasonPipe
834
+ ],
835
+ template: `
836
+ <jc-context-bar>
837
+ <a [routerLink]="['agents'] | jcLink" [queryParams]="ctx.keep()" class="jc-crumb">Agents</a><span class="jc-crumb-sep">›</span>
838
+ <h1>{{ agent.value()?.hostname ?? '…' }}</h1>
839
+ </jc-context-bar>
840
+ @if (agent.isLoading() && !agent.value()) { <mat-progress-bar mode="indeterminate" /> }
841
+ @if (agent.error()) { <p class="jc-error">{{ error() }}</p> }
842
+ @if (agent.value(); as a) {
843
+ <div class="jc-summary" data-testid="agent-summary">
844
+ <span class="jc-badge" data-testid="agent-state" [class.jc-health-healthy]="a.online" [class.jc-health-offline]="!a.online && a.status === 'Active'" [class.jc-health-none]="a.status !== 'Active'">
845
+ {{ a.status !== 'Active' ? a.status : a.online ? 'Online' : 'Not calling in' }}</span>
846
+ <span>{{ a.operatingSystem }}</span>
847
+ <span>version <span class="jc-mono" data-testid="agent-version">{{ a.version }}</span></span>
848
+ <span class="jc-muted">last seen {{ a.lastSeenAt | ago }}</span>
849
+ @if (a.resourceId) { <a [routerLink]="['resources', a.resourceId] | jcLink" [queryParams]="ctx.keep()">Host resource</a> }
850
+ </div>
851
+ <p class="jc-muted jc-small">Enrolled {{ a.enrolledAt | date: 'MMM d, y, HH:mm' }} by {{ a.enrolledBy }}. Certificate valid until {{ a.certificateNotAfter | date: 'MMM d, HH:mm' }}; the agent renews it when a third is left.</p>
852
+ @if (a.status !== 'Active') {
853
+ <p class="jc-notice" data-testid="agent-revoked">Revoked {{ a.revokedAt | date: 'MMM d, y, HH:mm' }} by {{ a.revokedBy }}: {{ a.revokeReason }}. The platform refuses its certificate for good.</p>
854
+ @if (successor(); as s) {
855
+ <p data-testid="agent-successor">{{ a.hostname }} enrolled again {{ s.enrolledAt | date: 'MMM d, HH:mm' }} as <a [routerLink]="['agents', s.id] | jcLink" [queryParams]="ctx.keep()">a new agent</a>.</p>
856
+ } @else {
857
+ <section class="jc-card" data-testid="reenroll">
858
+ <h2>Bring this host back</h2>
859
+ <p class="jc-muted jc-small">The host comes back as a new agent, with a new key: this one stays revoked, with its history. It needs a new token from an admin, put on the host.</p>
860
+ <button mat-flat-button type="button" data-testid="reenroll-create" [disabled]="creating()" (click)="reenroll(a.hostname)">Create a token for {{ a.hostname }}</button>
861
+ @if (reenrollError()) { <span class="jc-error" data-testid="reenroll-error"> {{ reenrollError() }}</span> }
862
+ @if (token(); as t) {
863
+ <div class="jc-notice" data-testid="reenroll-token">
864
+ <p>Replace the token in the agent's token file (<span class="jc-mono">Agent:EnrollmentTokenFile</span>) with this one. It works once, until {{ t.expiresAt | date: 'MMM d, HH:mm' }}, and <strong>won't be shown again</strong>.</p>
865
+ <p class="jc-row"><span class="jc-mono" data-testid="reenroll-token-value">{{ t.token }}</span>
866
+ <button mat-button type="button" (click)="copy(t.token)">{{ copied() === 'copied' ? 'Copied' : copied() === 'selected' ? 'Selected: press Ctrl+C' : 'Copy' }}</button></p>
867
+ <p>The agent notices it within seconds, sets its old identity aside and enrolls again: nothing else on the host changes. An agent from before 9 November doesn't: clear its data directory's identity files and restart it.</p>
868
+ </div>
869
+ }
870
+ </section>
871
+ }
872
+ } @else {
873
+ <section class="jc-card">
874
+ <h2>Ask the agent</h2>
875
+ <form class="jc-form" data-testid="command-form" (ngSubmit)="issue()">
876
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Action</mat-label>
877
+ <mat-select name="action" data-testid="command-action" [ngModel]="action()" (ngModelChange)="choose($event)">
878
+ @for (o of actionList(); track o.name) {
879
+ <mat-option [value]="o.name" [disabled]="o.permitted === false" [attr.data-testid]="'action-' + o.name">
880
+ {{ label(o.name) }}@if (o.custom) { <span class="jc-muted"> · custom</span> }@if (o.permitted === false) { <span class="jc-muted"> · not allowed on this host</span> }
881
+ </mat-option>
882
+ }
883
+ </mat-select>
884
+ </mat-form-field>
885
+ @if (action() === 'agent.update') {
886
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-md"><mat-label>Version</mat-label>
887
+ <mat-select name="version" data-testid="command-version" [(ngModel)]="version">
888
+ @for (p of packages.value()?.items ?? []; track p.version) { <mat-option [value]="p.version">{{ p.version }}</mat-option> }
889
+ </mat-select>
890
+ </mat-form-field>
891
+ @if (packages.value()?.items?.length === 0) { <span class="jc-muted jc-small">No signed packages are offered: see Agents:PackageDirectory.</span> }
892
+ } @else {
893
+ @for (p of selected()?.parameters ?? []; track p.name) {
894
+ @if (p.type === 'boolean') {
895
+ <mat-checkbox [name]="p.name" [attr.data-testid]="'command-param-' + p.name" [ngModel]="values()[p.name] === true" (ngModelChange)="set(p.name, $event)">{{ title(p) }}</mat-checkbox>
896
+ } @else if (p.allowed?.length) {
897
+ <mat-form-field subscriptSizing="dynamic" [class.jc-field-md]="p.type !== 'string'" [class.jc-field-wide]="p.type === 'string'"><mat-label>{{ title(p) }}</mat-label>
898
+ <mat-select [name]="p.name" [attr.data-testid]="'command-param-' + p.name" [ngModel]="values()[p.name] ?? ''" (ngModelChange)="set(p.name, $event)">
899
+ @if (!p.required) { <mat-option value="">Any</mat-option> }
900
+ @for (v of p.allowed; track v) { <mat-option [value]="v">{{ v }}</mat-option> }
901
+ </mat-select>
902
+ </mat-form-field>
903
+ } @else {
904
+ <mat-form-field subscriptSizing="dynamic" [class.jc-field-sm]="p.type === 'integer'" [class.jc-field-wide]="p.type === 'string'"><mat-label>{{ title(p) }}</mat-label>
905
+ <input matInput [type]="p.type === 'integer' ? 'number' : 'text'" [name]="p.name" [attr.data-testid]="'command-param-' + p.name" [attr.min]="p.minimum" [attr.max]="p.maximum"
906
+ [attr.maxlength]="p.maxLength" [placeholder]="p.description ?? ''" [ngModel]="values()[p.name] ?? ''" (ngModelChange)="set(p.name, $event)">
907
+ </mat-form-field>
908
+ }
909
+ }
910
+ }
911
+ @if (needsApproval()) {
912
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Why (for whoever approves it)</mat-label>
913
+ <input matInput name="requestReason" data-testid="request-reason" maxlength="500" [(ngModel)]="requestReason">
914
+ </mat-form-field>
915
+ }
916
+ <div class="jc-form-actions">
917
+ <button mat-flat-button type="submit" data-testid="command-issue" [disabled]="issuing() || selected()?.permitted === false">{{ needsApproval() ? 'Request' : action() === 'agent.update' ? 'Update' : 'Run' }}</button>
918
+ @if (issueError()) { <span class="jc-error" data-testid="command-error">{{ issueError() }}</span> }
919
+ @if (issued()) { <span class="jc-muted" data-testid="command-issued">{{ issued() }}</span> }
920
+ </div>
921
+ @if (selected(); as s) {
922
+ <div class="jc-muted jc-small jc-form-actions" data-testid="command-hint">
923
+ <div>{{ s.description }} <span data-testid="command-approval">{{ s.risk }} risk: {{ approvalText(s.approval) }}.</span></div>
924
+ @if (s.limits.length) { <div data-testid="command-limits">On this host: {{ s.limits.join('; ') }}.</div> }
925
+ </div>
926
+ }
927
+ </form>
928
+ @if (actions.value(); as list) {
929
+ @if (!list.reportedAt) {
930
+ <p class="jc-notice" data-testid="actions-not-reported">This agent doesn't report what its host allows (it's older than this platform): the list shows the built-in actions, and one its host doesn't permit comes back <strong>Rejected</strong>.</p>
931
+ } @else {
932
+ <p class="jc-muted jc-small">As the agent reported {{ list.reportedAt | ago }}, when it started. Its host still checks every command.</p>
933
+ }
934
+ }
935
+ </section>
936
+ }
937
+
938
+ @if (requestList().length) {
939
+ <section class="jc-card" data-testid="requests">
940
+ <h2>Requests</h2>
941
+ <table class="jc-table">
942
+ <thead><tr><th>Asked</th><th>Action</th><th>By, and why</th><th>State</th><th>Decided</th><th></th></tr></thead>
943
+ <tbody>
944
+ @for (r of requestList(); track r.id) {
945
+ <tr [attr.data-testid]="'request-' + r.id">
946
+ <td class="jc-nowrap">{{ r.requestedAt | date: 'MMM d, HH:mm:ss' }}</td>
947
+ <td><strong>{{ r.action }}</strong><div class="jc-muted jc-small">{{ r.risk }} risk</div></td>
948
+ <td>{{ r.requestedBy }}<div class="jc-small">{{ r.reason }}</div></td>
949
+ <td class="jc-nowrap"><span class="jc-badge" [class.jc-health-degraded]="r.state === 'Pending'" [class.jc-health-healthy]="r.state === 'Issued'"
950
+ [class.jc-health-none]="r.state !== 'Pending' && r.state !== 'Issued'" data-testid="request-state">{{ r.state === 'Pending' ? 'Waiting for approval' : r.state }}</span>
951
+ @if (r.state === 'Pending') { <div class="jc-muted jc-small">until {{ r.expiresAt | date: 'HH:mm' }}</div> }</td>
952
+ <td class="jc-small">@if (r.decidedBy) { {{ r.decidedBy }}, {{ r.decidedAt | date: 'HH:mm' }} }@if (r.comment) { <div>{{ r.comment }}</div> }</td>
953
+ <td class="jc-row-actions">@if (r.state === 'Pending') { <button mat-button type="button" [attr.data-testid]="'request-cancel-' + r.id" (click)="cancelRequest(r.id)">Cancel</button> }</td>
954
+ </tr>
955
+ }
956
+ </tbody>
957
+ </table>
958
+ </section>
959
+ }
960
+
961
+ <section class="jc-card" data-testid="commands">
962
+ <h2>Commands</h2>
963
+ @if (commands.error()) { <p class="jc-error">{{ commandsError() }}</p> }
964
+ <table class="jc-table">
965
+ <thead><tr><th>Issued</th><th>Action</th><th>By</th><th>State</th><th>Answer</th></tr></thead>
966
+ <tbody>
967
+ @for (c of allCommands(); track c.id) {
968
+ <tr [attr.data-testid]="'command-' + c.id">
969
+ <td class="jc-nowrap">{{ c.issuedAt | date: 'MMM d, HH:mm:ss' }}</td>
970
+ <td><strong>{{ c.action }}</strong>@if (describe(c); as d) { <div class="jc-small jc-mono">{{ d }}</div> }</td>
971
+ <td>{{ c.issuedBy }}</td>
972
+ <td class="jc-nowrap">
973
+ <span class="jc-badge" [class.jc-health-healthy]="c.state === 'Succeeded'" [class.jc-health-unhealthy]="c.state === 'Failed' || c.state === 'Rejected'"
974
+ [class.jc-health-degraded]="waiting(c)" [class.jc-health-none]="c.state === 'Expired' || c.state === 'Cancelled'" data-testid="command-state">{{ c.state }}</span>
975
+ @if (c.durationMs !== null) { <div class="jc-muted jc-small">{{ c.durationMs }} ms</div> }
976
+ </td>
977
+ <td class="jc-small" data-testid="command-answer">
978
+ @if (c.reason) { <div [class.jc-bad]="c.state !== 'Succeeded'">{{ c.reason | reason }}</div> }
979
+ @if (c.state === 'Succeeded' && c.result) {
980
+ @switch (c.action) {
981
+ @case ('host.summary') {
982
+ @if (summary(c); as h) {
983
+ <div>{{ h.hostname }} · {{ h.operatingSystem }} {{ h.architecture }} · up {{ uptime(h.uptimeSeconds) }}</div>
984
+ <div>{{ h.processorCount }} CPUs@if (h.loadAverage) { · load {{ h.loadAverage.join(' ') }} }@if (h.memoryTotalBytes) { · memory {{ bytes(h.memoryAvailableBytes) }} of {{ bytes(h.memoryTotalBytes) }} available }</div>
985
+ }
986
+ }
987
+ @case ('disk.usage') {
988
+ @if (disk(c); as d) {
989
+ <table class="jc-kv" data-testid="disk-result">
990
+ @for (f of fullestFirst(d, expanded().has(c.id)); track f.mountPoint) {
991
+ <tr [class.jc-bad]="low(f)">
992
+ <td class="jc-mono">{{ f.mountPoint }}</td><td>{{ f.format }}</td><td class="jc-nowrap">{{ bytes(f.availableBytes) }} free of {{ bytes(f.totalBytes) }}</td>
993
+ </tr>
994
+ } @empty { <tr><td class="jc-muted">No filesystems there.</td></tr> }
995
+ </table>
996
+ @if (d.filesystems.length > shown) {
997
+ <button mat-button type="button" [attr.data-testid]="'disk-toggle-' + c.id" (click)="toggle(c.id)">
998
+ {{ expanded().has(c.id) ? 'Show the fullest ' + shown : 'Show all ' + d.filesystems.length }}</button>
999
+ }
1000
+ @if (d.truncated) { <div class="jc-muted">More filesystems than the agent reports at once.</div> }
1001
+ }
1002
+ }
1003
+ @case ('tcp.reachability') {
1004
+ @if (tcp(c); as t) {
1005
+ @if (t.reachable) { <div>Reachable at {{ t.address }} in {{ t.elapsedMs }} ms</div> }
1006
+ @else { <div class="jc-bad">Not reachable after {{ t.elapsedMs }} ms: {{ t.error }}</div> }
1007
+ }
1008
+ }
1009
+ @default {
1010
+ @if (flat(c.result); as rows) {
1011
+ <table class="jc-kv" data-testid="custom-result">@for (r of rows; track r[0]) { <tr><td>{{ r[0] }}</td><td class="jc-mono">{{ r[1] }}</td></tr> }</table>
1012
+ } @else { <pre class="jc-mono" style="white-space: pre-wrap; margin: 0" data-testid="custom-result">{{ json(c.result) }}</pre> }
1013
+ }
1014
+ }
1015
+ }
1016
+ @if (waiting(c)) { <div class="jc-muted">{{ c.state === 'Pending' ? 'Waiting for the agent to call in' : 'Handed to the agent' }}, until {{ c.expiresAt | date: 'HH:mm:ss' }}</div> }
1017
+ </td>
1018
+ </tr>
1019
+ } @empty { <tr><td colspan="5" class="jc-muted">Nothing asked yet.</td></tr> }
1020
+ </tbody>
1021
+ </table>
1022
+ @if (nextCursor()) { <button mat-button type="button" data-testid="commands-older" (click)="loadOlder()">Older</button> }
1023
+ </section>
1024
+
1025
+ @if (a.status === 'Active') {
1026
+ <section class="jc-card">
1027
+ <h2>Revoke</h2>
1028
+ <p class="jc-muted jc-small">The agent stops at its next call: the platform refuses its certificate from then on, and commands still waiting are cancelled. It can't be undone; the host would enroll again with a new token.</p>
1029
+ <form class="jc-form" (ngSubmit)="revoke()">
1030
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Why</mat-label><input matInput name="reason" data-testid="revoke-reason" [(ngModel)]="reason" maxlength="500" (ngModelChange)="confirming.set(false)"></mat-form-field>
1031
+ @if (confirming()) {
1032
+ <button mat-flat-button color="warn" type="submit" data-testid="revoke-confirm" [disabled]="revoking()">Revoke {{ a.hostname }}</button>
1033
+ <button mat-button type="button" (click)="confirming.set(false)">Cancel</button>
1034
+ } @else {
1035
+ <button mat-stroked-button type="submit" data-testid="revoke" [disabled]="!reason.trim()">Revoke</button>
1036
+ }
1037
+ @if (revokeError()) { <span class="jc-error" data-testid="revoke-error">{{ revokeError() }}</span> }
1038
+ </form>
1039
+ </section>
1040
+ }
1041
+ }`
1042
+ }]
1043
+ }],
1044
+ ctorParameters: () => [],
1045
+ propDecorators: { id: [{
1046
+ type: i0.Input,
1047
+ args: [{
1048
+ isSignal: true,
1049
+ alias: "id",
1050
+ required: true
1051
+ }]
1052
+ }] }
1053
+ });
1054
+ export { AgentPage };
1055
+
1056
+ //# sourceMappingURL=juice-js-observability-agent.page-D6nP3YbF.mjs.map