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 f49e20535 [improve] optimization notification code validation (#2102)
f49e20535 is described below
commit f49e20535cc4069b4c95c369f628dfa02218d3a8
Author: Jast <[email protected]>
AuthorDate: Thu Jun 20 09:14:16 2024 +0800
[improve] optimization notification code validation (#2102)
Co-authored-by: zhangshenghang <[email protected]>
Co-authored-by: tomsun28 <[email protected]>
---
.../impl/FlyBookAlertNotifyHandlerImpl.java | 2 +-
.../alert/alert-notice/alert-notice.component.html | 18 +++---------
.../alert/alert-notice/alert-notice.component.ts | 34 ++--------------------
web-app/src/assets/i18n/zh-CN.json | 1 -
4 files changed, 8 insertions(+), 47 deletions(-)
diff --git
a/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImpl.java
b/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImpl.java
index 2bf6f6c1b..0ee227fdb 100644
---
a/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImpl.java
+++
b/manager/src/main/java/org/apache/hertzbeat/manager/component/alerter/impl/FlyBookAlertNotifyHandlerImpl.java
@@ -92,7 +92,7 @@ final class FlyBookAlertNotifyHandlerImpl extends
AbstractAlertNotifyHandlerImpl
List<List<FlyBookContent>> contents =
Collections.singletonList(contentList);
zhCn.setContent(contents);
- String webHookUrl = alerterProperties.getFlyBookWebhookUrl() +
receiver.getWechatId();
+ String webHookUrl = alerterProperties.getFlyBookWebhookUrl() +
receiver.getAccessToken();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<FlyBookWebHookDto> flyEntity = new
HttpEntity<>(flyBookWebHookDto, headers);
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 92ceaad08..472f8b05d 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
@@ -586,19 +586,9 @@
</nz-form-item>
<nz-form-item *ngIf="receiver.type === 4">
<nz-form-label [nzSpan]="7" nzFor="phone">{{ 'alert.notice.type.phone'
| i18n }}</nz-form-label>
- <nz-form-control [nzErrorTip]="phoneErrorTpl" [nzSpan]="12">
+ <nz-form-control [nzErrorTip]="'validation.phone.invalid' | i18n"
[nzSpan]="12">
<input [(ngModel)]="receiver.phone"
pattern="^(1\d{10})(,\s*1\d{10})*$" id="WePhone" name="phone" nz-input
type="tel" />
</nz-form-control>
- <ng-template #phoneErrorTpl>
- <ng-container *ngIf="receiverForm.controls['phone'].errors">
- <div
*ngIf="receiverForm.controls['phone'].hasError('invalidPhone')">
- {{ receiverForm.controls['phone'].errors['invalidPhone'] }}
- </div>
- <div *ngIf="receiverForm.controls['phone'].hasError('pattern')">
- {{ 'validation.phone.invalid' | i18n }}
- </div>
- </ng-container>
- </ng-template>
</nz-form-item>
<nz-form-item *ngIf="receiver.type === 4">
<nz-form-label [nzSpan]="7" nzFor="userId">{{
'alert.notice.type.userId' | i18n }}</nz-form-label>
@@ -634,16 +624,16 @@
</nz-form-control>
</nz-form-item>
<nz-form-item *ngIf="receiver.type === 6">
- <nz-form-label [nzSpan]="7" nzFor="wechatId"
[nzRequired]="receiver.type === 6">{{
+ <nz-form-label [nzSpan]="7" nzFor="accessToken"
[nzRequired]="receiver.type === 6">{{
'alert.notice.type.fei-shu-key' | i18n
}}</nz-form-label>
<nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' |
i18n">
<input
- [(ngModel)]="receiver.wechatId"
+ [(ngModel)]="receiver.accessToken"
(ngModelChange)="onSplitTokenStr(6)"
nz-input
[required]="receiver.type === 6"
- name="wechatId"
+ name="accessToken"
type="text"
/>
</nz-form-control>
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 0ea35aed6..2014dafbf 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
@@ -300,10 +300,10 @@ export class AlertNoticeComponent implements OnInit {
}
break;
case 6:
- if (this.receiver?.wechatId) {
- index = this.receiver.wechatId.indexOf('hook');
+ if (this.receiver?.accessToken) {
+ index = this.receiver.accessToken.indexOf('hook');
if (index > 0) {
- this.receiver.wechatId = this.receiver.wechatId.substring(index +
5);
+ this.receiver.accessToken =
this.receiver.accessToken.substring(index + 5);
}
}
break;
@@ -352,35 +352,7 @@ export class AlertNoticeComponent implements OnInit {
this.isManageReceiverModalVisible = false;
}
- private markAllControlsAsTouched(form: NgForm | undefined): void {
- Object.keys(form!.controls).forEach(field => {
- const control = form!.controls[field];
- control.markAsTouched();
- });
- }
-
- private markAllControlsAsUnTouched(form: NgForm | undefined): void {
- Object.keys(form!.controls).forEach(field => {
- const control = form!.controls[field];
- control.markAsUntouched();
- });
- }
-
onManageReceiverModalOk() {
- if (this.receiver.type == 4) {
- if (!this.receiver.phone && !this.receiver.userId) {
- this.markAllControlsAsTouched(this.receiverForm);
- this.receiverForm!.controls['phone'].setErrors({ invalidPhone:
this.i18nSvc.fanyi('validation.phone.or.userid.invalid') });
- this.markAllControlsAsUnTouched(this.receiverForm);
- return;
- } else {
- const errors = this.receiverForm!.controls['phone'].errors;
- if (errors && errors.invalidPhone) {
- delete errors.invalidPhone;
- this.receiverForm!.controls['phone'].setErrors(errors);
- }
- }
- }
if (this.receiverForm?.invalid) {
let isWaring = false;
Object.values(this.receiverForm.controls).forEach(control => {
diff --git a/web-app/src/assets/i18n/zh-CN.json
b/web-app/src/assets/i18n/zh-CN.json
index 008d9cd2f..f8f453fd5 100644
--- a/web-app/src/assets/i18n/zh-CN.json
+++ b/web-app/src/assets/i18n/zh-CN.json
@@ -695,7 +695,6 @@
"validation.email.wrong-format": "邮箱地址格式错误!",
"validation.email.invalid": "无效的邮箱地址!",
"validation.phone.invalid": "无效的手机号!",
- "validation.phone.or.userid.invalid": "用户ID或手机号至少填写一个!",
"validation.verification-code.invalid": "无效的验证码,应是6位数字!",
"validation.password.required": "请输入密码!",
"validation.password.twice": "两次输入的密码不匹配!",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]