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 c9e69673c13b53d3644bbfd113f44d0591c4a31e
Author: tomsun28 <[email protected]>
AuthorDate: Fri Jan 3 16:00:00 2025 +0800

    [webapp] update alert inhibit
    
    Signed-off-by: tomsun28 <[email protected]>
---
 .../common/constants/CommonConstants.java          |  5 ++
 web-app/src/app/pojo/AlertSilence.ts               |  5 +-
 .../alert-silence/alert-silence.component.html     | 52 +------------
 .../alert/alert-silence/alert-silence.component.ts | 85 ----------------------
 web-app/src/assets/i18n/en-US.json                 |  2 +-
 web-app/src/assets/i18n/zh-CN.json                 |  2 +-
 web-app/src/assets/i18n/zh-TW.json                 |  2 +-
 7 files changed, 11 insertions(+), 142 deletions(-)

diff --git 
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/constants/CommonConstants.java
 
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/constants/CommonConstants.java
index 062adacb4..f4bdb3cbe 100644
--- 
a/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/constants/CommonConstants.java
+++ 
b/hertzbeat-common/src/main/java/org/apache/hertzbeat/common/constants/CommonConstants.java
@@ -101,6 +101,11 @@ public interface CommonConstants {
      * Alarm severity label key
      */
     String LABEL_ALERT_SEVERITY = "severity";
+
+    /**
+     * Alarm severity fatal level
+     */
+    String LABEL_ALERT_FATAL = "fatal";
     
     /**
      * alarm severity emergency level
diff --git a/web-app/src/app/pojo/AlertSilence.ts 
b/web-app/src/app/pojo/AlertSilence.ts
index d5d75dce3..444f4f180 100644
--- a/web-app/src/app/pojo/AlertSilence.ts
+++ b/web-app/src/app/pojo/AlertSilence.ts
@@ -17,8 +17,6 @@
  * under the License.
  */
 
-import { TagItem } from './NoticeRule';
-
 export class AlertSilence {
   id!: number;
   name!: string;
@@ -26,8 +24,7 @@ export class AlertSilence {
   matchAll: boolean = true;
   type: number = 0;
   times!: number;
-  priorities!: number[];
-  tags!: TagItem[];
+  labels!: Record<string, string>;
   days!: number[];
   periodStart: Date = new Date();
   periodEnd: Date = new Date();
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 f4d9d12db..68ccef7a7 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
@@ -79,7 +79,6 @@
       <th nzAlign="center" nzLeft nzWidth="3%" [(nzChecked)]="checkedAll" 
(nzCheckedChange)="onAllChecked($event)"></th>
       <th nzAlign="center" nzWidth="8%">{{ 'alert.silence.name' | i18n }}</th>
       <th nzAlign="center" nzWidth="14%">{{ 'alert.silence.type' | i18n }}</th>
-      <th nzAlign="center" nzWidth="14%">{{ 'alert.silence.tags' | i18n }}</th>
       <th nzAlign="center" nzWidth="8%">{{ 'alert.silence.times' | i18n }}</th>
       <th nzAlign="center" nzWidth="8%">{{ 'alert.silence.enable' | i18n 
}}</th>
       <th nzAlign="center" nzWidth="15%">{{ 'common.edit' | i18n }}</th>
@@ -101,16 +100,6 @@
           <span>{{ 'alert.silence.type.cyc' | i18n }}</span>
         </nz-tag>
       </td>
-      <td nzAlign="center" *ngIf="!data.matchAll">
-        <nz-tag nzColor="processing" style="margin-top: 2px" *ngFor="let tag 
of data.tags; let i = index">
-          {{ sliceTagName(tag) }}
-        </nz-tag>
-      </td>
-      <td nzAlign="center" *ngIf="data.matchAll">
-        <nz-tag nzColor="warning">
-          {{ 'alert.silence.match-all' | i18n }}
-        </nz-tag>
-      </td>
       <td nzAlign="center">
         <nz-tag nzColor="processing">
           <i nz-icon nzType="audio-muted" nzTheme="outline"></i>
@@ -182,46 +171,9 @@
         </nz-form-control>
       </nz-form-item>
       <nz-form-item *ngIf="!silence.matchAll">
-        <nz-form-label nzSpan="7" nzFor="tags" nzRequired="true">{{ 
'alert.silence.tags' | i18n }}</nz-form-label>
-        <nz-form-control nzSpan="12" [nzErrorTip]="'validation.required' | 
i18n">
-          <nz-select
-            [(ngModel)]="matchTags"
-            [nzDisabled]="silence.matchAll"
-            (nzOpenChange)="loadTagsOption()"
-            [nzOptions]="tagsOption"
-            [nzMaxTagCount]="5"
-            [nzDropdownMatchSelectWidth]="false"
-            nzShowSearch
-            nzMode="multiple"
-            nzAllowClear
-            [nzPlaceHolder]="'alert.notice.rule.tag.placeholder' | i18n"
-            required
-            name="tags"
-            id="tags"
-          >
-          </nz-select>
-        </nz-form-control>
-      </nz-form-item>
-      <nz-form-item *ngIf="!silence.matchAll">
-        <nz-form-label nzSpan="7" nzFor="priorities" nzRequired="true">{{ 
'alert.silence.priority' | i18n }}</nz-form-label>
+        <nz-form-label nzSpan="7" nzFor="labels" nzRequired="true">{{ 
'alert.silence.labels' | i18n }}</nz-form-label>
         <nz-form-control nzSpan="12" [nzErrorTip]="'validation.required' | 
i18n">
-          <nz-select
-            [(ngModel)]="silence.priorities"
-            [nzDisabled]="silence.matchAll"
-            (ngModelChange)="onPrioritiesChange()"
-            nzShowSearch
-            nzMode="multiple"
-            nzAllowClear
-            [nzPlaceHolder]="'alert.notice.rule.priority.placeholder' | i18n"
-            required
-            name="priorities"
-            id="priorities"
-          >
-            <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>
+          <app-labels-input [(ngModel)]="silence.labels" name="labels" 
required></app-labels-input>
         </nz-form-control>
       </nz-form-item>
       <nz-form-item>
diff --git 
a/web-app/src/app/routes/alert/alert-silence/alert-silence.component.ts 
b/web-app/src/app/routes/alert/alert-silence/alert-silence.component.ts
index b25f33577..baf32d84d 100644
--- a/web-app/src/app/routes/alert/alert-silence/alert-silence.component.ts
+++ b/web-app/src/app/routes/alert/alert-silence/alert-silence.component.ts
@@ -29,7 +29,6 @@ import { finalize } from 'rxjs/operators';
 import { AlertSilence } from '../../../pojo/AlertSilence';
 import { TagItem } from '../../../pojo/NoticeRule';
 import { AlertSilenceService } from '../../../service/alert-silence.service';
-import { TagService } from '../../../service/tag.service';
 
 @Component({
   selector: 'app-alert-silence',
@@ -41,7 +40,6 @@ export class AlertSilenceComponent implements OnInit {
     private modal: NzModalService,
     private notifySvc: NzNotificationService,
     private alertSilenceService: AlertSilenceService,
-    private tagService: TagService,
     @Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService
   ) {}
 
@@ -208,8 +206,6 @@ export class AlertSilenceComponent implements OnInit {
   isManageModalOkLoading = false;
   isManageModalAdd = true;
   silence: AlertSilence = new AlertSilence();
-  searchTag!: string;
-  tagsOption: any[] = [];
   matchTags: string[] = [];
   silenceDates!: Date[];
   dayCheckOptions = [
@@ -269,19 +265,6 @@ export class AlertSilenceComponent implements OnInit {
             this.isManageModalVisible = true;
             this.isManageModalAdd = false;
             this.matchTags = [];
-            if (this.silence.tags != undefined) {
-              this.silence.tags.forEach(item => {
-                let tag = `${item.name}`;
-                if (item.value != undefined) {
-                  tag = `${tag}:${item.value}`;
-                }
-                this.matchTags.push(tag);
-                this.tagsOption.push({
-                  value: tag,
-                  label: tag
-                });
-              });
-            }
           } else {
             
this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), 
message.msg);
           }
@@ -301,22 +284,6 @@ export class AlertSilenceComponent implements OnInit {
       });
       return;
     }
-    this.silence.tags = [];
-    this.matchTags.forEach(tag => {
-      let tmp: string[] = tag.split(':');
-      let tagItem = new TagItem();
-      if (tmp.length == 1) {
-        tagItem.name = tmp[0];
-        this.silence.tags.push(tagItem);
-      } else if (tmp.length == 2) {
-        tagItem.name = tmp[0];
-        tagItem.value = tmp[1];
-        this.silence.tags.push(tagItem);
-      }
-    });
-    if (this.silence.priorities != undefined) {
-      this.silence.priorities = this.silence.priorities.filter(item => item != 
null && item != 9);
-    }
     if (this.silence.type === 0) {
       this.silence.periodStart = this.silenceDates[0];
       this.silence.periodEnd = this.silenceDates[1];
@@ -375,56 +342,4 @@ export class AlertSilenceComponent implements OnInit {
         );
     }
   }
-
-  onPrioritiesChange() {
-    if (this.silence.priorities != undefined) {
-      let isAll = false;
-      this.silence.priorities.forEach(item => {
-        if (item == 9) {
-          isAll = true;
-        }
-      });
-      if (isAll) {
-        this.silence.priorities = [9, 0, 1, 2];
-      }
-    }
-  }
-
-  loadTagsOption() {
-    let tagsInit$ = this.tagService.loadTags(this.searchTag, undefined, 0, 
1000).subscribe(
-      message => {
-        if (message.code === 0) {
-          let page = message.data;
-          this.tagsOption = [];
-          if (page.content != undefined) {
-            page.content.forEach(item => {
-              let tag = `${item.name}`;
-              if (item.tagValue != undefined) {
-                tag = `${tag}:${item.tagValue}`;
-              }
-              this.tagsOption.push({
-                value: tag,
-                label: tag
-              });
-            });
-          }
-        } else {
-          console.warn(message.msg);
-        }
-        tagsInit$.unsubscribe();
-      },
-      error => {
-        tagsInit$.unsubscribe();
-        console.error(error.msg);
-      }
-    );
-  }
-
-  sliceTagName(tag: any): string {
-    if (tag.value != undefined && tag.value.trim() != '') {
-      return `${tag.name}:${tag.value}`;
-    } else {
-      return tag.name;
-    }
-  }
 }
diff --git a/web-app/src/assets/i18n/en-US.json 
b/web-app/src/assets/i18n/en-US.json
index 4da42df07..2174fea8e 100644
--- a/web-app/src/assets/i18n/en-US.json
+++ b/web-app/src/assets/i18n/en-US.json
@@ -225,7 +225,7 @@
   "alert.silence.type.once": "One Time Silence",
   "alert.silence.type.cyc": "Periodic Silence",
   "alert.silence.type": "Silence Type",
-  "alert.silence.tags": "Tag Match",
+  "alert.silence.labels": "Tag Match",
   "alert.silence.time": "Silence Period",
   "alert.silence.times": "Silenced Alerts Num",
   "alert.silence.enable": "Enable Silence",
diff --git a/web-app/src/assets/i18n/zh-CN.json 
b/web-app/src/assets/i18n/zh-CN.json
index 1218de369..7cdda7224 100644
--- a/web-app/src/assets/i18n/zh-CN.json
+++ b/web-app/src/assets/i18n/zh-CN.json
@@ -226,7 +226,7 @@
   "alert.silence.type.once": "一次性静默",
   "alert.silence.type.cyc": "周期性静默",
   "alert.silence.type": "静默类型",
-  "alert.silence.tags": "匹配标签",
+  "alert.silence.labels": "匹配标签",
   "alert.silence.time": "静默时段",
   "alert.silence.times": "已静默告警数",
   "alert.silence.enable": "启用静默策略",
diff --git a/web-app/src/assets/i18n/zh-TW.json 
b/web-app/src/assets/i18n/zh-TW.json
index aa9f01c22..7c8ac3464 100644
--- a/web-app/src/assets/i18n/zh-TW.json
+++ b/web-app/src/assets/i18n/zh-TW.json
@@ -238,7 +238,7 @@
   "alert.silence.type.once": "一次性靜默",
   "alert.silence.type.cyc": "週期性靜默",
   "alert.silence.type": "靜默類型",
-  "alert.silence.tags": "匹配標籤",
+  "alert.silence.labels": "匹配標籤",
   "alert.silence.time": "靜默時段",
   "alert.silence.times": "已靜默告警數",
   "alert.silence.enable": "啟用靜默策略",


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to