Rename config.json => defaultLayoutConfig.json
Change-Id: I6365ab3e0da0c98a0be6a8f12420973e9896297f
This commit is contained in:
parent
6d40b87c7d
commit
e6cbd2e844
@ -67,7 +67,7 @@ angular.module('bansho.authentication', [])
|
|||||||
session.create(data.access.token.id, data.access.token.expires);
|
session.create(data.access.token.id, data.access.token.expires);
|
||||||
$http.defaults.headers.common['X-Auth-Token'] = session.sessionId;
|
$http.defaults.headers.common['X-Auth-Token'] = session.sessionId;
|
||||||
|
|
||||||
configManager.fetchConfig(configManager.getDevelopmentConfig().useStoredConfig).then(function () {
|
configManager.fetchLayoutConfig(configManager.getDevelopmentConfig().useStoredConfig).then(function () {
|
||||||
themeManager.setTheme(configManager.getTheme());
|
themeManager.setTheme(configManager.getTheme());
|
||||||
$location.path('/view');
|
$location.path('/view');
|
||||||
}, function (message) {
|
}, function (message) {
|
||||||
|
@ -89,7 +89,7 @@ angular.module('bansho.config', [])
|
|||||||
|
|
||||||
.service('configManager', ['$http', '$q', 'componentsConfig', 'surveilConfig',
|
.service('configManager', ['$http', '$q', 'componentsConfig', 'surveilConfig',
|
||||||
function ($http, $q, componentsConfig, surveilConfig) {
|
function ($http, $q, componentsConfig, surveilConfig) {
|
||||||
var config = {},
|
var layoutConfig = {},
|
||||||
developmentConfig = {};
|
developmentConfig = {};
|
||||||
|
|
||||||
this.loadDevelopmentConfig = function() {
|
this.loadDevelopmentConfig = function() {
|
||||||
@ -114,37 +114,37 @@ angular.module('bansho.config', [])
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.getConfigData = function (templateName) {
|
this.getConfigData = function (templateName) {
|
||||||
return config.data[templateName];
|
return layoutConfig.data[templateName];
|
||||||
};
|
};
|
||||||
|
|
||||||
this.readConfig = function () {
|
this.readLayoutConfig = function () {
|
||||||
return config.data;
|
return layoutConfig.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.saveConfig = function(configuration) {
|
this.saveLayoutConfig = function(configuration) {
|
||||||
config.data = configuration;
|
layoutConfig.data = configuration;
|
||||||
saveConfig();
|
saveLayoutConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setThemeAndSave = function (theme) {
|
this.setThemeAndSave = function (theme) {
|
||||||
config.data.banshoConfig.theme = theme;
|
layoutConfig.data.banshoConfig.theme = theme;
|
||||||
saveConfig();
|
saveLayoutConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getTheme = function () {
|
this.getTheme = function () {
|
||||||
var theme;
|
var theme;
|
||||||
|
|
||||||
if (config.data) {
|
if (layoutConfig.data) {
|
||||||
theme = config.data.banshoConfig.theme;
|
theme = layoutConfig.data.banshoConfig.theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
var saveConfig = function () {
|
var saveLayoutConfig = function () {
|
||||||
var responsePromise = $q.defer();
|
var responsePromise = $q.defer();
|
||||||
|
|
||||||
$http.post(surveilConfig.endpoint('config'), JSON.stringify(config.data))
|
$http.post(surveilConfig.endpoint('appConfig'), JSON.stringify(layoutConfig.data))
|
||||||
.success(function () {
|
.success(function () {
|
||||||
responsePromise.resolve();
|
responsePromise.resolve();
|
||||||
})
|
})
|
||||||
@ -155,19 +155,19 @@ angular.module('bansho.config', [])
|
|||||||
return responsePromise.promise;
|
return responsePromise.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fetchConfig = function (useStoredConfig) {
|
this.fetchLayoutConfig = function (useStoredConfig) {
|
||||||
var responsePromise = $q.defer();
|
var responsePromise = $q.defer();
|
||||||
|
|
||||||
componentsConfig.load();
|
componentsConfig.load();
|
||||||
|
|
||||||
$http.get(surveilConfig.endpoint('config'))
|
$http.get(surveilConfig.endpoint('appConfig'))
|
||||||
.success(function (conf) {
|
.success(function (conf) {
|
||||||
if (!useStoredConfig || jQuery.isEmptyObject(conf)) {
|
if (!useStoredConfig || jQuery.isEmptyObject(conf)) {
|
||||||
$http.get('components/config/config.json')
|
$http.get('components/config/defaultLayoutConfig.json')
|
||||||
.success(function (conf) {
|
.success(function (conf) {
|
||||||
config.data = conf;
|
layoutConfig.data = conf;
|
||||||
|
|
||||||
$http.post(surveilConfig.endpoint('config'), JSON.stringify(conf))
|
$http.post(surveilConfig.endpoint('appConfig'), JSON.stringify(conf))
|
||||||
.success(function () {
|
.success(function () {
|
||||||
responsePromise.resolve();
|
responsePromise.resolve();
|
||||||
})
|
})
|
||||||
@ -179,7 +179,7 @@ angular.module('bansho.config', [])
|
|||||||
responsePromise.reject('Failed to fetch default config');
|
responsePromise.reject('Failed to fetch default config');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
config.data = conf;
|
layoutConfig.data = conf;
|
||||||
responsePromise.resolve();
|
responsePromise.resolve();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -10,7 +10,7 @@ angular.module('bansho.surveil', [])
|
|||||||
surveilEndpoints = {
|
surveilEndpoints = {
|
||||||
status: apiUrl + '/status',
|
status: apiUrl + '/status',
|
||||||
actions: apiUrl + '/actions',
|
actions: apiUrl + '/actions',
|
||||||
config: apiUrl + '/bansho/config'
|
appConfig: apiUrl + '/bansho/config'
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
setAuthUrl: function (url) {
|
setAuthUrl: function (url) {
|
||||||
|
@ -43,7 +43,7 @@ angular.module('bansho.view', ['ngRoute',
|
|||||||
|
|
||||||
.service('loadConfig', ['configManager', 'viewsTemplate', function (configManager, viewsTemplate) {
|
.service('loadConfig', ['configManager', 'viewsTemplate', function (configManager, viewsTemplate) {
|
||||||
return function () {
|
return function () {
|
||||||
var viewsConfig = configManager.readConfig();
|
var viewsConfig = configManager.readLayoutConfig();
|
||||||
|
|
||||||
angular.forEach(viewsConfig, function (config, view) {
|
angular.forEach(viewsConfig, function (config, view) {
|
||||||
viewsTemplate[view] = config.template;
|
viewsTemplate[view] = config.template;
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
angular.module('bansho.view.config', [])
|
angular.module('bansho.view.config', [])
|
||||||
.controller('ConfigCtrl', ['$scope', '$window', 'configManager',
|
.controller('ConfigCtrl', ['$scope', '$window', 'configManager',
|
||||||
function ($scope, $window, configManager) {
|
function ($scope, $window, configManager) {
|
||||||
$scope.configuration = JSON.stringify(configManager.readConfig(),null,4);
|
$scope.configuration = JSON.stringify(configManager.readLayoutConfig(), null, 4);
|
||||||
|
|
||||||
$scope.saveConfiguration = function () {
|
$scope.saveConfiguration = function () {
|
||||||
configManager.saveConfig(JSON.parse($scope.configuration));
|
configManager.saveLayoutConfig(JSON.parse($scope.configuration));
|
||||||
$window.location.reload();
|
$window.location.reload();
|
||||||
};
|
};
|
||||||
}]);
|
}]);
|
||||||
|
Loading…
Reference in New Issue
Block a user