From 9c41efbf269c6161b2cebca09525370a98dc5185 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Fri, 6 Mar 2015 17:08:07 -0500 Subject: [PATCH] Extract tactical and table config object --- app/components/table/table.js | 10 ++++++++++ app/components/tactical/tactical.js | 7 +++++++ app/dashboard/dashboard.js | 26 ++++---------------------- app/single_table/single_table.js | 16 +++------------- 4 files changed, 24 insertions(+), 35 deletions(-) diff --git a/app/components/table/table.js b/app/components/table/table.js index 7cc4252..6f08ac4 100644 --- a/app/components/table/table.js +++ b/app/components/table/table.js @@ -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) { diff --git a/app/components/tactical/tactical.js b/app/components/tactical/tactical.js index c428874..1356b68 100644 --- a/app/components/tactical/tactical.js +++ b/app/components/tactical/tactical.js @@ -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; diff --git a/app/dashboard/dashboard.js b/app/dashboard/dashboard.js index 55be11e..901016f 100644 --- a/app/dashboard/dashboard.js +++ b/app/dashboard/dashboard.js @@ -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)); } } diff --git a/app/single_table/single_table.js b/app/single_table/single_table.js index fd22509..ceae888 100644 --- a/app/single_table/single_table.js +++ b/app/single_table/single_table.js @@ -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;