From a10f9aef32bddeab5817401d28cf4f70b37883b9 Mon Sep 17 00:00:00 2001 From: Emil Momchev <80454439+Mrgoblings@users.noreply.github.com> Date: Wed, 4 Dec 2024 15:21:25 +0200 Subject: [PATCH] add: logging and error handling (#4493) --- .../api/NavigationExtension/NavigationService.js | 2 +- .../NavigationGroupsService.js | 2 +- .../dirigible/portal/js/navigation-controller.js | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/api/NavigationExtension/NavigationService.js b/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/api/NavigationExtension/NavigationService.js index 0bbc6bd2d6..983f7c50d8 100644 --- a/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/api/NavigationExtension/NavigationService.js +++ b/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/api/NavigationExtension/NavigationService.js @@ -15,7 +15,7 @@ for (let i = 0; i < navigationExtensions.length; i++) { const navigation = getNavigation(); navigationList.push(navigation); } catch (err) { - console.error(err) + console.error(`Failed to load a navigation group in NavigationService: ${err}\npath: ${path}`); } } diff --git a/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/api/NavigationGroupsExtension/NavigationGroupsService.js b/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/api/NavigationGroupsExtension/NavigationGroupsService.js index 93f934c351..0e36a15962 100644 --- a/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/api/NavigationGroupsExtension/NavigationGroupsService.js +++ b/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/api/NavigationGroupsExtension/NavigationGroupsService.js @@ -15,7 +15,7 @@ for (let i = 0; i < groupExtensions.length; i++) { const group = getGroup(); groupList.push(group); } catch (err) { - console.error(err) + console.error(`Failed to load a widget in WidgetService: ${err}\npath: ${path}`); } } diff --git a/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/js/navigation-controller.js b/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/js/navigation-controller.js index ffc37da46c..1bda3d160f 100644 --- a/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/js/navigation-controller.js +++ b/components/resources/resources-portal/src/main/resources/META-INF/dirigible/portal/js/navigation-controller.js @@ -9,8 +9,17 @@ navigation.controller("LaunchpadViewController", ["$scope", "messageHub", "$http function loadNavigationGroups() { return $http.get("/services/js/portal/api/NavigationGroupsExtension/NavigationGroupsService.js") .then(function (response) { + for (itemData of response.data) { + if (!itemData || !itemData.icon || !itemData.order || !itemData.label) { + console.error(`Invalid navigation group data: ${JSON.stringify(itemData)}. Missing one of the properties: icon, order, label`); + return; + } + } + $scope.groups = response.data; + $scope.groups.sort((a, b) => a.order - b.order) + response.data.forEach(elem => { $scope.groupItems[elem.label.toLowerCase()] = []; }); @@ -41,7 +50,7 @@ navigation.controller("LaunchpadViewController", ["$scope", "messageHub", "$http function addNavigationItem(itemData) { if (!itemData || !itemData.label || !itemData.group || !itemData.order || !itemData.link) { - console.error('Invalid item data:', itemData); + console.error(`Invalid item data: ${JSON.stringify(itemData)} Missing one of the properties: label, group, order, link`); return; } @@ -54,7 +63,8 @@ navigation.controller("LaunchpadViewController", ["$scope", "messageHub", "$http $scope.groupItems[groupKey].push({ id: itemData.id, label: itemData.label, - link: itemData.link + link: itemData.link, + order: itemData.order }); }