@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
@@ -1 +1 @@
1
- {"version":3,"file":"juice-js-observability-alert.page-DOAX9WWa.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/alert.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { apiResource } from '../shared/resource';\nimport { DatePipe, LowerCasePipe } 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';\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, LowerCasePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule,\n ContextBar, HealthBadge, KeyValueTable, AgoPipe, ReasonPipe],\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 <section class=\"jc-card\" data-testid=\"alert-notifications\">\n <h2>Notifications</h2>\n @if (notifications.value(); as n) {\n @for (e of n.escalations; track e.policy) {\n <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>\n }\n <table class=\"jc-table\">\n <thead><tr><th>To</th><th>Event</th><th>Status</th><th>Attempts</th><th>Detail</th><th>When</th></tr></thead>\n <tbody>\n @for (x of n.deliveries; track x.delivery.id) {\n <tr>\n <td>{{ x.endpointKey }} <span class=\"jc-muted jc-small\">{{ x.kind }}</span></td>\n <td>{{ x.delivery.event }}@if (x.delivery.escalationStep) { step {{ x.delivery.escalationStep }} }</td>\n <td [class.jc-bad]=\"x.delivery.status === 'Failed'\">{{ x.delivery.status }}</td>\n <td>{{ x.delivery.attempts }}</td>\n <td class=\"jc-small\">{{ x.delivery.lastError }}@if (x.delivery.nextAttemptAt && x.delivery.status === 'Retrying') { · next {{ x.delivery.nextAttemptAt | date: 'HH:mm:ss' }} }</td>\n <td class=\"jc-nowrap\">{{ x.delivery.createdAt | date: 'MMM d, HH:mm:ss' }}</td>\n </tr>\n } @empty { <tr><td colspan=\"6\" class=\"jc-muted\">Nothing sent about this alert: no channel takes it.</td></tr> }\n </tbody>\n </table>\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\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":";;;;;;;;;;;;;;;;AAkIA,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;CAErB,SAAS,YAAY;EAAE,cAAc,KAAK,GAAE;EAAI,SAAS,EAAE,aAAa,KAAK,IAAI,MAAM,MAAM;CAAC,CAAE;CAChG,QAAQ,eAAe,YAAY,KAAK,OAAO,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACxD,UAAU,YAAY;EAAE,cAAc,KAAK,GAAE;EAAI,SAAS,EAAE,aAAa,KAAK,IAAI,eAAe,MAAM;CAAC,CAAE;CAC1G,eAAe,eAAe,YAAY,KAAK,QAAQ,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,E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,MAAA;IAAA,MAAA,GAAA;IAAA,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA,CAAA,cAAA;IAAA,UAAA,CAAA,gBAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAC7I;IAAU,UAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAW,UAAA;IAAA,QAAA,CAAA,SAAA,OAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAa,UAAA;IAAA,QAAA,CAAA,UAAA,OAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAD9B;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAc;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAa,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MACb;IAAO,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAU,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AA2GlD,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EA9GrB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAU;IAAe;IAAa;IAAiB;IAAoB;IAAgB;IACzH;IAAY;IAAa;IAAe;IAAS;GAAU;GAC7D,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyGX,CAAA"}
1
+ {"version":3,"file":"juice-js-observability-alert.page-79qA1Wqg.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/alert.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';\nimport { apiResource } from '../shared/resource';\nimport { DatePipe, LowerCasePipe } 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';\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, LowerCasePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule,\n ContextBar, HealthBadge, KeyValueTable, AgoPipe, ReasonPipe],\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 <section class=\"jc-card\" data-testid=\"alert-notifications\">\n <h2>Notifications</h2>\n @if (notifications.value(); as n) {\n @for (e of n.escalations; track e.policy) {\n <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>\n }\n <table class=\"jc-table\">\n <thead><tr><th>To</th><th>Event</th><th>Status</th><th>Attempts</th><th>Detail</th><th>When</th></tr></thead>\n <tbody>\n @for (x of n.deliveries; track x.delivery.id) {\n <tr>\n <td>{{ x.endpointKey }} <span class=\"jc-muted jc-small\">{{ x.kind }}</span></td>\n <td>{{ x.delivery.event }}@if (x.delivery.escalationStep) { step {{ x.delivery.escalationStep }} }</td>\n <td [class.jc-bad]=\"x.delivery.status === 'Failed'\">{{ x.delivery.status }}</td>\n <td>{{ x.delivery.attempts }}</td>\n <td class=\"jc-small\">{{ x.delivery.lastError }}@if (x.delivery.nextAttemptAt && x.delivery.status === 'Retrying') { · next {{ x.delivery.nextAttemptAt | date: 'HH:mm:ss' }} }</td>\n <td class=\"jc-nowrap\">{{ x.delivery.createdAt | date: 'MMM d, HH:mm:ss' }}</td>\n </tr>\n } @empty { <tr><td colspan=\"6\" class=\"jc-muted\">Nothing sent about this alert: no channel takes it.</td></tr> }\n </tbody>\n </table>\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\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":";;;;;;;;;;;;;;;;AAkIA,IAAa,YAAb,MAAa,UAAS;CACD,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CA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AAU,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AA2GlD,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAS,YAAA,CAAA;EA9GrB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAU;IAAe;IAAa;IAAiB;IAAoB;IAAgB;IACzH;IAAY;IAAa;IAAe;IAAS;GAAU;GAC7D,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyGX,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
2
- import { h as AgoPipe, o as problemText, s as cursorList, u as ContextBar } from "./juice-js-observability-telemetry-BftWSOaQ.mjs";
2
+ import { c as ContextBar, g as AgoPipe, o as problemText, p as cursorList } from "./juice-js-observability-telemetry-B98lekF2.mjs";
3
3
  import * as i0 from "@angular/core";
4
4
  import { ChangeDetectionStrategy, Component, computed, inject, input } from "@angular/core";
5
5
  import { RouterLink } from "@angular/router";
@@ -208,4 +208,4 @@ i0.ɵɵngDeclareClassMetadata({
208
208
  });
209
209
  export { AlertsPage };
210
210
 
211
- //# sourceMappingURL=juice-js-observability-alerts.page-DUXXBanH.mjs.map
211
+ //# sourceMappingURL=juice-js-observability-alerts.page-DVqDxYSq.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"juice-js-observability-alerts.page-DUXXBanH.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/alerts.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\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 } from '../shared/format';\nimport { ContextBar } from '../shared/ui';\nimport { cursorList } from '../shared/paging';\nimport { problemText } from '../shared/telemetry';\n\n/** Alerts, newest first (Console requirements §14), filtered by state; 100 at a time, with the next on request. */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, MatButtonModule, MatProgressBarModule, ContextBar, AgoPipe],\n template: `\n <jc-context-bar><h1>Alerts</h1>\n @for (s of states; track s) {\n <a class=\"jc-chip\" [class.jc-selected]=\"s === (state() ?? 'firing')\" [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep({ state: s })\">{{ s }}</a>\n }\n </jc-context-bar>\n @if (alerts.first.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (alerts.first.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n <table class=\"jc-table\">\n <thead><tr><th>Severity</th><th>Rule</th><th>Subject</th><th>State</th><th>Value</th><th>Fired</th><th>Acknowledged</th></tr></thead>\n <tbody>\n @for (a of alerts.items(); track a.id) {\n <tr>\n <td><span class=\"jc-badge\" [class.jc-health-unhealthy]=\"a.severity === 'Critical'\" [class.jc-health-degraded]=\"a.severity === 'Warning'\">{{ a.severity }}</span></td>\n <td><a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.rule }}</a></td>\n <td>{{ a.subjectKey }}</td>\n <td>{{ a.state }}@if (a.noData) { <span class=\"jc-muted\" title=\"The last evaluation had too few samples; the state is kept\"> · no data</span> }</td>\n <td>{{ a.lastValue ?? '—' }}</td>\n <td>{{ a.firedAt | ago }}</td>\n <td>{{ a.acknowledgedBy ?? '—' }}</td>\n </tr>\n } @empty { @if (alerts.first.hasValue()) { <tr><td colspan=\"7\" class=\"jc-muted\">No {{ state() ?? 'firing' }} alerts.</td></tr> } }\n </tbody>\n </table>\n @if (alerts.items().length > 0) {\n <div class=\"jc-more\">\n <span class=\"jc-muted\">{{ alerts.items().length }} {{ state() ?? 'firing' }} alert{{ alerts.items().length === 1 ? '' : 's' }}{{ alerts.hasMore() ? ', newest first' : '' }}</span>\n @if (alerts.hasMore()) {\n <button mat-button (click)=\"alerts.more()\" [disabled]=\"alerts.loadingMore()\">{{ alerts.loadingMore() ? 'Loading…' : 'Load more' }}</button>\n }\n @if (alerts.moreError()) { <span class=\"jc-error\">{{ moreError() }}</span> }\n </div>\n }`,\n})\nexport class AlertsPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n protected readonly states = ['firing', 'pending', 'resolved'];\n readonly state = input<string>();\n protected readonly alerts = cursorList(\n () => ({ state: this.state() ?? 'firing', environment: this.ctx.environment() }), params => params, q => this.api.alerts(q));\n protected readonly error = computed(() => problemText(this.alerts.first.error()));\n protected readonly moreError = computed(() => problemText(this.alerts.moreError()));\n}\n"],"mappings":";;;;;;;;;AAkDA,IAAa,aAAb,MAAa,WAAU;CACF,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CACrB,SAAS;EAAC;EAAU;EAAW;CAAU;CACnD,QAAQ,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACb,SAAS,kBACnB;EAAE,OAAO,KAAK,MAAK,KAAM;EAAU,aAAa,KAAK,IAAI,YAAW;CAAE,KAAK,WAAU,SAAQ,MAAK,KAAK,IAAI,OAAO,CAAC,CAAC;CAC1G,QAAQ,eAAe,YAAY,KAAK,OAAO,MAAM,MAAK,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CAC9D,YAAY,eAAe,YAAY,KAAK,OAAO,UAAS,CAAE,GAAE,GAAA,YAAA,CAAA,EAAA,WAAA,YAAA,CAAA,+BAAA,CAAA,CAAA;CARxE,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCX,CAAA"}
1
+ {"version":3,"file":"juice-js-observability-alerts.page-DVqDxYSq.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/alerts.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\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 } from '../shared/format';\nimport { ContextBar } from '../shared/ui';\nimport { cursorList } from '../shared/paging';\nimport { problemText } from '../shared/telemetry';\n\n/** Alerts, newest first (Console requirements §14), filtered by state; 100 at a time, with the next on request. */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, MatButtonModule, MatProgressBarModule, ContextBar, AgoPipe],\n template: `\n <jc-context-bar><h1>Alerts</h1>\n @for (s of states; track s) {\n <a class=\"jc-chip\" [class.jc-selected]=\"s === (state() ?? 'firing')\" [routerLink]=\"['alerts'] | jcLink\" [queryParams]=\"ctx.keep({ state: s })\">{{ s }}</a>\n }\n </jc-context-bar>\n @if (alerts.first.isLoading()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (alerts.first.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n <table class=\"jc-table\">\n <thead><tr><th>Severity</th><th>Rule</th><th>Subject</th><th>State</th><th>Value</th><th>Fired</th><th>Acknowledged</th></tr></thead>\n <tbody>\n @for (a of alerts.items(); track a.id) {\n <tr>\n <td><span class=\"jc-badge\" [class.jc-health-unhealthy]=\"a.severity === 'Critical'\" [class.jc-health-degraded]=\"a.severity === 'Warning'\">{{ a.severity }}</span></td>\n <td><a [routerLink]=\"['alerts', a.id] | jcLink\" [queryParams]=\"ctx.keep()\">{{ a.rule }}</a></td>\n <td>{{ a.subjectKey }}</td>\n <td>{{ a.state }}@if (a.noData) { <span class=\"jc-muted\" title=\"The last evaluation had too few samples; the state is kept\"> · no data</span> }</td>\n <td>{{ a.lastValue ?? '—' }}</td>\n <td>{{ a.firedAt | ago }}</td>\n <td>{{ a.acknowledgedBy ?? '—' }}</td>\n </tr>\n } @empty { @if (alerts.first.hasValue()) { <tr><td colspan=\"7\" class=\"jc-muted\">No {{ state() ?? 'firing' }} alerts.</td></tr> } }\n </tbody>\n </table>\n @if (alerts.items().length > 0) {\n <div class=\"jc-more\">\n <span class=\"jc-muted\">{{ alerts.items().length }} {{ state() ?? 'firing' }} alert{{ alerts.items().length === 1 ? '' : 's' }}{{ alerts.hasMore() ? ', newest first' : '' }}</span>\n @if (alerts.hasMore()) {\n <button mat-button (click)=\"alerts.more()\" [disabled]=\"alerts.loadingMore()\">{{ alerts.loadingMore() ? 'Loading…' : 'Load more' }}</button>\n }\n @if (alerts.moreError()) { <span class=\"jc-error\">{{ moreError() }}</span> }\n </div>\n }`,\n})\nexport class AlertsPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n protected readonly states = ['firing', 'pending', 'resolved'];\n readonly state = input<string>();\n protected readonly alerts = cursorList(\n () => ({ state: this.state() ?? 'firing', environment: this.ctx.environment() }), params => params, q => this.api.alerts(q));\n protected readonly error = computed(() => problemText(this.alerts.first.error()));\n protected readonly moreError = computed(() => problemText(this.alerts.moreError()));\n}\n"],"mappings":";;;;;;;;;AAkDA,IAAa,aAAb,MAAa,WAAU;CACF,MAAM,OAAO,cAAc;CAC7B,MAAM,OAAO,UAAU;CACrB,SAAS;EAAC;EAAU;EAAW;CAAU;CACnD,QAAQ,MAAe,GAAA,YAAA,CAAA,QAAA,EAAA,WAAA,QAAA,CAAA,+BAAA,CAAA,CAAA;CACb,SAAS,kBACnB;EAAE,OAAO,KAAK,MAAK,KAAM;EAAU,aAAa,KAAK,IAAI,YAAW;CAAE,KAAK,WAAU,SAAQ,MAAK,KAAK,IAAI,OAAO,CAAC,CAA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AA,MAAA;IAAA,MAAiE;IAAO,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAmC/E,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAU,YAAA,CAAA;EArCtB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAiB;IAAsB;IAAY;GAAO;GAC1F,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiCX,CAAA"}
@@ -0,0 +1,383 @@
1
+ import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
2
+ import { c as ContextBar, g as AgoPipe, h as apiResource, o as problemText } from "./juice-js-observability-telemetry-B98lekF2.mjs";
3
+ import * as i0 from "@angular/core";
4
+ import { ChangeDetectionStrategy, Component, computed, effect, inject, signal } 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 i4 from "@angular/material/input";
13
+ import { MatInputModule } from "@angular/material/input";
14
+ import * as i5 from "@angular/material/progress-bar";
15
+ import { MatProgressBarModule } from "@angular/material/progress-bar";
16
+ import * as i3 from "@angular/material/select";
17
+ var ApprovalsPage = class ApprovalsPage {
18
+ ctx = inject(ContextService);
19
+ api = inject(ApiService);
20
+ busy = signal(null, ...ngDevMode ? [{ debugName: "busy" }] : /* istanbul ignore next */ []);
21
+ comments = signal({}, ...ngDevMode ? [{ debugName: "comments" }] : /* istanbul ignore next */ []);
22
+ errors = signal({}, ...ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []);
23
+ pending = apiResource({ stream: () => this.api.actionRequests({ state: "Pending" }) });
24
+ recent = apiResource({ stream: () => this.api.actionRequests({ limit: 30 }) });
25
+ decided = computed(() => (this.recent.value()?.items ?? []).filter((r) => r.state !== "Pending"), ...ngDevMode ? [{ debugName: "decided" }] : /* istanbul ignore next */ []);
26
+ error = computed(() => problemText(this.pending.error()), ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
27
+ constructor() {
28
+ effect((onCleanup) => {
29
+ this.pending.value();
30
+ const timer = setTimeout(() => {
31
+ this.pending.reload();
32
+ this.recent.reload();
33
+ }, 1e4);
34
+ onCleanup(() => clearTimeout(timer));
35
+ });
36
+ }
37
+ describe(r) {
38
+ return Object.entries(r.parameters ?? {}).map(([k, v]) => `${k}=${typeof v === "string" ? v : JSON.stringify(v)}`).join(", ");
39
+ }
40
+ comment(id, text) {
41
+ this.comments.update((c) => ({
42
+ ...c,
43
+ [id]: text
44
+ }));
45
+ }
46
+ decide(r, call) {
47
+ this.busy.set(r.id);
48
+ this.errors.update((e) => ({
49
+ ...e,
50
+ [r.id]: ""
51
+ }));
52
+ call.subscribe({
53
+ next: () => {
54
+ this.busy.set(null);
55
+ this.pending.reload();
56
+ this.recent.reload();
57
+ },
58
+ error: (e) => {
59
+ this.busy.set(null);
60
+ const status = e.status;
61
+ const text = status === 403 && r.policy === "SecondPerson" ? `An admin other than ${r.requestedBy} has to approve this.` : status === 403 ? "Deciding needs the admin role." : problemText(e);
62
+ this.errors.update((x) => ({
63
+ ...x,
64
+ [r.id]: text
65
+ }));
66
+ }
67
+ });
68
+ }
69
+ approve(r) {
70
+ this.decide(r, this.api.approveRequest(r.id, (this.comments()[r.id] ?? "").trim()));
71
+ }
72
+ reject(r) {
73
+ const comment = (this.comments()[r.id] ?? "").trim();
74
+ if (!comment) {
75
+ this.errors.update((e) => ({
76
+ ...e,
77
+ [r.id]: "Say why in the comment."
78
+ }));
79
+ return;
80
+ }
81
+ this.decide(r, this.api.rejectRequest(r.id, comment));
82
+ }
83
+ static ɵfac = i0.ɵɵngDeclareFactory({
84
+ minVersion: "12.0.0",
85
+ version: "22.2.4",
86
+ ngImport: i0,
87
+ type: ApprovalsPage,
88
+ deps: [],
89
+ target: i0.ɵɵFactoryTarget.Component
90
+ });
91
+ static ɵcmp = i0.ɵɵngDeclareComponent({
92
+ minVersion: "17.0.0",
93
+ version: "22.2.4",
94
+ type: ApprovalsPage,
95
+ isStandalone: true,
96
+ selector: "ng-component",
97
+ ngImport: i0,
98
+ template: `
99
+ <jc-context-bar><h1>Approvals</h1></jc-context-bar>
100
+ @if (pending.isLoading() && !pending.value()) { <mat-progress-bar mode="indeterminate" /> }
101
+ @if (pending.error()) { <p class="jc-error">{{ error() }}</p> }
102
+
103
+ <section class="jc-card" data-testid="approvals-pending">
104
+ <h2>Waiting</h2>
105
+ @for (r of pending.value()?.items ?? []; track r.id) {
106
+ <div class="jc-list-row" [attr.data-testid]="'approval-' + r.id">
107
+ <div>
108
+ <strong>{{ r.action }}</strong> on <a [routerLink]="['agents', r.agentId] | jcLink" [queryParams]="ctx.keep()">{{ r.hostname }}</a>
109
+ <span class="jc-badge" [class.jc-health-unhealthy]="r.risk === 'High'" [class.jc-health-degraded]="r.risk !== 'High'">{{ r.risk }} risk</span>
110
+ @if (describe(r); as d) { <div class="jc-mono jc-small">{{ d }}</div> }
111
+ <div class="jc-small">{{ r.requestedBy }}, {{ r.requestedAt | ago }}: {{ r.reason }}</div>
112
+ <div class="jc-muted jc-small">{{ r.policy === 'SecondPerson' ? 'Needs an admin other than ' + r.requestedBy : 'Needs an admin' }}. Expires {{ r.expiresAt | date: 'HH:mm' }}.</div>
113
+ </div>
114
+ <form class="jc-form" (ngSubmit)="approve(r)">
115
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-md"><mat-label>Comment</mat-label>
116
+ <input matInput [name]="'comment-' + r.id" [attr.data-testid]="'approval-comment-' + r.id" maxlength="500" [ngModel]="comments()[r.id] ?? ''" (ngModelChange)="comment(r.id, $event)">
117
+ </mat-form-field>
118
+ <button mat-flat-button type="submit" [attr.data-testid]="'approve-' + r.id" [disabled]="busy() === r.id">Approve</button>
119
+ <button mat-stroked-button type="button" [attr.data-testid]="'reject-' + r.id" [disabled]="busy() === r.id" (click)="reject(r)">Reject</button>
120
+ @if (errors()[r.id]; as e) { <span class="jc-error" [attr.data-testid]="'approval-error-' + r.id">{{ e }}</span> }
121
+ </form>
122
+ </div>
123
+ } @empty { <p class="jc-muted" data-testid="approvals-none">Nothing is waiting for approval.</p> }
124
+ </section>
125
+
126
+ <section class="jc-card">
127
+ <h2>Decided lately</h2>
128
+ <table class="jc-table" data-testid="approvals-decided">
129
+ <thead><tr><th>Asked</th><th>Action</th><th>By</th><th>Decision</th></tr></thead>
130
+ <tbody>
131
+ @for (r of decided(); track r.id) {
132
+ <tr>
133
+ <td class="jc-nowrap">{{ r.requestedAt | date: 'MMM d, HH:mm' }}</td>
134
+ <td><strong>{{ r.action }}</strong> on <a [routerLink]="['agents', r.agentId] | jcLink" [queryParams]="ctx.keep()">{{ r.hostname }}</a></td>
135
+ <td>{{ r.requestedBy }}</td>
136
+ <td>{{ r.state }}@if (r.decidedBy) { by {{ r.decidedBy }} }@if (r.command) { · command {{ r.command.state }} }@if (r.comment) { <div class="jc-small">{{ r.comment }}</div> }</td>
137
+ </tr>
138
+ } @empty { <tr><td colspan="4" class="jc-muted">None yet.</td></tr> }
139
+ </tbody>
140
+ </table>
141
+ </section>`,
142
+ isInline: true,
143
+ dependencies: [
144
+ {
145
+ kind: "directive",
146
+ type: RouterLink,
147
+ selector: "[routerLink]",
148
+ inputs: [
149
+ "target",
150
+ "queryParams",
151
+ "fragment",
152
+ "queryParamsHandling",
153
+ "state",
154
+ "info",
155
+ "relativeTo",
156
+ "preserveFragment",
157
+ "skipLocationChange",
158
+ "replaceUrl",
159
+ "browserUrl",
160
+ "routerLink"
161
+ ]
162
+ },
163
+ {
164
+ kind: "ngmodule",
165
+ type: FormsModule
166
+ },
167
+ {
168
+ kind: "directive",
169
+ type: i1.ɵNgNoValidate,
170
+ selector: "form:not([ngNoForm]):not([ngNativeValidate])"
171
+ },
172
+ {
173
+ kind: "directive",
174
+ type: i1.DefaultValueAccessor,
175
+ 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]"
176
+ },
177
+ {
178
+ kind: "directive",
179
+ type: i1.NgControlStatus,
180
+ selector: "[formControlName],[ngModel],[formControl]"
181
+ },
182
+ {
183
+ kind: "directive",
184
+ type: i1.NgControlStatusGroup,
185
+ selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
186
+ },
187
+ {
188
+ kind: "directive",
189
+ type: i1.MaxLengthValidator,
190
+ selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]",
191
+ inputs: ["maxlength"]
192
+ },
193
+ {
194
+ kind: "directive",
195
+ type: i1.NgModel,
196
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
197
+ inputs: [
198
+ "name",
199
+ "disabled",
200
+ "ngModel",
201
+ "ngModelOptions"
202
+ ],
203
+ outputs: ["ngModelChange"],
204
+ exportAs: ["ngModel"]
205
+ },
206
+ {
207
+ kind: "directive",
208
+ type: i1.NgForm,
209
+ selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
210
+ inputs: ["ngFormOptions"],
211
+ outputs: ["ngSubmit"],
212
+ exportAs: ["ngForm"]
213
+ },
214
+ {
215
+ kind: "ngmodule",
216
+ type: MatButtonModule
217
+ },
218
+ {
219
+ kind: "component",
220
+ type: i2.MatButton,
221
+ 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] ",
222
+ inputs: ["matButton"],
223
+ exportAs: ["matButton", "matAnchor"]
224
+ },
225
+ {
226
+ kind: "ngmodule",
227
+ type: MatFormFieldModule
228
+ },
229
+ {
230
+ kind: "component",
231
+ type: i3.MatFormField,
232
+ selector: "mat-form-field",
233
+ inputs: [
234
+ "hideRequiredMarker",
235
+ "color",
236
+ "floatLabel",
237
+ "appearance",
238
+ "subscriptSizing",
239
+ "hintLabel"
240
+ ],
241
+ exportAs: ["matFormField"]
242
+ },
243
+ {
244
+ kind: "directive",
245
+ type: i3.MatLabel,
246
+ selector: "mat-label"
247
+ },
248
+ {
249
+ kind: "ngmodule",
250
+ type: MatInputModule
251
+ },
252
+ {
253
+ kind: "directive",
254
+ type: i4.MatInput,
255
+ selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
256
+ inputs: [
257
+ "disabled",
258
+ "id",
259
+ "placeholder",
260
+ "name",
261
+ "required",
262
+ "type",
263
+ "errorStateMatcher",
264
+ "aria-describedby",
265
+ "value",
266
+ "readonly",
267
+ "disabledInteractive"
268
+ ],
269
+ exportAs: ["matInput"]
270
+ },
271
+ {
272
+ kind: "ngmodule",
273
+ type: MatProgressBarModule
274
+ },
275
+ {
276
+ kind: "component",
277
+ type: i5.MatProgressBar,
278
+ selector: "mat-progress-bar",
279
+ inputs: [
280
+ "color",
281
+ "value",
282
+ "bufferValue",
283
+ "mode"
284
+ ],
285
+ outputs: ["animationEnd"],
286
+ exportAs: ["matProgressBar"]
287
+ },
288
+ {
289
+ kind: "component",
290
+ type: ContextBar,
291
+ selector: "jc-context-bar"
292
+ },
293
+ {
294
+ kind: "pipe",
295
+ type: LinkPipe,
296
+ name: "jcLink"
297
+ },
298
+ {
299
+ kind: "pipe",
300
+ type: DatePipe,
301
+ name: "date"
302
+ },
303
+ {
304
+ kind: "pipe",
305
+ type: AgoPipe,
306
+ name: "ago"
307
+ }
308
+ ],
309
+ changeDetection: i0.ChangeDetectionStrategy.OnPush
310
+ });
311
+ };
312
+ i0.ɵɵngDeclareClassMetadata({
313
+ minVersion: "12.0.0",
314
+ version: "22.2.4",
315
+ ngImport: i0,
316
+ type: ApprovalsPage,
317
+ decorators: [{
318
+ type: Component,
319
+ args: [{
320
+ changeDetection: ChangeDetectionStrategy.OnPush,
321
+ imports: [
322
+ LinkPipe,
323
+ RouterLink,
324
+ DatePipe,
325
+ FormsModule,
326
+ MatButtonModule,
327
+ MatFormFieldModule,
328
+ MatInputModule,
329
+ MatProgressBarModule,
330
+ ContextBar,
331
+ AgoPipe
332
+ ],
333
+ template: `
334
+ <jc-context-bar><h1>Approvals</h1></jc-context-bar>
335
+ @if (pending.isLoading() && !pending.value()) { <mat-progress-bar mode="indeterminate" /> }
336
+ @if (pending.error()) { <p class="jc-error">{{ error() }}</p> }
337
+
338
+ <section class="jc-card" data-testid="approvals-pending">
339
+ <h2>Waiting</h2>
340
+ @for (r of pending.value()?.items ?? []; track r.id) {
341
+ <div class="jc-list-row" [attr.data-testid]="'approval-' + r.id">
342
+ <div>
343
+ <strong>{{ r.action }}</strong> on <a [routerLink]="['agents', r.agentId] | jcLink" [queryParams]="ctx.keep()">{{ r.hostname }}</a>
344
+ <span class="jc-badge" [class.jc-health-unhealthy]="r.risk === 'High'" [class.jc-health-degraded]="r.risk !== 'High'">{{ r.risk }} risk</span>
345
+ @if (describe(r); as d) { <div class="jc-mono jc-small">{{ d }}</div> }
346
+ <div class="jc-small">{{ r.requestedBy }}, {{ r.requestedAt | ago }}: {{ r.reason }}</div>
347
+ <div class="jc-muted jc-small">{{ r.policy === 'SecondPerson' ? 'Needs an admin other than ' + r.requestedBy : 'Needs an admin' }}. Expires {{ r.expiresAt | date: 'HH:mm' }}.</div>
348
+ </div>
349
+ <form class="jc-form" (ngSubmit)="approve(r)">
350
+ <mat-form-field subscriptSizing="dynamic" class="jc-field-md"><mat-label>Comment</mat-label>
351
+ <input matInput [name]="'comment-' + r.id" [attr.data-testid]="'approval-comment-' + r.id" maxlength="500" [ngModel]="comments()[r.id] ?? ''" (ngModelChange)="comment(r.id, $event)">
352
+ </mat-form-field>
353
+ <button mat-flat-button type="submit" [attr.data-testid]="'approve-' + r.id" [disabled]="busy() === r.id">Approve</button>
354
+ <button mat-stroked-button type="button" [attr.data-testid]="'reject-' + r.id" [disabled]="busy() === r.id" (click)="reject(r)">Reject</button>
355
+ @if (errors()[r.id]; as e) { <span class="jc-error" [attr.data-testid]="'approval-error-' + r.id">{{ e }}</span> }
356
+ </form>
357
+ </div>
358
+ } @empty { <p class="jc-muted" data-testid="approvals-none">Nothing is waiting for approval.</p> }
359
+ </section>
360
+
361
+ <section class="jc-card">
362
+ <h2>Decided lately</h2>
363
+ <table class="jc-table" data-testid="approvals-decided">
364
+ <thead><tr><th>Asked</th><th>Action</th><th>By</th><th>Decision</th></tr></thead>
365
+ <tbody>
366
+ @for (r of decided(); track r.id) {
367
+ <tr>
368
+ <td class="jc-nowrap">{{ r.requestedAt | date: 'MMM d, HH:mm' }}</td>
369
+ <td><strong>{{ r.action }}</strong> on <a [routerLink]="['agents', r.agentId] | jcLink" [queryParams]="ctx.keep()">{{ r.hostname }}</a></td>
370
+ <td>{{ r.requestedBy }}</td>
371
+ <td>{{ r.state }}@if (r.decidedBy) { by {{ r.decidedBy }} }@if (r.command) { · command {{ r.command.state }} }@if (r.comment) { <div class="jc-small">{{ r.comment }}</div> }</td>
372
+ </tr>
373
+ } @empty { <tr><td colspan="4" class="jc-muted">None yet.</td></tr> }
374
+ </tbody>
375
+ </table>
376
+ </section>`
377
+ }]
378
+ }],
379
+ ctorParameters: () => []
380
+ });
381
+ export { ApprovalsPage };
382
+
383
+ //# sourceMappingURL=juice-js-observability-approvals.page-DXi3O9Ol.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"juice-js-observability-approvals.page-DXi3O9Ol.mjs","names":[],"sources":["../../../../projects/juice-js/observability/src/lib/pages/approvals.page.ts"],"sourcesContent":["import { LinkPipe } from '../core/options';\nimport { ChangeDetectionStrategy, Component, computed, effect, inject, 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 { ActionRequest } from '../core/models';\nimport { AgoPipe } from '../shared/format';\nimport { apiResource } from '../shared/resource';\nimport { problemText } from '../shared/telemetry';\nimport { ContextBar } from '../shared/ui';\n\n/**\n * Requests waiting for approval, across every agent (roadmap Phase 8), and the ones decided lately. Admins approve or reject; under a\n * second-person policy, not their own. Approving signs the command and the agent runs it at its next poll.\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [LinkPipe, RouterLink, DatePipe, FormsModule, MatButtonModule, MatFormFieldModule, MatInputModule, MatProgressBarModule, ContextBar, AgoPipe],\n template: `\n <jc-context-bar><h1>Approvals</h1></jc-context-bar>\n @if (pending.isLoading() && !pending.value()) { <mat-progress-bar mode=\"indeterminate\" /> }\n @if (pending.error()) { <p class=\"jc-error\">{{ error() }}</p> }\n\n <section class=\"jc-card\" data-testid=\"approvals-pending\">\n <h2>Waiting</h2>\n @for (r of pending.value()?.items ?? []; track r.id) {\n <div class=\"jc-list-row\" [attr.data-testid]=\"'approval-' + r.id\">\n <div>\n <strong>{{ r.action }}</strong> on <a [routerLink]=\"['agents', r.agentId] | jcLink\" [queryParams]=\"ctx.keep()\">{{ r.hostname }}</a>\n <span class=\"jc-badge\" [class.jc-health-unhealthy]=\"r.risk === 'High'\" [class.jc-health-degraded]=\"r.risk !== 'High'\">{{ r.risk }} risk</span>\n @if (describe(r); as d) { <div class=\"jc-mono jc-small\">{{ d }}</div> }\n <div class=\"jc-small\">{{ r.requestedBy }}, {{ r.requestedAt | ago }}: {{ r.reason }}</div>\n <div class=\"jc-muted jc-small\">{{ r.policy === 'SecondPerson' ? 'Needs an admin other than ' + r.requestedBy : 'Needs an admin' }}. Expires {{ r.expiresAt | date: 'HH:mm' }}.</div>\n </div>\n <form class=\"jc-form\" (ngSubmit)=\"approve(r)\">\n <mat-form-field subscriptSizing=\"dynamic\" class=\"jc-field-md\"><mat-label>Comment</mat-label>\n <input matInput [name]=\"'comment-' + r.id\" [attr.data-testid]=\"'approval-comment-' + r.id\" maxlength=\"500\" [ngModel]=\"comments()[r.id] ?? ''\" (ngModelChange)=\"comment(r.id, $event)\">\n </mat-form-field>\n <button mat-flat-button type=\"submit\" [attr.data-testid]=\"'approve-' + r.id\" [disabled]=\"busy() === r.id\">Approve</button>\n <button mat-stroked-button type=\"button\" [attr.data-testid]=\"'reject-' + r.id\" [disabled]=\"busy() === r.id\" (click)=\"reject(r)\">Reject</button>\n @if (errors()[r.id]; as e) { <span class=\"jc-error\" [attr.data-testid]=\"'approval-error-' + r.id\">{{ e }}</span> }\n </form>\n </div>\n } @empty { <p class=\"jc-muted\" data-testid=\"approvals-none\">Nothing is waiting for approval.</p> }\n </section>\n\n <section class=\"jc-card\">\n <h2>Decided lately</h2>\n <table class=\"jc-table\" data-testid=\"approvals-decided\">\n <thead><tr><th>Asked</th><th>Action</th><th>By</th><th>Decision</th></tr></thead>\n <tbody>\n @for (r of decided(); track r.id) {\n <tr>\n <td class=\"jc-nowrap\">{{ r.requestedAt | date: 'MMM d, HH:mm' }}</td>\n <td><strong>{{ r.action }}</strong> on <a [routerLink]=\"['agents', r.agentId] | jcLink\" [queryParams]=\"ctx.keep()\">{{ r.hostname }}</a></td>\n <td>{{ r.requestedBy }}</td>\n <td>{{ r.state }}@if (r.decidedBy) { by {{ r.decidedBy }} }@if (r.command) { · command {{ r.command.state }} }@if (r.comment) { <div class=\"jc-small\">{{ r.comment }}</div> }</td>\n </tr>\n } @empty { <tr><td colspan=\"4\" class=\"jc-muted\">None yet.</td></tr> }\n </tbody>\n </table>\n </section>`,\n})\nexport class ApprovalsPage {\n protected readonly ctx = inject(ContextService);\n private readonly api = inject(ApiService);\n protected readonly busy = signal<string | null>(null);\n protected readonly comments = signal<Record<string, string>>({});\n protected readonly errors = signal<Record<string, string>>({});\n\n protected readonly pending = apiResource({ stream: () => this.api.actionRequests({ state: 'Pending' }) });\n private readonly recent = apiResource({ stream: () => this.api.actionRequests({ limit: 30 }) });\n protected readonly decided = computed(() => (this.recent.value()?.items ?? []).filter(r => r.state !== 'Pending'));\n protected readonly error = computed(() => problemText(this.pending.error()));\n\n constructor() {\n // Others ask and decide too: look again every 10 seconds.\n effect(onCleanup => {\n this.pending.value();\n const timer = setTimeout(() => { this.pending.reload(); this.recent.reload(); }, 10_000);\n onCleanup(() => clearTimeout(timer));\n });\n }\n\n protected describe(r: ActionRequest): string {\n return Object.entries(r.parameters ?? {}).map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`).join(', ');\n }\n\n protected comment(id: string, text: string) { this.comments.update(c => ({ ...c, [id]: text })); }\n\n private decide(r: ActionRequest, call: Observable<ActionRequest>) {\n this.busy.set(r.id);\n this.errors.update(e => ({ ...e, [r.id]: '' }));\n call.subscribe({\n next: () => { this.busy.set(null); this.pending.reload(); this.recent.reload(); },\n error: e => {\n this.busy.set(null);\n const status = (e as { status?: number }).status;\n const text = status === 403 && r.policy === 'SecondPerson' ? `An admin other than ${r.requestedBy} has to approve this.`\n : status === 403 ? 'Deciding needs the admin role.' : problemText(e);\n this.errors.update(x => ({ ...x, [r.id]: text }));\n },\n });\n }\n\n protected approve(r: ActionRequest) { this.decide(r, this.api.approveRequest(r.id, (this.comments()[r.id] ?? '').trim())); }\n\n protected reject(r: ActionRequest) {\n const comment = (this.comments()[r.id] ?? '').trim();\n if (!comment) { this.errors.update(e => ({ ...e, [r.id]: 'Say why in the comment.' })); return; }\n this.decide(r, this.api.rejectRequest(r.id, comment));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsEA,IAAa,gBAAb,MAAa,cAAa;CACL,MAAM,OAAO,cAAc;CAC7B,MAAM,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AA;IAAA,MAAA,GAAA;IAAA,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,UAAA,CAAA,UAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;GAAoB;GAAA;IAAA,MAAA;IAAA,MAAA,GAAA;IAAA,UAAA;IAAA,QAAA;KAAA;KAAA;KAAA;KAAA;IAAA;IAAA,SAAA,CAAA,cAAA;IAAA,UAAA,CAAA,gBAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAE;IAAU,UAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAlI;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAc;IAAQ,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAsG;IAAO,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AA8C1I,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAa,YAAA,CAAA;EAhDzB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAU;IAAa;IAAiB;IAAoB;IAAgB;IAAsB;IAAY;GAAO;GACrJ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CX,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { ApiService, ContextService, LinkPipe } from "./juice-js-observability.mjs";
2
- import { S as apiResource, o as problemText, u as ContextBar } from "./juice-js-observability-telemetry-BftWSOaQ.mjs";
2
+ import { c as ContextBar, h as apiResource, o as problemText } from "./juice-js-observability-telemetry-B98lekF2.mjs";
3
3
  import * as i0 from "@angular/core";
