Refactor : Config module is more generic
This commit is contained in:
parent
76e301f938
commit
ef33a35100
@ -5,9 +5,7 @@ angular.element(document).ready(function () {
|
|||||||
$.get('components/config/config.json', function (data) {
|
$.get('components/config/config.json', function (data) {
|
||||||
|
|
||||||
angular.module('adagios.config').config(['readConfigProvider', function (readConfigProvider) {
|
angular.module('adagios.config').config(['readConfigProvider', function (readConfigProvider) {
|
||||||
readConfigProvider.setDashboardConfig(data.dashboardConfig);
|
readConfigProvider.loadJSON(data);
|
||||||
readConfigProvider.setHostsConfig(data.hostsConfig);
|
|
||||||
readConfigProvider.setServicesConfig(data.servicesConfig);
|
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
angular.bootstrap(document, ['adagios']);
|
angular.bootstrap(document, ['adagios']);
|
||||||
|
@ -1,33 +1,21 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
function AdagiosConfig(dashboardConfig, hostsConfig, servicesConfig) {
|
function AdagiosConfig(data) {
|
||||||
this.dashboardConfig = dashboardConfig;
|
this.data = data;
|
||||||
this.hostsConfig = hostsConfig;
|
|
||||||
this.servicesConfig = servicesConfig;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.module('adagios.config', [])
|
angular.module('adagios.config', [])
|
||||||
|
|
||||||
.provider('readConfig', function ReadConfigProvider() {
|
.provider('readConfig', function ReadConfigProvider() {
|
||||||
|
|
||||||
var dashboardConfig = {},
|
var data = {};
|
||||||
hostsConfig = {},
|
|
||||||
servicesConfig = {};
|
|
||||||
|
|
||||||
this.setDashboardConfig = function (value) {
|
this.loadJSON = function (value) {
|
||||||
dashboardConfig = value;
|
data = value;
|
||||||
};
|
|
||||||
|
|
||||||
this.setHostsConfig = function (value) {
|
|
||||||
hostsConfig = value;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setServicesConfig = function (value) {
|
|
||||||
servicesConfig = value;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$get = [function getConfigFactory() {
|
this.$get = [function getConfigFactory() {
|
||||||
return new AdagiosConfig(dashboardConfig, hostsConfig, servicesConfig);
|
return new AdagiosConfig(data);
|
||||||
}];
|
}];
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ angular.module('adagios.tactical', ['ngRoute',
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
.run(['readConfig', 'dashboardConfig', function (readConfig, dashboardConfig) {
|
.run(['readConfig', 'dashboardConfig', function (readConfig, dashboardConfig) {
|
||||||
dashboardConfig.cells = readConfig.dashboardConfig.cells;
|
dashboardConfig.cells = readConfig.data.dashboardConfig.cells;
|
||||||
dashboardConfig.apiName = readConfig.dashboardConfig.apiName;
|
dashboardConfig.apiName = readConfig.data.dashboardConfig.apiName;
|
||||||
dashboardConfig.filters = readConfig.dashboardConfig.filters;
|
dashboardConfig.filters = readConfig.data.dashboardConfig.filters;
|
||||||
}]);
|
}]);
|
||||||
|
@ -20,7 +20,7 @@ angular.module('adagios.view.hosts', ['ngRoute',
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
.run(['readConfig', 'hostsConfig', function (readConfig, hostsConfig) {
|
.run(['readConfig', 'hostsConfig', function (readConfig, hostsConfig) {
|
||||||
hostsConfig.cells = readConfig.hostsConfig.cells;
|
hostsConfig.cells = readConfig.data.hostsConfig.cells;
|
||||||
hostsConfig.apiName = readConfig.hostsConfig.apiName;
|
hostsConfig.apiName = readConfig.data.hostsConfig.apiName;
|
||||||
hostsConfig.filters = readConfig.hostsConfig.filters;
|
hostsConfig.filters = readConfig.data.hostsConfig.filters;
|
||||||
}]);
|
}]);
|
||||||
|
@ -20,7 +20,7 @@ angular.module('adagios.view.services', ['ngRoute',
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
.run(['readConfig', 'servicesConfig', function (readConfig, servicesConfig) {
|
.run(['readConfig', 'servicesConfig', function (readConfig, servicesConfig) {
|
||||||
servicesConfig.cells = readConfig.servicesConfig.cells;
|
servicesConfig.cells = readConfig.data.servicesConfig.cells;
|
||||||
servicesConfig.apiName = readConfig.servicesConfig.apiName;
|
servicesConfig.apiName = readConfig.data.servicesConfig.apiName;
|
||||||
servicesConfig.filters = readConfig.servicesConfig.filters;
|
servicesConfig.filters = readConfig.data.servicesConfig.filters;
|
||||||
}]);
|
}]);
|
||||||
|
Loading…
Reference in New Issue
Block a user