@juice-js/observability 1.5.0-alpha.62 → 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,790 +0,0 @@
1
- import { ApiService, OBSERVABILITY_OPTIONS } from "./juice-js-observability.mjs";
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 { forkJoin, 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_CHANNEL = {
23
- id: null,
24
- key: "",
25
- kind: "Slack",
26
- url: "",
27
- secretRef: "",
28
- recipients: "",
29
- ruleKeys: "",
30
- environments: "",
31
- minimumSeverity: "Info",
32
- groupWindowSeconds: 0,
33
- firing: true,
34
- resolved: true,
35
- enabled: true
36
- };
37
- const NEW_POLICY = {
38
- editing: false,
39
- key: "",
40
- name: "",
41
- ruleKeys: "",
42
- environments: "",
43
- minimumSeverity: "Critical",
44
- stopOnAcknowledge: true,
45
- enabled: true,
46
- steps: ""
47
- };
48
- var NotificationsPage = class NotificationsPage {
49
- api = inject(ApiService);
50
- notificationsLink = inject(OBSERVABILITY_OPTIONS).notificationsLink ?? null;
51
- channel = signal(null, ...ngDevMode ? [{ debugName: "channel" }] : /* istanbul ignore next */ []);
52
- policy = signal(null, ...ngDevMode ? [{ debugName: "policy" }] : /* istanbul ignore next */ []);
53
- history = signal(null, ...ngDevMode ? [{ debugName: "history" }] : /* istanbul ignore next */ []);
54
- saving = signal(false, ...ngDevMode ? [{ debugName: "saving" }] : /* istanbul ignore next */ []);
55
- channelError = signal("", ...ngDevMode ? [{ debugName: "channelError" }] : /* istanbul ignore next */ []);
56
- policyError = signal("", ...ngDevMode ? [{ debugName: "policyError" }] : /* istanbul ignore next */ []);
57
- allowError = signal("", ...ngDevMode ? [{ debugName: "allowError" }] : /* istanbul ignore next */ []);
58
- retryError = signal("", ...ngDevMode ? [{ debugName: "retryError" }] : /* istanbul ignore next */ []);
59
- testing = signal(null, ...ngDevMode ? [{ debugName: "testing" }] : /* istanbul ignore next */ []);
60
- tests = signal({}, ...ngDevMode ? [{ debugName: "tests" }] : /* istanbul ignore next */ []);
61
- destination = "";
62
- ports = "";
63
- data = apiResource({ stream: () => forkJoin({
64
- channels: this.api.channels().pipe(map((p) => p.items)),
65
- policies: this.api.escalationPolicies().pipe(map((p) => p.items)),
66
- allowlist: this.api.allowlist().pipe(map((p) => p.items))
67
- }) });
68
- error = computed(() => problemText(this.data.error()), ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
69
- channels = computed(() => this.data.value()?.channels ?? [], ...ngDevMode ? [{ debugName: "channels" }] : /* istanbul ignore next */ []);
70
- policies = computed(() => this.data.value()?.policies ?? [], ...ngDevMode ? [{ debugName: "policies" }] : /* istanbul ignore next */ []);
71
- allowed = computed(() => this.data.value()?.allowlist ?? [], ...ngDevMode ? [{ debugName: "allowed" }] : /* istanbul ignore next */ []);
72
- deliveries = apiResource({
73
- params: () => this.history() ?? void 0,
74
- stream: ({ params }) => this.api.deliveries(params)
75
- });
76
- deliveriesError = computed(() => problemText(this.deliveries.error()), ...ngDevMode ? [{ debugName: "deliveriesError" }] : /* istanbul ignore next */ []);
77
- newChannel() {
78
- this.channelError.set("");
79
- return { ...NEW_CHANNEL };
80
- }
81
- newPolicy() {
82
- this.policyError.set("");
83
- return { ...NEW_POLICY };
84
- }
85
- editChannel(c) {
86
- this.channelError.set("");
87
- this.channel.set({
88
- id: c.id,
89
- key: c.key,
90
- kind: c.kind,
91
- url: "",
92
- secretRef: c.secretRef ?? "",
93
- recipients: (c.recipients ?? []).join(", "),
94
- ruleKeys: c.ruleKeys.join(", "),
95
- environments: c.environments.join(", "),
96
- minimumSeverity: c.minimumSeverity,
97
- groupWindowSeconds: c.groupWindowSeconds,
98
- firing: c.events.includes("alert.firing"),
99
- resolved: c.events.includes("alert.resolved"),
100
- enabled: c.enabled
101
- });
102
- }
103
- run(request, error, done) {
104
- this.saving.set(true);
105
- error("");
106
- request.subscribe({
107
- next: () => {
108
- this.saving.set(false);
109
- done();
110
- this.data.reload();
111
- },
112
- error: (e) => {
113
- this.saving.set(false);
114
- error(e.status === 403 ? "This needs the admin role." : problemText(e));
115
- }
116
- });
117
- }
118
- saveChannel(f) {
119
- const events = [f.firing ? "alert.firing" : "", f.resolved ? "alert.resolved" : ""].filter(Boolean);
120
- const body = {
121
- key: f.key,
122
- kind: f.kind,
123
- url: f.kind === "Webhook" && f.url.trim() ? f.url.trim() : void 0,
124
- secretRef: f.kind === "Email" ? void 0 : f.secretRef.trim(),
125
- recipients: f.kind === "Email" ? list(f.recipients) : void 0,
126
- events,
127
- ruleKeys: list(f.ruleKeys),
128
- environments: list(f.environments).map((e) => e.toLowerCase()),
129
- minimumSeverity: f.minimumSeverity,
130
- groupWindowSeconds: f.groupWindowSeconds || 0,
131
- enabled: f.enabled
132
- };
133
- this.run(f.id ? this.api.updateChannel(f.id, body) : this.api.createChannel(body), (m) => this.channelError.set(m), () => this.channel.set(null));
134
- }
135
- editPolicy(p) {
136
- this.policyError.set("");
137
- this.policy.set({
138
- editing: true,
139
- key: p.key,
140
- name: p.name,
141
- ruleKeys: p.ruleKeys.join(", "),
142
- environments: p.environments.join(", "),
143
- minimumSeverity: p.minimumSeverity,
144
- stopOnAcknowledge: p.stopOnAcknowledge,
145
- enabled: p.enabled,
146
- steps: p.steps.map((s) => `${s.afterMinutes}: ${s.endpointKeys.join(", ")}`).join("\n")
147
- });
148
- }
149
- parseSteps(text) {
150
- return text.split("\n").map((l) => l.trim()).filter(Boolean).map((line) => {
151
- const [minutes, ...rest] = line.split(":");
152
- return {
153
- afterMinutes: Number(minutes.trim()),
154
- endpointKeys: list(rest.join(":"))
155
- };
156
- });
157
- }
158
- savePolicy(f) {
159
- const body = {
160
- key: f.key,
161
- name: f.name,
162
- enabled: f.enabled,
163
- ruleKeys: list(f.ruleKeys),
164
- environments: list(f.environments).map((e) => e.toLowerCase()),
165
- minimumSeverity: f.minimumSeverity,
166
- stopOnAcknowledge: f.stopOnAcknowledge,
167
- steps: this.parseSteps(f.steps)
168
- };
169
- this.run(f.editing ? this.api.updateEscalationPolicy(f.key, body) : this.api.createEscalationPolicy(body), (m) => this.policyError.set(m), () => this.policy.set(null));
170
- }
171
- addAllowed() {
172
- this.run(this.api.putAllowlist(this.destination.trim(), list(this.ports).map(Number)), (m) => this.allowError.set(m), () => {
173
- this.destination = "";
174
- this.ports = "";
175
- });
176
- }
177
- removeAllowed(destination) {
178
- this.run(this.api.removeAllowlist(destination), (m) => this.allowError.set(m), () => void 0);
179
- }
180
- testChannel(id) {
181
- this.testing.set(id);
182
- const show = (ok, text) => {
183
- this.testing.set(null);
184
- this.tests.update((t) => ({
185
- ...t,
186
- [id]: {
187
- ok,
188
- text
189
- }
190
- }));
191
- };
192
- this.api.testChannel(id).subscribe({
193
- next: (r) => show(r.delivered, r.delivered ? `Test delivered in ${r.durationMs} ms${r.statusCode ? ` (HTTP ${r.statusCode})` : ""}` : `Test failed: ${r.error ?? "unknown"}${r.statusCode ? ` (HTTP ${r.statusCode})` : ""}`),
194
- error: (e) => show(false, e.status === 403 ? "Testing a channel needs the admin role." : problemText(e))
195
- });
196
- }
197
- retry(deliveryId) {
198
- const channel = this.history();
199
- if (!channel) return;
200
- this.run(this.api.retryDelivery(channel, deliveryId), (m) => this.retryError.set(m), () => this.deliveries.reload());
201
- }
202
- static ɵfac = i0.ɵɵngDeclareFactory({
203
- minVersion: "12.0.0",
204
- version: "22.2.4",
205
- ngImport: i0,
206
- type: NotificationsPage,
207
- deps: [],
208
- target: i0.ɵɵFactoryTarget.Component
209
- });
210
- static ɵcmp = i0.ɵɵngDeclareComponent({
211
- minVersion: "17.0.0",
212
- version: "22.2.4",
213
- type: NotificationsPage,
214
- isStandalone: true,
215
- selector: "ng-component",
216
- ngImport: i0,
217
- template: `
218
- <jc-context-bar><h1>Notifications</h1></jc-context-bar>
219
- @if (notificationsLink; as link) {
220
- <p class="jc-notice" data-testid="notifications-moved">Alert notifications now have their own pages: deliveries, routes, integrations and
221
- templates are in <a [routerLink]="link" data-testid="notifications-link">Alerts › Notifications</a>. The webhooks here keep working until
222
- they are retired.</p>
223
- }
224
- @if (data.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
225
- @if (data.error()) { <p class="jc-error">{{ error() }}</p> }
226
-
227
- <section class="jc-card">
228
- <h2>Channels <button mat-button type="button" data-testid="channel-new" (click)="channel.set(newChannel())">New channel</button></h2>
229
- @if (channel(); as f) {
230
- <form class="jc-form" data-testid="channel-form" (ngSubmit)="saveChannel(f)">
231
- @if (!f.id) {
232
- <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>
233
- <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Kind</mat-label>
234
- <mat-select name="kind" [(ngModel)]="f.kind"><mat-option value="Slack">Slack</mat-option><mat-option value="Teams">Teams</mat-option><mat-option value="Email">Email</mat-option><mat-option value="Webhook">Signed webhook</mat-option></mat-select>
235
- </mat-form-field>
236
- }
237
- @if (f.kind === 'Webhook') { <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>{{ f.id ? 'New URL (keeps the current one if empty)' : 'URL' }}</mat-label><input matInput name="url" [(ngModel)]="f.url"></mat-form-field> }
238
- @if (f.kind === 'Email') { <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Recipients, comma separated</mat-label><input matInput name="recipients" [(ngModel)]="f.recipients"></mat-form-field> }
239
- @else {
240
- <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>{{ f.kind === 'Webhook' ? 'Signing secret reference' : 'Reference to the channel URL' }}</mat-label><input matInput name="secretRef" [(ngModel)]="f.secretRef" placeholder="env:JUICE_WEBHOOK_OPS"></mat-form-field>
241
- <p class="jc-muted jc-small jc-form-actions">{{ f.kind === 'Webhook' ? 'The name of where the signing secret is, set on the host.' : 'A Slack or Teams URL is itself a credential, so it stays on the host: this is the name of where it is.' }} Not the secret itself.</p>
242
- }
243
- <mat-form-field subscriptSizing="dynamic"><mat-label>Only these rules</mat-label><input matInput name="ruleKeys" [(ngModel)]="f.ruleKeys"></mat-form-field>
244
- <mat-form-field subscriptSizing="dynamic"><mat-label>Only these environments</mat-label><input matInput name="environments" [(ngModel)]="f.environments"></mat-form-field>
245
- <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Severity at least</mat-label>
246
- <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>
247
- </mat-form-field>
248
- <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Group for (s)</mat-label><input matInput type="number" min="0" max="3600" name="group" [(ngModel)]="f.groupWindowSeconds"></mat-form-field>
249
- <mat-checkbox name="firing" [(ngModel)]="f.firing">Firing</mat-checkbox>
250
- <mat-checkbox name="resolved" [(ngModel)]="f.resolved">Resolved</mat-checkbox>
251
- <mat-checkbox name="enabled" [(ngModel)]="f.enabled">Enabled</mat-checkbox>
252
- <div class="jc-form-actions">
253
- <button mat-flat-button type="submit" data-testid="channel-save" [disabled]="saving()">Save</button>
254
- <button mat-button type="button" (click)="channel.set(null)">Cancel</button>
255
- @if (channelError()) { <span class="jc-error" data-testid="channel-error">{{ channelError() }}</span> }
256
- </div>
257
- </form>
258
- }
259
- <table class="jc-table" data-testid="channels">
260
- <thead><tr><th>Channel</th><th>Kind</th><th>Destination</th><th>Takes</th><th>Failed (24 h)</th><th>Waiting</th><th></th></tr></thead>
261
- <tbody>
262
- @for (c of channels(); track c.id) {
263
- <tr [class.jc-muted]="!c.enabled">
264
- <td><strong>{{ c.key }}</strong><div class="jc-muted jc-small">@if (!c.enabled) { disabled · }@if (c.managedBy === 'config') { from the webhooks file }</div></td>
265
- <td>{{ c.kind }}</td>
266
- <td>{{ c.destination }}</td>
267
- <td class="jc-small">{{ c.minimumSeverity }} and above@if (c.environments.length) { · {{ c.environments.join(', ') }} }@if (c.ruleKeys.length) { · {{ c.ruleKeys.join(', ') }} }@if (c.groupWindowSeconds) { · grouped {{ c.groupWindowSeconds }} s }</td>
268
- <td [class.jc-bad]="c.recentFailures > 0">{{ c.recentFailures }}</td>
269
- <td>{{ c.waiting }}</td>
270
- <td class="jc-row-actions">
271
- <button mat-button type="button" [attr.data-testid]="'channel-history-' + c.key" (click)="history.set(history() === c.id ? null : c.id)">History</button>
272
- <button mat-button type="button" [attr.data-testid]="'channel-test-' + c.key" [disabled]="testing() === c.id" (click)="testChannel(c.id)">Test</button>
273
- @if (c.managedBy !== 'config') { <button mat-button type="button" [attr.data-testid]="'channel-edit-' + c.key" (click)="editChannel(c)">Change</button> }
274
- @if (tests()[c.id]; as t) { <div class="jc-small" [class.jc-error]="!t.ok" [attr.data-testid]="'channel-test-result-' + c.key">{{ t.text }}</div> }
275
- </td>
276
- </tr>
277
- } @empty { <tr><td colspan="7" class="jc-muted">No channels: alerts fire, but nobody is told.</td></tr> }
278
- </tbody>
279
- </table>
280
- @if (history()) {
281
- <h3>Delivery history</h3>
282
- @if (deliveries.error()) { <p class="jc-error">{{ deliveriesError() }}</p> }
283
- <table class="jc-table" data-testid="channel-history">
284
- <thead><tr><th>Created</th><th>Event</th><th>Status</th><th>Attempts</th><th>Last result</th><th></th></tr></thead>
285
- <tbody>
286
- @for (d of deliveries.value()?.items ?? []; track d.id) {
287
- <tr>
288
- <td class="jc-nowrap">{{ d.createdAt | date: 'MMM d, HH:mm:ss' }}</td>
289
- <td>{{ d.event }}@if (d.escalationStep) { step {{ d.escalationStep }} }</td>
290
- <td [class.jc-bad]="d.status === 'Failed'">{{ d.status }}</td>
291
- <td>{{ d.attempts }}</td>
292
- <td class="jc-small">{{ d.lastError ?? (d.lastStatusCode ? 'HTTP ' + d.lastStatusCode : '') }}</td>
293
- <td class="jc-row-actions">@if (d.status === 'Failed') { <button mat-button type="button" [attr.data-testid]="'delivery-retry-' + d.id" [disabled]="saving()" (click)="retry(d.id)">Retry</button> }</td>
294
- </tr>
295
- } @empty { <tr><td colspan="6" class="jc-muted">Nothing sent yet.</td></tr> }
296
- </tbody>
297
- </table>
298
- @if (retryError()) { <p class="jc-error" data-testid="delivery-retry-error">{{ retryError() }}</p> }
299
- }
300
- </section>
301
-
302
- <section class="jc-card">
303
- <h2>Escalation <button mat-button type="button" data-testid="policy-new" (click)="policy.set(newPolicy())">New policy</button></h2>
304
- @if (policy(); as f) {
305
- <form class="jc-form" data-testid="policy-form" (ngSubmit)="savePolicy(f)">
306
- @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> }
307
- <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>
308
- <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Steps, one a line</mat-label><textarea matInput name="steps" rows="3" [(ngModel)]="f.steps" placeholder="5: oncall-slack&#10;15: pager, lead-email"></textarea></mat-form-field>
309
- <p class="jc-muted jc-small jc-form-actions">Minutes after firing, then the channels to tell if the alert is still open.</p>
310
- <mat-form-field subscriptSizing="dynamic"><mat-label>Only these rules</mat-label><input matInput name="ruleKeys" [(ngModel)]="f.ruleKeys"></mat-form-field>
311
- <mat-form-field subscriptSizing="dynamic"><mat-label>Only these environments</mat-label><input matInput name="environments" [(ngModel)]="f.environments"></mat-form-field>
312
- <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Severity at least</mat-label>
313
- <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>
314
- </mat-form-field>
315
- <mat-checkbox name="stop" [(ngModel)]="f.stopOnAcknowledge">Stop when acknowledged</mat-checkbox>
316
- <mat-checkbox name="policyEnabled" [(ngModel)]="f.enabled">Enabled</mat-checkbox>
317
- <div class="jc-form-actions">
318
- <button mat-flat-button type="submit" data-testid="policy-save" [disabled]="saving()">Save</button>
319
- <button mat-button type="button" (click)="policy.set(null)">Cancel</button>
320
- @if (policyError()) { <span class="jc-error" data-testid="policy-error">{{ policyError() }}</span> }
321
- </div>
322
- </form>
323
- }
324
- <table class="jc-table" data-testid="policies">
325
- <thead><tr><th>Policy</th><th>Steps</th><th>Applies to</th><th>Stops when</th><th></th></tr></thead>
326
- <tbody>
327
- @for (p of policies(); track p.id) {
328
- <tr [class.jc-muted]="!p.enabled">
329
- <td><strong>{{ p.name }}</strong><div class="jc-muted jc-small">{{ p.key }}@if (!p.enabled) { · disabled }</div></td>
330
- <td class="jc-small">@for (s of p.steps; track s.afterMinutes) { <div>{{ s.afterMinutes }} min: {{ s.endpointKeys.join(', ') }}</div> }</td>
331
- <td class="jc-small">{{ p.minimumSeverity }} and above@if (p.environments.length) { · {{ p.environments.join(', ') }} }@if (p.ruleKeys.length) { · {{ p.ruleKeys.join(', ') }} }</td>
332
- <td class="jc-small">{{ p.stopOnAcknowledge ? 'Acknowledged or resolved' : 'Resolved' }}</td>
333
- <td class="jc-row-actions"><button mat-button type="button" (click)="editPolicy(p)">Change</button></td>
334
- </tr>
335
- } @empty { <tr><td colspan="5" class="jc-muted">No policies: a firing alert notifies once.</td></tr> }
336
- </tbody>
337
- </table>
338
- </section>
339
-
340
- <section class="jc-card">
341
- <h2>Private destinations</h2>
342
- <p class="jc-muted jc-small">A channel may reach a private address only if it's listed here. Loopback, link-local and cloud metadata addresses are never reachable.</p>
343
- <form class="jc-form" (ngSubmit)="addAllowed()">
344
- <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>CIDR or host name</mat-label><input matInput name="destination" data-testid="allow-destination" [(ngModel)]="destination"></mat-form-field>
345
- <mat-form-field subscriptSizing="dynamic" class="jc-field-md"><mat-label>Ports (443 if empty)</mat-label><input matInput name="ports" data-testid="allow-ports" [(ngModel)]="ports"></mat-form-field>
346
- <button mat-stroked-button type="submit" data-testid="allow-add" [disabled]="saving()">Allow</button>
347
- @if (allowError()) { <span class="jc-error" data-testid="allow-error">{{ allowError() }}</span> }
348
- </form>
349
- <table class="jc-table" data-testid="allowlist">
350
- <tbody>
351
- @for (a of allowed(); track a.destination) {
352
- <tr>
353
- <td><strong>{{ a.destination }}</strong> @if (a.managedBy === 'config') { <span class="jc-muted jc-small">from the webhooks file</span> }</td>
354
- <td>{{ a.ports.length ? a.ports.join(', ') : '443' }}</td>
355
- <td class="jc-row-actions">@if (a.managedBy !== 'config') { <button mat-button type="button" (click)="removeAllowed(a.destination)">Remove</button> }</td>
356
- </tr>
357
- } @empty { <tr><td class="jc-muted">None: channels reach public addresses only.</td></tr> }
358
- </tbody>
359
- </table>
360
- </section>`,
361
- isInline: true,
362
- dependencies: [
363
- {
364
- kind: "ngmodule",
365
- type: FormsModule
366
- },
367
- {
368
- kind: "directive",
369
- type: i1.ɵNgNoValidate,
370
- selector: "form:not([ngNoForm]):not([ngNativeValidate])"
371
- },
372
- {
373
- kind: "directive",
374
- type: i1.DefaultValueAccessor,
375
- 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]"
376
- },
377
- {
378
- kind: "directive",
379
- type: i1.NumberValueAccessor,
380
- selector: "input[type=number]:not([ngNoCva])[formControlName],input[type=number]:not([ngNoCva])[formControl],input[type=number]:not([ngNoCva])[ngModel]"
381
- },
382
- {
383
- kind: "directive",
384
- type: i1.NgControlStatus,
385
- selector: "[formControlName],[ngModel],[formControl]"
386
- },
387
- {
388
- kind: "directive",
389
- type: i1.NgControlStatusGroup,
390
- selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]"
391
- },
392
- {
393
- kind: "directive",
394
- type: i1.RequiredValidator,
395
- selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]",
396
- inputs: ["required"]
397
- },
398
- {
399
- kind: "directive",
400
- type: i1.MinValidator,
401
- selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]",
402
- inputs: ["min"]
403
- },
404
- {
405
- kind: "directive",
406
- type: i1.MaxValidator,
407
- selector: "input[type=number][max][formControlName],input[type=number][max][formControl],input[type=number][max][ngModel]",
408
- inputs: ["max"]
409
- },
410
- {
411
- kind: "directive",
412
- type: i1.NgModel,
413
- selector: "[ngModel]:not([formControlName]):not([formControl])",
414
- inputs: [
415
- "name",
416
- "disabled",
417
- "ngModel",
418
- "ngModelOptions"
419
- ],
420
- outputs: ["ngModelChange"],
421
- exportAs: ["ngModel"]
422
- },
423
- {
424
- kind: "directive",
425
- type: i1.NgForm,
426
- selector: "form:not([ngNoForm]):not([formGroup]):not([formArray]),ng-form,[ngForm]",
427
- inputs: ["ngFormOptions"],
428
- outputs: ["ngSubmit"],
429
- exportAs: ["ngForm"]
430
- },
431
- {
432
- kind: "ngmodule",
433
- type: MatButtonModule
434
- },
435
- {
436
- kind: "component",
437
- type: i2.MatButton,
438
- 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] ",
439
- inputs: ["matButton"],
440
- exportAs: ["matButton", "matAnchor"]
441
- },
442
- {
443
- kind: "ngmodule",
444
- type: MatCheckboxModule
445
- },
446
- {
447
- kind: "component",
448
- type: i3.MatCheckbox,
449
- selector: "mat-checkbox",
450
- inputs: [
451
- "aria-label",
452
- "aria-labelledby",
453
- "aria-describedby",
454
- "aria-expanded",
455
- "aria-controls",
456
- "aria-owns",
457
- "id",
458
- "required",
459
- "labelPosition",
460
- "name",
461
- "value",
462
- "disableRipple",
463
- "tabIndex",
464
- "color",
465
- "disabledInteractive",
466
- "checked",
467
- "disabled",
468
- "indeterminate"
469
- ],
470
- outputs: ["change", "indeterminateChange"],
471
- exportAs: ["matCheckbox"]
472
- },
473
- {
474
- kind: "ngmodule",
475
- type: MatFormFieldModule
476
- },
477
- {
478
- kind: "component",
479
- type: i4.MatFormField,
480
- selector: "mat-form-field",
481
- inputs: [
482
- "hideRequiredMarker",
483
- "color",
484
- "floatLabel",
485
- "appearance",
486
- "subscriptSizing",
487
- "hintLabel"
488
- ],
489
- exportAs: ["matFormField"]
490
- },
491
- {
492
- kind: "directive",
493
- type: i4.MatLabel,
494
- selector: "mat-label"
495
- },
496
- {
497
- kind: "ngmodule",
498
- type: MatInputModule
499
- },
500
- {
501
- kind: "directive",
502
- type: i5.MatInput,
503
- selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]",
504
- inputs: [
505
- "disabled",
506
- "id",
507
- "placeholder",
508
- "name",
509
- "required",
510
- "type",
511
- "errorStateMatcher",
512
- "aria-describedby",
513
- "value",
514
- "readonly",
515
- "disabledInteractive"
516
- ],
517
- exportAs: ["matInput"]
518
- },
519
- {
520
- kind: "ngmodule",
521
- type: MatProgressBarModule
522
- },
523
- {
524
- kind: "component",
525
- type: i6.MatProgressBar,
526
- selector: "mat-progress-bar",
527
- inputs: [
528
- "color",
529
- "value",
530
- "bufferValue",
531
- "mode"
532
- ],
533
- outputs: ["animationEnd"],
534
- exportAs: ["matProgressBar"]
535
- },
536
- {
537
- kind: "ngmodule",
538
- type: MatSelectModule
539
- },
540
- {
541
- kind: "component",
542
- type: i4.MatSelect,
543
- selector: "mat-select",
544
- inputs: [
545
- "aria-describedby",
546
- "panelClass",
547
- "disabled",
548
- "disableRipple",
549
- "tabIndex",
550
- "hideSingleSelectionIndicator",
551
- "placeholder",
552
- "required",
553
- "multiple",
554
- "disableOptionCentering",
555
- "compareWith",
556
- "value",
557
- "aria-label",
558
- "aria-labelledby",
559
- "errorStateMatcher",
560
- "typeaheadDebounceInterval",
561
- "sortComparator",
562
- "id",
563
- "panelWidth",
564
- "canSelectNullableOptions"
565
- ],
566
- outputs: [
567
- "openedChange",
568
- "opened",
569
- "closed",
570
- "selectionChange",
571
- "valueChange"
572
- ],
573
- exportAs: ["matSelect"]
574
- },
575
- {
576
- kind: "component",
577
- type: i4.MatOption,
578
- selector: "mat-option",
579
- inputs: [
580
- "value",
581
- "id",
582
- "disabled"
583
- ],
584
- outputs: ["onSelectionChange"],
585
- exportAs: ["matOption"]
586
- },
587
- {
588
- kind: "component",
589
- type: ContextBar,
590
- selector: "jc-context-bar"
591
- },
592
- {
593
- kind: "directive",
594
- type: RouterLink,
595
- selector: "[routerLink]",
596
- inputs: [
597
- "target",
598
- "queryParams",
599
- "fragment",
600
- "queryParamsHandling",
601
- "state",
602
- "info",
603
- "relativeTo",
604
- "preserveFragment",
605
- "skipLocationChange",
606
- "replaceUrl",
607
- "browserUrl",
608
- "routerLink"
609
- ]
610
- },
611
- {
612
- kind: "pipe",
613
- type: DatePipe,
614
- name: "date"
615
- }
616
- ],
617
- changeDetection: i0.ChangeDetectionStrategy.OnPush
618
- });
619
- };
620
- i0.ɵɵngDeclareClassMetadata({
621
- minVersion: "12.0.0",
622
- version: "22.2.4",
623
- ngImport: i0,
624
- type: NotificationsPage,
625
- decorators: [{
626
- type: Component,
627
- args: [{
628
- changeDetection: ChangeDetectionStrategy.OnPush,
629
- imports: [
630
- DatePipe,
631
- FormsModule,
632
- MatButtonModule,
633
- MatCheckboxModule,
634
- MatFormFieldModule,
635
- MatInputModule,
636
- MatProgressBarModule,
637
- MatSelectModule,
638
- ContextBar,
639
- RouterLink
640
- ],
641
- template: `
642
- <jc-context-bar><h1>Notifications</h1></jc-context-bar>
643
- @if (notificationsLink; as link) {
644
- <p class="jc-notice" data-testid="notifications-moved">Alert notifications now have their own pages: deliveries, routes, integrations and
645
- templates are in <a [routerLink]="link" data-testid="notifications-link">Alerts › Notifications</a>. The webhooks here keep working until
646
- they are retired.</p>
647
- }
648
- @if (data.isLoading()) { <mat-progress-bar mode="indeterminate" /> }
649
- @if (data.error()) { <p class="jc-error">{{ error() }}</p> }
650
-
651
- <section class="jc-card">
652
- <h2>Channels <button mat-button type="button" data-testid="channel-new" (click)="channel.set(newChannel())">New channel</button></h2>
653
- @if (channel(); as f) {
654
- <form class="jc-form" data-testid="channel-form" (ngSubmit)="saveChannel(f)">
655
- @if (!f.id) {
656
- <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>
657
- <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Kind</mat-label>
658
- <mat-select name="kind" [(ngModel)]="f.kind"><mat-option value="Slack">Slack</mat-option><mat-option value="Teams">Teams</mat-option><mat-option value="Email">Email</mat-option><mat-option value="Webhook">Signed webhook</mat-option></mat-select>
659
- </mat-form-field>
660
- }
661
- @if (f.kind === 'Webhook') { <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>{{ f.id ? 'New URL (keeps the current one if empty)' : 'URL' }}</mat-label><input matInput name="url" [(ngModel)]="f.url"></mat-form-field> }
662
- @if (f.kind === 'Email') { <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Recipients, comma separated</mat-label><input matInput name="recipients" [(ngModel)]="f.recipients"></mat-form-field> }
663
- @else {
664
- <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>{{ f.kind === 'Webhook' ? 'Signing secret reference' : 'Reference to the channel URL' }}</mat-label><input matInput name="secretRef" [(ngModel)]="f.secretRef" placeholder="env:JUICE_WEBHOOK_OPS"></mat-form-field>
665
- <p class="jc-muted jc-small jc-form-actions">{{ f.kind === 'Webhook' ? 'The name of where the signing secret is, set on the host.' : 'A Slack or Teams URL is itself a credential, so it stays on the host: this is the name of where it is.' }} Not the secret itself.</p>
666
- }
667
- <mat-form-field subscriptSizing="dynamic"><mat-label>Only these rules</mat-label><input matInput name="ruleKeys" [(ngModel)]="f.ruleKeys"></mat-form-field>
668
- <mat-form-field subscriptSizing="dynamic"><mat-label>Only these environments</mat-label><input matInput name="environments" [(ngModel)]="f.environments"></mat-form-field>
669
- <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Severity at least</mat-label>
670
- <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>
671
- </mat-form-field>
672
- <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Group for (s)</mat-label><input matInput type="number" min="0" max="3600" name="group" [(ngModel)]="f.groupWindowSeconds"></mat-form-field>
673
- <mat-checkbox name="firing" [(ngModel)]="f.firing">Firing</mat-checkbox>
674
- <mat-checkbox name="resolved" [(ngModel)]="f.resolved">Resolved</mat-checkbox>
675
- <mat-checkbox name="enabled" [(ngModel)]="f.enabled">Enabled</mat-checkbox>
676
- <div class="jc-form-actions">
677
- <button mat-flat-button type="submit" data-testid="channel-save" [disabled]="saving()">Save</button>
678
- <button mat-button type="button" (click)="channel.set(null)">Cancel</button>
679
- @if (channelError()) { <span class="jc-error" data-testid="channel-error">{{ channelError() }}</span> }
680
- </div>
681
- </form>
682
- }
683
- <table class="jc-table" data-testid="channels">
684
- <thead><tr><th>Channel</th><th>Kind</th><th>Destination</th><th>Takes</th><th>Failed (24 h)</th><th>Waiting</th><th></th></tr></thead>
685
- <tbody>
686
- @for (c of channels(); track c.id) {
687
- <tr [class.jc-muted]="!c.enabled">
688
- <td><strong>{{ c.key }}</strong><div class="jc-muted jc-small">@if (!c.enabled) { disabled · }@if (c.managedBy === 'config') { from the webhooks file }</div></td>
689
- <td>{{ c.kind }}</td>
690
- <td>{{ c.destination }}</td>
691
- <td class="jc-small">{{ c.minimumSeverity }} and above@if (c.environments.length) { · {{ c.environments.join(', ') }} }@if (c.ruleKeys.length) { · {{ c.ruleKeys.join(', ') }} }@if (c.groupWindowSeconds) { · grouped {{ c.groupWindowSeconds }} s }</td>
692
- <td [class.jc-bad]="c.recentFailures > 0">{{ c.recentFailures }}</td>
693
- <td>{{ c.waiting }}</td>
694
- <td class="jc-row-actions">
695
- <button mat-button type="button" [attr.data-testid]="'channel-history-' + c.key" (click)="history.set(history() === c.id ? null : c.id)">History</button>
696
- <button mat-button type="button" [attr.data-testid]="'channel-test-' + c.key" [disabled]="testing() === c.id" (click)="testChannel(c.id)">Test</button>
697
- @if (c.managedBy !== 'config') { <button mat-button type="button" [attr.data-testid]="'channel-edit-' + c.key" (click)="editChannel(c)">Change</button> }
698
- @if (tests()[c.id]; as t) { <div class="jc-small" [class.jc-error]="!t.ok" [attr.data-testid]="'channel-test-result-' + c.key">{{ t.text }}</div> }
699
- </td>
700
- </tr>
701
- } @empty { <tr><td colspan="7" class="jc-muted">No channels: alerts fire, but nobody is told.</td></tr> }
702
- </tbody>
703
- </table>
704
- @if (history()) {
705
- <h3>Delivery history</h3>
706
- @if (deliveries.error()) { <p class="jc-error">{{ deliveriesError() }}</p> }
707
- <table class="jc-table" data-testid="channel-history">
708
- <thead><tr><th>Created</th><th>Event</th><th>Status</th><th>Attempts</th><th>Last result</th><th></th></tr></thead>
709
- <tbody>
710
- @for (d of deliveries.value()?.items ?? []; track d.id) {
711
- <tr>
712
- <td class="jc-nowrap">{{ d.createdAt | date: 'MMM d, HH:mm:ss' }}</td>
713
- <td>{{ d.event }}@if (d.escalationStep) { step {{ d.escalationStep }} }</td>
714
- <td [class.jc-bad]="d.status === 'Failed'">{{ d.status }}</td>
715
- <td>{{ d.attempts }}</td>
716
- <td class="jc-small">{{ d.lastError ?? (d.lastStatusCode ? 'HTTP ' + d.lastStatusCode : '') }}</td>
717
- <td class="jc-row-actions">@if (d.status === 'Failed') { <button mat-button type="button" [attr.data-testid]="'delivery-retry-' + d.id" [disabled]="saving()" (click)="retry(d.id)">Retry</button> }</td>
718
- </tr>
719
- } @empty { <tr><td colspan="6" class="jc-muted">Nothing sent yet.</td></tr> }
720
- </tbody>
721
- </table>
722
- @if (retryError()) { <p class="jc-error" data-testid="delivery-retry-error">{{ retryError() }}</p> }
723
- }
724
- </section>
725
-
726
- <section class="jc-card">
727
- <h2>Escalation <button mat-button type="button" data-testid="policy-new" (click)="policy.set(newPolicy())">New policy</button></h2>
728
- @if (policy(); as f) {
729
- <form class="jc-form" data-testid="policy-form" (ngSubmit)="savePolicy(f)">
730
- @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> }
731
- <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>
732
- <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>Steps, one a line</mat-label><textarea matInput name="steps" rows="3" [(ngModel)]="f.steps" placeholder="5: oncall-slack&#10;15: pager, lead-email"></textarea></mat-form-field>
733
- <p class="jc-muted jc-small jc-form-actions">Minutes after firing, then the channels to tell if the alert is still open.</p>
734
- <mat-form-field subscriptSizing="dynamic"><mat-label>Only these rules</mat-label><input matInput name="ruleKeys" [(ngModel)]="f.ruleKeys"></mat-form-field>
735
- <mat-form-field subscriptSizing="dynamic"><mat-label>Only these environments</mat-label><input matInput name="environments" [(ngModel)]="f.environments"></mat-form-field>
736
- <mat-form-field subscriptSizing="dynamic" class="jc-field-sm"><mat-label>Severity at least</mat-label>
737
- <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>
738
- </mat-form-field>
739
- <mat-checkbox name="stop" [(ngModel)]="f.stopOnAcknowledge">Stop when acknowledged</mat-checkbox>
740
- <mat-checkbox name="policyEnabled" [(ngModel)]="f.enabled">Enabled</mat-checkbox>
741
- <div class="jc-form-actions">
742
- <button mat-flat-button type="submit" data-testid="policy-save" [disabled]="saving()">Save</button>
743
- <button mat-button type="button" (click)="policy.set(null)">Cancel</button>
744
- @if (policyError()) { <span class="jc-error" data-testid="policy-error">{{ policyError() }}</span> }
745
- </div>
746
- </form>
747
- }
748
- <table class="jc-table" data-testid="policies">
749
- <thead><tr><th>Policy</th><th>Steps</th><th>Applies to</th><th>Stops when</th><th></th></tr></thead>
750
- <tbody>
751
- @for (p of policies(); track p.id) {
752
- <tr [class.jc-muted]="!p.enabled">
753
- <td><strong>{{ p.name }}</strong><div class="jc-muted jc-small">{{ p.key }}@if (!p.enabled) { · disabled }</div></td>
754
- <td class="jc-small">@for (s of p.steps; track s.afterMinutes) { <div>{{ s.afterMinutes }} min: {{ s.endpointKeys.join(', ') }}</div> }</td>
755
- <td class="jc-small">{{ p.minimumSeverity }} and above@if (p.environments.length) { · {{ p.environments.join(', ') }} }@if (p.ruleKeys.length) { · {{ p.ruleKeys.join(', ') }} }</td>
756
- <td class="jc-small">{{ p.stopOnAcknowledge ? 'Acknowledged or resolved' : 'Resolved' }}</td>
757
- <td class="jc-row-actions"><button mat-button type="button" (click)="editPolicy(p)">Change</button></td>
758
- </tr>
759
- } @empty { <tr><td colspan="5" class="jc-muted">No policies: a firing alert notifies once.</td></tr> }
760
- </tbody>
761
- </table>
762
- </section>
763
-
764
- <section class="jc-card">
765
- <h2>Private destinations</h2>
766
- <p class="jc-muted jc-small">A channel may reach a private address only if it's listed here. Loopback, link-local and cloud metadata addresses are never reachable.</p>
767
- <form class="jc-form" (ngSubmit)="addAllowed()">
768
- <mat-form-field subscriptSizing="dynamic" class="jc-field-wide"><mat-label>CIDR or host name</mat-label><input matInput name="destination" data-testid="allow-destination" [(ngModel)]="destination"></mat-form-field>
769
- <mat-form-field subscriptSizing="dynamic" class="jc-field-md"><mat-label>Ports (443 if empty)</mat-label><input matInput name="ports" data-testid="allow-ports" [(ngModel)]="ports"></mat-form-field>
770
- <button mat-stroked-button type="submit" data-testid="allow-add" [disabled]="saving()">Allow</button>
771
- @if (allowError()) { <span class="jc-error" data-testid="allow-error">{{ allowError() }}</span> }
772
- </form>
773
- <table class="jc-table" data-testid="allowlist">
774
- <tbody>
775
- @for (a of allowed(); track a.destination) {
776
- <tr>
777
- <td><strong>{{ a.destination }}</strong> @if (a.managedBy === 'config') { <span class="jc-muted jc-small">from the webhooks file</span> }</td>
778
- <td>{{ a.ports.length ? a.ports.join(', ') : '443' }}</td>
779
- <td class="jc-row-actions">@if (a.managedBy !== 'config') { <button mat-button type="button" (click)="removeAllowed(a.destination)">Remove</button> }</td>
780
- </tr>
781
- } @empty { <tr><td class="jc-muted">None: channels reach public addresses only.</td></tr> }
782
- </tbody>
783
- </table>
784
- </section>`
785
- }]
786
- }]
787
- });
788
- export { NotificationsPage };
789
-
790
- //# sourceMappingURL=juice-js-observability-notifications.page-BpiDip9e.mjs.map