Extract tactical and table config object

This commit is contained in:
Frédéric Vachon 2015-03-06 17:08:07 -05:00
parent 144490eba2
commit 9c41efbf26
4 changed files with 24 additions and 35 deletions

View File

@ -129,6 +129,16 @@ angular.module('adagios.table', ['adagios.live',
};
}])
.value('TableConfigObj', function (config) {
this.title = config.title;
this.CellsText = config.cells.text.join();
this.CellsName = config.cells.name.join();
this.ApiName = config.apiName;
this.Filters = config.filters;
this.IsWrappable = config.isWrappable;
this.NoRepeatCell = config.noRepeatCell;
})
.service('processColumnRepeat', function () {
function clearFields(entry, fields) {

View File

@ -7,6 +7,13 @@ angular.module('adagios.tactical', ['adagios.tactical.status_overview',
.value('tacticalConfig', {})
.value('TacticalConfigObj', function (config) {
this.title = config.title;
this.statusOverview = config.components.statusOverview;
this.currentHealth = config.components.currentHealth;
this.topAlertProducers = config.components.topAlertProducers;
})
.controller('TacticalCtrl', ['$scope', 'tacticalConfig', function ($scope, tacticalConfig) {
$scope.statusOverview = tacticalConfig.statusOverview;

View File

@ -15,8 +15,8 @@ angular.module('adagios.view.dashboard', ['ngRoute',
});
}])
.controller('DashboardCtrl', ['$scope', 'dashboardConfig', 'getServices', 'tableConfig',
function ($scope, dashboardConfig, getServices, tableConfig) {
.controller('DashboardCtrl', ['$scope', 'dashboardConfig', 'getServices', 'tableConfig', 'TableConfigObj', 'TacticalConfigObj',
function ($scope, dashboardConfig, getServices, tableConfig, TableConfigObj, TacticalConfigObj) {
var fields = ['state'],
filters = {'isnot' : { 'state' : ['0'] }},
@ -36,32 +36,14 @@ angular.module('adagios.view.dashboard', ['ngRoute',
components = dashboardConfig.data.components;
function TableConfig(config) {
this.title = config.title;
this.CellsText = config.cells.text.join();
this.CellsName = config.cells.name.join();
this.ApiName = config.apiName;
this.Filters = config.filters;
this.IsWrappable = config.isWrappable;
this.NoRepeatCell = config.noRepeatCell;
}
function TacticalConfig(config) {
this.title = config.title;
this.statusOverview = config.components.statusOverview;
this.currentHealth = config.components.currentHealth;
this.topAlertProducers = config.components.topAlertProducers;
}
for (i = 0; i < components.length; i += 1) {
component = components[i];
config = component.config;
if (component.type === 'table') {
$scope.dashboardTables.push(new TableConfig(config));
$scope.dashboardTables.push(new TableConfigObj(config));
} else if (component.type === 'tactical') {
$scope.dashboardTactical.push(new TacticalConfig(config));
console.log($scope.dashboardTactical[0].statusOverview);
$scope.dashboardTactical.push(new TacticalConfigObj(config));
}
}

View File

@ -16,8 +16,8 @@ angular.module('adagios.view.singleTable', ['ngRoute',
});
}])
.controller('SingleTableCtrl', ['$scope', '$routeParams', 'singleTableConfig', 'tableConfig',
function ($scope, $routeParams, singleTableConfig, tableConfig) {
.controller('SingleTableCtrl', ['$scope', '$routeParams', 'singleTableConfig', 'tableConfig', 'TableConfigObj',
function ($scope, $routeParams, singleTableConfig, tableConfig, TableConfigObj) {
var viewName = "";
tableConfig.index = 0;
@ -28,17 +28,7 @@ angular.module('adagios.view.singleTable', ['ngRoute',
throw new Error("ERROR : 'view' GET parameter must be the custom view name");
}
function TableConfig(config) {
this.title = config.title;
this.CellsText = config.cells.text.join();
this.CellsName = config.cells.name.join();
this.ApiName = config.apiName;
this.Filters = config.filters;
this.IsWrappable = config.isWrappable;
this.NoRepeatCell = config.noRepeatCell;
}
$scope.tableConfig = new TableConfig(singleTableConfig[viewName].components[0].config);
$scope.tableConfig = new TableConfigObj(singleTableConfig[viewName].components[0].config);
$scope.singleTableTitle = singleTableConfig[viewName].title;
$scope.singleTableRefreshInterval = singleTableConfig[viewName].refreshInterval;