From e02eedb965170a390b289894df78ca032191f595 Mon Sep 17 00:00:00 2001 From: Vincent Fournier Date: Fri, 14 Aug 2015 16:36:32 -0400 Subject: [PATCH] Add generic tables Change-Id: I515d59ee5c7026bc95c229f26c6897c1ee97cab3 --- app/components/config/componentsConfig.json | 8 +- .../config/defaultLayoutConfig.json | 82 +++++++++++++++++++ app/components/directive/table/table.html | 57 +++++++++---- app/components/directive/table/table.js | 30 ++++++- app/components/sidebar/sidebar.html | 1 + app/components/surveil/config.js | 1 - 6 files changed, 159 insertions(+), 20 deletions(-) diff --git a/app/components/config/componentsConfig.json b/app/components/config/componentsConfig.json index a8bd56e..352a6e1 100644 --- a/app/components/config/componentsConfig.json +++ b/app/components/config/componentsConfig.json @@ -227,7 +227,8 @@ "filter": { "services": {}, "hosts": {}, - "events": {} + "events": {}, + "commands": {} } } }, @@ -281,6 +282,11 @@ "provider": "config", "endpoint": "hosts", "filter": "allHostConfigTemplate" + }, + "commands": { + "provider": "config", + "endpoint": "commands", + "filter": "all" } } } diff --git a/app/components/config/defaultLayoutConfig.json b/app/components/config/defaultLayoutConfig.json index a04ba33..99a8960 100644 --- a/app/components/config/defaultLayoutConfig.json +++ b/app/components/config/defaultLayoutConfig.json @@ -855,5 +855,87 @@ ] } ] + }, + "commands": { + "template": "page", + "components": [ + { + "type": "panel", + "components": [ + { + "type": "title", + "attributes": { + "title": "Commands" + } + }, + { + "type": "actionbar", + "attributes": { + "tableId": [ + 0 + ] + }, + "components": [ + { + "type": "actionbar-recheck", + "attributes": {} + }, + { + "type": "actionbar-more", + "attributes": {} + }, + { + "type": "actionbar-search-filter", + "attributes": {} + } + ] + }, + { + "type": "table", + "attributes": { + "tableId": 0, + "headerFollow": true, + "inputSource": "commands", + "isWrappable": false, + "noRepeatCell": "", + "checkColumn": false, + "pagingbar": true, + "cellUrls": { + "command_name": { + "view": "command", + "params": [ + "command_name" + ] + } + } + } + } + ] + } + ] + }, + "command": { + "template": "page", + "components": [ + { + "type": "panel", + "components": [ + { + "type": "container", + "components": [ + { + "type": "info", + "attributes": { + "datamodel": { + "Command": "command" + } + } + } + ] + } + ] + } + ] + } } diff --git a/app/components/directive/table/table.html b/app/components/directive/table/table.html index 9bd9f4a..d9ec901 100644 --- a/app/components/directive/table/table.html +++ b/app/components/directive/table/table.html @@ -1,17 +1,22 @@
-
-

{{title}}

-
- + + + + + @@ -20,22 +25,46 @@ - + + + + + - - - + + + + + + + + - - + +
+ + {{cellsText[i]}} - + {{key}} + +
+ + {{cellsText[i]}} - + {{key}} + +
+
+
+
+ + {{entry[key]}} + + + {{entry[key]}} + +
-
\ No newline at end of file + diff --git a/app/components/directive/table/table.js b/app/components/directive/table/table.js index 083f503..47073f8 100644 --- a/app/components/directive/table/table.js +++ b/app/components/directive/table/table.js @@ -23,8 +23,8 @@ angular.module('bansho.table', ['bansho.datasource', options: '=' }, templateUrl: 'components/directive/table/table.html', - controller: ['$scope', 'headerFollow', 'datasource', 'templateManager', - function ($scope, headerFollow, datasource, templateManager) { + controller: ['$scope', '$window', 'headerFollow', 'datasource', 'templateManager', + function ($scope, $window, headerFollow, datasource, templateManager) { var conf = {}, i; @@ -34,8 +34,22 @@ angular.module('bansho.table', ['bansho.datasource', conf.title = $scope.options.attributes.title; conf.cells = {'text': [], 'name': []}; - conf.cells.text = $scope.options.attributes.cells.text; - conf.cells.name = $scope.options.attributes.cells.name; + if ($scope.options.attributes.cells) { + $scope.allCells = false; + conf.cells.text = $scope.options.attributes.cells.text; + conf.cells.name = $scope.options.attributes.cells.name; + } else { + $scope.allCells = true; + } + + $scope.cellUrls = $scope.options.attributes.cellUrls; + $scope.createUrl = function (entry, urlParam) { + var url = "/#/view?view=" + urlParam.view; + angular.forEach(urlParam.params, function (paramName) { + url += '&' + paramName + '=' + entry[paramName]; + }); + $window.location = url; + }; conf.inputSource = $scope.options.attributes.inputSource; conf.isWrappable = $scope.options.attributes.isWrappable; @@ -69,6 +83,14 @@ angular.module('bansho.table', ['bansho.datasource', datasource.registerDataChanged($scope.tableId, function (data, isCheckAll) { $scope.isCheckAll = isCheckAll; $scope.entries = data; + if ($scope.allCells) { + $scope.columns = {}; + angular.forEach($scope.entries, function (entry) { + angular.forEach(entry, function (value, key) { + $scope.columns[key] = true; + }); + }); + } }); datasource.refreshTableData($scope.tableId); templateManager.addInterval(function refreshTable () { diff --git a/app/components/sidebar/sidebar.html b/app/components/sidebar/sidebar.html index 0ec4e08..969a698 100644 --- a/app/components/sidebar/sidebar.html +++ b/app/components/sidebar/sidebar.html @@ -39,6 +39,7 @@