@juice-js/observability 1.1.0 → 1.2.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.
Files changed (66) hide show
  1. package/README.md +4 -2
  2. package/fesm2022/juice-js-observability-agent.page-Vb7LDThl.mjs +1144 -0
  3. package/fesm2022/juice-js-observability-agent.page-Vb7LDThl.mjs.map +1 -0
  4. package/fesm2022/juice-js-observability-agents.page-Ch-tBwQO.mjs +413 -0
  5. package/fesm2022/juice-js-observability-agents.page-Ch-tBwQO.mjs.map +1 -0
  6. package/fesm2022/{juice-js-observability-alert.page-nEy5Gc6j.mjs → juice-js-observability-alert.page-2kfKksIG.mjs} +200 -4
  7. package/fesm2022/juice-js-observability-alert.page-2kfKksIG.mjs.map +1 -0
  8. package/fesm2022/{juice-js-observability-alerts.page-DUXXBanH.mjs → juice-js-observability-alerts.page-BNmez0Ak.mjs} +2 -2
  9. package/fesm2022/{juice-js-observability-alerts.page-DUXXBanH.mjs.map → juice-js-observability-alerts.page-BNmez0Ak.mjs.map} +1 -1
  10. package/fesm2022/juice-js-observability-approvals.page-DBLw-vl1.mjs +387 -0
  11. package/fesm2022/juice-js-observability-approvals.page-DBLw-vl1.mjs.map +1 -0
  12. package/fesm2022/juice-js-observability-incident.page-D2GvuIft.mjs +436 -0
  13. package/fesm2022/juice-js-observability-incident.page-D2GvuIft.mjs.map +1 -0
  14. package/fesm2022/juice-js-observability-incidents.page-DhC3BkBo.mjs +438 -0
  15. package/fesm2022/juice-js-observability-incidents.page-DhC3BkBo.mjs.map +1 -0
  16. package/fesm2022/juice-js-observability-load-runs.page-DVuO4zFp.mjs +349 -0
  17. package/fesm2022/juice-js-observability-load-runs.page-DVuO4zFp.mjs.map +1 -0
  18. package/fesm2022/{juice-js-observability-logs.page-i76xbJLH.mjs → juice-js-observability-logs.page-PXWQMcvL.mjs} +3 -3
  19. package/fesm2022/{juice-js-observability-logs.page-i76xbJLH.mjs.map → juice-js-observability-logs.page-PXWQMcvL.mjs.map} +1 -1
  20. package/fesm2022/{juice-js-observability-metrics.page-Cq5S0yGJ.mjs → juice-js-observability-metrics.page-Ctm_EEFb.mjs} +3 -3
  21. package/fesm2022/{juice-js-observability-metrics.page-Cq5S0yGJ.mjs.map → juice-js-observability-metrics.page-Ctm_EEFb.mjs.map} +1 -1
  22. package/fesm2022/juice-js-observability-notifications.page-CtcV3Ei4.mjs +758 -0
  23. package/fesm2022/juice-js-observability-notifications.page-CtcV3Ei4.mjs.map +1 -0
  24. package/fesm2022/{juice-js-observability-overview.page-DXZl_fUh.mjs → juice-js-observability-overview.page-BRGpTOyc.mjs} +3 -3
  25. package/fesm2022/{juice-js-observability-overview.page-DXZl_fUh.mjs.map → juice-js-observability-overview.page-BRGpTOyc.mjs.map} +1 -1
  26. package/fesm2022/{juice-js-observability-resource.page-CauDE6kK.mjs → juice-js-observability-resource.page-O4GGdirR.mjs} +2 -2
  27. package/fesm2022/{juice-js-observability-resource.page-CauDE6kK.mjs.map → juice-js-observability-resource.page-O4GGdirR.mjs.map} +1 -1
  28. package/fesm2022/{juice-js-observability-resources.page-CukW8vVc.mjs → juice-js-observability-resources.page-B_AVPpes.mjs} +2 -2
  29. package/fesm2022/{juice-js-observability-resources.page-CukW8vVc.mjs.map → juice-js-observability-resources.page-B_AVPpes.mjs.map} +1 -1
  30. package/fesm2022/juice-js-observability-rules.page-CARCWaw_.mjs +581 -0
  31. package/fesm2022/juice-js-observability-rules.page-CARCWaw_.mjs.map +1 -0
  32. package/fesm2022/juice-js-observability-service.page-DRj1GO0Q.mjs +1257 -0
  33. package/fesm2022/juice-js-observability-service.page-DRj1GO0Q.mjs.map +1 -0
  34. package/fesm2022/{juice-js-observability-services.page-B1huLe_a.mjs → juice-js-observability-services.page-BbFbbvyH.mjs} +3 -3
  35. package/fesm2022/{juice-js-observability-services.page-B1huLe_a.mjs.map → juice-js-observability-services.page-BbFbbvyH.mjs.map} +1 -1
  36. package/fesm2022/juice-js-observability-silences.page-CoTqfGxY.mjs +523 -0
  37. package/fesm2022/juice-js-observability-silences.page-CoTqfGxY.mjs.map +1 -0
  38. package/fesm2022/juice-js-observability-slo.page-l7TOat-D.mjs +414 -0
  39. package/fesm2022/juice-js-observability-slo.page-l7TOat-D.mjs.map +1 -0
  40. package/fesm2022/juice-js-observability-slos.page-DNG6g6_R.mjs +267 -0
  41. package/fesm2022/juice-js-observability-slos.page-DNG6g6_R.mjs.map +1 -0
  42. package/fesm2022/juice-js-observability-suggestions-eQK_z0Nd.mjs +367 -0
  43. package/fesm2022/juice-js-observability-suggestions-eQK_z0Nd.mjs.map +1 -0
  44. package/fesm2022/{juice-js-observability-telemetry-BftWSOaQ.mjs → juice-js-observability-telemetry-DVwUTHSz.mjs} +101 -91
  45. package/fesm2022/juice-js-observability-telemetry-DVwUTHSz.mjs.map +1 -0
  46. package/fesm2022/juice-js-observability-timeline.page-CFSigOgk.mjs +213 -0
  47. package/fesm2022/juice-js-observability-timeline.page-CFSigOgk.mjs.map +1 -0
  48. package/fesm2022/{juice-js-observability-topology.page-aMWEXyMB.mjs → juice-js-observability-topology.page-BDfNpiql.mjs} +56 -4
  49. package/fesm2022/juice-js-observability-topology.page-BDfNpiql.mjs.map +1 -0
  50. package/fesm2022/{juice-js-observability-trace.page-DUCWnZL5.mjs → juice-js-observability-trace.page-CdW09ADY.mjs} +10 -8
  51. package/fesm2022/juice-js-observability-trace.page-CdW09ADY.mjs.map +1 -0
  52. package/fesm2022/{juice-js-observability-traces.page-DXSDdeTH.mjs → juice-js-observability-traces.page-CMuItN_m.mjs} +3 -3
  53. package/fesm2022/{juice-js-observability-traces.page-DXSDdeTH.mjs.map → juice-js-observability-traces.page-CMuItN_m.mjs.map} +1 -1
  54. package/fesm2022/juice-js-observability.mjs +507 -110
  55. package/fesm2022/juice-js-observability.mjs.map +1 -1
  56. package/package.json +1 -1
  57. package/styles/_observability.scss +26 -3
  58. package/types/juice-js-observability.d.ts +623 -1
  59. package/fesm2022/juice-js-observability-alert.page-nEy5Gc6j.mjs.map +0 -1
  60. package/fesm2022/juice-js-observability-rules.page-Crb07uWm.mjs +0 -175
  61. package/fesm2022/juice-js-observability-rules.page-Crb07uWm.mjs.map +0 -1
  62. package/fesm2022/juice-js-observability-service.page-Dt8bN2Ry.mjs +0 -726
  63. package/fesm2022/juice-js-observability-service.page-Dt8bN2Ry.mjs.map +0 -1
  64. package/fesm2022/juice-js-observability-telemetry-BftWSOaQ.mjs.map +0 -1
  65. package/fesm2022/juice-js-observability-topology.page-aMWEXyMB.mjs.map +0 -1
  66. package/fesm2022/juice-js-observability-trace.page-DUCWnZL5.mjs.map +0 -1
