Browse Source

Merge pull request #14311 from ArtemDzhereleiko/AD/bug-fix/cf-alarm-rule/validation-ct-disabled-option

Bug fixs for alarm rule and enhancement calculated fields
pull/14262/head
Vladyslav Prykhodko 7 months ago
committed by GitHub
parent
commit
fd682b7204
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rules-table-config.ts
  2. 3
      ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rules-table.component.ts
  3. 2
      ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-schedule.component.html
  4. 1
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.html
  5. 1
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.ts
  6. 1
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-dialog.component.html
  7. 1
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate-list.component.html
  8. 3
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate-list.component.ts
  9. 2
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate-value.component.html
  10. 12
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate-value.component.ts
  11. 1
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate.component.html
  12. 4
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate.component.ts
  13. 5
      ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts
  14. 3
      ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table.component.ts

5
ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rules-table-config.ts

@ -54,6 +54,7 @@ import {
CalculatedFieldDebugDialogData
} from "@home/components/calculated-fields/components/debug-dialog/calculated-field-debug-dialog.component";
import { AlarmSeverity, alarmSeverityTranslations } from "@shared/models/alarm.models";
import { UtilsService } from "@core/services/utils.service";
export class AlarmRulesTableConfig extends EntityTableConfig<any> {
@ -75,6 +76,7 @@ export class AlarmRulesTableConfig extends EntityTableConfig<any> {
private ownerId: EntityId = null,
private importExportService: ImportExportService,
private entityDebugSettingsService: EntityDebugSettingsService,
private utilsService: UtilsService,
) {
super();
this.tableTitle = this.translate.instant('alarm-rule.alarm-rules');
@ -115,7 +117,8 @@ export class AlarmRulesTableConfig extends EntityTableConfig<any> {
this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
this.columns.push(new DateEntityTableColumn<CalculatedFieldAlarmRule>('createdTime', 'common.created-time', this.datePipe, '150px'));
this.columns.push(new EntityTableColumn<CalculatedFieldAlarmRule>('name', 'alarm-rule.alarm-type', '33%'));
this.columns.push(new EntityTableColumn<CalculatedFieldAlarmRule>('name', 'alarm-rule.alarm-type', '33%',
entity => this.utilsService.customTranslation(entity.name, entity.name)));
this.columns.push(new EntityTableColumn<CalculatedFieldAlarmRule>('createRule', 'alarm-rule.severities', '67%',
entity => Object.keys(entity.configuration.createRules).map((severity) => this.translate.instant(alarmSeverityTranslations.get(severity as AlarmSeverity))).join(', '),
() => ({}), false));

3
ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rules-table.component.ts

@ -35,6 +35,7 @@ import { ImportExportService } from '@shared/import-export/import-export.service
import { EntityDebugSettingsService } from '@home/components/entity/debug/entity-debug-settings.service';
import { DatePipe } from '@angular/common';
import { AlarmRulesTableConfig } from "@home/components/alarm-rules/alarm-rules-table-config";
import { UtilsService } from "@core/services/utils.service";
@Component({
selector: 'tb-alarm-rules-table',
@ -63,6 +64,7 @@ export class AlarmRulesTableComponent {
private renderer: Renderer2,
private importExportService: ImportExportService,
private entityDebugSettingsService: EntityDebugSettingsService,
private utilsService: UtilsService,
private destroyRef: DestroyRef) {
effect(() => {
@ -80,6 +82,7 @@ export class AlarmRulesTableComponent {
this.ownerId(),
this.importExportService,
this.entityDebugSettingsService,
this.utilsService,
);
this.cd.markForCheck();
}

2
ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-schedule.component.html

@ -90,7 +90,7 @@
<input required matInput formControlName="endsOn" [matDatetimepicker]="endTimePicker">
</mat-form-field>
</div>
<div class="flex flex-1 items-center justify-center sm:max-w-[120px] mb-[22px] text-center"
<div class="flex flex-1 items-center justify-center sm:max-w-[120px] text-center"
[innerHTML]="getSchedulerRangeText(itemsSchedulerForm.at(day))">
</div>
</div>

1
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.html

@ -35,6 +35,7 @@
</mat-form-field>
<tb-alarm-rule-filter-predicate-list [valueType]="data.valueType"
[arguments]="arguments"
[argumentInUse]="data.argumentInUse"
[operation]="complexFilterFormGroup.get('operation').value"
formControlName="predicates">
</tb-alarm-rule-filter-predicate-list>

1
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.ts

@ -35,6 +35,7 @@ export interface AlarmRuleComplexFilterPredicateDialogData {
isAdd: boolean;
valueType: EntityKeyValueType;
arguments: Record<string, CalculatedFieldArgument>;
argumentInUse: string;
}
@Component({

1
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-dialog.component.html

@ -77,6 +77,7 @@
<tb-alarm-rule-filter-predicate-list [valueType]="filterFormGroup.get('valueType').value"
[operation]="filterFormGroup.get('operation').value"
[arguments]="arguments"
[argumentInUse]="filterFormGroup.get('argument').value"
formControlName="predicates">
</tb-alarm-rule-filter-predicate-list>
</section>

1
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate-list.component.html

@ -42,6 +42,7 @@
<tb-alarm-rule-filter-predicate
class="flex-1"
[arguments]="arguments"
[argumentInUse]="argumentInUse"
[valueType]="valueType"
[formControl]="predicateControl">
</tb-alarm-rule-filter-predicate>

3
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate-list.component.ts

@ -78,6 +78,8 @@ export class AlarmRuleFilterPredicateListComponent implements ControlValueAccess
@Input() arguments: Record<string, CalculatedFieldArgument>;
@Input() argumentInUse: string;
filterListFormGroup = this.fb.group({
predicates: this.fb.array([])
});
@ -195,6 +197,7 @@ export class AlarmRuleFilterPredicateListComponent implements ControlValueAccess
valueType: this.valueType,
isAdd: true,
arguments: this.arguments,
argumentInUse: this.argumentInUse
}
}).afterClosed().pipe(
map(result => result)

2
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate-value.component.html

@ -55,7 +55,7 @@
<mat-form-field class="flex-1 w-full" appearance="outline" subscriptSizing="dynamic">
<mat-select formControlName="dynamicValueArgument" placeholder="{{ 'action.set' | translate }}">
@for (argument of argumentsList; track argument) {
<mat-option [value]="argument">{{ argument }}</mat-option>
<mat-option [value]="argument" [disabled]="argument === argumentInUse">{{ argument }}</mat-option>
}
</mat-select>
@if (filterPredicateValueFormGroup.get('dynamicValueArgument').touched && filterPredicateValueFormGroup.get('dynamicValueArgument').hasError('required')) {

12
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate-value.component.ts

@ -57,6 +57,9 @@ export class AlarmRuleFilterPredicateValueComponent implements ControlValueAcces
@Input()
valueType: EntityKeyValueType;
@Input()
argumentInUse: string;
valueTypeEnum = EntityKeyValueType;
filterPredicateValueFormGroup: FormGroup<FormControlsFrom<AlarmRuleValue<string | number | boolean>>>;
@ -104,7 +107,7 @@ export class AlarmRuleFilterPredicateValueComponent implements ControlValueAcces
});
this.dynamicModeControl.valueChanges.pipe(
takeUntilDestroyed(this.destroyRef)
).subscribe(value => this.updateValueModeValidators(value))
).subscribe(value => this.updateValueModeValidators(value));
}
setDisabledState(isDisabled: boolean): void {
@ -114,16 +117,17 @@ export class AlarmRuleFilterPredicateValueComponent implements ControlValueAcces
} else {
this.filterPredicateValueFormGroup.enable({emitEvent: false});
this.dynamicModeControl.enable({emitEvent: false});
this.updateValueModeValidators(this.dynamicModeControl.value);
}
}
private updateValueModeValidators(isDynamicMode: boolean): void {
if (isDynamicMode) {
this.filterPredicateValueFormGroup.get('staticValue').disable({emitEvent: false});
this.filterPredicateValueFormGroup.get('dynamicValueArgument').enable({emitEvent: false});
this.filterPredicateValueFormGroup.get('dynamicValueArgument').enable();
} else {
this.filterPredicateValueFormGroup.get('staticValue').enable({emitEvent: false});
this.filterPredicateValueFormGroup.get('dynamicValueArgument').disable({emitEvent: false});
this.filterPredicateValueFormGroup.get('staticValue').enable();
}
}
@ -142,7 +146,7 @@ export class AlarmRuleFilterPredicateValueComponent implements ControlValueAcces
writeValue(predicateValue: AlarmRuleValue<string | number | boolean>): void {
this.filterPredicateValueFormGroup.patchValue(predicateValue, {emitEvent: false});
this.dynamicModeControl.patchValue(!!predicateValue.dynamicValueArgument?.length);
this.dynamicModeControl.patchValue(!!predicateValue.dynamicValueArgument?.length, {emitEvent: false});
}
private updateModel() {

1
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate.component.html

@ -71,6 +71,7 @@
@if (type !== filterPredicateType.COMPLEX) {
<tb-alarm-rule-filter-predicate-value class="flex-full"
[arguments]="arguments"
[argumentInUse]="argumentInUse"
[valueType]="valueType"
formControlName="value">
</tb-alarm-rule-filter-predicate-value>

4
ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-filter-predicate.component.ts

@ -70,6 +70,9 @@ export class AlarmRuleFilterPredicateComponent implements ControlValueAccessor,
@Input()
arguments: Record<string, CalculatedFieldArgument>;
@Input()
argumentInUse: string;
filterPredicateFormGroup = this.fb.group({
operation: [],
ignoreCase: false,
@ -146,6 +149,7 @@ export class AlarmRuleFilterPredicateComponent implements ControlValueAccessor,
valueType: this.valueType,
isAdd: false,
arguments: this.arguments,
argumentInUse: this.argumentInUse,
}
}).afterClosed().subscribe(
(result) => {

5
ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts

@ -59,6 +59,7 @@ import { ImportExportService } from '@shared/import-export/import-export.service
import { isObject } from '@core/utils';
import { EntityDebugSettingsService } from '@home/components/entity/debug/entity-debug-settings.service';
import { DatePipe } from '@angular/common';
import { UtilsService } from "@core/services/utils.service";
export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedField> {
@ -80,6 +81,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
private ownerId: EntityId = null,
private importExportService: ImportExportService,
private entityDebugSettingsService: EntityDebugSettingsService,
private utilsService: UtilsService,
) {
super();
this.tableTitle = this.translate.instant('entity.type-calculated-fields');
@ -124,7 +126,8 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
};
this.columns.push(new DateEntityTableColumn<CalculatedField>('createdTime', 'common.created-time', this.datePipe, '150px'));
this.columns.push(new EntityTableColumn<CalculatedField>('name', 'common.name', '33%'));
this.columns.push(new EntityTableColumn<CalculatedField>('name', 'common.name', '33%',
entity => this.utilsService.customTranslation(entity.name, entity.name)));
this.columns.push(new EntityTableColumn<CalculatedField>('type', 'common.type', '170px', entity => this.translate.instant(CalculatedFieldTypeTranslations.get(entity.type).name), () => ({whiteSpace: 'nowrap' })));
this.columns.push(expressionColumn);

3
ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table.component.ts

@ -35,6 +35,7 @@ import { CalculatedFieldsService } from '@core/http/calculated-fields.service';
import { ImportExportService } from '@shared/import-export/import-export.service';
import { EntityDebugSettingsService } from '@home/components/entity/debug/entity-debug-settings.service';
import { DatePipe } from '@angular/common';
import { UtilsService } from "@core/services/utils.service";
@Component({
selector: 'tb-calculated-fields-table',
@ -63,6 +64,7 @@ export class CalculatedFieldsTableComponent {
private renderer: Renderer2,
private importExportService: ImportExportService,
private entityDebugSettingsService: EntityDebugSettingsService,
private utilsService: UtilsService,
private destroyRef: DestroyRef) {
effect(() => {
@ -80,6 +82,7 @@ export class CalculatedFieldsTableComponent {
this.ownerId(),
this.importExportService,
this.entityDebugSettingsService,
this.utilsService,
);
this.cd.markForCheck();
}

Loading…
Cancel
Save