Browse Source

UI: Refactoring type

pull/14276/head
ArtemDzhereleiko 10 months ago
parent
commit
dd8e82fb2c
  1. 3
      ui-ngx/src/app/core/http/calculated-fields.service.ts
  2. 5
      ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rule-dialog.component.ts
  3. 2
      ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rules-table-config.ts
  4. 4
      ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition-dialog.component.ts
  5. 8
      ui-ngx/src/app/modules/home/components/alarm-rules/filter/alarm-rule-complex-filter-predicate-dialog.component.ts
  6. 2
      ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts
  7. 7
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts
  8. 2
      ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.model.ts
  9. 10
      ui-ngx/src/app/shared/models/calculated-field.models.ts

3
ui-ngx/src/app/core/http/calculated-fields.service.ts

@ -51,8 +51,7 @@ export class CalculatedFieldsService {
}
public getCalculatedFields({ entityType, id }: EntityId, pageLink: PageLink, type?: CalculatedFieldType, config?: RequestConfig): Observable<PageData<CalculatedField>> {
let url = `/api/${entityType}/${id}/calculatedFields${pageLink.toQuery()}`;
return this.http.get<PageData<CalculatedField>>(url, createDefaultHttpOptions(type ? {type} : null, config));
return this.http.get<PageData<CalculatedField>>(`/api/${entityType}/${id}/calculatedFields${pageLink.toQuery()}`, createDefaultHttpOptions(type ? {type} : null, config));
}
public testScript(inputParams: CalculatedFieldTestScriptInputParams, config?: RequestConfig): Observable<EntityTestScriptResult> {

5
ui-ngx/src/app/modules/home/components/alarm-rules/alarm-rule-dialog.component.ts

@ -55,6 +55,7 @@ export class AlarmRuleDialogComponent extends DialogComponent<AlarmRuleDialogCom
fieldFormGroup = this.fb.group({
name: ['', [Validators.required, Validators.pattern(oneSpaceInsideRegex), Validators.maxLength(255)]],
type: [CalculatedFieldType.ALARM],
debugSettings: [],
configuration: this.fb.group({
arguments: this.fb.control({}),
@ -159,8 +160,8 @@ export class AlarmRuleDialogComponent extends DialogComponent<AlarmRuleDialogCom
}
private applyDialogData(): void {
const { configuration = {}, debugSettings = { failuresEnabled: true, allEnabled: true }, ...value } = this.data.value ?? {};
this.fieldFormGroup.patchValue({ configuration, debugSettings, ...value }, {emitEvent: false});
const { configuration = {}, type = CalculatedFieldType.ALARM, debugSettings = { failuresEnabled: true, allEnabled: true }, ...value } = this.data.value ?? {};
this.fieldFormGroup.patchValue({ configuration, type, debugSettings, ...value }, {emitEvent: false});
}
private observeIsLoading(): void {

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

@ -176,7 +176,7 @@ export class AlarmRulesTableConfig extends EntityTableConfig<any> {
debugSettings,
debugConfig: {
entityType: EntityType.CALCULATED_FIELD,
isAlarmRule: true,
entityLabel: 'alarm-rule.alarm-rule',
additionalActionConfig,
},
onSettingsAppliedFn: settings => this.onDebugConfigChanged(id.id, settings)

4
ui-ngx/src/app/modules/home/components/alarm-rules/cf-alarm-rule-condition-dialog.component.ts

@ -74,11 +74,11 @@ export class CfAlarmRuleConditionDialogComponent extends DialogComponent<CfAlarm
unit: this.fb.control(TimeUnit.SECONDS, Validators.required),
value: this.fb.group({
staticValue: this.fb.control<number | null>(null, [Validators.required, Validators.min(1), Validators.max(2147483647), Validators.pattern('[0-9]*')]),
dynamicValueArgument: this.fb.control<string | null>(null, Validators.required),
dynamicValueArgument: this.fb.control<string>('', Validators.required),
}),
count: this.fb.group({
staticValue: this.fb.control<number | null>(null, [Validators.required, Validators.min(1), Validators.max(2147483647), Validators.pattern('[0-9]*')]),
dynamicValueArgument: this.fb.control<string | null>(null, Validators.required),
dynamicValueArgument: this.fb.control<string>('', Validators.required),
}),
});

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

@ -80,10 +80,8 @@ export class AlarmRuleComplexFilterPredicateDialogComponent extends
}
save(): void {
if (this.complexFilterFormGroup.valid) {
const predicate: ComplexAlarmRuleFilterPredicate = this.complexFilterFormGroup.value as ComplexAlarmRuleFilterPredicate;
predicate.type = FilterPredicateType.COMPLEX;
this.dialogRef.close(predicate);
}
const predicate = this.complexFilterFormGroup.value as ComplexAlarmRuleFilterPredicate;
predicate.type = FilterPredicateType.COMPLEX;
this.dialogRef.close(predicate);
}
}

2
ui-ngx/src/app/modules/home/components/calculated-fields/components/calculated-field-arguments/calculated-field-argument-panel.component.ts

@ -315,7 +315,7 @@ export class CalculatedFieldArgumentPanelComponent implements OnInit, AfterViewI
}
private updatedRefEntityIdState(type: ArgumentEntityType, emitEvent = true): void {
const isEntityWithId = !!type && type !== ArgumentEntityType.Tenant && type !== ArgumentEntityType.Current;
const isEntityWithId = !!type && ![ArgumentEntityType.Tenant, ArgumentEntityType.Current, ArgumentEntityType.Owner].includes(type);
this.argumentFormGroup.get('refEntityId')[isEntityWithId ? 'enable' : 'disable']({emitEvent});
if (!isEntityWithId) {
this.entityNameSubject.next(null);

7
ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings-panel.component.ts

@ -53,7 +53,7 @@ export class EntityDebugSettingsPanelComponent extends PageComponent implements
@Input({ transform: booleanAttribute }) failuresEnabled = false;
@Input({ transform: booleanAttribute }) allEnabled = false;
@Input({ transform: booleanAttribute }) isAlarmRule = false;
@Input() entityLabel = '';
@Input() entityType: EntityType;
@Input() allEnabledUntil = 0;
@Input() maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE;
@ -65,7 +65,6 @@ export class EntityDebugSettingsPanelComponent extends PageComponent implements
maxMessagesCount: string;
maxTimeFrameDuration: number;
initialAllEnabled: boolean;
entityLabel: string;
isDebugAllActive$ = this.debugAllControl.valueChanges.pipe(
startWith(this.debugAllControl.value),
@ -110,9 +109,7 @@ export class EntityDebugSettingsPanelComponent extends PageComponent implements
this.onFailuresControl.patchValue(this.failuresEnabled);
this.debugAllControl.patchValue(this.allEnabled);
this.initialAllEnabled = this.allEnabled || this.allEnabledUntil > new Date().getTime();
if (this.isAlarmRule) {
this.entityLabel = 'alarm-rule.alarm-rule';
} else {
if (!this.entityLabel) {
this.entityLabel = entityTypeTranslations.has(this.entityType) ? entityTypeTranslations.get(this.entityType).type : 'debug-settings.entity';
}
}

2
ui-ngx/src/app/modules/home/components/entity/debug/entity-debug-settings.model.ts

@ -28,7 +28,7 @@ export interface EntityDebugSettingPanelConfig {
maxDebugModeDuration?: number;
additionalActionConfig?: AdditionalDebugActionConfig;
entityType: EntityType;
isAlarmRule?: boolean;
entityLabel?: string;
}
onSettingsAppliedFn: (settings: EntityDebugSettings) => void;
}

10
ui-ngx/src/app/shared/models/calculated-field.models.ts

@ -276,6 +276,10 @@ export interface CalculatedFieldArgument {
timeWindow?: number;
}
export interface RefDynamicSourceConfiguration {
type: ArgumentEntityType.Owner;
}
export enum AggFunction {
AVG='AVG',
MIN='MIN',
@ -328,14 +332,14 @@ export interface CalculatedFieldGeofencing {
perimeterKeyName: string;
reportStrategy: GeofencingReportStrategy;
refEntityId?: RefEntityId;
refDynamicSourceConfiguration: RefDynamicSourceConfiguration;
refDynamicSourceConfiguration: RefDynamicSourceGeofencingConfiguration;
createRelationsWithMatchedZones: boolean;
relationType: string;
direction: EntitySearchDirection;
}
export interface RefDynamicSourceConfiguration {
type?: ArgumentEntityType.RelationQuery | ArgumentEntityType.Owner;
export interface RefDynamicSourceGeofencingConfiguration {
type: ArgumentEntityType.RelationQuery | ArgumentEntityType.Owner;
levels?: Array<RelationPathLevel>;
}

Loading…
Cancel
Save