@@ -0,0 +1,436 @@
1
+ import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
2
+ import { c as ContextBar, h as apiResource, o as problemText } from "./juice-js-observability-telemetry-DVwUTHSz.mjs";
3
+ import { t as SuggestionsCard } from "./juice-js-observability-suggestions-eQK_z0Nd.mjs";
4
+ import * as i0 from "@angular/core";
5
+ import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from "@angular/core";
6
+ import { RouterLink } from "@angular/router";
7
+ import { DatePipe } from "@angular/common";
8
+ import * as i1 from "@angular/forms";
9
+ import { FormsModule } from "@angular/forms";
10
+ import * as i2 from "@angular/material/button";
11
+ import { MatButtonModule } from "@angular/material/button";
12
+ import { MatFormFieldModule } from "@angular/material/form-field";
13
+ import * as i4 from "@angular/material/input";
14
+ import { MatInputModule } from "@angular/material/input";
15
+ import * as i5 from "@angular/material/progress-bar";
16
+ import { MatProgressBarModule } from "@angular/material/progress-bar";
17
+ import * as i3 from "@angular/material/select";
18
+ const MOVES = {
19
+ Open: [
20
+ "Investigating",
21
+ "Mitigated",
22
+ "Resolved"
23
+ ],
24
+ Investigating: ["Mitigated", "Resolved"],
25
+ Mitigated: ["Investigating", "Resolved"],
26
+ Resolved: ["Investigating"]
27
+ };
28
+ var IncidentPage = class IncidentPage {
29
+ ctx = inject(ContextService);
30
+ api = inject(ApiService);
31
+ id = input.required(...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
32
+ text = "";
33
+ sending = signal(false, ...ngDevMode ? [{ debugName: "sending" }] : /* istanbul ignore next */ []);
34
+ actionError = signal("", ...ngDevMode ? [{ debugName: "actionError" }] : /* istanbul ignore next */ []);
35
+ detail = apiResource({
36
+ params: () => this.id(),
37
+ stream: ({ params }) => this.api.incident(params)
38
+ });
39
+ error = computed(() => problemText(this.detail.error()), ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
40
+ suggestions = apiResource({
41
+ params: () => this.detail.value() && this.detail.value().incident.state !== "Resolved" ? this.id() : void 0,
42
+ stream: ({ params }) => this.api.incidentSuggestions(params)
43
+ });
44
+ suggestionsError = computed(() => problemText(this.suggestions.error()), ...ngDevMode ? [{ debugName: "suggestionsError" }] : /* istanbul ignore next */ []);
45
+ decided() {
46
+ this.detail.reload();
47
+ this.suggestions.reload();
48
+ }
49
+ moves(state) {
50
+ return MOVES[state] ?? [];
51
+ }
52
+ describe(e) {
53
+ switch (e.type) {
54
+ case "created": return "Opened";
55
+ case "state": return `${e.from} → ${e.to}`;
56
+ case "note": return "Note";
57
+ case "alert_added": return "Alert added";
58
+ case "alert_removed": return "Alert removed";
59
+ default: return e.type;
60
+ }
61
+ }
62
+ run(request) {
63
+ this.sending.set(true);
64
+ this.actionError.set("");
65
+ request.subscribe({
66
+ next: () => {
67
+ this.sending.set(false);
68
+ this.text = "";
69
+ this.detail.reload();
70
+ },
71
+ error: (e) => {
72
+ this.sending.set(false);
73
+ this.actionError.set(e.status === 403 ? "This needs the operator or admin role." : problemText(e));
74
+ }
75
+ });
76
+ }
77
+ move(to) {
78
+ this.run(this.api.moveIncident(this.id(), to, this.text));
79
+ }
80
+ note() {
81
+ this.run(this.api.addIncidentNote(this.id(), this.text));
82
+ }
83
+ removeAlert(alertId) {
84
+ this.run(this.api.removeIncidentAlert(this.id(), alertId));
85
+ }
86
+ static ɵfac = i0.ɵɵngDeclareFactory({
87
+ minVersion: "12.0.0",
88
+ version: "22.2.4",
89
+ ngImport: i0,
90
+ type: IncidentPage,
91
+ deps: [],
92
+ target: i0.ɵɵFactoryTarget.Component
93
+ });
94
+ static ɵcmp = i0.ɵɵngDeclareComponent({
95
+ minVersion: "17.0.0",
96
+ version: "22.2.4",
97
+ type: IncidentPage,
98
+ isStandalone: true,
99
+ selector: "ng-component",
100
+ inputs: { id: {
101
+ classPropertyName: "id",
102
+ publicName: "id",
103
+ isSignal: true,
104
+ isRequired: true,
105
+ transformFunction: null
106
+ } },
107
+ ngImport: i0,
108
+ template: `
109
+ <jc-context-bar>
110
+ <a [routerLink]="['incidents'] | jcLink" [queryParams]="ctx.keep()" class="jc-crumb">Incidents</a><span class="jc-crumb-sep">›</span>
111
+ <h1>{{ detail.value()?.incident?.title ?? '…' }}</h1>
112
+ </jc-context-bar>
113
+ @if (detail.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
114
+ @if (detail.error()) { <p class="jc-error">{{ error() }}</p> }
115
+ @if (detail.value(); as d) {
116
+ <div class="jc-summary">
117
+ <span class="jc-badge" [class.jc-health-unhealthy]="d.incident.severity === 'Critical'" [class.jc-health-degraded]="d.incident.severity === 'Warning'">{{ d.incident.severity }}</span>
118
+ <strong data-testid="incident-state">{{ d.incident.state }}</strong>
119
+ <span class="jc-muted">Opened by {{ d.incident.createdBy }} {{ d.incident.createdAt | date: 'MMM d, HH:mm' }}</span>
120
+ </div>
121
+ @if (d.incident.state !== 'Resolved' && d.openAlerts > 0) {
122
+ <p class="jc-notice" data-testid="incident-open-alerts">{{ d.openAlerts }} of its alerts {{ d.openAlerts === 1 ? 'is' : 'are' }} still open. Resolving the incident won't change them.</p>
123
+ }
124
+ <section class="jc-card">
125
+ <h2>Move or note</h2>
126
+ <form class="jc-form" (ngSubmit)="note()">
127
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Comment or note</mat-label><input matInput name="text" data-testid="incident-text" [(ngModel)]="text" maxlength="2000"></mat-form-field>
128
+ <button mat-stroked-button type="submit" data-testid="incident-note" [disabled]="sending()">Add note</button>
129
+ @for (m of moves(d.incident.state); track m) {
130
+ <button mat-flat-button type="button" [attr.data-testid]="'incident-move-' + m" [disabled]="sending()" (click)="move(m)">{{ d.incident.state === 'Resolved' ? 'Reopen' : m }}</button>
131
+ }
132
+ @if (actionError()) { <span class="jc-error" data-testid="incident-action-error">{{ actionError() }}</span> }
133
+ </form>
134
+ </section>
135
+ <section class="jc-card" data-testid="incident-alerts">
136
+ <h2>Alerts</h2>
137
+ <table class="jc-table"><tbody>
138
+ @for (a of d.alerts; track a.id) {
139
+ <tr>
140
+ <td><a [routerLink]="['alerts', a.id] | jcLink" [queryParams]="ctx.keep()">{{ a.rule }}</a></td>
141
+ <td>{{ a.subjectKey }}</td><td>{{ a.severity }}</td><td>{{ a.state }}</td>
142
+ <td class="jc-row-actions"><button mat-button type="button" (click)="removeAlert(a.id)">Remove</button></td>
143
+ </tr>
144
+ } @empty { <tr><td class="jc-muted">None. Open an alert and use “Open an incident”, or add one through the API.</td></tr> }
145
+ </tbody></table>
146
+ </section>
147
+ @if (d.incident.state !== 'Resolved') {
148
+ <section class="jc-card" data-testid="incident-suggestions">
149
+ <h2>Suggested alerts</h2>
150
+ <jc-suggestions [suggestions]="suggestions.value()" [withAlert]="true" [incident]="d.incident.id" (decided)="decided()" />
151
+ @if (suggestions.error()) { <p class="jc-error">{{ suggestionsError() }}</p> }
152
+ </section>
153
+ }
154
+ <section class="jc-card" data-testid="incident-events">
155
+ <h2>What happened</h2>
156
+ <table class="jc-table"><tbody>
157
+ @for (e of d.events; track $index) {
158
+ <tr>
159
+ <td class="jc-nowrap">{{ e.at | date: 'MMM d, HH:mm:ss' }}</td>
160
+ <td>{{ e.actor }}</td>
161
+ <td><strong>{{ describe(e) }}</strong>@if (e.text) { <div>{{ e.text }}</div> }</td>
162
+ </tr>
163
+ }
164
+ </tbody></table>
165
+ </section>
166
+ }`,
167
+ isInline: true,
168
+ dependencies: [
169
+ {
170
+ kind: "directive",
171
+ type: RouterLink,
172
+ selector: "[routerLink]",
173
+ inputs: [
174
+ "target",
175
+ "queryParams",
176
+ "fragment",
177
+ "queryParamsHandling",
178
+ "state",
179
+ "info",
180
+ "relativeTo",
181
+ "preserveFragment",
182
+ "skipLocationChange",
183
+ "replaceUrl",
184
+ "browserUrl",
185
+ "routerLink"
186
+ ]
187
+ },
188
+ {
189
+ kind: "ngmodule",
190
+ type: FormsModule
191
+ },
192
+ {
193
+ kind: "directive",
194
+ type: i1.ɵNgNoValidate,
195
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
196
+ },
197
+ {
198
+ kind: "directive",
199
+ type: i1.DefaultValueAccessor,
200
+ 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]"
201
+ },
202
+ {
203
+ kind: "directive",
204
+ type: i1.NgControlStatus,
205
+ selector: "[formControlName],[ngModel],[formControl]"
206
+ },
207
+ {
208
+ kind: "directive",
209
+ type: i1.NgControlStatusGroup,
210
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
211
+ },
212
+ {
213
+ kind: "directive",
214
+ type: i1.MaxLengthValidator,
215
+ selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]",
216
+ inputs: ["maxlength"]
217
+ },
218
+ {
219
+ kind: "directive",
220
+ type: i1.NgModel,
221
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
222
+ inputs: [
223
+ "name",
224
+ "disabled",
225
+ "ngModel",
226
+ "ngModelOptions"
227
+ ],
228
+ outputs: ["ngModelChange"],
229
+ exportAs: ["ngModel"]
230
+ },
231
+ {
232
+ kind: "directive",
233
+ type: i1.NgForm,
234
+ selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
235
+ inputs: ["ngFormOptions"],
236
+ outputs: ["ngSubmit"],
237
+ exportAs: ["ngForm"]
238
+ },
239
+ {
240
+ kind: "ngmodule",
241
+ type: MatButtonModule
242
+ },
243
+ {
244
+ kind: "component",
245
+ type: i2.MatButton,
246
+ 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] ",
247
+ inputs: ["matButton"],
248
+ exportAs: ["matButton", "matAnchor"]
249
+ },
250
+ {
251
+ kind: "ngmodule",
252
+ type: MatFormFieldModule
253
+ },
254
+ {
255
+ kind: "component",
256
+ type: i3.MatFormField,
257
+ selector: "mat-form-field",
258
+ inputs: [
259
+ "hideRequiredMarker",
260
+ "color",
261
+ "floatLabel",
262
+ "appearance",
263
+ "subscriptSizing",
264
+ "hintLabel"
265
+ ],
266
+ exportAs: ["matFormField"]
267
+ },
268
+ {
269
+ kind: "directive",
270
+ type: i3.MatLabel,
271
+ selector: "mat-label"
272
+ },
273
+ {
274
+ kind: "ngmodule",
275
+ type: MatInputModule
276
+ },
277
+ {
278
+ kind: "directive",
279
+ type: i4.MatInput,
280
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
281
+ inputs: [
282
+ "disabled",
283
+ "id",
284
+ "placeholder",
285
+ "name",
286
+ "required",
287
+ "type",
288
+ "errorStateMatcher",
289
+ "aria-describedby",
290
+ "value",
291
+ "readonly",
292
+ "disabledInteractive"
293
+ ],
294
+ exportAs: ["matInput"]
295
+ },
296
+ {
297
+ kind: "ngmodule",
298
+ type: MatProgressBarModule
299
+ },
300
+ {
301
+ kind: "component",
302
+ type: i5.MatProgressBar,
303
+ selector: "mat-progress-bar",
304
+ inputs: [
305
+ "color",
306
+ "value",
307
+ "bufferValue",
308
+ "mode"
309
+ ],
310
+ outputs: ["animationEnd"],
311
+ exportAs: ["matProgressBar"]
312
+ },
313
+ {
314
+ kind: "component",
315
+ type: ContextBar,
316
+ selector: "jc-context-bar"
317
+ },
318
+ {
319
+ kind: "component",
320
+ type: SuggestionsCard,
321
+ selector: "jc-suggestions",
322
+ inputs: [
323
+ "suggestions",
324
+ "withAlert",
325
+ "incident"
326
+ ],
327
+ outputs: ["decided"]
328
+ },
329
+ {
330
+ kind: "pipe",
331
+ type: LinkPipe,
332
+ name: "jcLink"
333
+ },
334
+ {
335
+ kind: "pipe",
336
+ type: DatePipe,
337
+ name: "date"
338
+ }
339
+ ],
340
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
341
+ });
342
+ };
343
+ i0.ɵɵngDeclareClassMetadata({
344
+ minVersion: "12.0.0",
345
+ version: "22.2.4",
346
+ ngImport: i0,
347
+ type: IncidentPage,
348
+ decorators: [{
349
+ type: Component,
350
+ args: [{
351
+ changeDetection: ChangeDetectionStrategy.OnPush,
352
+ imports: [
353
+ LinkPipe,
354
+ RouterLink,
355
+ DatePipe,
356
+ FormsModule,
357
+ MatButtonModule,
358
+ MatFormFieldModule,
359
+ MatInputModule,
360
+ MatProgressBarModule,
361
+ ContextBar,
362
+ SuggestionsCard
363
+ ],
364
+ template: `
365
+ <jc-context-bar>
366
+ <a [routerLink]="['incidents'] | jcLink" [queryParams]="ctx.keep()" class="jc-crumb">Incidents</a><span class="jc-crumb-sep">›</span>
367
+ <h1>{{ detail.value()?.incident?.title ?? '…' }}</h1>
368
+ </jc-context-bar>
369
+ @if (detail.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
370
+ @if (detail.error()) { <p class="jc-error">{{ error() }}</p> }
371
+ @if (detail.value(); as d) {
372
+ <div class="jc-summary">
373
+ <span class="jc-badge" [class.jc-health-unhealthy]="d.incident.severity === 'Critical'" [class.jc-health-degraded]="d.incident.severity === 'Warning'">{{ d.incident.severity }}</span>
374
+ <strong data-testid="incident-state">{{ d.incident.state }}</strong>
375
+ <span class="jc-muted">Opened by {{ d.incident.createdBy }} {{ d.incident.createdAt | date: 'MMM d, HH:mm' }}</span>
376
+ </div>
377
+ @if (d.incident.state !== 'Resolved' && d.openAlerts > 0) {
378
+ <p class="jc-notice" data-testid="incident-open-alerts">{{ d.openAlerts }} of its alerts {{ d.openAlerts === 1 ? 'is' : 'are' }} still open. Resolving the incident won't change them.</p>
379
+ }
380
+ <section class="jc-card">
381
+ <h2>Move or note</h2>
382
+ <form class="jc-form" (ngSubmit)="note()">
383
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Comment or note</mat-label><input matInput name="text" data-testid="incident-text" [(ngModel)]="text" maxlength="2000"></mat-form-field>
384
+ <button mat-stroked-button type="submit" data-testid="incident-note" [disabled]="sending()">Add note</button>
385
+ @for (m of moves(d.incident.state); track m) {
386
+ <button mat-flat-button type="button" [attr.data-testid]="'incident-move-' + m" [disabled]="sending()" (click)="move(m)">{{ d.incident.state === 'Resolved' ? 'Reopen' : m }}</button>
387
+ }
388
+ @if (actionError()) { <span class="jc-error" data-testid="incident-action-error">{{ actionError() }}</span> }
389
+ </form>
390
+ </section>
391
+ <section class="jc-card" data-testid="incident-alerts">
392
+ <h2>Alerts</h2>
393
+ <table class="jc-table"><tbody>
394
+ @for (a of d.alerts; track a.id) {
395
+ <tr>
396
+ <td><a [routerLink]="['alerts', a.id] | jcLink" [queryParams]="ctx.keep()">{{ a.rule }}</a></td>
397
+ <td>{{ a.subjectKey }}</td><td>{{ a.severity }}</td><td>{{ a.state }}</td>
398
+ <td class="jc-row-actions"><button mat-button type="button" (click)="removeAlert(a.id)">Remove</button></td>
399
+ </tr>
400
+ } @empty { <tr><td class="jc-muted">None. Open an alert and use “Open an incident”, or add one through the API.</td></tr> }
401
+ </tbody></table>
402
+ </section>
403
+ @if (d.incident.state !== 'Resolved') {
404
+ <section class="jc-card" data-testid="incident-suggestions">
405
+ <h2>Suggested alerts</h2>
406
+ <jc-suggestions [suggestions]="suggestions.value()" [withAlert]="true" [incident]="d.incident.id" (decided)="decided()" />
407
+ @if (suggestions.error()) { <p class="jc-error">{{ suggestionsError() }}</p> }
408
+ </section>
409
+ }
410
+ <section class="jc-card" data-testid="incident-events">
411
+ <h2>What happened</h2>
412
+ <table class="jc-table"><tbody>
413
+ @for (e of d.events; track $index) {
414
+ <tr>
415
+ <td class="jc-nowrap">{{ e.at | date: 'MMM d, HH:mm:ss' }}</td>
416
+ <td>{{ e.actor }}</td>
417
+ <td><strong>{{ describe(e) }}</strong>@if (e.text) { <div>{{ e.text }}</div> }</td>
418
+ </tr>
419
+ }
420
+ </tbody></table>
421
+ </section>
422
+ }`
423
+ }]
424
+ }],
425
+ propDecorators: { id: [{
426
+ type: i0.Input,
427
+ args: [{
428
+ isSignal: true,
429
+ alias: "id",
430
+ required: true
431
+ }]
432
+ }] }
433
+ });
434
+ export { IncidentPage };
435
+
436
+ //# sourceMappingURL=juice-js-observability-incident.page-D2GvuIft.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"juice-js-observability-incident.page-D2GvuIft.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/incident.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { DatePipe } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatFormFieldModule } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MatProgressBarModule } from '@angular/material/progress-bar';\nimport { RouterLink } from '@angular/router';\nimport { Observable } from 'rxjs';\nimport { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { IncidentEvent } from '../core/models';\nimport { apiResource } from '../shared/resource';\nimport { problemText } from '../shared/telemetry';\nimport { ContextBar } from '../shared/ui';\nimport { SuggestionsCard } from '../shared/suggestions';\n\nconst MOVES: Record<string, string[]> = {\n Open: ['Investigating', 'Mitigated', 'Resolved'],\n Investigating: ['Mitigated', 'Resolved'],\n Mitigated: ['Investigating', 'Resolved'],\n Resolved: ['Investigating'],\n};\n\n/** One incident: its state and the moves from it, its alerts, and who did what. Resolving it changes no alert, and says so if some are still open. */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, DatePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule, ContextBar, SuggestionsCard],\n template: `\n <jc-context-bar>\n <a [routerLink]=\"['incidents'] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-crumb\">Incidents</a><span class=\"jc-crumb-sep\">›</span>\n <h1>{{ detail.value()?.incident?.title ?? '…' }}</h1>\n </jc-context-bar>\n @if (detail.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (detail.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n @if (detail.value(); as d) {\n <div class=\"jc-summary\">\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"d.incident.severity === 'Critical'\" [class.jc-health-degraded]=\"d.incident.severity === 'Warning'\">{{ d.incident.severity }}</span>\n <strong data-testid=\"incident-state\">{{ d.incident.state }}</strong>\n <span class=\"jc-muted\">Opened by {{ d.incident.createdBy }} {{ d.incident.createdAt | date: 'MMM d, HH:mm' }}</span>\n </div>\n @if (d.incident.state !== 'Resolved' && d.openAlerts > 0) {\n <p class=\"jc-notice\" data-testid=\"incident-open-alerts\">{{ d.openAlerts }} of its alerts {{ d.openAlerts === 1 ? 'is' : 'are' }} still open. Resolving the incident won't change them.</p>\n }\n <section class=\"jc-card\">\n <h2>Move or note</h2>\n <form class=\"jc-form\" (ngSubmit)=\"note()\">\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-wide\"><mat-label>Comment or note</mat-label><input matInput name=\"text\" data-testid=\"incident-text\" [(ngModel)]=\"text\" maxlength=\"2000\"></mat-form-field>\n <button mat-stroked-button type=\"submit\" data-testid=\"incident-note\" [disabled]=\"sending()\">Add note</button>\n @for (m of moves(d.incident.state); track m) {\n <button mat-flat-button type=\"button\" [attr.data-testid]=\"'incident-move-' + m\" [disabled]=\"sending()\" (click)=\"move(m)\">{{ d.incident.state === 'Resolved' ? 'Reopen' : m }}</button>\n }\n @if (actionError()) { <span class=\"jc-error\" data-testid=\"incident-action-error\">{{ actionError() }}</span> }\n </form>\n </section>\n <section class=\"jc-card\" data-testid=\"incident-alerts\">\n <h2>Alerts</h2>\n <table class=\"jc-table\"><tbody>\n @for (a of d.alerts; track a.id) {\n <tr>\n <td><a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.rule }}</a></td>\n <td>{{ a.subjectKey }}</td><td>{{ a.severity }}</td><td>{{ a.state }}</td>\n <td class=\"jc-row-actions\"><button mat-button type=\"button\" (click)=\"removeAlert(a.id)\">Remove</button></td>\n </tr>\n } @empty { <tr><td class=\"jc-muted\">None. Open an alert and use “Open an incident”, or add one through the API.</td></tr> }\n </tbody></table>\n </section>\n @if (d.incident.state !== 'Resolved') {\n <section class=\"jc-card\" data-testid=\"incident-suggestions\">\n <h2>Suggested alerts</h2>\n <jc-suggestions [suggestions]=\"suggestions.value()\" [withAlert]=\"true\" [incident]=\"d.incident.id\" (decided)=\"decided()\" />\n @if (suggestions.error()) { <p class=\"jc-error\">{{ suggestionsError() }}</p> }\n </section>\n }\n <section class=\"jc-card\" data-testid=\"incident-events\">\n <h2>What happened</h2>\n <table class=\"jc-table\"><tbody>\n @for (e of d.events; track $index) {\n <tr>\n <td class=\"jc-nowrap\">{{ e.at | date: 'MMM d, HH:mm:ss' }}</td>\n <td>{{ e.actor }}</td>\n <td><strong>{{ describe(e) }}</strong>@if (e.text) { <div>{{ e.text }}</div> }</td>\n </tr>\n }\n </tbody></table>\n </section>\n }`,\n})\nexport class IncidentPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n readonly id = input.required<string>();\n protected text = '';\n protected readonly sending = signal(false);\n protected readonly actionError = signal('');\n\n protected readonly detail = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.incident(params) });\n protected readonly error = computed(() => problemText(this.detail.error()));\n /** A resolved incident is suggested nothing, so its page doesn't ask. */\n protected readonly suggestions = apiResource({\n params: () => (this.detail.value() && this.detail.value()!.incident.state !== 'Resolved' ? this.id() : undefined),\n stream: ({ params }) => this.api.incidentSuggestions(params),\n });\n protected readonly suggestionsError = computed(() => problemText(this.suggestions.error()));\n\n protected decided() { this.detail.reload(); this.suggestions.reload(); }\n\n protected moves(state: string): string[] { return MOVES[state] ?? []; }\n\n protected describe(e: IncidentEvent): string {\n switch (e.type) {\n case 'created': return 'Opened';\n case 'state': return `${e.from} → ${e.to}`;\n case 'note': return 'Note';\n case 'alert_added': return 'Alert added';\n case 'alert_removed': return 'Alert removed';\n default: return e.type;\n }\n }\n\n private run<T>(request: Observable<T>) {\n this.sending.set(true);\n this.actionError.set('');\n request.subscribe({\n next: () => { this.sending.set(false); this.text = ''; this.detail.reload(); },\n error: e => { this.sending.set(false); this.actionError.set((e as { status?: number }).status === 403 ? 'This needs the operator or admin role.' : problemText(e)); },\n });\n }\n\n protected move(to: string) { this.run(this.api.moveIncident(this.id(), to, this.text)); }\n protected note() { this.run(this.api.addIncidentNote(this.id(), this.text)); }\n protected removeAlert(alertId: string) { this.run(this.api.removeIncidentAlert(this.id(), alertId)); }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAM,QAAkC;CACtC,MAAM;EAAC;EAAiB;EAAa;CAAU;CAC/C,eAAe,CAAC,aAAa,UAAU;CACvC,WAAW,CAAC,iBAAiB,UAAU;CACvC,UAAU,CAAC,eAAe;AAC3B;AAkED,IAAa,eAAb,MAAa,aAAY;CACJ,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CAC/B,KAAK,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAC5B,OAAO;CACE,UAAU,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,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