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 c708254cd31175d070fa9294098e15d7663659d4 Author: tomsun28 <[email protected]> AuthorDate: Fri Jan 3 10:37:43 2025 +0800 [webapp] update alert inhibit Signed-off-by: tomsun28 <[email protected]> --- .../shared/components/labels-input/labels-input.component.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web-app/src/app/shared/components/labels-input/labels-input.component.ts b/web-app/src/app/shared/components/labels-input/labels-input.component.ts index ce5676af7..e1f88002d 100644 --- a/web-app/src/app/shared/components/labels-input/labels-input.component.ts +++ b/web-app/src/app/shared/components/labels-input/labels-input.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, Output, OnInit, forwardRef } from '@angular/core'; +import { Component, Input, OnInit, forwardRef } from '@angular/core'; import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'; interface KeyValuePair { @@ -26,7 +26,7 @@ export class LabelsInputComponent implements OnInit, ControlValueAccessor { keyValues: KeyValuePair[] = []; - // ControlValueAccessor 接口实现 + // ControlValueAccessor private onChange: any = () => {}; private onTouched: any = () => {}; @@ -50,7 +50,7 @@ export class LabelsInputComponent implements OnInit, ControlValueAccessor { } setDisabledState(isDisabled: boolean): void { - // 如果需要处理禁用状态,可以在这里实现 + // set disabled state here } ngOnInit(): void { @@ -86,7 +86,11 @@ export class LabelsInputComponent implements OnInit, ControlValueAccessor { result[item.key] = item.value || ''; } }); - this.onChange(result); + if (Object.keys(result).length === 0 || Object.values(result).every(v => v === '')) { + this.onChange(null); + } else { + this.onChange(result); + } this.onTouched(); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
