Browse Source

UI: Updated filter and calculated fields page icon

pull/14609/head
Vladyslav_Prykhodko 6 months ago
parent
commit
b06dd754bc
  1. 2
      ui-ngx/src/app/core/services/menu.models.ts
  2. 32
      ui-ngx/src/app/modules/home/components/calculated-fields/calculated-fields-table-config.ts
  3. 11
      ui-ngx/src/app/modules/home/components/calculated-fields/table-header/calculated-fields-filter-config.component.html
  4. 7
      ui-ngx/src/app/modules/home/components/calculated-fields/table-header/calculated-fields-filter-config.component.ts
  5. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

2
ui-ngx/src/app/core/services/menu.models.ts

@ -634,7 +634,7 @@ export const menuSectionMap = new Map<MenuId, MenuSection>([
name: 'entity.type-calculated-fields',
type: 'link',
path: '/calculatedFields',
icon: 'mdi:plus-minus-variant',
icon: 'mdi:function-variant',
}
],
[

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

@ -99,6 +99,7 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
this.handleRowClick = ($event, entity) => {
this.editCalculatedField($event, entity);
this.rowPointer = true;
return true;
};
}
@ -131,30 +132,15 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
const expressionColumn = new EntityTableColumn<CalculatedField>('expression', 'calculated-fields.expression', '250px');
expressionColumn.sortable = false;
expressionColumn.cellContentFunction = entity => {
const expressionLabel = this.getExpressionLabel(entity);
return expressionLabel?.length < 45 ? expressionLabel : `<span style="display: inline-block; width: 45ch">${expressionLabel.substring(0, 44)}…</span>`;
}
expressionColumn.cellTooltipFunction = entity => {
const expressionLabel = this.getExpressionLabel(entity);
return expressionLabel?.length < 45 ? null : expressionLabel
};
this.columns.push(new DateEntityTableColumn<CalculatedField>('createdTime', 'common.created-time', this.datePipe, '150px'));
this.columns.push(new EntityTableColumn<CalculatedField>('name', 'common.name', this.pageMode ? '30%' :'33%',
this.columns.push(new EntityTableColumn<CalculatedField>('name', 'common.name', this.pageMode ? '33%' : '60%',
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);
if (this.pageMode) {
this.columns.push(new EntityTableColumn<CalculatedFieldAlarmRule>('entityType', 'alarm-rule.target-entity-type', '15%',
entity => this.translate.instant(entityTypeTranslations.get(entity.entityId.entityType).type)));
this.columns.push(new EntityLinkTableColumn<CalculatedFieldAlarmRule>('entityName', 'alarm-rule.target-entity', '30%',
this.columns.push(new EntityLinkTableColumn<CalculatedFieldAlarmRule>('entityName', 'calculated-fields.target-entity', '33%',
entity => this.utilsService.customTranslation(entity['entityName'], entity['entityName']),
entity => getEntityDetailsPageURL(entity.entityId?.id, entity.entityId?.entityType as EntityType), false));
}
this.columns.push(new EntityTableColumn<CalculatedField>('type', 'common.type', this.pageMode ? '33%' : '40%', entity => this.translate.instant(CalculatedFieldTypeTranslations.get(entity.type).name), () => ({whiteSpace: 'nowrap' })));
this.cellActionDescriptors.push(
{
@ -192,16 +178,6 @@ export class CalculatedFieldsTableConfig extends EntityTableConfig<CalculatedFie
);
}
private getExpressionLabel(entity: CalculatedField): string {
if (entity.type === CalculatedFieldType.SCRIPT ||
entity.type === CalculatedFieldType.PROPAGATION && entity.configuration.applyExpressionToResolvedArguments === true) {
return 'function calculate(ctx, ' + Object.keys(entity.configuration.arguments).join(', ') + ')';
} else if (entity.type === CalculatedFieldType.SIMPLE) {
return entity.configuration.expression ?? '';
}
return '';
}
fetchCalculatedFields(pageLink: PageLink): Observable<PageData<CalculatedField>> {
return this.pageMode ?
this.calculatedFieldsService.getCalculatedFieldsFilter(pageLink, this.calculatedFieldFilterConfig):

11
ui-ngx/src/app/modules/home/components/calculated-fields/table-header/calculated-fields-filter-config.component.html

@ -56,17 +56,6 @@
</ng-template>
<ng-template #calculatedFieldsFilter>
<div class="tb-form-panel tb-calculated-fields-config-component no-padding no-border" [formGroup]="cfFilterForm">
<div class="tb-form-row column-xs">
<div class="fixed-title-width" translate>calculated-fields.calculated-field-names</div>
<tb-string-items-list subscriptSizing="dynamic"
formControlName="name"
appearance="outline"
fieldClass="flex"
class="flex-1"
placeholder="{{ !cfFilterForm.get('name').value?.length ? ('calculated-fields.all-names' | translate) : '' }}"
allowUserValue>
</tb-string-items-list>
</div>
<div class="tb-form-row column-xs">
<div class="fixed-title-width" translate>calculated-fields.calculated-field-types</div>
<tb-string-items-list subscriptSizing="dynamic"

7
ui-ngx/src/app/modules/home/components/calculated-fields/table-header/calculated-fields-filter-config.component.ts

@ -89,7 +89,6 @@ export class CalculatedFieldsFilterConfigComponent implements OnInit, ControlVal
@Input()
initialCfFilterConfig: CalculatedFieldsQuery = {
name: [],
types: [],
entityType: null,
entities: []
@ -139,7 +138,6 @@ export class CalculatedFieldsFilterConfigComponent implements OnInit, ControlVal
}
}
this.cfFilterForm = this.fb.group({
name: [null, []],
types: [null, []],
entityType: [null, []],
entities: [null, []]
@ -249,9 +247,6 @@ export class CalculatedFieldsFilterConfigComponent implements OnInit, ControlVal
if ((isUndefinedOrNull(filter1) || isEmpty(filter1)) && (isUndefinedOrNull(filter2) || isEmpty(filter2))) {
return true;
} else if (isDefinedAndNotNull(filter1) && isDefinedAndNotNull(filter2)) {
if (!isArraysEqualIgnoreUndefined(filter1.name, filter2.name)) {
return false;
}
if (!isArraysEqualIgnoreUndefined(filter1.types, filter2.types)) {
return false;
}
@ -265,7 +260,6 @@ export class CalculatedFieldsFilterConfigComponent implements OnInit, ControlVal
private updateCfConfigForm(cfFilterConfig?: CalculatedFieldsQuery) {
this.cfFilterForm.patchValue({
name: cfFilterConfig?.name ?? [],
types: cfFilterConfig?.types ?? [],
entityType: cfFilterConfig?.entityType ?? null,
entities: cfFilterConfig?.entities ?? [],
@ -279,7 +273,6 @@ export class CalculatedFieldsFilterConfigComponent implements OnInit, ControlVal
private cfFilterFromFormValue(formValue: any): CalculatedFieldsQuery {
return {
name: formValue?.name ?? [],
types: formValue?.types ?? [],
entityType: formValue?.entityType ?? null,
entities: formValue?.entities ?? [],

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

@ -1221,10 +1221,9 @@
"deduplication-interval-min": "Deduplication interval should be at least {{ sec }} seconds.",
"deduplication-interval-required": "Deduplication interval is required.",
"calculated-fields-filter": "Calculated fields filter",
"calculated-field-names": "Calculated field names",
"calculated-field-types": "Calculated field types",
"any-type": "Any type",
"all-names": "All",
"target-entity": "Target entity",
"metrics": {
"metrics": "Metrics",
"metrics-empty": "At least one metric must be configured.",

Loading…
Cancel
Save