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>> { 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>>(`/api/${entityType}/${id}/calculatedFields${pageLink.toQuery()}`, createDefaultHttpOptions(type ? {type} : null, config));
return this.http.get<PageData<CalculatedField>>(url, createDefaultHttpOptions(type ? {type} : null, config));
} }
public testScript(inputParams: CalculatedFieldTestScriptInputParams, config?: RequestConfig): Observable<EntityTestScriptResult> { 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({ fieldFormGroup = this.fb.group({
name: ['', [Validators.required, Validators.pattern(oneSpaceInsideRegex), Validators.maxLength(255)]], name: ['', [Validators.required, Validators.pattern(oneSpaceInsideRegex), Validators.maxLength(255)]],
type: [CalculatedFieldType.ALARM],
debugSettings: [], debugSettings: [],
configuration: this.fb.group({ configuration: this.fb.group({
arguments: this.fb.control({}), arguments: this.fb.control({}),
@ -159,8 +160,8 @@ export class AlarmRuleDialogComponent extends DialogComponent<AlarmRuleDialogCom
} }
private applyDialogData(): void { private applyDialogData(): void {
const { configuration = {}, debugSettings = { failuresEnabled: true, allEnabled: true }, ...value } = this.data.value ?? {}; const { configuration = {}, type = CalculatedFieldType.ALARM, debugSettings = { failuresEnabled: true, allEnabled: true }, ...value } = this.data.value ?? {};
this.fieldFormGroup.patchValue({ configuration, debugSettings, ...value }, {emitEvent: false}); this.fieldFormGroup.patchValue({ configuration, type, debugSettings, ...value }, {emitEvent: false});
} }
private observeIsLoading(): void { 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, debugSettings,
debugConfig: { debugConfig: {
entityType: EntityType.CALCULATED_FIELD, entityType: EntityType.CALCULATED_FIELD,
isAlarmRule: true, entityLabel: 'alarm-rule.alarm-rule',
additionalActionConfig, additionalActionConfig,
}, },
onSettingsAppliedFn: settings => this.onDebugConfigChanged(id.id, settings) 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), unit: this.fb.control(TimeUnit.SECONDS, Validators.required),
value: this.fb.group({ value: this.fb.group({
staticValue: this.fb.control<number | null>(null, [Validators.required, Validators.min(1), Validators.max(2147483647), Validators.pattern('[0-9]*')]), 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({ count: this.fb.group({
staticValue: this.fb.control<number | null>(null, [Validators.required, Validators.min(1), Validators.max(2147483647), Validators.pattern('[0-9]*')]), 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 { save(): void {
if (this.complexFilterFormGroup.valid) { const predicate = this.complexFilterFormGroup.value as ComplexAlarmRuleFilterPredicate;
const predicate: ComplexAlarmRuleFilterPredicate = this.complexFilterFormGroup.value as ComplexAlarmRuleFilterPredicate; predicate.type = FilterPredicateType.COMPLEX;
predicate.type = FilterPredicateType.COMPLEX; this.dialogRef.close(predicate);
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 { 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}); this.argumentFormGroup.get('refEntityId')[isEntityWithId ? 'enable' : 'disable']({emitEvent});
if (!isEntityWithId) { if (!isEntityWithId) {
this.entityNameSubject.next(null); 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 }) failuresEnabled = false;
@Input({ transform: booleanAttribute }) allEnabled = false; @Input({ transform: booleanAttribute }) allEnabled = false;
@Input({ transform: booleanAttribute }) isAlarmRule = false; @Input() entityLabel = '';
@Input() entityType: EntityType; @Input() entityType: EntityType;
@Input() allEnabledUntil = 0; @Input() allEnabledUntil = 0;
@Input() maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE; @Input() maxDebugModeDuration = getCurrentAuthState(this.store).maxDebugModeDurationMinutes * MINUTE;
@ -65,7 +65,6 @@ export class EntityDebugSettingsPanelComponent extends PageComponent implements
maxMessagesCount: string; maxMessagesCount: string;
maxTimeFrameDuration: number; maxTimeFrameDuration: number;
initialAllEnabled: boolean; initialAllEnabled: boolean;
entityLabel: string;
isDebugAllActive$ = this.debugAllControl.valueChanges.pipe( isDebugAllActive$ = this.debugAllControl.valueChanges.pipe(
startWith(this.debugAllControl.value), startWith(this.debugAllControl.value),
@ -110,9 +109,7 @@ export class EntityDebugSettingsPanelComponent extends PageComponent implements
this.onFailuresControl.patchValue(this.failuresEnabled); this.onFailuresControl.patchValue(this.failuresEnabled);
this.debugAllControl.patchValue(this.allEnabled); this.debugAllControl.patchValue(this.allEnabled);
this.initialAllEnabled = this.allEnabled || this.allEnabledUntil > new Date().getTime(); this.initialAllEnabled = this.allEnabled || this.allEnabledUntil > new Date().getTime();
if (this.isAlarmRule) { if (!this.entityLabel) {
this.entityLabel = 'alarm-rule.alarm-rule';
} else {
this.entityLabel = entityTypeTranslations.has(this.entityType) ? entityTypeTranslations.get(this.entityType).type : 'debug-settings.entity'; 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; maxDebugModeDuration?: number;
additionalActionConfig?: AdditionalDebugActionConfig; additionalActionConfig?: AdditionalDebugActionConfig;
entityType: EntityType; entityType: EntityType;
isAlarmRule?: boolean; entityLabel?: string;
} }
onSettingsAppliedFn: (settings: EntityDebugSettings) => void; onSettingsAppliedFn: (settings: EntityDebugSettings) => void;
} }

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

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

Loading…
Cancel
Save