@juice-js/observability 1.5.0-alpha.46 → 1.5.0-alpha.93

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.
@@ -1,9 +1,9 @@
1
- import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
1
+ import { ApiService, ContextService, LinkPipe, ObservabilityLinks } from "./juice-js-observability.mjs";
2
2
  import { c as ContextBar, g as AgoPipe, h as apiResource, l as HealthBadge, o as problemText, u as KeyValueTable, y as ReasonPipe } from "./juice-js-observability-telemetry-BG91FqGp.mjs";
3
3
  import { t as SuggestionsCard } from "./juice-js-observability-suggestions-CgXS6o6u.mjs";
4
4
  import * as i0 from "@angular/core";
5
5
  import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from "@angular/core";
6
- import { DatePipe, LowerCasePipe } from "@angular/common";
6
+ import { DatePipe } from "@angular/common";
7
7
  import { RouterLink } from "@angular/router";
8
8
  import * as i1 from "@angular/forms";
9
9
  import { FormsModule } from "@angular/forms";
@@ -37,6 +37,14 @@ var AlertPage = class AlertPage {
37
37
  stream: ({ params }) => this.api.alertNotifications(params)
38
38
  });
39
39
  notificationsError = computed(() => problemText(this.notifications.error()), ...ngDevMode ? [{ debugName: "notificationsError" }] : /* istanbul ignore next */ []);
