Browse Source

UI: Add hint and refactor models

pull/14293/head
Vladyslav_Prykhodko 11 months ago
parent
commit
243ba16cc3
  1. 2
      ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts
  2. 5
      ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html
  3. 4
      ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/geofencing-configuration.component.ts
  4. 2
      ui-ngx/src/app/modules/home/components/calculated-fields/components/propagation-configuration/propagation-configuration.component.ts
  5. 2
      ui-ngx/src/app/modules/home/components/calculated-fields/components/related-entities-aggregation-configuration/related-entities-aggregation-component.component.ts
  6. 2
      ui-ngx/src/app/modules/home/components/calculated-fields/components/simple-configuration/simple-configuration.component.ts
  7. 46
      ui-ngx/src/app/shared/models/calculated-field.models.ts
  8. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

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

@ -125,7 +125,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
this.columns.push(new DateEntityTableColumn<CalculatedField>('createdTime', 'common.created-time', this.datePipe, '150px')); 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%'));
this.columns.push(new EntityTableColumn<CalculatedField>('type', 'common.type', '170px', entity => this.translate.instant(CalculatedFieldTypeTranslations.get(entity.type)), () => ({whiteSpace: 'nowrap' }))); 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); this.columns.push(expressionColumn);
this.cellActionDescriptors.push( this.cellActionDescriptors.push(

5
ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html

@ -57,9 +57,12 @@
<mat-label>{{ 'common.type' | translate }}</mat-label> <mat-label>{{ 'common.type' | translate }}</mat-label>
<mat-select formControlName="type"> <mat-select formControlName="type">
@for (type of fieldTypes; track type) { @for (type of fieldTypes; track type) {
<mat-option [value]="type">{{ CalculatedFieldTypeTranslations.get(type) | translate}}</mat-option> <mat-option [value]="type">{{ CalculatedFieldTypeTranslations.get(type).name | translate}}</mat-option>
} }
</mat-select> </mat-select>
@if (CalculatedFieldTypeTranslations.get(fieldFormGroup.get('type').value).hint) {
<mat-hint>{{ CalculatedFieldTypeTranslations.get(fieldFormGroup.get('type').value).hint | translate }}</mat-hint>
}
</mat-form-field> </mat-form-field>
</div> </div>
@switch (fieldFormGroup.get('type').value) { @switch (fieldFormGroup.get('type').value) {

4
ui-ngx/src/app/modules/home/components/calculated-fields/components/geofencing-configuration/geofencing-configuration.component.ts

@ -34,7 +34,7 @@ import {
notEmptyObjectValidator, notEmptyObjectValidator,
OutputType OutputType
} from '@shared/models/calculated-field.models'; } from '@shared/models/calculated-field.models';
import { AttributeScope, DataKeyType } from '@shared/models/telemetry/telemetry.models'; import { DataKeyType } from '@shared/models/telemetry/telemetry.models';
import { getCurrentAuthState } from '@core/auth/auth.selectors'; import { getCurrentAuthState } from '@core/auth/auth.selectors';
import { Store } from '@ngrx/store'; import { Store } from '@ngrx/store';
import { AppState } from '@core/core.state'; import { AppState } from '@core/core.state';
@ -80,7 +80,7 @@ export class GeofencingConfigurationComponent implements ControlValueAccessor, V
zoneGroups: this.fb.control<Record<string, CalculatedFieldGeofencing>>({}, notEmptyObjectValidator()), zoneGroups: this.fb.control<Record<string, CalculatedFieldGeofencing>>({}, notEmptyObjectValidator()),
scheduledUpdateEnabled: [true], scheduledUpdateEnabled: [true],
scheduledUpdateInterval: [this.minAllowedScheduledUpdateIntervalInSecForCF], scheduledUpdateInterval: [this.minAllowedScheduledUpdateIntervalInSecForCF],
output: this.fb.control<CalculatedFieldOutput>({scope: AttributeScope.SERVER_SCOPE, type: OutputType.Timeseries}) output: this.fb.control<CalculatedFieldOutput>({type: OutputType.Timeseries})
}); });
currentEntityFilter: EntityFilter; currentEntityFilter: EntityFilter;

2
ui-ngx/src/app/modules/home/components/calculated-fields/components/propagation-configuration/propagation-configuration.component.ts

@ -38,7 +38,6 @@ import {
PropagationDirectionTranslations, PropagationDirectionTranslations,
PropagationWithExpression PropagationWithExpression
} from '@shared/models/calculated-field.models'; } from '@shared/models/calculated-field.models';
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ScriptLanguage } from '@app/shared/models/rule-node.models'; import { ScriptLanguage } from '@app/shared/models/rule-node.models';
@ -83,7 +82,6 @@ export class PropagationConfigurationComponent implements ControlValueAccessor,
}), }),
expression: [calculatedFieldDefaultScript], expression: [calculatedFieldDefaultScript],
output: this.fb.control<CalculatedFieldOutput>({ output: this.fb.control<CalculatedFieldOutput>({
scope: AttributeScope.SERVER_SCOPE,
type: OutputType.Timeseries, type: OutputType.Timeseries,
}), }),
}); });

2
ui-ngx/src/app/modules/home/components/calculated-fields/components/related-entities-aggregation-configuration/related-entities-aggregation-component.component.ts

