This is an automated email from the ASF dual-hosted git repository.

gongchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git


The following commit(s) were added to refs/heads/master by this push:
     new f9f12a2b9 [fixbug] required field check (#2022)
f9f12a2b9 is described below

commit f9f12a2b9e0cd745c4bc70f2ac057a5e17828d1e
Author: Jast <[email protected]>
AuthorDate: Sat May 25 12:28:29 2024 +0800

    [fixbug] required field check (#2022)
    
    Signed-off-by: Jast <[email protected]>
    Co-authored-by: zhangshenghang <[email protected]>
    Co-authored-by: tomsun28 <[email protected]>
---
 .../alert/alert-notice/alert-notice.component.ts   | 34 +++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git 
a/web-app/src/app/routes/alert/alert-notice/alert-notice.component.ts 
b/web-app/src/app/routes/alert/alert-notice/alert-notice.component.ts
index 99702bd59..1049d7075 100644
--- a/web-app/src/app/routes/alert/alert-notice/alert-notice.component.ts
+++ b/web-app/src/app/routes/alert/alert-notice/alert-notice.component.ts
@@ -17,7 +17,8 @@
  * under the License.
  */
 
-import { Component, Inject, OnInit } from '@angular/core';
+import { Component, Inject, OnInit, ViewChild } from '@angular/core';
+import { NgForm } from '@angular/forms';
 import { I18NService } from '@core';
 import { ALAIN_I18N_TOKEN } from '@delon/theme';
 import { NzModalService } from 'ng-zorro-antd/modal';
@@ -69,6 +70,10 @@ export class AlertNoticeComponent implements OnInit {
   tagsOption: any[] = [];
   filterTags: string[] = [];
   isLimit: boolean = false;
+  @ViewChild('receiverForm', { static: false }) receiverForm: NgForm | 
undefined;
+  @ViewChild('templateForm', { static: false }) templateForm: NgForm | 
undefined;
+  @ViewChild('ruleForm', { static: false }) ruleForm: NgForm | undefined;
+
   dayCheckOptions = [
     { label: this.i18nSvc.fanyi('common.week.7'), value: 7, checked: true },
     { label: this.i18nSvc.fanyi('common.week.1'), value: 1, checked: true },
@@ -348,6 +353,15 @@ export class AlertNoticeComponent implements OnInit {
   }
 
   onManageReceiverModalOk() {
+    if (this.receiverForm?.invalid) {
+      Object.values(this.receiverForm.controls).forEach(control => {
+        if (control.invalid) {
+          control.markAsDirty();
+          control.updateValueAndValidity({ onlySelf: true });
+        }
+      });
+      return;
+    }
     this.isManageReceiverModalOkLoading = true;
     if (this.isManageReceiverModalAdd) {
       const modalOk$ = this.noticeReceiverSvc
@@ -691,6 +705,15 @@ export class AlertNoticeComponent implements OnInit {
   }
 
   onManageRuleModalOk() {
+    if (this.ruleForm?.invalid) {
+      Object.values(this.ruleForm.controls).forEach(control => {
+        if (control.invalid) {
+          control.markAsDirty();
+          control.updateValueAndValidity({ onlySelf: true });
+        }
+      });
+      return;
+    }
     this.rule.receiverName = [];
     this.receiversOption.forEach(option => {
       this.rule.receiverId.forEach(id => {
@@ -777,6 +800,15 @@ export class AlertNoticeComponent implements OnInit {
   }
 
   onManageTemplateModalOk() {
+    if (this.templateForm?.invalid) {
+      Object.values(this.templateForm.controls).forEach(control => {
+        if (control.invalid) {
+          control.markAsDirty();
+          control.updateValueAndValidity({ onlySelf: true });
+        }
+      });
+      return;
+    }
     this.isManageTemplateModalOkLoading = true;
     if (this.isManageTemplateModalAdd) {
       this.template.preset = false;


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

Reply via email to