-
Notifications
You must be signed in to change notification settings - Fork 5
/
settings.js
31 lines (26 loc) · 954 Bytes
/
settings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
cdbmanager.service('settings', ["$localStorage", function ($localStorage) {
let self = this;
$localStorage.settings = $localStorage.settings || {};
this.initSetting = function (name, defaultValue) {
if ($localStorage.settings[name] == undefined) {
$localStorage.settings[name] = defaultValue;
}
self[name] = $localStorage.settings[name];
};
this.initSetting("rowsPerPage", 10);
this.initSetting("sqlConsoleRowsPerPage", 10);
this.initSetting("showAnalysisTables", false);
this.initSetting("showOverviewTables", false);
}]);
cdbmanager.controller('settingsCtrl', ["$scope", "$localStorage", "settings", function ($scope, $localStorage, settings) {
$scope.settings = settings;
$scope.$watch(function () {
return JSON.stringify(settings);
}, function () {
for (let key in settings) {
if (settings.hasOwnProperty(key)) {
$localStorage.settings[key] = settings[key];
}
}
});
}]);