40
+ links = inject(ObservabilityLinks);
41
+ correlation(key) {
42
+ const l = this.links.correlation(key);
43
+ return l ? {
44
+ href: "href" in l ? l.href : null,
45
+ route: "route" in l ? l.route : []
46
+ } : null;
47
+ }
40
48
  suggestions = apiResource({
41
49
  params: () => this.detail.value()?.alert.state === "Firing" ? this.id() : void 0,
42
50
  stream: ({ params }) => this.api.alertSuggestions(params)
@@ -200,24 +208,10 @@ var AlertPage = class AlertPage {
200
208
  <section class="jc-card" data-testid="alert-notifications">
201
209
  <h2>Notifications</h2>
202
210
  @if (notifications.value(); as n) {
203
- @for (e of n.escalations; track e.policy) {
204
- <p>Escalation <strong>{{ e.name }}</strong>: {{ e.stepsSent }} of {{ e.steps }} steps sent, {{ e.state | lowercase }}@if (e.stopReason) { ({{ e.stopReason | reason }}) }@if (e.nextAt) {, next at {{ e.nextAt | date: 'HH:mm:ss' }} }</p>
205
- }
206
- <table class="jc-table">
207
- <thead><tr><th>To</th><th>Event</th><th>Status</th><th>Attempts</th><th>Detail</th><th>When</th></tr></thead>
208
- <tbody>
209
- @for (x of n.deliveries; track x.delivery.id) {
210
- <tr>
211
- <td>{{ x.endpointKey }} <span class="jc-muted jc-small">{{ x.kind }}</span></td>
212
- <td>{{ x.delivery.event }}@if (x.delivery.escalationStep) { step {{ x.delivery.escalationStep }} }</td>
213
- <td [class.jc-bad]="x.delivery.status === 'Failed'">{{ x.delivery.status }}</td>
214
- <td>{{ x.delivery.attempts }}</td>
215
- <td class="jc-small">{{ x.delivery.lastError }}@if (x.delivery.nextAttemptAt && x.delivery.status === 'Retrying') { · next {{ x.delivery.nextAttemptAt | date: 'HH:mm:ss' }} }</td>
216
- <td class="jc-nowrap">{{ x.delivery.createdAt | date: 'MMM d, HH:mm:ss' }}</td>
217
- </tr>
218
- } @empty { <tr><td colspan="6" class="jc-muted">Nothing sent about this alert: no channel takes it.</td></tr> }
219
- </tbody>
220
- </table>
211
+ @if (correlation(n.correlationKey); as link) {
212
+ @if (link.href) { <p><a data-testid="alert-deliveries-link" [href]="link.href">Deliveries and escalation</a></p> }
213
+ @else { <p><a data-testid="alert-deliveries-link" [routerLink]="link.route">Deliveries and escalation</a></p> }
214
+ } @else { <p class="jc-muted jc-small">Deliveries and escalation are on the Notifications pages, which this host has not mounted.</p> }
221
215
  }
222
216
  @if (notifications.error()) { <p class="jc-error">{{ notificationsError() }}</p> }
223
217
  </section>
@@ -426,11 +420,6 @@ var AlertPage = class AlertPage {
426
420
  type: DatePipe,
427
421
  name: "date"
428
422
  },
429
- {
430
- kind: "pipe",
431
- type: LowerCasePipe,
432
- name: "lowercase"
433
- },
434
423
  {
435
424
  kind: "pipe",
436
425
  type: AgoPipe,
@@ -458,7 +447,6 @@ i0.ɵɵngDeclareClassMetadata({
458
447
  LinkPipe,
459
448
  RouterLink,
460
449
  DatePipe,
461
- LowerCasePipe,
462
450
  FormsModule,
463
451
  MatButtonModule,
464
452
  MatFormFieldModule,
@@ -542,24 +530,10 @@ i0.ɵɵngDeclareClassMetadata({
542
530
  <section class="jc-card" data-testid="alert-notifications">
543
531
  <h2>Notifications</h2>
544
532
  @if (notifications.value(); as n) {
545
- @for (e of n.escalations; track e.policy) {
546
- <p>Escalation <strong>{{ e.name }}</strong>: {{ e.stepsSent }} of {{ e.steps }} steps sent, {{ e.state | lowercase }}@if (e.stopReason) { ({{ e.stopReason | reason }}) }@if (e.nextAt) {, next at {{ e.nextAt | date: 'HH:mm:ss' }} }</p>
547
- }
548
- <table class="jc-table">
549
- <thead><tr><th>To</th><th>Event</th><th>Status</th><th>Attempts</th><th>Detail</th><th>When</th></tr></thead>
550
- <tbody>
551
- @for (x of n.deliveries; track x.delivery.id) {
552
- <tr>
553
- <td>{{ x.endpointKey }} <span class="jc-muted jc-small">{{ x.kind }}</span></td>
554
- <td>{{ x.delivery.event }}@if (x.delivery.escalationStep) { step {{ x.delivery.escalationStep }} }</td>
555
- <td [class.jc-bad]="x.delivery.status === 'Failed'">{{ x.delivery.status }}</td>
556
- <td>{{ x.delivery.attempts }}</td>
557
- <td class="jc-small">{{ x.delivery.lastError }}@if (x.delivery.nextAttemptAt && x.delivery.status === 'Retrying') { · next {{ x.delivery.nextAttemptAt | date: 'HH:mm:ss' }} }</td>
558
- <td class="jc-nowrap">{{ x.delivery.createdAt | date: 'MMM d, HH:mm:ss' }}</td>
559
- </tr>
560
- } @empty { <tr><td colspan="6" class="jc-muted">Nothing sent about this alert: no channel takes it.</td></tr> }
561
- </tbody>
562
- </table>
533
+ @if (correlation(n.correlationKey); as link) {
534
+ @if (link.href) { <p><a data-testid="alert-deliveries-link" [href]="link.href">Deliveries and escalation</a></p> }
535
+ @else { <p><a data-testid="alert-deliveries-link" [routerLink]="link.route">Deliveries and escalation</a></p> }
536
+ } @else { <p class="jc-muted jc-small">Deliveries and escalation are on the Notifications pages, which this host has not mounted.</p> }
563
537
  }
564
538
  @if (notifications.error()) { <p class="jc-error">{{ notificationsError() }}</p> }
565
539
  </section>
@@ -597,4 +571,4 @@ i0.ɵɵngDeclareClassMetadata({
597
571
  });
598
572
  export { AlertPage };
599
573
 
600
- //# sourceMappingURL=juice-js-observability-alert.page-CEGqjaqf.mjs.map
574
+ //# sourceMappingURL=juice-js-observability-alert.page-DbO20r7s.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"juice-js-observability-alert.page-DbO20r7s.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/alert.page.ts"],"sourcesContent":["import { LinkPipe, ObservabilityLinks } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { apiResource } from '../shared/resource';\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 { ApiService } from '../core/api.service';\nimport { ContextService } from '../core/context.service';\nimport { AgoPipe, ReasonPipe } from '../shared/format';\nimport { ContextBar, HealthBadge, KeyValueTable } from '../shared/ui';\nimport { problemText } from '../shared/telemetry';\nimport { SuggestionsCard } from '../shared/suggestions';\nimport { CorrelationDecision } from '../core/models';\n\n/**\n * One alert (Console requirements §14): evidence, lifecycle history, the subject's health and reasons, the way into\n * the investigation, and acknowledgement for operators.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, DatePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule,\n ContextBar, HealthBadge, KeyValueTable, AgoPipe, ReasonPipe, SuggestionsCard],\n template: `\n <jc-context-bar>\n <a [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep()\" class=\"jc-crumb\">Alerts</a><span class=\"jc-crumb-sep\">›</span>\n <h1>{{ detail.value()?.alert?.rule ?? '…' }}</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.alert.severity === 'Critical'\" [class.jc-health-degraded]=\"d.alert.severity === 'Warning'\">{{ d.alert.severity }}</span>\n <strong>{{ d.alert.state }}</strong>\n <span>{{ d.alert.subjectKey }}</span>\n @if (d.alert.noData) { <span class=\"jc-muted\">no data at the last evaluation: state kept</span> }\n @if (d.alert.subjectType === 'service' && d.alert.subjectId) {\n <a mat-flat-button [routerLink]=\"['services', d.alert.subjectId] | jcLink\" [queryParams]=\"investigate(d.alert.environment)\">Investigate</a>\n <a mat-stroked-button [routerLink]=\"['services', d.alert.subjectId] | jcLink\" [queryParams]=\"investigate(d.alert.environment, { tab: 'traces', status: 'error' })\">Error traces</a>\n }\n @for (l of d.links; track l.url) { <a mat-button [href]=\"l.url\" target=\"_blank\" rel=\"noopener\">{{ l.title }} ↗</a> }\n @if (d.alert.state !== 'Resolved') {\n <a mat-stroked-button data-testid=\"alert-open-incident\" [routerLink]=\"['incidents'] | jcLink\" [queryParams]=\"incidentLink(d.alert.id, d.alert.rule, d.alert.subjectKey)\">Open an incident</a>\n <a mat-stroked-button data-testid=\"alert-silence\" [routerLink]=\"['silences'] | jcLink\" [queryParams]=\"silenceLink(d.alert.subjectKey, d.alert.environment, d.alert.subjectType)\">Silence this</a>\n }\n </div>\n @if (notifications.value(); as n) {\n @for (s of n.silences; track s.id) {\n <p class=\"jc-notice\" data-testid=\"alert-silenced\">Notifications are held until {{ s.endsAt | date: 'MMM d, HH:mm' }}: “{{ s.comment }}” ({{ s.createdBy }}). The alert itself still fires and resolves.</p>\n }\n @for (i of n.incidents; track i.id) {\n <p>In incident <a [routerLink]=\"['incidents', i.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ i.title }}</a> ({{ i.state }})</p>\n }\n }\n <div class=\"jc-grid-2\">\n <section class=\"jc-card\"><h2>Evidence</h2><jc-kv [values]=\"d.evidence\" /></section>\n <section class=\"jc-card\">\n <h2>Subject health</h2>\n @for (h of d.subjectHealth; track h.subjectId + h.environment) {\n <p><jc-health [state]=\"h.state\" [stale]=\"h.stale\" /> {{ h.environment }}</p>\n <ul class=\"jc-reasons\">@for (r of h.reasons; track r) { <li>{{ r | reason }}</li> }</ul>\n } @empty { <p class=\"jc-muted\">No health for this subject.</p> }\n </section>\n </div>\n <section class=\"jc-card\" data-testid=\"alert-related\">\n <h2>Around this alert</h2>\n @if (related.value(); as r) {\n <p class=\"jc-notice\" data-testid=\"alert-related-note\">{{ r.note }}</p>\n <table class=\"jc-table\"><tbody>\n @for (i of r.items; track i.type + i.id) {\n <tr>\n <td class=\"jc-nowrap\">{{ i.at | date: 'MMM d, HH:mm:ss' }}</td>\n <td><strong>{{ i.title }}</strong>@if (i.detail) { <div class=\"jc-muted jc-small\">{{ i.detail }}</div> }</td>\n <td class=\"jc-small\"><ul class=\"jc-reasons\">@for (x of i.reasons; track x.code) { <li>{{ x.text }} <span class=\"jc-muted\">(+{{ x.points }})</span></li> }</ul></td>\n </tr>\n } @empty { <tr><td class=\"jc-muted\">No changes or dependency health changes in the 2 hours before this alert.</td></tr> }\n </tbody></table>\n @if (d.alert.subjectId && d.alert.subjectType === 'service') {\n <a mat-stroked-button [routerLink]=\"['timeline'] | jcLink\" [queryParams]=\"timelineLink(d.alert.subjectId, d.alert.environment, r.breachStartedAt)\">Open the timeline</a>\n }\n }\n @if (related.error()) { <p class=\"jc-error\">{{ relatedError() }}</p> }\n </section>\n @if (d.alert.state === 'Firing' || merged()) {\n <section class=\"jc-card\" data-testid=\"alert-suggestions\">\n <h2>Suggested with this alert</h2>\n @if (merged(); as m) { <p data-testid=\"alert-suggestion-merged\">Merged into <a [routerLink]=\"['incidents', m] | jcLink\" [queryParams]=\"ctx.keep()\">the incident</a>.</p> }\n <jc-suggestions [suggestions]=\"suggestions.value()\" (decided)=\"decided($event)\" />\n @if (suggestions.error()) { <p class=\"jc-error\">{{ suggestionsError() }}</p> }\n </section>\n }\n <section class=\"jc-card\" data-testid=\"alert-notifications\">\n <h2>Notifications</h2>\n @if (notifications.value(); as n) {\n @if (correlation(n.correlationKey); as link) {\n @if (link.href) { <p><a data-testid=\"alert-deliveries-link\" [href]=\"link.href\">Deliveries and escalation</a></p> }\n @else { <p><a data-testid=\"alert-deliveries-link\" [routerLink]=\"link.route\">Deliveries and escalation</a></p> }\n } @else { <p class=\"jc-muted jc-small\">Deliveries and escalation are on the Notifications pages, which this host has not mounted.</p> }\n }\n @if (notifications.error()) { <p class=\"jc-error\">{{ notificationsError() }}</p> }\n </section>\n <section class=\"jc-card\">\n <h2>History</h2>\n <table class=\"jc-table\"><tbody>\n @for (t of d.history; track t.at + t.to) {\n <tr><td>{{ t.at | date: 'MMM d, HH:mm:ss' }}</td><td>{{ t.from ?? '—' }} → <strong>{{ t.to }}</strong></td><td>{{ t.reason | reason }}</td><td>{{ t.value ?? '—' }}</td></tr>\n }\n </tbody></table>\n </section>\n <section class=\"jc-card\">\n <h2>Acknowledgement</h2>\n @if (d.alert.acknowledgedAt) {\n <p>By <strong>{{ d.alert.acknowledgedBy }}</strong> {{ d.alert.acknowledgedAt | ago }}@if (d.acknowledgeComment) {: “{{ d.acknowledgeComment }}”}</p>\n } @else if (d.alert.state !== 'Resolved') {\n <form (ngSubmit)=\"acknowledge()\" class=\"jc-filter-form\">\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-wide\"><mat-label>Comment</mat-label><input matInput name=\"comment\" [(ngModel)]=\"comment\" maxlength=\"1000\"></mat-form-field>\n <button mat-flat-button type=\"submit\" [disabled]=\"sending()\">Acknowledge</button>\n </form>\n @if (ackError()) { <p class=\"jc-error\">{{ ackError() }}</p> }\n } @else { <p class=\"jc-muted\">Resolved without acknowledgement.</p> }\n </section>\n }`,\n})\nexport class AlertPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n readonly id = input.required<string>();\n protected comment = '';\n protected readonly sending = signal(false);\n protected readonly ackError = signal('');\n\n protected readonly detail = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.alert(params) });\n protected readonly error = computed(() => problemText(this.detail.error()));\n protected readonly related = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.relatedToAlert(params) });\n protected readonly relatedError = computed(() => problemText(this.related.error()));\n protected readonly notifications = apiResource({ params: () => this.id(), stream: ({ params }) => this.api.alertNotifications(params) });\n protected readonly notificationsError = computed(() => problemText(this.notifications.error()));\n private readonly links = inject(ObservabilityLinks);\n /** The admin page of the alert's correlation: an external link or a route, as the host mounted the pages. */\n protected correlation(key: string) { const l = this.links.correlation(key); return l ? { href: 'href' in l ? l.href : null, route: 'route' in l ? l.route : [] } : null; }\n /** Only a firing alert is suggested with others, so only its page asks. */\n protected readonly suggestions = apiResource({\n params: () => (this.detail.value()?.alert.state === 'Firing' ? this.id() : undefined),\n stream: ({ params }) => this.api.alertSuggestions(params),\n });\n protected readonly suggestionsError = computed(() => problemText(this.suggestions.error()));\n /** The incident a suggestion on this page was merged into. Keyed by alert: the page is reused when a suggestion's link opens another alert. */\n private readonly mergedInto = signal<{ alert: string; incident: string } | null>(null);\n protected readonly merged = computed(() => (this.mergedInto()?.alert === this.id() ? this.mergedInto()!.incident : null));\n\n /** A decision, or null when one was refused because the list was stale: either way, read it again. */\n protected decided(d: CorrelationDecision | null) {\n if (d?.incidentId) this.mergedInto.set({ alert: this.id(), incident: d.incidentId });\n this.suggestions.reload();\n this.notifications.reload();\n }\n\n incidentLink(alert: string, rule: string, subject: string) { return this.ctx.keep({ alert, title: `${rule} on ${subject}` }); }\n\n /** The new-silence form, filled in for this alert's subject. */\n silenceLink(subject: string, environment: string | null, type: string) {\n const name = type === 'service' ? subject.replace(/^service:/, '').replace(/@[^@]*$/, '') : null;\n const host = type === 'host' ? subject.replace(/^host:/, '') : null;\n return this.ctx.keep({ service: name, environment, host });\n }\n\n /** The service page over the alert's environment, from shortly before the breach. */\n /** The service's timeline from 2 hours before the breach to 1 hour after. */\n timelineLink(service: string, environment: string | null, breach: string) {\n const at = new Date(breach).getTime();\n return this.ctx.keep({ service, env: environment, range: null, from: new Date(at - 2 * 3_600_000).toISOString(), to: new Date(at + 3_600_000).toISOString() });\n }\n\n investigate(environment: string | null, extra: Record<string, string> = {}) {\n const alert = this.detail.value()?.alert;\n const start = alert?.breachStartedAt ? new Date(alert.breachStartedAt).getTime() - 15 * 60_000 : null;\n const end = alert?.resolvedAt ? new Date(alert.resolvedAt).getTime() + 5 * 60_000 : Date.now();\n const window = start && end - start <= 24 * 3_600_000\n ? { from: new Date(start).toISOString(), to: new Date(end).toISOString(), range: null } : {};\n return this.ctx.keep({ env: environment, ...window, ...extra });\n }\n\n acknowledge() {\n this.sending.set(true);\n this.ackError.set('');\n this.api.acknowledge(this.id(), this.comment).subscribe({\n next: () => { this.sending.set(false); this.detail.reload(); this.notifications.reload(); },\n error: e => {\n this.sending.set(false);\n this.ackError.set((e as { status?: number }).status === 403 ? 'Acknowledging needs the operator or admin role.' : problemText(e));\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA8HA,IAAa,YAAb,MAAa,UAAS;CACD,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CAC/B,KAAK,MAAM,SAAkB,GAAA,YAAA,CAAA,EAAA,WAAA,KAAA,CAAA,+BAAA,CAAA,CAAA;CAC5B,UAAU;CACD,UAAU,OAAO,OAAM,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;CACvB,WAAW,OAAO,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,WAAA,CAAA,+BAAA,CAAA,CAAA;CA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js";
2
+ import { c as ContextBar, h as apiResource, o as problemText } from "./juice-js-observability-telemetry-BG91FqGp.mjs";
3
+ import * as i0 from "@angular/core";
4
+ import { ChangeDetectionStrategy, Component, computed, inject, signal } from "@angular/core";
5
+ import { DatePipe } from "@angular/common";
6
+ import { RouterLink } from "@angular/router";
7
+ import { map } from "rxjs";
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 i5 from "@angular/material/input";
14
+ import { MatInputModule } from "@angular/material/input";
15
+ import * as i6 from "@angular/material/progress-bar";
16
+ import { MatProgressBarModule } from "@angular/material/progress-bar";
17
+ import * as i4 from "@angular/material/select";
18
+ import { MatSelectModule } from "@angular/material/select";
19
+ import * as i3 from "@angular/material/checkbox";
20
+ import { MatCheckboxModule } from "@angular/material/checkbox";
21
+ const list = (text) => text.split(",").map((s) => s.trim()).filter(Boolean);
22
+ const NEW_POLICY = {
23
+ editing: false,
24
+ key: "",
25
+ name: "",
26
+ ruleKeys: "",
27
+ environments: "",
28
+ minimumSeverity: "Critical",
29
+ enabled: true
30
+ };
31
+ var NotificationsPage = class NotificationsPage {
32
+ api = inject(ApiService);
33
+ links = inject(ObservabilityLinks);
34
+ canAdmin = inject(OBSERVABILITY_CAN_ADMIN);
35
+ admin = () => this.canAdmin();
36
+ deleteError = signal("", ...ngDevMode ? [{ debugName: "deleteError" }] : /* istanbul ignore next */ []);
37
+ policy = signal(null, ...ngDevMode ? [{ debugName: "policy" }] : /* istanbul ignore next */ []);
38
+ saving = signal(false, ...ngDevMode ? [{ debugName: "saving" }] : /* istanbul ignore next */ []);
39
+ policyError = signal("", ...ngDevMode ? [{ debugName: "policyError" }] : /* istanbul ignore next */ []);
40
+ data = apiResource({ stream: () => this.api.escalationPolicies().pipe(map((p) => p.items)) });
41
+ error = computed(() => problemText(this.data.error()), ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
42
+ policies = computed(() => this.data.value() ?? [], ...ngDevMode ? [{ debugName: "policies" }] : /* istanbul ignore next */ []);
43
+ steps() {
44
+ const l = this.links.admin("escalation-policies");
45
+ return l ? {
46
+ href: "href" in l ? l.href : null,
47
+ route: "route" in l ? l.route : []
48
+ } : null;
49
+ }
50
+ newPolicy() {
51
+ this.policyError.set("");
52
+ return { ...NEW_POLICY };
53
+ }
54
+ editPolicy(p) {
55
+ this.policyError.set("");
56
+ this.policy.set({
57
+ editing: true,
58
+ key: p.key,
59
+ name: p.name,
60
+ ruleKeys: p.ruleKeys.join(", "),
61
+ environments: p.environments.join(", "),
62
+ minimumSeverity: p.minimumSeverity,
63
+ enabled: p.enabled
64
+ });
65
+ }
66
+ savePolicy(f) {
67
+ const body = {
68
+ key: f.key,
69
+ name: f.name,
70
+ enabled: f.enabled,
71
+ ruleKeys: list(f.ruleKeys),
72
+ environments: list(f.environments).map((e) => e.toLowerCase()),
73
+ minimumSeverity: f.minimumSeverity
74
+ };
75
+ this.saving.set(true);
76
+ this.policyError.set("");
77
+ (f.editing ? this.api.updateEscalationPolicy(f.key, body) : this.api.createEscalationPolicy(body)).subscribe({
78
+ next: () => {
79
+ this.saving.set(false);
80
+ this.policy.set(null);
81
+ this.data.reload();
82
+ },
83
+ error: (e) => {
84
+ this.saving.set(false);
85
+ this.policyError.set(e.status === 403 ? "This needs the admin role." : problemText(e));
86
+ }
87
+ });
88
+ }
89
+ deletePolicy(key) {
90
+ this.saving.set(true);
91
+ this.deleteError.set("");
92
+ this.api.deleteEscalationPolicy(key).subscribe({
93
+ next: () => {
94
+ this.saving.set(false);
95
+ this.data.reload();
96
+ },
97
+ error: (e) => {
98
+ this.saving.set(false);
99
+ this.deleteError.set(e.status === 403 ? "This needs the admin role." : problemText(e));
100
+ }
101
+ });
102
+ }
103
+ static ɵfac = i0.ɵɵngDeclareFactory({
104
+ minVersion: "12.0.0",
105
+ version: "22.2.4",
106
+ ngImport: i0,
107
+ type: NotificationsPage,
108
+ deps: [],
109
+ target: i0.ɵɵFactoryTarget.Component
110
+ });
111
+ static ɵcmp = i0.ɵɵngDeclareComponent({
112
+ minVersion: "17.0.0",
113
+ version: "22.2.4",
114
+ type: NotificationsPage,
115
+ isStandalone: true,
116
+ selector: "ng-component",
117
+ ngImport: i0,
118
+ template: `
119
+ <jc-context-bar><h1>Escalation selection</h1></jc-context-bar>
120
+ @if (data.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
121
+ @if (error()) { <p class="jc-error">{{ error() }}</p> }
122
+
123
+ <section class="jc-card">
124
+ <h2>Selections @if (admin()) { <button mat-button type="button" data-testid="policy-new" (click)="policy.set(newPolicy())">New selection</button> }</h2>
125
+ <p class="jc-muted jc-small">Which alerts escalate. What an escalation does is set on the Notifications Escalation Policies page.</p>
126
+ @if (policy(); as f) {
127
+ <form class="jc-form" data-testid="policy-form" (ngSubmit)="savePolicy(f)">
128
+ @if (!f.editing) { <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Key</mat-label><input matInput name="key" [(ngModel)]="f.key" required></mat-form-field> }
129
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Name</mat-label><input matInput name="name" [(ngModel)]="f.name" required></mat-form-field>
130
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Only these rules</mat-label><input matInput name="ruleKeys" [(ngModel)]="f.ruleKeys"></mat-form-field>
131
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Only these environments</mat-label><input matInput name="environments" [(ngModel)]="f.environments"></mat-form-field>
132
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Severity at least</mat-label>
133
+ <mat-select name="minimumSeverity" [(ngModel)]="f.minimumSeverity"><mat-option value="Info">Info</mat-option><mat-option value="Warning">Warning</mat-option><mat-option value="Critical">Critical</mat-option></mat-select>
134
+ </mat-form-field>
135
+ <mat-checkbox name="policyEnabled" [(ngModel)]="f.enabled">Enabled</mat-checkbox>
136
+ <div class="jc-form-actions">
137
+ <button mat-flat-button type="submit" data-testid="policy-save" [disabled]="saving()">Save</button>
138
+ <button mat-button type="button" (click)="policy.set(null)">Cancel</button>
139
+ @if (policyError()) { <span class="jc-error" data-testid="policy-error">{{ policyError() }}</span> }
140
+ </div>
141
+ </form>
142
+ }
143
+ <table class="jc-table" data-testid="policies">
144
+ <thead><tr><th>Selection</th><th>Applies to</th><th>Steps</th><th>Changed</th><th></th></tr></thead>
145
+ <tbody>
146
+ @for (p of policies(); track p.id) {
147
+ <tr [class.jc-muted]="!p.enabled">
148
+ <td><strong>{{ p.name }}</strong><div class="jc-muted jc-small">{{ p.key }}@if (!p.enabled) { · disabled }</div></td>
149
+ <td class="jc-small">{{ p.minimumSeverity }} and above@if (p.environments.length) { · {{ p.environments.join(', ') }} }@if (p.ruleKeys.length) { · {{ p.ruleKeys.join(', ') }} }</td>
150
+ <td class="jc-small">
151
+ @if (steps(); as link) {
152
+ @if (link.href) { <a [href]="link.href" [attr.data-testid]="'steps-' + p.key">Steps</a> }
153
+ @else { <a [routerLink]="link.route" [attr.data-testid]="'steps-' + p.key">Steps</a> }
154
+ }
155
+ @if (!p.pipelinePolicyExists) { <span class="jc-bad" [attr.data-testid]="'no-pipeline-policy-' + p.key">No policy with this key in Notifications: alerts notify once</span> }
156
+ </td>
157
+ <td class="jc-small jc-nowrap">{{ p.updatedAt | date: 'MMM d, HH:mm' }}</td>
158
+ <td class="jc-row-actions">@if (admin()) {
159
+ <button mat-button type="button" [attr.data-testid]="'policy-change-' + p.key" (click)="editPolicy(p)">Change</button>
160
+ <button mat-button type="button" [attr.data-testid]="'policy-delete-' + p.key" [disabled]="saving()" (click)="deletePolicy(p.key)">Delete</button>
161
+ }</td>
162
+ </tr>
163
+ } @empty { <tr><td colspan="5" class="jc-muted">No selections: a firing alert notifies once.</td></tr> }
164
+ </tbody>
165
+ </table>
166
+ @if (deleteError()) { <p class="jc-error" data-testid="policy-delete-error">{{ deleteError() }}</p> }
167
+ </section>`,
168
+ isInline: true,
169
+ dependencies: [
170
+ {
171
+ kind: "ngmodule",
172
+ type: FormsModule
173
+ },
174
+ {
175
+ kind: "directive",
176
+ type: i1.ɵNgNoValidate,
177
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
178
+ },
179
+ {
180
+ kind: "directive",
181
+ type: i1.DefaultValueAccessor,
182
+ 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]"
183
+ },
184
+ {
185
+ kind: "directive",
186
+ type: i1.NgControlStatus,
187
+ selector: "[formControlName],[ngModel],[formControl]"
188
+ },
189
+ {
190
+ kind: "directive",
191
+ type: i1.NgControlStatusGroup,
192
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
193
+ },
194
+ {
195
+ kind: "directive",
196
+ type: i1.RequiredValidator,
197
+ selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]",
198
+ inputs: ["required"]
199
+ },
200
+ {
201
+ kind: "directive",
202
+ type: i1.NgModel,
203
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
204
+ inputs: [
205
+ "name",
206
+ "disabled",
207
+ "ngModel",
208
+ "ngModelOptions"
209
+ ],
210
+ outputs: ["ngModelChange"],
211
+ exportAs: ["ngModel"]
212
+ },
213
+ {
214
+ kind: "directive",
215
+ type: i1.NgForm,
216
+ selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
217
+ inputs: ["ngFormOptions"],
218
+ outputs: ["ngSubmit"],
219
+ exportAs: ["ngForm"]
220
+ },
221
+ {
222
+ kind: "ngmodule",
223
+ type: MatButtonModule
224
+ },
225
+ {
226
+ kind: "component",
227
+ type: i2.MatButton,
228
+ 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] ",
229
+ inputs: ["matButton"],
230
+ exportAs: ["matButton", "matAnchor"]
231
+ },
232
+ {
233
+ kind: "ngmodule",
234
+ type: MatCheckboxModule
235
+ },
236
+ {
237
+ kind: "component",
238
+ type: i3.MatCheckbox,
239
+ selector: "mat-checkbox",
240
+ inputs: [
241
+ "aria-label",
242
+ "aria-labelledby",
243
+ "aria-describedby",
244
+ "aria-expanded",
245
+ "aria-controls",
246
+ "aria-owns",
247
+ "id",
248
+ "required",
249
+ "labelPosition",
250
+ "name",
251
+ "value",
252
+ "disableRipple",
253
+ "tabIndex",
254
+ "color",
255
+ "disabledInteractive",
256
+ "checked",
257
+ "disabled",
258
+ "indeterminate"
259
+ ],
260
+ outputs: ["change", "indeterminateChange"],
261
+ exportAs: ["matCheckbox"]
262
+ },
263
+ {
264
+ kind: "ngmodule",
265
+ type: MatFormFieldModule
266
+ },
267
+ {
268
+ kind: "component",
269
+ type: i4.MatFormField,
270
+ selector: "mat-form-field",
271
+ inputs: [
272
+ "hideRequiredMarker",
273
+ "color",
274
+ "floatLabel",
275
+ "appearance",
276
+ "subscriptSizing",
277
+ "hintLabel"
278
+ ],
279
+ exportAs: ["matFormField"]
280
+ },
281
+ {
282
+ kind: "directive",
283
+ type: i4.MatLabel,
284
+ selector: "mat-label"
285
+ },
286
+ {
287
+ kind: "ngmodule",
288
+ type: MatInputModule
289
+ },
290
+ {
291
+ kind: "directive",
292
+ type: i5.MatInput,
293
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
294
+ inputs: [
295
+ "disabled",
296
+ "id",
297
+ "placeholder",
298
+ "name",
299
+ "required",
300
+ "type",
301
+ "errorStateMatcher",
302
+ "aria-describedby",
303
+ "value",
304
+ "readonly",
305
+ "disabledInteractive"
306
+ ],
307
+ exportAs: ["matInput"]
308
+ },
309
+ {
310
+ kind: "ngmodule",
311
+ type: MatProgressBarModule
312
+ },
313
+ {
314
+ kind: "component",
315
+ type: i6.MatProgressBar,
316
+ selector: "mat-progress-bar",
317
+ inputs: [
318
+ "color",
319
+ "value",
320
+ "bufferValue",
321
+ "mode"
322
+ ],
323
+ outputs: ["animationEnd"],
324
+ exportAs: ["matProgressBar"]
325
+ },
326
+ {
327
+ kind: "ngmodule",
328
+ type: MatSelectModule
329
+ },
330
+ {
331
+ kind: "component",
332
+ type: i4.MatSelect,
333
+ selector: "mat-select",
334
+ inputs: [
335
+ "aria-describedby",
336
+ "panelClass",
337
+ "disabled",
338
+ "disableRipple",
339
+ "tabIndex",
340
+ "hideSingleSelectionIndicator",
341
+ "placeholder",
342
+ "required",
343
+ "multiple",
344
+ "disableOptionCentering",
345
+ "compareWith",
346
+ "value",
347
+ "aria-label",
348
+ "aria-labelledby",
349
+ "errorStateMatcher",
350
+ "typeaheadDebounceInterval",
351
+ "sortComparator",
352
+ "id",
353
+ "panelWidth",
354
+ "canSelectNullableOptions"
355
+ ],
356
+ outputs: [
357
+ "openedChange",
358
+ "opened",
359
+ "closed",
360
+ "selectionChange",
361
+ "valueChange"
362
+ ],
363
+ exportAs: ["matSelect"]
364
+ },
365
+ {
366
+ kind: "component",
367
+ type: i4.MatOption,
368
+ selector: "mat-option",
369
+ inputs: [
370
+ "value",
371
+ "id",
372
+ "disabled"
373
+ ],
374
+ outputs: ["onSelectionChange"],
375
+ exportAs: ["matOption"]
376
+ },
377
+ {
378
+ kind: "component",
379
+ type: ContextBar,
380
+ selector: "jc-context-bar"
381
+ },
382
+ {
383
+ kind: "directive",
384
+ type: RouterLink,
385
+ selector: "[routerLink]",
386
+ inputs: [
387
+ "target",
388
+ "queryParams",
389
+ "fragment",
390
+ "queryParamsHandling",
391
+ "state",
392
+ "info",
393
+ "relativeTo",
394
+ "preserveFragment",
395
+ "skipLocationChange",
396
+ "replaceUrl",
397
+ "browserUrl",
398
+ "routerLink"
399
+ ]
400
+ },
401
+ {
402
+ kind: "pipe",
403
+ type: DatePipe,
404
+ name: "date"
405
+ }
406
+ ],
407
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
408
+ });
409
+ };
410
+ i0.ɵɵngDeclareClassMetadata({
411
+ minVersion: "12.0.0",
412
+ version: "22.2.4",
413
+ ngImport: i0,
414
+ type: NotificationsPage,
415
+ decorators: [{
416
+ type: Component,
417
+ args: [{
418
+ changeDetection: ChangeDetectionStrategy.OnPush,
419
+ imports: [
420
+ DatePipe,
421
+ FormsModule,
422
+ MatButtonModule,
423
+ MatCheckboxModule,
424
+ MatFormFieldModule,
425
+ MatInputModule,
426
+ MatProgressBarModule,
427
+ MatSelectModule,
428
+ ContextBar,
429
+ RouterLink
430
+ ],
431
+ template: `
432
+ <jc-context-bar><h1>Escalation selection</h1></jc-context-bar>
433
+ @if (data.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
434
+ @if (error()) { <p class="jc-error">{{ error() }}</p> }
435
+
436
+ <section class="jc-card">
437
+ <h2>Selections @if (admin()) { <button mat-button type="button" data-testid="policy-new" (click)="policy.set(newPolicy())">New selection</button> }</h2>
438
+ <p class="jc-muted jc-small">Which alerts escalate. What an escalation does is set on the Notifications Escalation Policies page.</p>
439
+ @if (policy(); as f) {
440
+ <form class="jc-form" data-testid="policy-form" (ngSubmit)="savePolicy(f)">
441
+ @if (!f.editing) { <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Key</mat-label><input matInput name="key" [(ngModel)]="f.key" required></mat-form-field> }
442
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Name</mat-label><input matInput name="name" [(ngModel)]="f.name" required></mat-form-field>
443
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Only these rules</mat-label><input matInput name="ruleKeys" [(ngModel)]="f.ruleKeys"></mat-form-field>
444
+ <mat-form-field subscriptSizing="dynamic"><mat-label>Only these environments</mat-label><input matInput name="environments" [(ngModel)]="f.environments"></mat-form-field>
445
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Severity at least</mat-label>
446
+ <mat-select name="minimumSeverity" [(ngModel)]="f.minimumSeverity"><mat-option value="Info">Info</mat-option><mat-option value="Warning">Warning</mat-option><mat-option value="Critical">Critical</mat-option></mat-select>
447
+ </mat-form-field>
448
+ <mat-checkbox name="policyEnabled" [(ngModel)]="f.enabled">Enabled</mat-checkbox>
449
+ <div class="jc-form-actions">
450
+ <button mat-flat-button type="submit" data-testid="policy-save" [disabled]="saving()">Save</button>
451
+ <button mat-button type="button" (click)="policy.set(null)">Cancel</button>
452
+ @if (policyError()) { <span class="jc-error" data-testid="policy-error">{{ policyError() }}</span> }
453
+ </div>
454
+ </form>
455
+ }
456
+ <table class="jc-table" data-testid="policies">
457
+ <thead><tr><th>Selection</th><th>Applies to</th><th>Steps</th><th>Changed</th><th></th></tr></thead>
458
+ <tbody>
459
+ @for (p of policies(); track p.id) {
460
+ <tr [class.jc-muted]="!p.enabled">
461
+ <td><strong>{{ p.name }}</strong><div class="jc-muted jc-small">{{ p.key }}@if (!p.enabled) { · disabled }</div></td>
462
+ <td class="jc-small">{{ p.minimumSeverity }} and above@if (p.environments.length) { · {{ p.environments.join(', ') }} }@if (p.ruleKeys.length) { · {{ p.ruleKeys.join(', ') }} }</td>
463
+ <td class="jc-small">
464
+ @if (steps(); as link) {
465
+ @if (link.href) { <a [href]="link.href" [attr.data-testid]="'steps-' + p.key">Steps</a> }
466
+ @else { <a [routerLink]="link.route" [attr.data-testid]="'steps-' + p.key">Steps</a> }
467
+ }
468
+ @if (!p.pipelinePolicyExists) { <span class="jc-bad" [attr.data-testid]="'no-pipeline-policy-' + p.key">No policy with this key in Notifications: alerts notify once</span> }
469
+ </td>
470
+ <td class="jc-small jc-nowrap">{{ p.updatedAt | date: 'MMM d, HH:mm' }}</td>
471
+ <td class="jc-row-actions">@if (admin()) {
472
+ <button mat-button type="button" [attr.data-testid]="'policy-change-' + p.key" (click)="editPolicy(p)">Change</button>
473
+ <button mat-button type="button" [attr.data-testid]="'policy-delete-' + p.key" [disabled]="saving()" (click)="deletePolicy(p.key)">Delete</button>
474
+ }</td>
475
+ </tr>
476
+ } @empty { <tr><td colspan="5" class="jc-muted">No selections: a firing alert notifies once.</td></tr> }
477
+ </tbody>
478
+ </table>
479
+ @if (deleteError()) { <p class="jc-error" data-testid="policy-delete-error">{{ deleteError() }}</p> }
480
+ </section>`
481
+ }]
482
+ }]
483
+ });
484
+ export { NotificationsPage };
485
+
486
+ //# sourceMappingURL=juice-js-observability-notifications.page-COE-1zr0.mjs.map