Rename config.json => defaultLayoutConfig.json

Change-Id: I6365ab3e0da0c98a0be6a8f12420973e9896297f
This commit is contained in:
Vincent Fournier 2015-07-30 16:02:21 -04:00
parent 6d40b87c7d
commit e6cbd2e844
6 changed files with 24 additions and 24 deletions

View File

@ -67,7 +67,7 @@ angular.module('bansho.authentication', [])
session.create(data.access.token.id, data.access.token.expires);
$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());
$location.path('/view');
}, function (message) {

View File

@ -89,7 +89,7 @@ angular.module('bansho.config', [])
.service('configManager', ['$http', '$q', 'componentsConfig', 'surveilConfig',
function ($http, $q, componentsConfig, surveilConfig) {
var config = {},
var layoutConfig = {},
developmentConfig = {};
this.loadDevelopmentConfig = function() {
@ -114,37 +114,37 @@ angular.module('bansho.config', [])
};
this.getConfigData = function (templateName) {
return config.data[templateName];
return layoutConfig.data[templateName];
};
this.readConfig = function () {
return config.data;
this.readLayoutConfig = function () {
return layoutConfig.data;
};
this.saveConfig = function(configuration) {
config.data = configuration;
saveConfig();
this.saveLayoutConfig = function(configuration) {
layoutConfig.data = configuration;
saveLayoutConfig();
};
this.setThemeAndSave = function (theme) {
config.data.banshoConfig.theme = theme;
saveConfig();
layoutConfig.data.banshoConfig.theme = theme;
saveLayoutConfig();
};
this.getTheme = function () {
var theme;
if (config.data) {
theme = config.data.banshoConfig.theme;
if (layoutConfig.data) {
theme = layoutConfig.data.banshoConfig.theme;
}
return theme;
};
var saveConfig = function () {
var saveLayoutConfig = function () {
var responsePromise = $q.defer();
$http.post(surveilConfig.endpoint('config'), JSON.stringify(config.data))
$http.post(surveilConfig.endpoint('appConfig'), JSON.stringify(layoutConfig.data))
.success(function () {
responsePromise.resolve();
})
@ -155,19 +155,19 @@ angular.module('bansho.config', [])
return responsePromise.promise;
};
this.fetchConfig = function (useStoredConfig) {
this.fetchLayoutConfig = function (useStoredConfig) {
var responsePromise = $q.defer();
componentsConfig.load();
$http.get(surveilConfig.endpoint('config'))
$http.get(surveilConfig.endpoint('appConfig'))
.success(function (conf) {
if (!useStoredConfig || jQuery.isEmptyObject(conf)) {
$http.get('components/config/config.json')
$http.get('components/config/defaultLayoutConfig.json')
.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 () {
responsePromise.resolve();
})
@ -179,7 +179,7 @@ angular.module('bansho.config', [])
responsePromise.reject('Failed to fetch default config');
});
} else {
config.data = conf;
layoutConfig.data = conf;
responsePromise.resolve();
}
})

View File

@ -10,7 +10,7 @@ angular.module('bansho.surveil', [])
surveilEndpoints = {
status: apiUrl + '/status',
actions: apiUrl + '/actions',
config: apiUrl + '/bansho/config'
appConfig: apiUrl + '/bansho/config'
};
},
setAuthUrl: function (url) {

View File

@ -43,7 +43,7 @@ angular.module('bansho.view', ['ngRoute',
.service('loadConfig', ['configManager', 'viewsTemplate', function (configManager, viewsTemplate) {
return function () {
var viewsConfig = configManager.readConfig();
var viewsConfig = configManager.readLayoutConfig();
angular.forEach(viewsConfig, function (config, view) {
viewsTemplate[view] = config.template;

View File

@ -5,10 +5,10 @@
angular.module('bansho.view.config', [])
.controller('ConfigCtrl', ['$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 () {
configManager.saveConfig(JSON.parse($scope.configuration));
configManager.saveLayoutConfig(JSON.parse($scope.configuration));
$window.location.reload();
};
}]);