@ -36,7 +36,6 @@ import {
OutputType, OutputType,
PropagationDirectionTranslations PropagationDirectionTranslations
} from '@shared/models/calculated-field.models'; } from '@shared/models/calculated-field.models';
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
import { map } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ScriptLanguage } from '@app/shared/models/rule-node.models'; import { ScriptLanguage } from '@app/shared/models/rule-node.models';
@ -89,7 +88,6 @@ export class RelatedEntitiesAggregationComponentComponent implements ControlValu
metrics: this.fb.control({}, notEmptyObjectValidator()), metrics: this.fb.control({}, notEmptyObjectValidator()),
deduplicationIntervalInSec: [this.minAllowedDeduplicationIntervalInSecForCF], deduplicationIntervalInSec: [this.minAllowedDeduplicationIntervalInSecForCF],
output: this.fb.control<CalculatedFieldOutput>({ output: this.fb.control<CalculatedFieldOutput>({
scope: AttributeScope.SERVER_SCOPE,
type: OutputType.Timeseries, type: OutputType.Timeseries,
}), }),
useLatestTs: [false] useLatestTs: [false]

2
ui-ngx/src/app/modules/home/components/calculated-fields/components/simple-configuration/simple-configuration.component.ts

@ -35,7 +35,6 @@ import {
getCalculatedFieldArgumentsHighlights, getCalculatedFieldArgumentsHighlights,
OutputType OutputType
} from '@shared/models/calculated-field.models'; } from '@shared/models/calculated-field.models';
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { deepClone } from '@core/utils'; import { deepClone } from '@core/utils';
import { EntityId } from '@shared/models/id/entity-id'; import { EntityId } from '@shared/models/id/entity-id';
@ -87,7 +86,6 @@ export class SimpleConfigurationComponent implements ControlValueAccessor, Valid
expressionSCRIPT: [calculatedFieldDefaultScript], expressionSCRIPT: [calculatedFieldDefaultScript],
output: this.fb.control<CalculatedFieldSimpleOutput>({ output: this.fb.control<CalculatedFieldSimpleOutput>({
name: '', name: '',
scope: AttributeScope.SERVER_SCOPE,
type: OutputType.Timeseries, type: OutputType.Timeseries,
decimalsByDefault: null decimalsByDefault: null
}), }),

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

@ -79,13 +79,29 @@ export enum CalculatedFieldType {
ALARM = 'ALARM', ALARM = 'ALARM',
} }
export const CalculatedFieldTypeTranslations = new Map<CalculatedFieldType, string>( interface CalculatedFieldTypeTranslate {
name: string;
hint?: string;
}
export const CalculatedFieldTypeTranslations = new Map<CalculatedFieldType, CalculatedFieldTypeTranslate>(
[ [
[CalculatedFieldType.SIMPLE, 'calculated-fields.type.simple'], [CalculatedFieldType.SIMPLE, {
[CalculatedFieldType.SCRIPT, 'calculated-fields.type.script'], name: 'calculated-fields.type.simple'
[CalculatedFieldType.GEOFENCING, 'calculated-fields.type.geofencing'], }],
[CalculatedFieldType.PROPAGATION, 'calculated-fields.type.propagation'], [CalculatedFieldType.SCRIPT, {
[CalculatedFieldType.RELATED_ENTITIES_AGGREGATION, 'calculated-fields.type.related-entities-aggregation'], name: 'calculated-fields.type.script'
}],
[CalculatedFieldType.GEOFENCING, {
name: 'calculated-fields.type.geofencing'
}],
[CalculatedFieldType.PROPAGATION, {
name: 'calculated-fields.type.propagation'
}],
[CalculatedFieldType.RELATED_ENTITIES_AGGREGATION, {
name: 'calculated-fields.type.related-entities-aggregation',
hint: 'calculated-fields.type.related-entities-aggregation-hint'
}],
] ]
) )
@ -127,7 +143,7 @@ export interface CalculatedFieldRelatedAggregationConfiguration {
metrics: Record<string, CalculatedFieldAggMetric>; metrics: Record<string, CalculatedFieldAggMetric>;
deduplicationIntervalInSec: number; deduplicationIntervalInSec: number;
useLatestTs: boolean; useLatestTs: boolean;
output: Omit<CalculatedFieldSimpleOutput, 'name'>; output: CalculatedFieldOutput & { decimalsByDefault?: number; };
} }
interface BasePropagationConfiguration { interface BasePropagationConfiguration {
@ -161,12 +177,20 @@ export type CalculatedFieldPropagationConfiguration =
| PropagationWithNoExpression | PropagationWithNoExpression
| PropagationWithExpression; | PropagationWithExpression;
export interface CalculatedFieldOutput { export type CalculatedFieldOutput =
type: OutputType; | CalculatedFieldOutputAttribute
scope?: AttributeScope; | CalculatedFieldOutputTimeSeries;
export interface CalculatedFieldOutputAttribute {
type: OutputType.Attribute,
scope: AttributeScope;
}
export interface CalculatedFieldOutputTimeSeries {
type: OutputType.Timeseries;
} }
export interface CalculatedFieldSimpleOutput extends CalculatedFieldOutput { export type CalculatedFieldSimpleOutput = CalculatedFieldOutput & {
name: string; name: string;
decimalsByDefault?: number; decimalsByDefault?: number;
} }

3
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -1057,7 +1057,8 @@
"script": "Script", "script": "Script",
"geofencing" : "Geofencing", "geofencing" : "Geofencing",
"propagation": "Propagation", "propagation": "Propagation",
"related-entities-aggregation": "Related entities aggregation" "related-entities-aggregation": "Related entities aggregation",
"related-entities-aggregation-hint": "Aggregation of data from related entities"
}, },
"arguments": "Arguments", "arguments": "Arguments",
"decimals-by-default": "Decimals by default", "decimals-by-default": "Decimals by default",

Loading…
Cancel
Save