From 144490eba2f31dc8dc374648a6917d70158f2e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Fri, 6 Mar 2015 16:42:55 -0500 Subject: [PATCH] single_table template --- Gruntfile.js | 12 +-- app/app.js | 4 +- app/components/sidebar/sidebar.html | 4 +- app/components/sidebar/sidebar.js | 2 +- app/components/table/table.js | 2 +- app/custom_views/custom_views.js | 56 ----------- app/dashboard/dashboard.js | 94 +++++++++---------- app/hosts/hosts.html | 22 ----- app/hosts/hosts.js | 35 ------- app/services/services.html | 22 ----- app/services/services.js | 36 ------- .../single_table.html} | 8 +- app/single_table/single_table.js | 55 +++++++++++ 13 files changed, 114 insertions(+), 238 deletions(-) delete mode 100644 app/custom_views/custom_views.js delete mode 100644 app/hosts/hosts.html delete mode 100644 app/hosts/hosts.js delete mode 100644 app/services/services.html delete mode 100644 app/services/services.js rename app/{custom_views/custom_views.html => single_table/single_table.html} (85%) create mode 100644 app/single_table/single_table.js diff --git a/Gruntfile.js b/Gruntfile.js index 739b623..5b9819d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -110,9 +110,7 @@ module.exports = function (grunt) { '<%= project.app %>/components/table/cell_host_address/cell_host_address.js', '<%= project.app %>/components/table/cell_host_status/cell_host_status.js', '<%= project.app %>/dashboard/dashboard.js', - '<%= project.app %>/hosts/hosts.js', - '<%= project.app %>/services/services.js', - '<%= project.app %>/custom_views/custom_views.js' + '<%= project.app %>/single_table/single_table.js' ] }], options: { @@ -145,9 +143,7 @@ module.exports = function (grunt) { '<%= project.build %>/components/table/cell_host_address/cell_host_address.js': '<%= project.app %>/components/table/cell_host_address/cell_host_address.js', '<%= project.build %>/components/table/cell_host_status/cell_host_status.js': '<%= project.app %>/components/table/cell_host_status/cell_host_status.js', '<%= project.build %>/dashboard/dashboard.js': '<%= project.app %>/dashboard/dashboard.js', - '<%= project.build %>/hosts/hosts.js': '<%= project.app %>/hosts/hosts.js', - '<%= project.build %>/services/services.js': '<%= project.app %>/services/services.js', - '<%= project.build %>/custom_views/custom_views.js' : '<%= project.app %>/custom_views/custom_views.js' + '<%= project.build %>/single_table/single_table.js' : '<%= project.app %>/single_table/single_table.js' }, { '<%= project.build %>/js/adagios.min.js' : [ @@ -174,9 +170,7 @@ module.exports = function (grunt) { '<%= project.build %>/components/table/cell_host_address/cell_host_address.js', '<%= project.build %>/components/table/cell_host_status/cell_host_status.js', '<%= project.build %>/dashboard/dashboard.js', - '<%= project.build %>/hosts/hosts.js', - '<%= project.build %>/services/services.js', - '<%= project.build %>/custom_views/custom_views.js' + '<%= project.build %>/single_table/single_table.js' ] } ], diff --git a/app/app.js b/app/app.js index 4494c7c..dd19bd9 100644 --- a/app/app.js +++ b/app/app.js @@ -19,9 +19,7 @@ angular.module('adagios', [ 'adagios.topbar', 'adagios.config', 'adagios.view.dashboard', - 'adagios.view.hosts', - 'adagios.view.services', - 'adagios.view.custom' + 'adagios.view.singleTable' ]) .config(['$routeProvider', function ($routeProvider) { diff --git a/app/components/sidebar/sidebar.html b/app/components/sidebar/sidebar.html index 31f33ad..4256acc 100644 --- a/app/components/sidebar/sidebar.html +++ b/app/components/sidebar/sidebar.html @@ -16,8 +16,8 @@ diff --git a/app/components/sidebar/sidebar.js b/app/components/sidebar/sidebar.js index 35e9989..ff893b6 100644 --- a/app/components/sidebar/sidebar.js +++ b/app/components/sidebar/sidebar.js @@ -6,7 +6,7 @@ angular.module('adagios.sidebar', []) $scope.getClass = function (path) { var class_name = ""; - if ($location.path().substr(0, path.length) === path) { + if ($location.url().substr(0, path.length) === path) { class_name = "state--current"; } diff --git a/app/components/table/table.js b/app/components/table/table.js index 015ad6e..7cc4252 100644 --- a/app/components/table/table.js +++ b/app/components/table/table.js @@ -12,7 +12,7 @@ angular.module('adagios.table', ['adagios.live', 'adagios.table.cell_host_status' ]) - .value('tableConfig', { 'cellToFieldsMap': {}, 'cellWrappableField': {}, 'index': 0}) + .value('tableConfig', {'cellToFieldsMap': {}, 'cellWrappableField': {}, 'index': 0}) .controller('TableCtrl', ['$scope', '$interval', 'getServices', 'tableConfig', 'processColumnRepeat', function ($scope, $interval, getServices, tableConfig, processColumnRepeat) { diff --git a/app/custom_views/custom_views.js b/app/custom_views/custom_views.js deleted file mode 100644 index 3a9d161..0000000 --- a/app/custom_views/custom_views.js +++ /dev/null @@ -1,56 +0,0 @@ -'use strict'; - -angular.module('adagios.view.custom', ['ngRoute', - 'adagios.tactical.status_overview', - 'adagios.tactical.current_health', - 'adagios.tactical.top_alert_producers', - 'adagios.table' - ]) - - .value('customViewsConfig', {}) - - .config(['$routeProvider', function ($routeProvider) { - $routeProvider.when('/customViews', { - templateUrl: 'custom_views/custom_views.html', - controller: 'CustomViewsCtrl' - }); - }]) - - .controller('CustomViewsCtrl', [ '$scope', '$routeParams', 'customViewsConfig', 'tableConfig', - function ($scope, $routeParams, customViewsConfig, tableConfig) { - var viewName = ""; - - tableConfig.index = 0; - - if (!!$routeParams.view) { - viewName = $routeParams.view; - } else { - console.error("ERROR : 'view' GET parameter must be the custom view name"); - return; - } - - 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(customViewsConfig[viewName].components[0].config); - - $scope.singleTableTitle = customViewsConfig[viewName].title; - $scope.singleTableRefreshInterval = customViewsConfig[viewName].refreshInterval; - }]) - - .run(['readConfig', 'customViewsConfig', function (readConfig, customViewsConfig) { - var viewsConfig = readConfig.data; - - angular.forEach(viewsConfig, function (config, view) { - if (config.template === "singleTable") { - customViewsConfig[view] = config; - } - }); - }]); diff --git a/app/dashboard/dashboard.js b/app/dashboard/dashboard.js index 1a96947..55be11e 100644 --- a/app/dashboard/dashboard.js +++ b/app/dashboard/dashboard.js @@ -16,60 +16,60 @@ angular.module('adagios.view.dashboard', ['ngRoute', }]) .controller('DashboardCtrl', ['$scope', 'dashboardConfig', 'getServices', 'tableConfig', - function ($scope, dashboardConfig, getServices, tableConfig) { + function ($scope, dashboardConfig, getServices, tableConfig) { - var fields = ['state'], - filters = {'isnot' : { 'state' : ['0'] }}, - apiName = 'hosts', - components = [], - component, - config, - i = 0; + var fields = ['state'], + filters = {'isnot' : { 'state' : ['0'] }}, + apiName = 'hosts', + components = [], + component, + config, + i = 0; - tableConfig.index = 0; - $scope.dashboardTitle = dashboardConfig.data.title; - $scope.dashboardTemplate = dashboardConfig.data.template; - $scope.dashboardRefreshInterval = dashboardConfig.data.refreshInterval; + tableConfig.index = 0; + $scope.dashboardTitle = dashboardConfig.data.title; + $scope.dashboardTemplate = dashboardConfig.data.template; + $scope.dashboardRefreshInterval = dashboardConfig.data.refreshInterval; - $scope.dashboardTactical = []; - $scope.dashboardTables = []; + $scope.dashboardTactical = []; + $scope.dashboardTables = []; - components = dashboardConfig.data.components; + 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)); - } else if (component.type === 'tactical') { - $scope.dashboardTactical.push(new TacticalConfig(config)); - console.log($scope.dashboardTactical[0].statusOverview); + 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; } - } - getServices(fields, filters, apiName) - .success(function (data) { - $scope.nbHostProblems = data.length; - }); - }]) + 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)); + } else if (component.type === 'tactical') { + $scope.dashboardTactical.push(new TacticalConfig(config)); + console.log($scope.dashboardTactical[0].statusOverview); + } + } + + getServices(fields, filters, apiName) + .success(function (data) { + $scope.nbHostProblems = data.length; + }); + }]) .run(['readConfig', 'dashboardConfig', function (readConfig, dashboardConfig) { dashboardConfig.data = readConfig.data.dashboardConfig; diff --git a/app/hosts/hosts.html b/app/hosts/hosts.html deleted file mode 100644 index ebb48b6..0000000 --- a/app/hosts/hosts.html +++ /dev/null @@ -1,22 +0,0 @@ -
- -
- -
-
-
-

{{hostsTitle}}

-
-
-
- - - -
-
diff --git a/app/hosts/hosts.js b/app/hosts/hosts.js deleted file mode 100644 index 5b71080..0000000 --- a/app/hosts/hosts.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -angular.module('adagios.view.hosts', ['ngRoute', - 'adagios.table' - ]) - - .value('hostsConfig', {}) - - .config(['$routeProvider', function ($routeProvider) { - $routeProvider.when('/hosts', { - templateUrl: 'hosts/hosts.html', - controller: 'HostsCtrl' - }); - }]) - - .controller('HostsCtrl', ['$scope', 'hostsConfig', function ($scope, hostsConfig) { - $scope.hostsTitle = hostsConfig.title; - $scope.hostsCellsText = hostsConfig.cellsText.join(); - $scope.hostsCellsName = hostsConfig.cellsName.join(); - $scope.hostsApiName = hostsConfig.apiName; - $scope.hostsFilters = hostsConfig.filters; - $scope.hostsIsWrappable = hostsConfig.isWrappable; - $scope.hostsRefreshInterval = hostsConfig.refreshInterval; - }]) - - .run(['readConfig', 'hostsConfig', function (readConfig, hostsConfig) { - hostsConfig.title = readConfig.data.hostsConfig.title; - hostsConfig.cellsText = readConfig.data.hostsConfig.cells.text; - hostsConfig.cellsName = readConfig.data.hostsConfig.cells.name; - hostsConfig.apiName = readConfig.data.hostsConfig.apiName; - hostsConfig.filters = readConfig.data.hostsConfig.filters; - hostsConfig.isWrappable = readConfig.data.hostsConfig.isWrappable; - hostsConfig.noRepeatCell = readConfig.data.hostsConfig.noRepeatCell; - hostsConfig.refreshInterval = readConfig.data.hostsConfig.refreshInterval; - }]); diff --git a/app/services/services.html b/app/services/services.html deleted file mode 100644 index 0309696..0000000 --- a/app/services/services.html +++ /dev/null @@ -1,22 +0,0 @@ -
- -
- -
-
-
-

{{servicesTitle}}

-
-
-
- - - -
-
diff --git a/app/services/services.js b/app/services/services.js deleted file mode 100644 index 9aa681a..0000000 --- a/app/services/services.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -angular.module('adagios.view.services', ['ngRoute', - 'adagios.table' - ]) - - .value('servicesConfig', {}) - - .config(['$routeProvider', function ($routeProvider) { - $routeProvider.when('/services', { - templateUrl: 'services/services.html', - controller: 'ServicesCtrl' - }); - }]) - - .controller('ServicesCtrl', ['$scope', 'servicesConfig', function ($scope, servicesConfig) { - $scope.servicesTitle = servicesConfig.title; - $scope.servicesCellsText = servicesConfig.cellsText.join(); - $scope.servicesCellsName = servicesConfig.cellsName.join(); - $scope.servicesApiName = servicesConfig.apiName; - $scope.servicesFilters = servicesConfig.filters; - $scope.servicesIsWrappable = servicesConfig.isWrappable; - $scope.servicesNoRepeatCell = servicesConfig.noRepeatCell; - $scope.servicesRefreshInterval = servicesConfig.refreshInterval; - }]) - - .run(['readConfig', 'servicesConfig', function (readConfig, servicesConfig) { - servicesConfig.title = readConfig.data.servicesConfig.title; - servicesConfig.cellsText = readConfig.data.servicesConfig.cells.text; - servicesConfig.cellsName = readConfig.data.servicesConfig.cells.name; - servicesConfig.apiName = readConfig.data.servicesConfig.apiName; - servicesConfig.filters = readConfig.data.servicesConfig.filters; - servicesConfig.isWrappable = readConfig.data.servicesConfig.isWrappable; - servicesConfig.noRepeatCell = readConfig.data.servicesConfig.noRepeatCell; - servicesConfig.refreshInterval = readConfig.data.servicesConfig.refreshInterval; - }]); diff --git a/app/custom_views/custom_views.html b/app/single_table/single_table.html similarity index 85% rename from app/custom_views/custom_views.html rename to app/single_table/single_table.html index 770d831..502d248 100644 --- a/app/custom_views/custom_views.html +++ b/app/single_table/single_table.html @@ -1,7 +1,7 @@ -
- +
+
- +
@@ -12,7 +12,7 @@