From 022f2e29d72d2c1aa4372a2fdbac2704073342e1 Mon Sep 17 00:00:00 2001 From: Vincent Fournier Date: Tue, 14 Jul 2015 19:57:27 -0400 Subject: [PATCH] Refactoring of single table and generic actionbar Change-Id: I64d8851d87bac157d66d64669bcb08f3bd19ffc1 --- app/components/config/config.js | 10 +-- app/components/config/config.json | 76 ++++++++++++++-- app/components/table/actionbar/actionbar.html | 86 ------------------- app/components/table/actionbar/actionbar.js | 60 +++---------- .../actionbar/actions/acknowledge_form.html | 39 --------- .../actionbar/actions/downtime_form.html | 27 ------ .../actionbar/actions/recheck_button.html | 4 - .../component_acknowledge/acknowledge.html | 48 +++++++++++ .../component_acknowledge/acknowledge.js | 45 ++++++++++ .../component_downtime/downtime.html | 37 ++++++++ .../actionbar/component_downtime/downtime.js | 43 ++++++++++ .../actionbar/component_filter/filter.html | 20 +++++ .../actionbar/component_filter/filter.js | 39 +++++++++ .../table/actionbar/component_more/more.html | 25 ++++++ .../table/actionbar/component_more/more.js | 13 +++ .../actionbar/component_recheck/recheck.html | 6 ++ .../actionbar/component_recheck/recheck.js | 36 ++++++++ .../search_filter.html | 21 +++++ .../component_search_filter/search_filter.js | 19 ++++ app/components/table/table.js | 6 +- app/index.html | 9 +- app/routing_view/routing_view.js | 7 +- app/templates/dashboard/dashboard.html | 2 +- app/templates/dashboard/dashboard.js | 20 ++--- app/templates/single_table/single_table.html | 27 ------ app/templates/single_table/single_table.js | 25 ------ app/templates/tables/tables.html | 5 ++ app/templates/tables/tables.js | 58 +++++++++++++ 28 files changed, 521 insertions(+), 292 deletions(-) delete mode 100644 app/components/table/actionbar/actions/acknowledge_form.html delete mode 100644 app/components/table/actionbar/actions/downtime_form.html delete mode 100644 app/components/table/actionbar/actions/recheck_button.html create mode 100644 app/components/table/actionbar/component_acknowledge/acknowledge.html create mode 100644 app/components/table/actionbar/component_acknowledge/acknowledge.js create mode 100644 app/components/table/actionbar/component_downtime/downtime.html create mode 100644 app/components/table/actionbar/component_downtime/downtime.js create mode 100644 app/components/table/actionbar/component_filter/filter.html create mode 100644 app/components/table/actionbar/component_filter/filter.js create mode 100644 app/components/table/actionbar/component_more/more.html create mode 100644 app/components/table/actionbar/component_more/more.js create mode 100644 app/components/table/actionbar/component_recheck/recheck.html create mode 100644 app/components/table/actionbar/component_recheck/recheck.js create mode 100644 app/components/table/actionbar/component_search_filter/search_filter.html create mode 100644 app/components/table/actionbar/component_search_filter/search_filter.js delete mode 100644 app/templates/single_table/single_table.html delete mode 100644 app/templates/single_table/single_table.js create mode 100644 app/templates/tables/tables.html create mode 100644 app/templates/tables/tables.js diff --git a/app/components/config/config.js b/app/components/config/config.js index d78f209..3d0c15d 100644 --- a/app/components/config/config.js +++ b/app/components/config/config.js @@ -67,14 +67,8 @@ angular.module('bansho.config', []) return developmentConfig; }; - this.loadByTemplate = function (templateName, destination) { - var viewsConfig = config.data; - - angular.forEach(viewsConfig, function (conf, view) { - if (conf.template === templateName) { - destination[view] = conf; - } - }); + this.getConfigData = function (templateName) { + return config.data[templateName]; }; this.readConfig = function () { diff --git a/app/components/config/config.json b/app/components/config/config.json index 7cac146..dd21c47 100644 --- a/app/components/config/config.json +++ b/app/components/config/config.json @@ -7,6 +7,27 @@ "refreshInterval": 30, "template": "dashboard", "components": [ + { + "type": "actionbar", + "config": { + "components": [ + "filter", + "acknowledge", + "downtime", + "recheck", + "more", + "search-filter" + ], + "tableId": [ + 0, + 1, + 2, + 3 + ] + } + } + ], + "extra_components": [ { "type": "tactical", "config": { @@ -188,12 +209,27 @@ "liveHosts": { "title": "Hosts", "refreshInterval": 30, - "template": "single_table", + "template": "tables", "components": [ + { + "type": "actionbar", + "config": { + "components": [ + "filter", + "acknowledge", + "downtime", + "recheck", + "more", + "search-filter" + ], + "tableId": [0] + } + }, { "type": "table", "config": { "title": "Hosts", + "tableId": 0, "cells": { "text": [ "Host", @@ -229,12 +265,27 @@ "liveServices": { "title": "Services", "refreshInterval": 30, - "template": "single_table", + "template": "tables", "components": [ + { + "type": "actionbar", + "config": { + "components": [ + "filter", + "acknowledge", + "downtime", + "recheck", + "more", + "search-filter" + ], + "tableId": [0] + } + }, { "type": "table", "config": { "title": "Services", + "tableId": 0, "cells": { "text": [ "Host", @@ -249,7 +300,6 @@ "status_last_check" ] }, - "headerFollow": true, "inputSource": { "service": "surveilStatus", "config": { @@ -259,9 +309,9 @@ }, "isWrappable": false, "noRepeatCell": "host", - "checkColumn": true, - "containsActionBar": true - + "headerFollow": true, + "containsActionBar": true, + "checkColumn": true } } ] @@ -269,12 +319,24 @@ "liveEvents": { "title": "Events", "refreshInterval": 30, - "template": "single_table", + "template": "tables", "components": [ + { + "type": "actionbar", + "config": { + "components": [ + "filter", + "more", + "search-filter" + ], + "tableId": [0] + } + }, { "type": "table", "config": { "title": "Hosts", + "tableId": 0, "cells": { "text": [ "Event type", diff --git a/app/components/table/actionbar/actionbar.html b/app/components/table/actionbar/actionbar.html index 0cb44b2..2ad68de 100644 --- a/app/components/table/actionbar/actionbar.html +++ b/app/components/table/actionbar/actionbar.html @@ -1,90 +1,4 @@ - - - - diff --git a/app/components/table/actionbar/actionbar.js b/app/components/table/actionbar/actionbar.js index e609140..85268aa 100644 --- a/app/components/table/actionbar/actionbar.js +++ b/app/components/table/actionbar/actionbar.js @@ -1,57 +1,25 @@ 'use strict'; angular.module('bansho.table.actionbar', ['bansho.table', 'bansho.surveil', 'bansho.notifications']) - .directive('banshoTableActionbar', function () { + .directive('banshoActionbar', ['$compile', function ($compile) { return { restrict: 'E', scope: { tableId: '=' }, - controller: ['$scope', 'tables', function ($scope, tables) { - $scope.isDowntimeShown = false; - $scope.isAcknowledgeShown = false; + templateUrl: 'components/table/actionbar/actionbar.html', + compile: function () { + return function (scope, element, attrs) { + scope.components = attrs.components.split(','); + if (angular.isArray(scope.components)) { + angular.forEach(scope.components, function (component) { + var banshoDirective = ""; - $scope.switchDowntimeForm = function () { - $scope.isAcknowledgeShown = false; - $scope.isDowntimeShown = !$scope.isDowntimeShown; + element.append(banshoDirective); + $compile(element.contents())(scope); + }); + } }; - - $scope.switchAcknowledgeForm = function () { - $scope.isDowntimeShown = false; - $scope.isAcknowledgeShown = !$scope.isAcknowledgeShown; - }; - - $scope.actionbarFilters = [{ - text: "All", - name: "all" - }, - { - text: "All OK", - name: "all_ok" - }, - { - text: "All Acknowledged", - name: "all_acknowledged" - }, - { - text: "All in Downtime", - name: "all_downtime" - }]; - - $scope.activeFilter = $scope.actionbarFilters[0]; - $scope.activateFilter = function (item) { - $scope.activeFilter = $scope.actionbarFilters[item]; - angular.forEach($scope.tableId, function (tableId) { - console.log("not yet implemented"); - }); - }; - - $scope.searchFilterChange = function () { - angular.forEach($scope.tableId, function (tableId) { - tables.setSearchFilter(tableId, $scope.searchFilter); - }); - }; - }], - templateUrl: 'components/table/actionbar/actionbar.html' + } }; - }); + }]); diff --git a/app/components/table/actionbar/actions/acknowledge_form.html b/app/components/table/actionbar/actions/acknowledge_form.html deleted file mode 100644 index ec6f294..0000000 --- a/app/components/table/actionbar/actions/acknowledge_form.html +++ /dev/null @@ -1,39 +0,0 @@ -

Acknowlege

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
diff --git a/app/components/table/actionbar/actions/downtime_form.html b/app/components/table/actionbar/actions/downtime_form.html deleted file mode 100644 index 902e233..0000000 --- a/app/components/table/actionbar/actions/downtime_form.html +++ /dev/null @@ -1,27 +0,0 @@ -

Downtime

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
diff --git a/app/components/table/actionbar/actions/recheck_button.html b/app/components/table/actionbar/actions/recheck_button.html deleted file mode 100644 index 847dafb..0000000 --- a/app/components/table/actionbar/actions/recheck_button.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/app/components/table/actionbar/component_acknowledge/acknowledge.html b/app/components/table/actionbar/component_acknowledge/acknowledge.html new file mode 100644 index 0000000..347067f --- /dev/null +++ b/app/components/table/actionbar/component_acknowledge/acknowledge.html @@ -0,0 +1,48 @@ +
  • + +
  • + +
    +

    Acknowlege

    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    diff --git a/app/components/table/actionbar/component_acknowledge/acknowledge.js b/app/components/table/actionbar/component_acknowledge/acknowledge.js new file mode 100644 index 0000000..a16237c --- /dev/null +++ b/app/components/table/actionbar/component_acknowledge/acknowledge.js @@ -0,0 +1,45 @@ +'use strict'; + +angular.module('bansho.table.actionbar') + .directive('banshoActionbarAcknowledge', [function () { + return { + restrict: 'E', + templateUrl: 'components/table/actionbar/component_acknowledge/acknowledge.html', + scope: { + tableId: '=' + }, + controller: ['$scope', 'tables', 'surveilActions', 'notifications', + function ($scope, tables, surveilActions, notifications) { + $scope.isAcknowledgeFormShown = false; + $scope.switchAcknowledgeFormShown = function () { + $scope.isAcknowledgeFormShown = !$scope.isAcknowledgeFormShown; + }; + + $scope.acknowledgeProblems = function () { + angular.forEach($scope.tableId, function (tableId) { + tables.forEachCheckedEntry(tableId, function (entry) { + var service_description; + + if ('description' in entry) { + service_description = entry.description; + } + + surveilActions.acknowledge(entry.host_name, service_description, $scope.attrs).then(function (data) { + notifications.push('success', 'Acknowledgement', 'Acknowledged ' + entry.host_name); + }, + function (error) { + notifications.push('error', 'Acknowledgement', 'Could not acknowledge ' + entry.host_name); + }); + }); + + tables.setAllCheckTable(tableId, false); + }); + + $scope.isAcknowledgeFormShown = false; + }; + } + ] + }; + }]); + + diff --git a/app/components/table/actionbar/component_downtime/downtime.html b/app/components/table/actionbar/component_downtime/downtime.html new file mode 100644 index 0000000..31316a0 --- /dev/null +++ b/app/components/table/actionbar/component_downtime/downtime.html @@ -0,0 +1,37 @@ +
  • + +
  • + +
    +

    Downtime

    +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    + diff --git a/app/components/table/actionbar/component_downtime/downtime.js b/app/components/table/actionbar/component_downtime/downtime.js new file mode 100644 index 0000000..9cedc24 --- /dev/null +++ b/app/components/table/actionbar/component_downtime/downtime.js @@ -0,0 +1,43 @@ +'use strict'; + +angular.module('bansho.table.actionbar') + .directive('banshoActionbarDowntime', [function () { + return { + restrict: 'E', + templateUrl: 'components/table/actionbar/component_downtime/downtime.html', + scope: { + tableId: '=' + }, + controller: ['$scope', 'tables', 'surveilActions', 'notifications', + function ($scope, tables, surveilActions, notifications) { + $scope.isDowntimeFormShown = false; + $scope.switchDowntimeFormShown = function () { + $scope.isDowntimeFormShown = !$scope.isDowntimeFormShown; + }; + + $scope.sendDowntime = function () { + angular.forEach($scope.tableId, function (tableId) { + tables.forEachCheckedEntry(tableId, function (entry) { + var service_description; + + if ('description' in entry) { + service_description = entry.description; + } + + surveilActions.downtime(entry.host_name, service_description, $scope.attrs).then(function (data) { + notifications.push('success', 'Downtime', 'Added downtime for ' + entry.host_name); + }, + function (error) { + notifications.push('error', 'Downtime', 'Could not add downtime for ' + entry.host_name); + }); + }); + + tables.setAllCheckTable(tableId, false); + }); + + $scope.isDowntimeFormShown = false; + }; + } + ] + }; + }]); diff --git a/app/components/table/actionbar/component_filter/filter.html b/app/components/table/actionbar/component_filter/filter.html new file mode 100644 index 0000000..d8c992e --- /dev/null +++ b/app/components/table/actionbar/component_filter/filter.html @@ -0,0 +1,20 @@ +
  • + + + +
  • diff --git a/app/components/table/actionbar/component_filter/filter.js b/app/components/table/actionbar/component_filter/filter.js new file mode 100644 index 0000000..b91428d --- /dev/null +++ b/app/components/table/actionbar/component_filter/filter.js @@ -0,0 +1,39 @@ +'use strict'; + +angular.module('bansho.table.actionbar') + .directive('banshoActionbarFilter', [function () { + return { + restrict: 'EA', + scope: { + 'tableId': '=' + }, + templateUrl: 'components/table/actionbar/component_filter/filter.html', + controller: ['$scope', 'tables', function ($scope, tables) { + $scope.possibleFilters = [ + { + text: "All", + name: "all" + }, + { + text: "All OK", + name: "all_ok" + }, + { + text: "All Acknowledged", + name: "all_acknowledged" + }, + { + text: "All in Downtime", + name: "all_downtime" + }]; + + $scope.activeFilter = $scope.possibleFilters[0]; + $scope.activateFilter = function (item) { + $scope.activeFilter = $scope.possibleFilters[item]; + angular.forEach($scope.tableId, function (tableId) { + console.log("not yet implemented"); + }); + }; + }] + }; + }]); diff --git a/app/components/table/actionbar/component_more/more.html b/app/components/table/actionbar/component_more/more.html new file mode 100644 index 0000000..b95db1f --- /dev/null +++ b/app/components/table/actionbar/component_more/more.html @@ -0,0 +1,25 @@ +
  • + + +
    + +
    +
  • diff --git a/app/components/table/actionbar/component_more/more.js b/app/components/table/actionbar/component_more/more.js new file mode 100644 index 0000000..199adf3 --- /dev/null +++ b/app/components/table/actionbar/component_more/more.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('bansho.table.actionbar') + .directive('banshoActionbarMore', [function () { + return { + restrict: 'E', + scope: { + 'tableId': '=' + }, + templateUrl: 'components/table/actionbar/component_more/more.html', + controller: ['$scope', 'tables', function ($scope, tables) {}] + }; + }]); diff --git a/app/components/table/actionbar/component_recheck/recheck.html b/app/components/table/actionbar/component_recheck/recheck.html new file mode 100644 index 0000000..d6c7a21 --- /dev/null +++ b/app/components/table/actionbar/component_recheck/recheck.html @@ -0,0 +1,6 @@ +
  • + +
  • diff --git a/app/components/table/actionbar/component_recheck/recheck.js b/app/components/table/actionbar/component_recheck/recheck.js new file mode 100644 index 0000000..795f82e --- /dev/null +++ b/app/components/table/actionbar/component_recheck/recheck.js @@ -0,0 +1,36 @@ +'use strict'; + +angular.module('bansho.table.actionbar') + .directive('banshoActionbarRecheck', [function () { + return { + restrict: 'EA', + scope: { + 'tableId': '=' + }, + templateUrl: 'components/table/actionbar/component_recheck/recheck.html', + controller: ['$scope', 'tables', 'surveilActions', 'notifications', + function ($scope, tables, surveilActions, notifications) { + $scope.sendRecheck = function () { + angular.forEach($scope.tableId, function (tableId) { + tables.forEachCheckedEntry(tableId, function (entry) { + var service_description; + + if ('description' in entry) { + service_description = entry.description; + } + + surveilActions.recheck(entry.host_name, service_description).then(function (data) { + notifications.push('success', 'Recheck', 'Scheduled recheck for ' + entry.host_name); + }, + function (error) { + notifications.push('error', 'Recheck', 'Could not schedule recheck for ' + entry.host_name); + }); + }); + + tables.setAllCheckTable(tableId, false); + }); + }; + } + ] + }; + }]); diff --git a/app/components/table/actionbar/component_search_filter/search_filter.html b/app/components/table/actionbar/component_search_filter/search_filter.html new file mode 100644 index 0000000..c72eef8 --- /dev/null +++ b/app/components/table/actionbar/component_search_filter/search_filter.html @@ -0,0 +1,21 @@ +
  • + +
  • +
  • + +
    +
      +
    • ...
    • +
    • ...
    • +
    • ...
    • +
    +
    +
  • diff --git a/app/components/table/actionbar/component_search_filter/search_filter.js b/app/components/table/actionbar/component_search_filter/search_filter.js new file mode 100644 index 0000000..4df0c59 --- /dev/null +++ b/app/components/table/actionbar/component_search_filter/search_filter.js @@ -0,0 +1,19 @@ +'use strict'; + +angular.module('bansho.table.actionbar') + .directive('banshoActionbarSearchFilter', [function () { + return { + restrict: 'E', + scope: { + 'tableId': '=' + }, + templateUrl: 'components/table/actionbar/component_search_filter/search_filter.html', + controller: ['$scope', 'tables', function ($scope, tables) { + $scope.searchFilterChange = function () { + angular.forEach($scope.tableId, function (tableId) { + tables.setSearchFilter(tableId, $scope.searchFilter); + }); + }; + }] + }; + }]); diff --git a/app/components/table/table.js b/app/components/table/table.js index ac1d95e..5117d2b 100644 --- a/app/components/table/table.js +++ b/app/components/table/table.js @@ -143,16 +143,14 @@ angular.module('bansho.table', ['bansho.surveil', }, compile: function () { return function (scope, element, attrs) { - var template = 'components/table/table.html', - conf; + conf = {}; if (!attrs.cellsText || !attrs.cellsName || !attrs.inputSource || !attrs.isWrappable) { throw new Error(' "cells-text", "cells-name", "inputSource" and "is-wrappable" attributes must be defined'); } // Create table configuration - conf = {}; conf.cells = { 'text': [], 'name': [] }; conf.cells.text = attrs.cellsText.split(','); conf.cells.name = attrs.cellsName.split(','); @@ -165,7 +163,6 @@ angular.module('bansho.table', ['bansho.surveil', tables.addTable(scope.tableId, conf); - //tableGlobalConfig.tableId = attrs.tableId; scope.checkColumn = scope.$eval(attrs.checkColumn); if (!!attrs.refreshInterval) { @@ -206,6 +203,7 @@ angular.module('bansho.table', ['bansho.surveil', .value('TableConfigObj', function (config) { this.title = config.title; + this.tableId = config.tableId; this.CellsText = config.cells.text.join(); this.CellsName = config.cells.name.join(); this.InputSource = config.inputSource; diff --git a/app/index.html b/app/index.html index ccd57f8..9a9ca76 100644 --- a/app/index.html +++ b/app/index.html @@ -66,7 +66,12 @@ - + + + + + + @@ -103,7 +108,7 @@ - + diff --git a/app/routing_view/routing_view.js b/app/routing_view/routing_view.js index 7e46a00..1afb8fb 100644 --- a/app/routing_view/routing_view.js +++ b/app/routing_view/routing_view.js @@ -18,10 +18,9 @@ angular.module('bansho.view', ['ngRoute', }); }]) - .controller('ViewCtrl', ['$scope', '$rootScope', '$location', '$routeParams', '$window', '$timeout', 'viewsTemplate', 'loadConfig', 'authService', 'configManager', - function ($scope, $rootScope, $location, $routeParams, $window, $timeout, viewsTemplate, loadConfig, authService, configManager) { - var templateName, - templateUrl; + .controller('ViewCtrl', ['$scope', '$rootScope', '$location', '$routeParams', '$window', '$timeout', 'viewsTemplate', 'loadConfig', + function ($scope, $rootScope, $location, $routeParams, $window, $timeout, viewsTemplate, loadConfig) { + var templateName; if (!$rootScope.isAuthenticated) { $location.path('/login'); diff --git a/app/templates/dashboard/dashboard.html b/app/templates/dashboard/dashboard.html index d15d81c..fe52aba 100644 --- a/app/templates/dashboard/dashboard.html +++ b/app/templates/dashboard/dashboard.html @@ -35,7 +35,7 @@ - +
    diff --git a/app/templates/dashboard/dashboard.js b/app/templates/dashboard/dashboard.js index d29b9b2..95f73bf 100644 --- a/app/templates/dashboard/dashboard.js +++ b/app/templates/dashboard/dashboard.js @@ -9,29 +9,25 @@ angular.module('bansho.view.dashboard', ['ngRoute', 'bansho.surveil' ]) - .value('dashboardConfig', {}) - - .controller('DashboardCtrl', ['$scope', '$routeParams', '$interval', 'configManager', 'dashboardConfig', 'TableConfigObj', 'TacticalConfigObj', 'surveilStatus', 'promisesManager', - function ($scope, $routeParams, $interval, configManager, dashboardConfig, TableConfigObj, TacticalConfigObj, surveilStatus, promisesManager) { + .controller('DashboardCtrl', ['$scope', '$routeParams', '$interval', 'configManager', 'TableConfigObj', 'TacticalConfigObj', 'surveilStatus', 'promisesManager', + function ($scope, $routeParams, $interval, configManager, TableConfigObj, TacticalConfigObj, surveilStatus, promisesManager) { var components = [], component, config, viewName = $scope.viewName, + pageConfig = configManager.getConfigData(viewName), i = 0, getData; - if (jQuery.isEmptyObject(dashboardConfig)) { - configManager.loadByTemplate('dashboard', dashboardConfig); - } - - $scope.dashboardTitle = dashboardConfig[viewName].title; - $scope.dashboardTemplate = dashboardConfig[viewName].template; - $scope.dashboardRefreshInterval = dashboardConfig[viewName].refreshInterval; + $scope.dashboardTitle = pageConfig.title; + $scope.dashboardTemplate = pageConfig.template; + $scope.dashboardRefreshInterval = pageConfig.refreshInterval; $scope.dashboardTactical = []; $scope.dashboardTables = []; - components = dashboardConfig[viewName].components; + $scope.components = pageConfig.components; + components = pageConfig.extra_components; for (i = 0; i < components.length; i += 1) { component = components[i]; diff --git a/app/templates/single_table/single_table.html b/app/templates/single_table/single_table.html deleted file mode 100644 index e94807f..0000000 --- a/app/templates/single_table/single_table.html +++ /dev/null @@ -1,27 +0,0 @@ -
    - -
    - -
    -
    -
    -

    {{singleTableTitle}}

    -
    -
    -
    - - - - - -
    -
    diff --git a/app/templates/single_table/single_table.js b/app/templates/single_table/single_table.js deleted file mode 100644 index 25655be..0000000 --- a/app/templates/single_table/single_table.js +++ /dev/null @@ -1,25 +0,0 @@ -/*global jQuery */ - -'use strict'; - -angular.module('bansho.view.singleTable', ['ngRoute', - 'bansho.tactical.status_overview', - 'bansho.tactical.current_health', - 'bansho.tactical.top_alert_producers', - 'bansho.table' - ]) - - .value('singleTableConfig', {}) - - .controller('SingleTableCtrl', ['$scope', '$routeParams', 'singleTableConfig', 'TableConfigObj', 'configManager', - function ($scope, $routeParams, singleTableConfig, TableConfigObj, configManager) { - var viewName = $scope.viewName; - - if (jQuery.isEmptyObject(singleTableConfig)) { - configManager.loadByTemplate('single_table', singleTableConfig); - } - - $scope.tableConfig = new TableConfigObj(singleTableConfig[viewName].components[0].config); - $scope.singleTableTitle = singleTableConfig[viewName].title; - $scope.singleTableRefreshInterval = singleTableConfig[viewName].refreshInterval; - }]); diff --git a/app/templates/tables/tables.html b/app/templates/tables/tables.html new file mode 100644 index 0000000..ecc5284 --- /dev/null +++ b/app/templates/tables/tables.html @@ -0,0 +1,5 @@ +
    +
    + +
    +
    diff --git a/app/templates/tables/tables.js b/app/templates/tables/tables.js new file mode 100644 index 0000000..47ecd07 --- /dev/null +++ b/app/templates/tables/tables.js @@ -0,0 +1,58 @@ +'use strict'; + +angular.module('bansho.view.singleTable', ['ngRoute', + 'bansho.tactical.status_overview', + 'bansho.tactical.current_health', + 'bansho.tactical.top_alert_producers', + 'bansho.table' + ]) + + .controller('TablesCtrl', ['$scope', 'configManager', + function ($scope, configManager) { + var pageConfig = configManager.getConfigData($scope.viewName); + + $scope.pageTitle = pageConfig.title; + $scope.refresh = pageConfig.refreshInterval; + $scope.components = pageConfig.components; + }]) + + .directive('banshoComponents', ['$compile', function ($compile) { + return { + restrict: "E", + replace: true, + scope: { + components: '=', + refresh: '=' + }, + template: "", + link: function (scope, element, attrs) { + if (angular.isArray(scope.components)) { + angular.forEach(scope.components, function (component) { + var banshoDirective = "