From 5a4b2cf40611869552fab97ee45c4a34af58cc98 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 19 Sep 2023 16:01:10 +0300 Subject: [PATCH 1/2] UI: Add support import widgets bundles in old format --- .../import-export/import-export.service.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts b/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts index 7ffcaae8e3..ea8479f173 100644 --- a/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts +++ b/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts @@ -398,7 +398,9 @@ export class ImportExportService { const widgetTypesDetails = widgetsBundleItem.widgetTypes; const saveWidgetTypesObservables: Array> = []; for (const widgetTypeDetails of widgetTypesDetails) { - saveWidgetTypesObservables.push(this.widgetService.saveImportedWidgetTypeDetails(widgetTypeDetails)); + saveWidgetTypesObservables.push( + this.widgetService.saveImportedWidgetTypeDetails(this.prepareWidgetTypes(widgetTypeDetails, savedWidgetsBundle)) + ); } widgetTypesObservable = forkJoin(saveWidgetTypesObservables); } else { @@ -432,6 +434,15 @@ export class ImportExportService { ); } + private prepareWidgetTypes(widgetTypes: WidgetTypeDetails & {alias?: string}, widgetsBundle: WidgetsBundle): WidgetTypeDetails { + if (!widgetTypes.fqn) { + widgetTypes.fqn = `${widgetsBundle.alias}.${widgetTypes.alias + ? widgetTypes.alias + : widgetTypes.name.toLowerCase().replace(/\W/g, '_')}`; + } + return widgetTypes; + } + public bulkImportEntities(entitiesData: BulkImportRequest, entityType: EntityType, config?: RequestConfig): Observable { switch (entityType) { case EntityType.DEVICE: From b4f0190454f9433fe6935bb44959ea78e5b5acb6 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Tue, 19 Sep 2023 18:06:54 +0300 Subject: [PATCH 2/2] Update import-export.service.ts --- .../import-export/import-export.service.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts b/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts index ea8479f173..e91375e75e 100644 --- a/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts +++ b/ui-ngx/src/app/modules/home/components/import-export/import-export.service.ts @@ -399,7 +399,7 @@ export class ImportExportService { const saveWidgetTypesObservables: Array> = []; for (const widgetTypeDetails of widgetTypesDetails) { saveWidgetTypesObservables.push( - this.widgetService.saveImportedWidgetTypeDetails(this.prepareWidgetTypes(widgetTypeDetails, savedWidgetsBundle)) + this.widgetService.saveImportedWidgetTypeDetails(this.prepareWidgetType(widgetTypeDetails, savedWidgetsBundle)) ); } widgetTypesObservable = forkJoin(saveWidgetTypesObservables); @@ -434,13 +434,13 @@ export class ImportExportService { ); } - private prepareWidgetTypes(widgetTypes: WidgetTypeDetails & {alias?: string}, widgetsBundle: WidgetsBundle): WidgetTypeDetails { - if (!widgetTypes.fqn) { - widgetTypes.fqn = `${widgetsBundle.alias}.${widgetTypes.alias - ? widgetTypes.alias - : widgetTypes.name.toLowerCase().replace(/\W/g, '_')}`; + private prepareWidgetType(widgetType: WidgetTypeDetails & {alias?: string}, widgetsBundle: WidgetsBundle): WidgetTypeDetails { + if (!widgetType.fqn) { + widgetType.fqn = `${widgetsBundle.alias}.${widgetType.alias + ? widgetType.alias + : widgetType.name.toLowerCase().replace(/\W/g, '_')}`; } - return widgetTypes; + return widgetType; } public bulkImportEntities(entitiesData: BulkImportRequest, entityType: EntityType, config?: RequestConfig): Observable {