From 3ddb3300f3e56fc083a483e6bf968bbf66bcecef Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 26 Nov 2024 16:46:03 +0200 Subject: [PATCH 1/2] UI: Add custom translate for description columns --- .../asset-profiles-table-config.resolver.ts | 9 ++++----- .../device-profiles-table-config.resolver.ts | 9 +++++---- .../recipient/recipient-table-config.resolver.ts | 6 ++++-- .../notification/rule/rule-table-config.resolver.ts | 6 ++++-- .../rulechain/rulechains-table-config.resolver.ts | 11 ++++++----- .../tenant-profiles-table-config.resolver.ts | 7 +++++-- 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/asset-profile/asset-profiles-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/asset-profile/asset-profiles-table-config.resolver.ts index 75463ed871..73226d3ff3 100644 --- a/ui-ngx/src/app/modules/home/pages/asset-profile/asset-profiles-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/asset-profile/asset-profiles-table-config.resolver.ts @@ -28,13 +28,12 @@ import { DatePipe } from '@angular/common'; import { EntityType, entityTypeResources, entityTypeTranslations } from '@shared/models/entity-type.models'; import { EntityAction } from '@home/models/entity/entity-component.models'; import { DialogService } from '@core/services/dialog.service'; -import { MatDialog } from '@angular/material/dialog'; import { ImportExportService } from '@shared/import-export/import-export.service'; -import { HomeDialogsService } from '@home/dialogs/home-dialogs.service'; import { AssetProfile } from '@shared/models/asset.models'; import { AssetProfileService } from '@core/http/asset-profile.service'; import { AssetProfileComponent } from '@home/components/profile/asset-profile.component'; import { AssetProfileTabsComponent } from './asset-profile-tabs.component'; +import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; @Injectable() export class AssetProfilesTableConfigResolver { @@ -43,12 +42,11 @@ export class AssetProfilesTableConfigResolver { constructor(private assetProfileService: AssetProfileService, private importExport: ImportExportService, - private homeDialogs: HomeDialogsService, private translate: TranslateService, private datePipe: DatePipe, private dialogService: DialogService, private router: Router, - private dialog: MatDialog) { + private customTranslate: CustomTranslatePipe) { this.config.entityType = EntityType.ASSET_PROFILE; this.config.entityComponent = AssetProfileComponent; @@ -61,7 +59,8 @@ export class AssetProfilesTableConfigResolver { this.config.columns.push( new DateEntityTableColumn('createdTime', 'common.created-time', this.datePipe, '150px'), new EntityTableColumn('name', 'asset-profile.name', '50%'), - new EntityTableColumn('description', 'asset-profile.description', '50%'), + new EntityTableColumn('description', 'asset-profile.description', '50%', + entity => this.customTranslate.transform(entity.description)), new EntityTableColumn('isDefault', 'asset-profile.default', '60px', entity => { return checkBoxCell(entity.default); diff --git a/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts index 2746dbd5f3..e4f0f7be55 100644 --- a/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts @@ -42,7 +42,7 @@ import { AddDeviceProfileDialogData } from '@home/components/profile/add-device-profile-dialog.component'; import { ImportExportService } from '@shared/import-export/import-export.service'; -import { HomeDialogsService } from '@home/dialogs/home-dialogs.service'; +import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; @Injectable() export class DeviceProfilesTableConfigResolver { @@ -51,12 +51,12 @@ export class DeviceProfilesTableConfigResolver { constructor(private deviceProfileService: DeviceProfileService, private importExport: ImportExportService, - private homeDialogs: HomeDialogsService, private translate: TranslateService, private datePipe: DatePipe, private dialogService: DialogService, private router: Router, - private dialog: MatDialog) { + private dialog: MatDialog, + private customTranslate: CustomTranslatePipe) { this.config.entityType = EntityType.DEVICE_PROFILE; this.config.entityComponent = DeviceProfileComponent; @@ -77,7 +77,8 @@ export class DeviceProfilesTableConfigResolver { new EntityTableColumn('transportType', 'device-profile.transport-type', '20%', (deviceProfile) => { return this.translate.instant(deviceTransportTypeTranslationMap.get(deviceProfile.transportType)); }), - new EntityTableColumn('description', 'device-profile.description', '40%'), + new EntityTableColumn('description', 'device-profile.description', '40%', + entity => this.customTranslate.transform(entity.description)), new EntityTableColumn('isDefault', 'device-profile.default', '60px', entity => { return checkBoxCell(entity.default); diff --git a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts index 23368b4584..354baf3877 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/recipient/recipient-table-config.resolver.ts @@ -35,6 +35,7 @@ import { RecipientTableHeaderComponent } from '@home/pages/notification/recipien import { ActivatedRouteSnapshot } from '@angular/router'; import { Injectable } from '@angular/core'; import { DatePipe } from '@angular/common'; +import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; @Injectable() export class RecipientTableConfigResolver { @@ -44,7 +45,8 @@ export class RecipientTableConfigResolver { constructor(private notificationService: NotificationService, private translate: TranslateService, private dialog: MatDialog, - private datePipe: DatePipe) { + private datePipe: DatePipe, + private customTranslate: CustomTranslatePipe) { this.config.entityType = EntityType.NOTIFICATION_TARGET; this.config.detailsPanelEnabled = false; @@ -82,7 +84,7 @@ export class RecipientTableConfigResolver { (target) => this.translate.instant(NotificationTargetTypeTranslationMap.get(target.configuration.type)), () => ({}), false), new EntityTableColumn('configuration.description', 'notification.description', '60%', - (target) => target.configuration.description || '', + (target) => this.customTranslate.transform(target.configuration.description || ''), () => ({}), false) ); } diff --git a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts index 1a0ec93953..8b23bf09ba 100644 --- a/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/notification/rule/rule-table-config.resolver.ts @@ -35,6 +35,7 @@ import { import { ActivatedRouteSnapshot } from '@angular/router'; import { Injectable } from '@angular/core'; import { DatePipe } from '@angular/common'; +import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; @Injectable() export class RuleTableConfigResolver { @@ -44,7 +45,8 @@ export class RuleTableConfigResolver { constructor(private notificationService: NotificationService, private translate: TranslateService, private dialog: MatDialog, - private datePipe: DatePipe) { + private datePipe: DatePipe, + private customTranslate: CustomTranslatePipe) { this.config.entityType = EntityType.NOTIFICATION_RULE; this.config.detailsPanelEnabled = false; @@ -81,7 +83,7 @@ export class RuleTableConfigResolver { (rule) => this.translate.instant(TriggerTypeTranslationMap.get(rule.triggerType)) || '', () => ({}), true), new EntityTableColumn('additionalConfig.description', 'notification.description', '30%', - (target) => target.additionalConfig?.description || '', + (target) => this.customTranslate.transform(target.additionalConfig?.description || ''), () => ({}), false) ); } diff --git a/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts index 8f3a73f018..46eb1636ac 100644 --- a/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/rulechain/rulechains-table-config.resolver.ts @@ -50,13 +50,12 @@ import { PageLink } from '@shared/models/page/page-link'; import { Edge } from '@shared/models/edge.models'; import { mergeMap } from 'rxjs/operators'; import { PageData } from '@shared/models/page/page-data'; -import { HomeDialogsService } from '@home/dialogs/home-dialogs.service'; +import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; @Injectable() export class RuleChainsTableConfigResolver { private readonly config: EntityTableConfig = new EntityTableConfig(); - private edge: Edge; constructor(private ruleChainService: RuleChainService, private dialogService: DialogService, @@ -64,10 +63,10 @@ export class RuleChainsTableConfigResolver { private importExport: ImportExportService, private itembuffer: ItemBufferService, private edgeService: EdgeService, - private homeDialogs: HomeDialogsService, private translate: TranslateService, private datePipe: DatePipe, - private router: Router) { + private router: Router, + private customTranslate: CustomTranslatePipe) { this.config.entityType = EntityType.RULE_CHAIN; this.config.entityComponent = RuleChainComponent; this.config.entityTabsComponent = RuleChainTabsComponent; @@ -128,7 +127,9 @@ export class RuleChainsTableConfigResolver { columns.push( new DateEntityTableColumn('createdTime', 'common.created-time', this.datePipe, '150px'), new EntityTableColumn('name', 'rulechain.name', '50%'), - new EntityTableColumn('description', 'rulechain.description', '50%', entity => entity.additionalInfo?.description ?? '') + new EntityTableColumn('description', 'rulechain.description', '50%', + entity => this.customTranslate.transform(entity.additionalInfo?.description || ''), + () => ({}), false) ); if (ruleChainScope === 'tenant' || ruleChainScope === 'edge') { columns.push( diff --git a/ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts index bd296fbe18..0d0ca87d3e 100644 --- a/ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts @@ -33,6 +33,7 @@ import { TenantProfileComponent } from '@home/components/profile/tenant-profile. import { TenantProfileTabsComponent } from './tenant-profile-tabs.component'; import { DialogService } from '@core/services/dialog.service'; import { ImportExportService } from '@shared/import-export/import-export.service'; +import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; @Injectable() export class TenantProfilesTableConfigResolver { @@ -44,7 +45,8 @@ export class TenantProfilesTableConfigResolver { private translate: TranslateService, private datePipe: DatePipe, private router: Router, - private dialogService: DialogService) { + private dialogService: DialogService, + private customTranslate: CustomTranslatePipe) { this.config.entityType = EntityType.TENANT_PROFILE; this.config.entityComponent = TenantProfileComponent; @@ -55,7 +57,8 @@ export class TenantProfilesTableConfigResolver { this.config.columns.push( new DateEntityTableColumn('createdTime', 'common.created-time', this.datePipe, '150px'), new EntityTableColumn('name', 'tenant-profile.name', '40%'), - new EntityTableColumn('description', 'tenant-profile.description', '60%'), + new EntityTableColumn('description', 'tenant-profile.description', '60%', + entity => this.customTranslate.transform(entity.description)), new EntityTableColumn('isDefault', 'tenant-profile.default', '60px', entity => { return checkBoxCell(entity.default); From a589da7f9f6a0103e47357b64da13b45d44c725d Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 26 Nov 2024 17:40:40 +0200 Subject: [PATCH 2/2] UI: Add custom translate for description columns fixed show null --- .../pages/asset-profile/asset-profiles-table-config.resolver.ts | 2 +- .../device-profile/device-profiles-table-config.resolver.ts | 2 +- .../tenant-profile/tenant-profiles-table-config.resolver.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/asset-profile/asset-profiles-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/asset-profile/asset-profiles-table-config.resolver.ts index 73226d3ff3..f6fa52567b 100644 --- a/ui-ngx/src/app/modules/home/pages/asset-profile/asset-profiles-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/asset-profile/asset-profiles-table-config.resolver.ts @@ -60,7 +60,7 @@ export class AssetProfilesTableConfigResolver { new DateEntityTableColumn('createdTime', 'common.created-time', this.datePipe, '150px'), new EntityTableColumn('name', 'asset-profile.name', '50%'), new EntityTableColumn('description', 'asset-profile.description', '50%', - entity => this.customTranslate.transform(entity.description)), + entity => this.customTranslate.transform(entity.description || '')), new EntityTableColumn('isDefault', 'asset-profile.default', '60px', entity => { return checkBoxCell(entity.default); diff --git a/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts index e4f0f7be55..e9125c3fe7 100644 --- a/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/device-profile/device-profiles-table-config.resolver.ts @@ -78,7 +78,7 @@ export class DeviceProfilesTableConfigResolver { return this.translate.instant(deviceTransportTypeTranslationMap.get(deviceProfile.transportType)); }), new EntityTableColumn('description', 'device-profile.description', '40%', - entity => this.customTranslate.transform(entity.description)), + entity => this.customTranslate.transform(entity.description || '')), new EntityTableColumn('isDefault', 'device-profile.default', '60px', entity => { return checkBoxCell(entity.default); diff --git a/ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts index 0d0ca87d3e..78cdccf3b1 100644 --- a/ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts @@ -58,7 +58,7 @@ export class TenantProfilesTableConfigResolver { new DateEntityTableColumn('createdTime', 'common.created-time', this.datePipe, '150px'), new EntityTableColumn('name', 'tenant-profile.name', '40%'), new EntityTableColumn('description', 'tenant-profile.description', '60%', - entity => this.customTranslate.transform(entity.description)), + entity => this.customTranslate.transform(entity.description || '')), new EntityTableColumn('isDefault', 'tenant-profile.default', '60px', entity => { return checkBoxCell(entity.default);