This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch simple-kilt
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git

commit c54d1b4968d092965f431d864ccb998c2232ae38
Author: Alex Heneveld <g...@alex.heneveld.org>
AuthorDate: Fri Jun 28 14:02:08 2024 +0100

    use color scheme mode as string
---
 .../components/task-sunburst/task-sunburst.directive.js | 17 ++++++++---------
 .../main/inspect/activities/kilt-panel.directive.js     |  6 +++---
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git 
a/ui-modules/app-inspector/app/components/task-sunburst/task-sunburst.directive.js
 
b/ui-modules/app-inspector/app/components/task-sunburst/task-sunburst.directive.js
index 066fc6bd..78eeecea 100644
--- 
a/ui-modules/app-inspector/app/components/task-sunburst/task-sunburst.directive.js
+++ 
b/ui-modules/app-inspector/app/components/task-sunburst/task-sunburst.directive.js
@@ -29,7 +29,7 @@ angular.module(MODULE_NAME, [])
 
 export default MODULE_NAME;
 
-export const STORAGE_KEY_COLOR_MODE = 'brooklyn.'+MODULE_NAME+'.toggle_colors';
+export const STORAGE_KEY_COLOR_MODE = 'brooklyn.'+MODULE_NAME+'.color_mode';
 
 export function taskSunburstDirective() {
     return {
@@ -46,8 +46,10 @@ export function taskSunburstDirective() {
 
 
     function controller($scope, $element, $state, $window, $timeout) {
-        const simpleColors = 
$window.localStorage.getItem(STORAGE_KEY_COLOR_MODE) || false;
-        $scope.colorScheme = simpleColors ? "simple" : "normal";
+        function lookupColorScheme() {
+            $scope.colorScheme = 
$window.localStorage.getItem(STORAGE_KEY_COLOR_MODE) || 'normal';
+        }
+        lookupColorScheme();
 
         const vizOptions = {};
         vizOptions.transitionScale = 1;
@@ -66,9 +68,7 @@ export function taskSunburstDirective() {
             console.warn("ResizeObserver not available; kilt diagram will not 
resize correctly.", e);
         }
 
-        $scope.$on('toggleColorScheme', (event, args) => {
-            $scope.colorScheme = args.simpleColors ? "simple" : "normal";
-        });
+        $scope.$on('changedKiltColorScheme', lookupColorScheme);
 
         function onUpdate() {
             viz.prepData();
@@ -427,7 +427,7 @@ function initVisualization($scope, $element, $state, 
options) {
       $state.go("main.inspect.activities.detail", {entityId: t.entityId, 
activityId: t.id});
     }
                 
-    result.redraw = function(simpleColorScheme) {
+    result.redraw = function() {
         // update chart size
         width = $element.find("svg")[0].getBoundingClientRect().width;
         var height = width * sizing.height_width_ratio;
@@ -444,8 +444,7 @@ function initVisualization($scope, $element, $state, 
options) {
     };
 
     result.resize = result.redraw;
-    result.toggleColorScheme = result.redraw;
- 
+
     result.prepData();
     result.redraw();
     chart.on("mouseleave", mouseleave);
diff --git 
a/ui-modules/app-inspector/app/views/main/inspect/activities/kilt-panel.directive.js
 
b/ui-modules/app-inspector/app/views/main/inspect/activities/kilt-panel.directive.js
index ef7dfb16..8baf14e3 100644
--- 
a/ui-modules/app-inspector/app/views/main/inspect/activities/kilt-panel.directive.js
+++ 
b/ui-modules/app-inspector/app/views/main/inspect/activities/kilt-panel.directive.js
@@ -55,12 +55,12 @@ export function activitiesListAndKiltPanelDirective() {
             vm.wideKilt = newValue;
         };
 
-        vm.simpleColors = window.localStorage.getItem(STORAGE_KEY_COLOR_MODE) 
|| false;
+        vm.simpleColors = 
window.localStorage.getItem(STORAGE_KEY_COLOR_MODE)=='simple';
         vm.toggleColorScheme = function () {
             vm.simpleColors = !vm.simpleColors;
-            $window.localStorage.setItem(STORAGE_KEY_COLOR_MODE, 
vm.simpleColors);
+            $window.localStorage.setItem(STORAGE_KEY_COLOR_MODE, 
vm.simpleColors ? 'simple' : 'normal');
             $timeout(function () {
-                $scope.$broadcast('toggleColorScheme', {simpleColors: 
vm.simpleColors})
+                $scope.$broadcast('changedKiltColorScheme')
             }, 0);
         };
     }

Reply via email to