From 5a4b2cf40611869552fab97ee45c4a34af58cc98 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Tue, 19 Sep 2023 16:01:10 +0300 Subject: [PATCH] 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: