Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Close #50 - include all panel config data in local editor #251

Merged
merged 1 commit into from
Dec 16, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions web/app/settings/settings.localconfig.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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!";
Expand Down