From 96c41946de80785bbbb26b1403770d044be6e891 Mon Sep 17 00:00:00 2001 From: kerwin612 Date: Tue, 9 Jul 2024 09:04:12 +0800 Subject: [PATCH] Further enhance and refine the optimizations implemented in #2215. --- .../monitor-form/monitor-form.component.html | 2 +- .../monitor-form/monitor-form.component.ts | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.html b/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.html index c44f49a3e4c..a3f848b0d66 100644 --- a/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.html +++ b/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.html @@ -59,7 +59,7 @@ diff --git a/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.ts b/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.ts index 45906dd013a..418ee1bf29b 100644 --- a/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.ts +++ b/web-app/src/app/routes/monitor/monitor-form/monitor-form.component.ts @@ -17,7 +17,7 @@ * under the License. */ -import { Component, EventEmitter, Input, Output } from '@angular/core'; +import { Component, EventEmitter, Input, Output, OnChanges, SimpleChanges } from '@angular/core'; import { FormGroup } from '@angular/forms'; import { Collector } from '../../../pojo/Collector'; @@ -29,7 +29,7 @@ import { ParamDefine } from '../../../pojo/ParamDefine'; templateUrl: './monitor-form.component.html', styleUrls: ['./monitor-form.component.less'] }) -export class MonitorFormComponent { +export class MonitorFormComponent implements OnChanges { @Input() monitor!: any; @Input() loading!: boolean; @Input() loadingTip!: string; @@ -46,8 +46,21 @@ export class MonitorFormComponent { @Output() readonly formDetect = new EventEmitter(); @Output() readonly hostChange = new EventEmitter(); + hasAdvancedParams: boolean = false; + constructor() {} + ngOnChanges(changes: SimpleChanges) { + if (changes.advancedParams && changes.advancedParams.currentValue !== changes.advancedParams.previousValue) { + for (const advancedParam of changes.advancedParams.currentValue) { + if (advancedParam.display !== false) { + this.hasAdvancedParams = true; + break; + } + } + } + } + onDetect(formGroup: FormGroup) { if (formGroup.invalid) { Object.values(formGroup.controls).forEach(control => {