4
4
  import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from "@angular/core";
5
5
  import { RouterLink } from "@angular/router";
@@ -397,4 +397,4 @@ i0.ɵɵngDeclareClassMetadata({
397
397
  });
398
398
  export { IncidentPage };
399
399
 
400
- //# sourceMappingURL=juice-js-observability-incident.page-CCHEWXou.mjs.map
400
+ //# sourceMappingURL=juice-js-observability-incident.page-CayeZdF_.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"juice-js-observability-incident.page-CCHEWXou.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';\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],\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 <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\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":";;;;;;;;;;;;;;;;AAiBA,MAAM,QAAkC;CACtC,MAAM;EAAC;EAAiB;EAAa;CAAU;CAC/C,eAAe,CAAC,aAAa,UAAU;CACvC,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AAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EAxDxB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAU;IAAa;IAAiB;IAAoB;IAAgB;IAAsB;GAAU;GAC5I,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDX,CAAA"}
1
+ {"version":3,"file":"juice-js-observability-incident.page-CayeZdF_.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';\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],\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 <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\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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,MAAA;GAAA;GAAA;IAAA,MAAA;IAAA,MAAc;IAAQ,MAAA;GAAA;EAAA;EAAA,iBAAA,GAAA,wBAAA;CAAA,CAAA;;AAsD7B,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAY,YAAA,CAAA;EAxDxB,MAAA;EAAU,MAAA,CAAA;GACT,iBAAiB,wBAAwB;GACzC,SAAS;IAAC;IAAU;IAAY;IAAU;IAAa;IAAiB;IAAoB;IAAgB;IAAsB;GAAU;GAC5I,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoDX,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { ApiService, ContextService, LinkPipe, OBSERVABILITY_OPTIONS } from "./juice-js-observability.mjs";
2
- import { S as apiResource, o as problemText, u as ContextBar } from "./juice-js-observability-telemetry-BftWSOaQ.mjs";
2
+ import { c as ContextBar, h as apiResource, o as problemText } from "./juice-js-observability-telemetry-B98lekF2.mjs";
3
3
  import * as i0 from "@angular/core";
4
4
  import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from "@angular/core";
5
5
  import { Router, RouterLink } from "@angular/router";
@@ -435,4 +435,4 @@ i0.ɵɵngDeclareClassMetadata({
435
435
  });
436
436
  export { IncidentsPage };
437
437
 
438
- //# sourceMappingURL=juice-js-observability-incidents.page-CpNqYp2W.mjs.map
438
+ //# sourceMappingURL=juice-js-observability-incidents.page-Bx7afoIh.mjs.map