From a2012214c49d070d5e5a17187ad623924758815b Mon Sep 17 00:00:00 2001 From: Yannick Schaus Date: Sat, 16 Dec 2017 18:23:19 +0100 Subject: [PATCH] Close #50 - include all panel config data in local editor Signed-off-by: Yannick Schaus --- .../settings.localconfig.controller.js | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/web/app/settings/settings.localconfig.controller.js b/web/app/settings/settings.localconfig.controller.js index 0f2bb45a..da5a70dc 100755 --- a/web/app/settings/settings.localconfig.controller.js +++ b/web/app/settings/settings.localconfig.controller.js @@ -24,7 +24,12 @@ vm.copyLabel = "Copy"; } - vm.rawLocalConfig = JSON.stringify($rootScope.dashboards, null, 4); + vm.rawLocalConfig = JSON.stringify({ + dashboards: $rootScope.dashboards, + menucolumns: $rootScope.menucolumns, + settings: $rootScope.settings, + customwidgets: $rootScope.customwidgets + }, null, 4); vm.file = {}; vm.copiedToClipboard = function (success) { @@ -42,6 +47,17 @@ try { vm.importMode = false; var json = JSON.parse(text); + + // handle legacy save files + if (angular.isArray(json)) { + text = JSON.stringify({ + dashboards: json, + menucolumns: 1, + settings: {}, + customwidgets: {} + }, null, 4); + } + vm.rawLocalConfig = text; vm.saveConfig(); } catch (e) { @@ -62,8 +78,16 @@ vm.saveConfig = function () { try { var newconf = JSON.parse(vm.rawLocalConfig); - // maybe add some checks here eventually - angular.copy(newconf, $rootScope.dashboards); + + if (!newconf.dashboards) { + throw 'No dashboards found!'; + } + + angular.copy(newconf.dashboards, $rootScope.dashboards); + angular.copy(newconf.settings, $rootScope.settings); + angular.copy(newconf.customwidgets, $rootScope.customwidgets); + $rootScope.menucolumns = newconf.menucolumns; + PersistenceService.saveDashboards(); PersistenceService.getDashboards(); vm.saveLabel = "Saved!";