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 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.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-select formControlName="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>
@if (CalculatedFieldTypeTranslations.get(fieldFormGroup.get('type').value).hint) {
<mat-hint>{{ CalculatedFieldTypeTranslations.get(fieldFormGroup.get('type').value).hint | translate }}</mat-hint>
}
</mat-form-field>
</div>
@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,
OutputType
} 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 { Store } from '@ngrx/store';
import { AppState } from '@core/core.state';
@ -80,7 +80,7 @@ export class GeofencingConfigurationComponent implements ControlValueAccessor, V
zoneGroups: this.fb.control<Record<string, CalculatedFieldGeofencing>>({}, notEmptyObjectValidator()),
scheduledUpdateEnabled: [true],
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;

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

@ -38,7 +38,6 @@ import {
PropagationDirectionTranslations,
PropagationWithExpression
} from '@shared/models/calculated-field.models';
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
import { map } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ScriptLanguage } from '@app/shared/models/rule-node.models';
@ -83,7 +82,6 @@ export class PropagationConfigurationComponent implements ControlValueAccessor,
}),
expression: [calculatedFieldDefaultScript],
output: this.fb.control<CalculatedFieldOutput>({
scope: AttributeScope.SERVER_SCOPE,
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,
PropagationDirectionTranslations
} from '@shared/models/calculated-field.models';
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
import { map } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { ScriptLanguage } from '@app/shared/models/rule-node.models';
@ -89,7 +88,6 @@ export class RelatedEntitiesAggregationComponentComponent implements ControlValu
metrics: this.fb.control({}, notEmptyObjectValidator()),
deduplicationIntervalInSec: [this.minAllowedDeduplicationIntervalInSecForCF],
output: this.fb.control<CalculatedFieldOutput>({
scope: AttributeScope.SERVER_SCOPE,
type: OutputType.Timeseries,
}),
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,
OutputType
} from '@shared/models/calculated-field.models';
import { AttributeScope } from '@shared/models/telemetry/telemetry.models';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { deepClone } from '@core/utils';
import { EntityId } from '@shared/models/id/entity-id';
@ -87,7 +86,6 @@ export class SimpleConfigurationComponent implements ControlValueAccessor, Valid
expressionSCRIPT: [calculatedFieldDefaultScript],
output: this.fb.control<CalculatedFieldSimpleOutput>({
name: '',
scope: AttributeScope.SERVER_SCOPE,
type: OutputType.Timeseries,
decimalsByDefault: null
}),

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

@ -79,13 +79,29 @@ export enum CalculatedFieldType {
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.SCRIPT, 'calculated-fields.type.script'],
[CalculatedFieldType.GEOFENCING, 'calculated-fields.type.geofencing'],
[CalculatedFieldType.PROPAGATION, 'calculated-fields.type.propagation'],
[CalculatedFieldType.RELATED_ENTITIES_AGGREGATION, 'calculated-fields.type.related-entities-aggregation'],
[CalculatedFieldType.SIMPLE, {
name: 'calculated-fields.type.simple'
}],
[CalculatedFieldType.SCRIPT, {
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>;
deduplicationIntervalInSec: number;
useLatestTs: boolean;
output: Omit<CalculatedFieldSimpleOutput, 'name'>;
output: CalculatedFieldOutput & { decimalsByDefault?: number; };
}
interface BasePropagationConfiguration {
@ -161,12 +177,20 @@ export type CalculatedFieldPropagationConfiguration =
| PropagationWithNoExpression
| PropagationWithExpression;
export interface CalculatedFieldOutput {
type: OutputType;
scope?: AttributeScope;
export type CalculatedFieldOutput =
| CalculatedFieldOutputAttribute
| 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;
decimalsByDefault?: number;
}

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

@ -1057,7 +1057,8 @@
"script": "Script",
"geofencing" : "Geofencing",
"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",
"decimals-by-default": "Decimals by default",

Loading…
Cancel
Save