This is an automated email from the ASF dual-hosted git repository. gongchao pushed a commit to branch alarm-1-3 in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
commit 3b23c3ad5c550aa711132632927d86042ed54e25 Author: tomsun28 <[email protected]> AuthorDate: Fri Jan 3 15:48:54 2025 +0800 [webapp] update alert inhibit Signed-off-by: tomsun28 <[email protected]> --- .../app/layout/basic/widgets/notify.component.ts | 2 +- web-app/src/app/pojo/AlertDefine.ts | 1 + .../alert/alert-center/alert-center.component.html | 8 +++--- .../alert/alert-notice/alert-notice.component.html | 8 +++--- .../alert-setting/alert-setting.component.html | 31 +++++++++++----------- .../alert/alert-setting/alert-setting.component.ts | 11 ++++++++ .../alert-silence/alert-silence.component.html | 8 +++--- .../app/routes/dashboard/dashboard.component.html | 12 ++++----- .../app/routes/dashboard/dashboard.component.ts | 2 +- web-app/src/assets/i18n/zh-CN.json | 2 +- 10 files changed, 49 insertions(+), 36 deletions(-) diff --git a/web-app/src/app/layout/basic/widgets/notify.component.ts b/web-app/src/app/layout/basic/widgets/notify.component.ts index 2a45af50a..b65ee7662 100644 --- a/web-app/src/app/layout/basic/widgets/notify.component.ts +++ b/web-app/src/app/layout/basic/widgets/notify.component.ts @@ -206,7 +206,7 @@ export class HeaderNotifyComponent implements OnInit, OnDestroy { let item = { id: alert.id, avatar: '/assets/img/notification.svg', - // title: `${alert.tags?.monitorName}--${this.i18nSvc.fanyi(`alert.priority.${alert.priority}`)}`, + // title: `${alert.tags?.monitorName}--${this.i18nSvc.fanyi(`alert.severity.${alert.severity}`)}`, title: alert.content, datetime: new Date(alert.activeAt).toLocaleString(), color: 'blue', diff --git a/web-app/src/app/pojo/AlertDefine.ts b/web-app/src/app/pojo/AlertDefine.ts index 07153662f..bfaf6dbf0 100644 --- a/web-app/src/app/pojo/AlertDefine.ts +++ b/web-app/src/app/pojo/AlertDefine.ts @@ -28,6 +28,7 @@ export class AlertDefine { // unit second period: number = 300; times: number = 3; + // severity: info, warning, critical, emergency, fatal labels!: Record<string, string>; annotations!: Record<string, string>; enable: boolean = true; diff --git a/web-app/src/app/routes/alert/alert-center/alert-center.component.html b/web-app/src/app/routes/alert/alert-center/alert-center.component.html index 8870e4e26..c141e8c60 100644 --- a/web-app/src/app/routes/alert/alert-center/alert-center.component.html +++ b/web-app/src/app/routes/alert/alert-center/alert-center.component.html @@ -40,10 +40,10 @@ [(ngModel)]="filterPriority" (ngModelChange)="loadAlertsTable()" > - <nz-option [nzLabel]="'alert.priority.all' | i18n" [nzValue]="9"></nz-option> - <nz-option [nzLabel]="'alert.priority.2' | i18n" [nzValue]="2"></nz-option> - <nz-option [nzLabel]="'alert.priority.1' | i18n" [nzValue]="1"></nz-option> - <nz-option [nzLabel]="'alert.priority.0' | i18n" [nzValue]="0"></nz-option> + <nz-option [nzLabel]="'alert.severity.all' | i18n" [nzValue]="9"></nz-option> + <nz-option [nzLabel]="'alert.severity.2' | i18n" [nzValue]="2"></nz-option> + <nz-option [nzLabel]="'alert.severity.1' | i18n" [nzValue]="1"></nz-option> + <nz-option [nzLabel]="'alert.severity.0' | i18n" [nzValue]="0"></nz-option> </nz-select> <nz-select class="mobile-hide" diff --git a/web-app/src/app/routes/alert/alert-notice/alert-notice.component.html b/web-app/src/app/routes/alert/alert-notice/alert-notice.component.html index f81609c4e..ee0e6e647 100644 --- a/web-app/src/app/routes/alert/alert-notice/alert-notice.component.html +++ b/web-app/src/app/routes/alert/alert-notice/alert-notice.component.html @@ -470,10 +470,10 @@ nzShowSearch required > - <nz-option [nzLabel]="'alert.priority.all' | i18n" [nzValue]="9"></nz-option> - <nz-option [nzLabel]="'alert.priority.0' | i18n" [nzValue]="0"></nz-option> - <nz-option [nzLabel]="'alert.priority.1' | i18n" [nzValue]="1"></nz-option> - <nz-option [nzLabel]="'alert.priority.2' | i18n" [nzValue]="2"></nz-option> + <nz-option [nzLabel]="'alert.severity.all' | i18n" [nzValue]="9"></nz-option> + <nz-option [nzLabel]="'alert.severity.0' | i18n" [nzValue]="0"></nz-option> + <nz-option [nzLabel]="'alert.severity.1' | i18n" [nzValue]="1"></nz-option> + <nz-option [nzLabel]="'alert.severity.2' | i18n" [nzValue]="2"></nz-option> </nz-select> </nz-form-control> </nz-form-item> diff --git a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html index 7d0229577..a0ed89183 100644 --- a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html +++ b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html @@ -96,7 +96,7 @@ <th nzAlign="center" nzWidth="8%">{{ 'alert.setting.type' | i18n }}</th> <th nzAlign="center" nzWidth="24%">{{ 'alert.setting.expr' | i18n }}</th> <th nzAlign="center" nzWidth="20%">{{ 'alert.setting.template' | i18n }}</th> - <th nzAlign="center" nzWidth="8%">{{ 'alert.priority' | i18n }}</th> + <th nzAlign="center" nzWidth="8%">{{ 'alert.severity' | i18n }}</th> <th nzAlign="center" nzWidth="8%">{{ 'alert.setting.enable' | i18n }}</th> <th nzAlign="center" nzWidth="8%">{{ 'common.edit' | i18n }}</th> </tr> @@ -120,17 +120,17 @@ </td> <td nzAlign="center">{{ data.template }}</td> <td nzAlign="center"> - <nz-tag *ngIf="data.priority == 0" nzColor="red"> + <nz-tag *ngIf="severity == 'emergency'" nzColor="red"> <i nz-icon nzType="bell" nzTheme="outline"></i> - <span>{{ 'alert.priority.0' | i18n }}</span> + <span>{{ 'alert.severity.0' | i18n }}</span> </nz-tag> - <nz-tag *ngIf="data.priority == 1" nzColor="orange"> + <nz-tag *ngIf="severity == 'critical'" nzColor="orange"> <i nz-icon nzType="bell" nzTheme="outline"></i> - <span>{{ 'alert.priority.1' | i18n }}</span> + <span>{{ 'alert.severity.1' | i18n }}</span> </nz-tag> - <nz-tag *ngIf="data.priority == 2" nzColor="yellow"> + <nz-tag *ngIf="severity == 'warning'" nzColor="yellow"> <i nz-icon nzType="bell" nzTheme="outline"></i> - <span>{{ 'alert.priority.2' | i18n }}</span> + <span>{{ 'alert.severity.2' | i18n }}</span> </nz-tag> </td> <td nzAlign="center"> @@ -481,19 +481,20 @@ </nz-form-control> </nz-form-item> <nz-form-item> - <nz-form-label nzSpan="7" nzRequired="true" nzFor="priority" [nzTooltipTitle]="'alert.setting.priority.tip' | i18n"> - {{ 'alert.priority' | i18n }} + <nz-form-label nzSpan="7" nzRequired="true" nzFor="severity" [nzTooltipTitle]="'alert.setting.priority.tip' | i18n"> + {{ 'alert.severity' | i18n }} </nz-form-label> <nz-form-control nzSpan="12" [nzErrorTip]="'validation.required' | i18n"> <nz-select - [(ngModel)]="define.priority" + [(ngModel)]="severity" + (ngModelChange)="onSeverityChange()" [nzPlaceHolder]="'alert.notice.rule.priority.placeholder' | i18n" - name="priority" - id="priority" + name="severity" + id="severity" > - <nz-option [nzValue]="0" [nzLabel]="'alert.priority.0' | i18n"></nz-option> - <nz-option [nzValue]="1" [nzLabel]="'alert.priority.1' | i18n"></nz-option> - <nz-option [nzValue]="2" [nzLabel]="'alert.priority.2' | i18n"></nz-option> + <nz-option [nzValue]="'emergency'" [nzLabel]="'alert.severity.0' | i18n"></nz-option> + <nz-option [nzValue]="'critical'" [nzLabel]="'alert.severity.1' | i18n"></nz-option> + <nz-option [nzValue]="'warning'" [nzLabel]="'alert.severity.2' | i18n"></nz-option> </nz-select> </nz-form-control> </nz-form-item> diff --git a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts index 1ff946e0a..b6b3cb1d7 100644 --- a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts +++ b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts @@ -468,6 +468,7 @@ export class AlertSettingComponent implements OnInit { currentMetrics: any[] = []; isExpr = false; userExpr!: string; + severity!: string; editAlertDefine(alertDefineId: number) { if (this.isLoadingEdit !== -1) return; @@ -488,6 +489,9 @@ export class AlertSettingComponent implements OnInit { message => { if (message.code === 0) { this.define = message.data; + if (this.define.labels && this.define.labels['severity']) { + this.severity = this.define.labels['severity']; + } // Set default period for periodic alert if not set if (this.define.type === 'periodic' && !this.define.period) { this.define.period = 300; @@ -848,6 +852,13 @@ export class AlertSettingComponent implements OnInit { } } + onSeverityChange() { + if (!this.define.labels) { + this.define.labels = {}; + } + this.define.labels['severity'] = this.severity; + } + onManageModalCancel() { this.cascadeValues = []; this.isExpr = false; diff --git a/web-app/src/app/routes/alert/alert-silence/alert-silence.component.html b/web-app/src/app/routes/alert/alert-silence/alert-silence.component.html index c57f5e7d0..f4d9d12db 100755 --- a/web-app/src/app/routes/alert/alert-silence/alert-silence.component.html +++ b/web-app/src/app/routes/alert/alert-silence/alert-silence.component.html @@ -217,10 +217,10 @@ name="priorities" id="priorities" > - <nz-option [nzLabel]="'alert.priority.all' | i18n" [nzValue]="9"></nz-option> - <nz-option [nzLabel]="'alert.priority.0' | i18n" [nzValue]="0"></nz-option> - <nz-option [nzLabel]="'alert.priority.1' | i18n" [nzValue]="1"></nz-option> - <nz-option [nzLabel]="'alert.priority.2' | i18n" [nzValue]="2"></nz-option> + <nz-option [nzLabel]="'alert.severity.all' | i18n" [nzValue]="9"></nz-option> + <nz-option [nzLabel]="'alert.severity.0' | i18n" [nzValue]="0"></nz-option> + <nz-option [nzLabel]="'alert.severity.1' | i18n" [nzValue]="1"></nz-option> + <nz-option [nzLabel]="'alert.severity.2' | i18n" [nzValue]="2"></nz-option> </nz-select> </nz-form-control> </nz-form-item> diff --git a/web-app/src/app/routes/dashboard/dashboard.component.html b/web-app/src/app/routes/dashboard/dashboard.component.html index a6e226f64..59e37eddd 100644 --- a/web-app/src/app/routes/dashboard/dashboard.component.html +++ b/web-app/src/app/routes/dashboard/dashboard.component.html @@ -398,17 +398,17 @@ <nz-timeline nzMode="left"> <nz-timeline-item *ngFor="let alert of alerts; let i = index" [nzLabel]="(alert.activeAt | date : 'YYYY-MM-dd HH:mm:ss')?.trim()"> <p style="font-weight: 400"> - <!-- <nz-tag *ngIf="alert.priority == 0" nzColor="red">--> + <!-- <nz-tag *ngIf="alert.severity == 0" nzColor="red">--> <!-- <i nz-icon nzType="bell" nzTheme="outline"></i>--> - <!-- <span>{{ 'alert.priority.0' | i18n }}</span>--> + <!-- <span>{{ 'alert.severity.0' | i18n }}</span>--> <!-- </nz-tag>--> - <!-- <nz-tag *ngIf="alert.priority == 1" nzColor="orange">--> + <!-- <nz-tag *ngIf="alert.severity == 1" nzColor="orange">--> <!-- <i nz-icon nzType="bell" nzTheme="outline"></i>--> - <!-- <span>{{ 'alert.priority.1' | i18n }}</span>--> + <!-- <span>{{ 'alert.severity.1' | i18n }}</span>--> <!-- </nz-tag>--> - <!-- <nz-tag *ngIf="alert.priority == 2" nzColor="yellow">--> + <!-- <nz-tag *ngIf="alert.severity == 2" nzColor="yellow">--> <!-- <i nz-icon nzType="bell" nzTheme="outline"></i>--> - <!-- <span>{{ 'alert.priority.2' | i18n }}</span>--> + <!-- <span>{{ 'alert.severity.2' | i18n }}</span>--> <!-- </nz-tag>--> <!-- <span>[{{ alert.tags.monitorName }}] </span>--> {{ alert.content }} diff --git a/web-app/src/app/routes/dashboard/dashboard.component.ts b/web-app/src/app/routes/dashboard/dashboard.component.ts index cb677d0dd..0c60e8688 100644 --- a/web-app/src/app/routes/dashboard/dashboard.component.ts +++ b/web-app/src/app/routes/dashboard/dashboard.component.ts @@ -298,7 +298,7 @@ export class DashboardComponent implements OnInit, OnDestroy { }, xAxis: { type: 'category', - data: [this.i18nSvc.fanyi('alert.priority.2'), this.i18nSvc.fanyi('alert.priority.1'), this.i18nSvc.fanyi('alert.priority.0')] + data: [this.i18nSvc.fanyi('alert.severity.2'), this.i18nSvc.fanyi('alert.severity.1'), this.i18nSvc.fanyi('alert.severity.0')] }, yAxis: { type: 'value' diff --git a/web-app/src/assets/i18n/zh-CN.json b/web-app/src/assets/i18n/zh-CN.json index 75636a189..1218de369 100644 --- a/web-app/src/assets/i18n/zh-CN.json +++ b/web-app/src/assets/i18n/zh-CN.json @@ -130,7 +130,7 @@ "2": "已恢复", "3": "已处理" }, - "priority": { + "severity": { "": "告警级别", "all": "全部级别", "0": "紧急告警", --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
