From 547da5b17ce3e3f37757703980ae526cfdf8b490 Mon Sep 17 00:00:00 2001 From: Vincent Fournier Date: Fri, 14 Aug 2015 14:35:04 -0400 Subject: [PATCH] Add container directive Change-Id: I60c86f468248054149ee9b66828ccf72c3094b0b --- app/app.js | 2 - app/components/config/config.json | 2 +- .../config/defaultLayoutConfig.json | 4 +- .../host.html => container/container.html} | 0 .../directive/container/container.js | 90 +++++++++++++++++++ .../host_cpu/host_cpu.html | 0 .../{host => container}/host_cpu/host_cpu.js | 5 +- .../host_live/host_live.html | 0 .../container/host_live/host_live.js | 13 +++ .../host_load/host_load.html | 0 .../host_load/host_load.js | 5 +- .../host_main/host_main.html | 0 .../host_main/host_main.js | 5 +- .../host_services_list.html | 0 .../host_services_list/host_services_list.js | 5 +- .../directive/container/info/info.html | 13 +++ .../directive/{ => container}/info/info.js | 8 +- .../service_graphs/service_graphs.html | 0 .../service_graphs/service_graphs.js | 13 +++ .../service_info/service_info.html | 0 .../container/service_info/service_info.js | 13 +++ .../service_live/service_live.html | 0 .../container/service_live/service_live.js | 13 +++ .../service_main/service_main.html | 0 .../service_main/service_main.js | 5 +- .../service_metrics/service_metrics.html | 0 .../service_metrics/service_metrics.js | 5 +- app/components/directive/directive.js | 4 +- app/components/directive/host/host.js | 55 ------------ .../directive/host/host_live/host_live.js | 12 --- app/components/directive/info/info.html | 11 --- app/components/directive/service/service.js | 12 --- .../service/service_graphs/service_graphs.js | 9 -- .../service/service_info/service_info.js | 9 -- .../service/service_live/service_live.js | 9 -- app/components/surveil/config.js | 49 ++++++---- app/index.html | 25 +++--- 37 files changed, 225 insertions(+), 171 deletions(-) rename app/components/directive/{host/host.html => container/container.html} (100%) create mode 100644 app/components/directive/container/container.js rename app/components/directive/{host => container}/host_cpu/host_cpu.html (100%) rename app/components/directive/{host => container}/host_cpu/host_cpu.js (54%) rename app/components/directive/{host => container}/host_live/host_live.html (100%) create mode 100644 app/components/directive/container/host_live/host_live.js rename app/components/directive/{host => container}/host_load/host_load.html (100%) rename app/components/directive/{host => container}/host_load/host_load.js (54%) rename app/components/directive/{host => container}/host_main/host_main.html (100%) rename app/components/directive/{host => container}/host_main/host_main.js (54%) rename app/components/directive/{host => container}/host_services_list/host_services_list.html (100%) rename app/components/directive/{host => container}/host_services_list/host_services_list.js (53%) create mode 100644 app/components/directive/container/info/info.html rename app/components/directive/{ => container}/info/info.js (62%) rename app/components/directive/{service => container}/service_graphs/service_graphs.html (100%) create mode 100644 app/components/directive/container/service_graphs/service_graphs.js rename app/components/directive/{service => container}/service_info/service_info.html (100%) create mode 100644 app/components/directive/container/service_info/service_info.js rename app/components/directive/{service => container}/service_live/service_live.html (100%) create mode 100644 app/components/directive/container/service_live/service_live.js rename app/components/directive/{service => container}/service_main/service_main.html (100%) rename app/components/directive/{service => container}/service_main/service_main.js (53%) rename app/components/directive/{service => container}/service_metrics/service_metrics.html (100%) rename app/components/directive/{service => container}/service_metrics/service_metrics.js (53%) delete mode 100644 app/components/directive/host/host.js delete mode 100644 app/components/directive/host/host_live/host_live.js delete mode 100644 app/components/directive/info/info.html delete mode 100644 app/components/directive/service/service_graphs/service_graphs.js delete mode 100644 app/components/directive/service/service_info/service_info.js delete mode 100644 app/components/directive/service/service_live/service_live.js diff --git a/app/app.js b/app/app.js index 7b1754e..fca6da4 100644 --- a/app/app.js +++ b/app/app.js @@ -11,8 +11,6 @@ angular.module('bansho', [ 'bansho.surveil', 'bansho.datasource', 'bansho.directive', - 'bansho.host', - 'bansho.service', 'bansho.drupal', 'bansho.drupal.tile', 'bansho.drupal.info', diff --git a/app/components/config/config.json b/app/components/config/config.json index afe0de0..643c7bd 100644 --- a/app/components/config/config.json +++ b/app/components/config/config.json @@ -2,7 +2,7 @@ "env": "production", "username":"", "password":"", - "useStoredConfig": true, + "useStoredConfig": false, "surveilApiUrl": "surveil/v2", "surveilAuthUrl": "surveil/v2/auth", "refreshInterval": -1 diff --git a/app/components/config/defaultLayoutConfig.json b/app/components/config/defaultLayoutConfig.json index 5456b6c..a04ba33 100644 --- a/app/components/config/defaultLayoutConfig.json +++ b/app/components/config/defaultLayoutConfig.json @@ -620,7 +620,7 @@ "type": "panel", "components": [ { - "type": "host", + "type": "container", "components": [ { "type": "host-main", @@ -663,7 +663,7 @@ "type": "panel", "components": [ { - "type": "service", + "type": "container", "components": [ { "type": "service-main", diff --git a/app/components/directive/host/host.html b/app/components/directive/container/container.html similarity index 100% rename from app/components/directive/host/host.html rename to app/components/directive/container/container.html diff --git a/app/components/directive/container/container.js b/app/components/directive/container/container.js new file mode 100644 index 0000000..8bf0347 --- /dev/null +++ b/app/components/directive/container/container.js @@ -0,0 +1,90 @@ +'use strict'; + +angular.module('bansho.container', []) + .directive('banshoContainer', function () { + return { + restrict: 'E', + scope: { + options: '=' + }, + templateUrl: 'components/directive/container/container.html', + controller: ['$scope', 'templateManager', 'surveilStatus', 'surveilConfig', 'iframeUrl', + function ($scope, templateManager, surveilStatus, surveilConfig, iframeUrl) { + $scope.param = { + //host: {} + }; + + $scope.addDirectiveParamRequirements = function (param) { + if ($scope.param[param] === undefined) { + fillParams[param](); + } + }; + + var fillParams = { + "configHost": function () { + surveilConfig.getHost(templateManager.getPageParam('host_name')) + .then(function (data) { + $scope.param.configHost = data[0]; + }); + }, + "command": function () { + surveilConfig.getCommand(templateManager.getPageParam('command_name')) + .then(function (data) { + $scope.param.command = data[0]; + }); + }, + "host": function () { + var hostname = templateManager.getPageParam('host_name'); + + surveilStatus.getHost(templateManager.getPageParam('host_name')).then(function (data) { + surveilStatus.getService(templateManager.getPageParam('host_name')).then(function (services) { + $scope.param.host = data[0]; + $scope.param.host.services = []; + angular.forEach(services, function (service) { + if (service.service_description === 'cpu') { + $scope.param.host.cpu = service; + } else if (service.service_description === 'load') { + $scope.param.host.load = service; + $scope.param.host.load.iframeUrl = iframeUrl.getIFrameUrl("metric_load1", hostname, "load"); + } else { + $scope.param.host.services.push(service); + } + }); + }); + }); + }, + "hostMetrics": function () { + var hostname = templateManager.getPageParam('host_name'); + + surveilStatus.getHostMetricNames(hostname).then(function (metrics) { + $scope.param.host.metrics = metrics; + angular.forEach(metrics, function (metric) { + surveilStatus.getHostMetric(hostname, metric).then(function (data) { + // TODO: waiting for ORBER BY DESC support in InfluxDB + }); + }); + }); + }, + "service": function () { + var hostname = templateManager.getPageParam('host_name'), + serviceDescription = templateManager.getPageParam('service_description'); + + surveilStatus.getService(hostname, serviceDescription).then(function (data) { + $scope.param.service = data[0]; + surveilStatus.getServiceMetricNames(hostname, serviceDescription).then(function(metric_names) { + $scope.param.service.iframeUrls = {}; + angular.forEach(metric_names, function (metricName) { + $scope.param.service.iframeUrls[metricName] = iframeUrl.getIFrameUrl("metric_" + metricName, hostname, serviceDescription); + surveilStatus.getServiceMetric(hostname, serviceDescription).then(function(data) { + // TODO: waiting for ORBER BY DESC support in InfluxDB + }); + }); + }); + }); + } + }; + + $scope.components = $scope.options.components; + }] + }; + }); diff --git a/app/components/directive/host/host_cpu/host_cpu.html b/app/components/directive/container/host_cpu/host_cpu.html similarity index 100% rename from app/components/directive/host/host_cpu/host_cpu.html rename to app/components/directive/container/host_cpu/host_cpu.html diff --git a/app/components/directive/host/host_cpu/host_cpu.js b/app/components/directive/container/host_cpu/host_cpu.js similarity index 54% rename from app/components/directive/host/host_cpu/host_cpu.js rename to app/components/directive/container/host_cpu/host_cpu.js index 5a28eca..652b229 100644 --- a/app/components/directive/host/host_cpu/host_cpu.js +++ b/app/components/directive/container/host_cpu/host_cpu.js @@ -1,12 +1,13 @@ 'use strict'; -angular.module('bansho.host') +angular.module('bansho.container') .directive('banshoHostCpu', function () { return { restrict: 'E', - templateUrl: 'components/directive/host/host_cpu/host_cpu.html', + templateUrl: 'components/directive/container/host_cpu/host_cpu.html', link: function (scope) { scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('host'); } }; }); diff --git a/app/components/directive/host/host_live/host_live.html b/app/components/directive/container/host_live/host_live.html similarity index 100% rename from app/components/directive/host/host_live/host_live.html rename to app/components/directive/container/host_live/host_live.html diff --git a/app/components/directive/container/host_live/host_live.js b/app/components/directive/container/host_live/host_live.js new file mode 100644 index 0000000..4e9081c --- /dev/null +++ b/app/components/directive/container/host_live/host_live.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('bansho.container') + .directive('banshoHostLive', function () { + return { + restrict: 'E', + templateUrl: 'components/directive/container/host_live/host_live.html', + link: function (scope) { + scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('host'); + } + }; + }); diff --git a/app/components/directive/host/host_load/host_load.html b/app/components/directive/container/host_load/host_load.html similarity index 100% rename from app/components/directive/host/host_load/host_load.html rename to app/components/directive/container/host_load/host_load.html diff --git a/app/components/directive/host/host_load/host_load.js b/app/components/directive/container/host_load/host_load.js similarity index 54% rename from app/components/directive/host/host_load/host_load.js rename to app/components/directive/container/host_load/host_load.js index b79fc3e..d6e1e8c 100644 --- a/app/components/directive/host/host_load/host_load.js +++ b/app/components/directive/container/host_load/host_load.js @@ -1,12 +1,13 @@ 'use strict'; -angular.module('bansho.host') +angular.module('bansho.container') .directive('banshoHostLoad', function () { return { restrict: 'E', - templateUrl: 'components/directive/host/host_load/host_load.html', + templateUrl: 'components/directive/container/host_load/host_load.html', link: function (scope) { scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('host'); } }; }); diff --git a/app/components/directive/host/host_main/host_main.html b/app/components/directive/container/host_main/host_main.html similarity index 100% rename from app/components/directive/host/host_main/host_main.html rename to app/components/directive/container/host_main/host_main.html diff --git a/app/components/directive/host/host_main/host_main.js b/app/components/directive/container/host_main/host_main.js similarity index 54% rename from app/components/directive/host/host_main/host_main.js rename to app/components/directive/container/host_main/host_main.js index 29c892c..3b9bd5f 100644 --- a/app/components/directive/host/host_main/host_main.js +++ b/app/components/directive/container/host_main/host_main.js @@ -1,12 +1,13 @@ 'use strict'; -angular.module('bansho.host') +angular.module('bansho.container') .directive('banshoHostMain', function () { return { restrict: 'E', - templateUrl: 'components/directive/host/host_main/host_main.html', + templateUrl: 'components/directive/container/host_main/host_main.html', link: function (scope) { scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('host'); } }; }); diff --git a/app/components/directive/host/host_services_list/host_services_list.html b/app/components/directive/container/host_services_list/host_services_list.html similarity index 100% rename from app/components/directive/host/host_services_list/host_services_list.html rename to app/components/directive/container/host_services_list/host_services_list.html diff --git a/app/components/directive/host/host_services_list/host_services_list.js b/app/components/directive/container/host_services_list/host_services_list.js similarity index 53% rename from app/components/directive/host/host_services_list/host_services_list.js rename to app/components/directive/container/host_services_list/host_services_list.js index c5474f2..c17c6d0 100644 --- a/app/components/directive/host/host_services_list/host_services_list.js +++ b/app/components/directive/container/host_services_list/host_services_list.js @@ -1,12 +1,13 @@ 'use strict'; -angular.module('bansho.host') +angular.module('bansho.container') .directive('banshoHostServicesList', function () { return { restrict: 'E', - templateUrl: 'components/directive/host/host_services_list/host_services_list.html', + templateUrl: 'components/directive/container/host_services_list/host_services_list.html', link: function (scope) { scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('host'); } }; }); diff --git a/app/components/directive/container/info/info.html b/app/components/directive/container/info/info.html new file mode 100644 index 0000000..d597415 --- /dev/null +++ b/app/components/directive/container/info/info.html @@ -0,0 +1,13 @@ + +
+

{{key}}

+ + + + + + + +
{{key}}{{value}}
+
+
diff --git a/app/components/directive/info/info.js b/app/components/directive/container/info/info.js similarity index 62% rename from app/components/directive/info/info.js rename to app/components/directive/container/info/info.js index 6b9096d..a35dfef 100644 --- a/app/components/directive/info/info.js +++ b/app/components/directive/container/info/info.js @@ -1,10 +1,10 @@ 'use strict'; -angular.module('bansho.info', []) +angular.module('bansho.container') .directive('banshoInfo', function () { return { restrict: 'E', - templateUrl: 'components/directive/info/info.html', + templateUrl: 'components/directive/container/info/info.html', link: function (scope) { scope.param = scope.$parent.param; angular.forEach(scope.components, function(component) { @@ -12,6 +12,10 @@ angular.module('bansho.info', []) scope.datamodels = component.attributes.datamodel; } }); + + angular.forEach(scope.datamodels, function (datamodel) { + scope.$parent.addDirectiveParamRequirements(datamodel); + }); } }; }); diff --git a/app/components/directive/service/service_graphs/service_graphs.html b/app/components/directive/container/service_graphs/service_graphs.html similarity index 100% rename from app/components/directive/service/service_graphs/service_graphs.html rename to app/components/directive/container/service_graphs/service_graphs.html diff --git a/app/components/directive/container/service_graphs/service_graphs.js b/app/components/directive/container/service_graphs/service_graphs.js new file mode 100644 index 0000000..90e8fd1 --- /dev/null +++ b/app/components/directive/container/service_graphs/service_graphs.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('bansho.container') + .directive('banshoServiceGraphs', function () { + return { + restrict: 'E', + templateUrl: 'components/directive/container/service_graphs/service_graphs.html', + link: function (scope) { + scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('service'); + } + }; + }); diff --git a/app/components/directive/service/service_info/service_info.html b/app/components/directive/container/service_info/service_info.html similarity index 100% rename from app/components/directive/service/service_info/service_info.html rename to app/components/directive/container/service_info/service_info.html diff --git a/app/components/directive/container/service_info/service_info.js b/app/components/directive/container/service_info/service_info.js new file mode 100644 index 0000000..cf8d5a4 --- /dev/null +++ b/app/components/directive/container/service_info/service_info.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('bansho.container') + .directive('banshoServiceInfo', function () { + return { + restrict: 'E', + templateUrl: 'components/directive/container/service_info/service_info.html', + link: function (scope) { + scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('service'); + } + }; + }); diff --git a/app/components/directive/service/service_live/service_live.html b/app/components/directive/container/service_live/service_live.html similarity index 100% rename from app/components/directive/service/service_live/service_live.html rename to app/components/directive/container/service_live/service_live.html diff --git a/app/components/directive/container/service_live/service_live.js b/app/components/directive/container/service_live/service_live.js new file mode 100644 index 0000000..4979cf0 --- /dev/null +++ b/app/components/directive/container/service_live/service_live.js @@ -0,0 +1,13 @@ +'use strict'; + +angular.module('bansho.container') + .directive('banshoServiceLive', function () { + return { + restrict: 'E', + templateUrl: 'components/directive/container/service_live/service_live.html', + link: function (scope) { + scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('service'); + } + }; + }); diff --git a/app/components/directive/service/service_main/service_main.html b/app/components/directive/container/service_main/service_main.html similarity index 100% rename from app/components/directive/service/service_main/service_main.html rename to app/components/directive/container/service_main/service_main.html diff --git a/app/components/directive/service/service_main/service_main.js b/app/components/directive/container/service_main/service_main.js similarity index 53% rename from app/components/directive/service/service_main/service_main.js rename to app/components/directive/container/service_main/service_main.js index 5e17623..fbcef12 100644 --- a/app/components/directive/service/service_main/service_main.js +++ b/app/components/directive/container/service_main/service_main.js @@ -1,12 +1,13 @@ 'use strict'; -angular.module('bansho.service') +angular.module('bansho.container') .directive('banshoServiceMain', function () { return { restrict: 'E', - templateUrl: 'components/directive/service/service_main/service_main.html', + templateUrl: 'components/directive/container/service_main/service_main.html', link: function (scope) { scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('service'); } }; }); diff --git a/app/components/directive/service/service_metrics/service_metrics.html b/app/components/directive/container/service_metrics/service_metrics.html similarity index 100% rename from app/components/directive/service/service_metrics/service_metrics.html rename to app/components/directive/container/service_metrics/service_metrics.html diff --git a/app/components/directive/service/service_metrics/service_metrics.js b/app/components/directive/container/service_metrics/service_metrics.js similarity index 53% rename from app/components/directive/service/service_metrics/service_metrics.js rename to app/components/directive/container/service_metrics/service_metrics.js index 6c734b9..229a59c 100644 --- a/app/components/directive/service/service_metrics/service_metrics.js +++ b/app/components/directive/container/service_metrics/service_metrics.js @@ -1,12 +1,13 @@ 'use strict'; -angular.module('bansho.service.metrics', []) +angular.module('bansho.container') .directive('banshoServiceMetrics', function () { return { restrict: 'E', - templateUrl: 'components/service/service_metrics/service_metrics.html', + templateUrl: 'components/directive/container/service_metrics/service_metrics.html', link: function (scope) { scope.param = scope.$parent.param; + scope.$parent.addDirectiveParamRequirements('service'); } }; }); diff --git a/app/components/directive/directive.js b/app/components/directive/directive.js index c0f2b97..5909519 100644 --- a/app/components/directive/directive.js +++ b/app/components/directive/directive.js @@ -2,10 +2,8 @@ angular.module('bansho.directive', [ 'bansho.actionbar', - 'bansho.host', + 'bansho.container', 'bansho.hostTree', - 'bansho.info', - 'bansho.service', 'bansho.table', 'bansho.tabpanel', 'bansho.tactical', diff --git a/app/components/directive/host/host.js b/app/components/directive/host/host.js deleted file mode 100644 index 04a2c66..0000000 --- a/app/components/directive/host/host.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -angular.module('bansho.host', ['bansho.datasource']) - - .directive('banshoHost', function () { - return { - restrict: 'E', - scope: { - options: '=' - }, - templateUrl: 'components/directive/host/host.html', - controller: ['$scope', 'templateManager', 'surveilStatus', 'surveilConfig', 'iframeUrl', - function ($scope, templateManager, surveilStatus, surveilConfig, iframeUrl) { - var hostname = templateManager.getPageParam('host_name'); - - $scope.param = { - host: {}, - configHost: {} - }; - - surveilConfig.getHost(hostname).then(function (data) { - $scope.param.configHost = data[0]; - }); - - surveilStatus.getHost(hostname).then(function (data) { - surveilStatus.getService(hostname).then(function(services) { - $scope.param.host = data[0]; - $scope.param.host.services = []; - angular.forEach(services, function (service) { - if (service.service_description === 'cpu') { - $scope.param.host.cpu = service; - } else if (service.service_description === 'load') { - $scope.param.host.load = service; - $scope.param.host.load.iframeUrl = iframeUrl.getIFrameUrl("metric_load1", hostname, "load"); - } else { - $scope.param.host.services.push(service); - } - }); - }); - - }); - - surveilStatus.getHostMetricNames(hostname).then(function(metrics) { - $scope.param.host.metrics = metrics; - angular.forEach(metrics, function (metric) { - surveilStatus.getHostMetric(hostname, metric).then(function(data) { - // TODO: waiting for ORBER BY DESC support in InfluxDB - }); - }); - }); - - $scope.components = $scope.options.components; - }] - }; - }); diff --git a/app/components/directive/host/host_live/host_live.js b/app/components/directive/host/host_live/host_live.js deleted file mode 100644 index 1e6d602..0000000 --- a/app/components/directive/host/host_live/host_live.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -angular.module('bansho.host') - .directive('banshoHostLive', function () { - return { - restrict: 'E', - templateUrl: 'components/directive/host/host_live/host_live.html', - link: function ($scope) { - $scope.param = $scope.$parent.param; - } - }; - }); diff --git a/app/components/directive/info/info.html b/app/components/directive/info/info.html deleted file mode 100644 index 308e877..0000000 --- a/app/components/directive/info/info.html +++ /dev/null @@ -1,11 +0,0 @@ -
-

{{key}}

- - - - - - - -
{{key}}{{value}}
-
diff --git a/app/components/directive/service/service.js b/app/components/directive/service/service.js index c4e2ab4..803019b 100644 --- a/app/components/directive/service/service.js +++ b/app/components/directive/service/service.js @@ -15,18 +15,6 @@ angular.module('bansho.service', ['bansho.datasource']) serviceDescription = templateManager.getPageParam('service_description'); $scope.param = {}; - surveilStatus.getService(hostname, serviceDescription).then(function (data) { - $scope.param.service = data[0]; - surveilStatus.getServiceMetricNames(hostname, serviceDescription).then(function(metric_names) { - $scope.param.service.iframeUrls = {}; - angular.forEach(metric_names, function (metricName) { - $scope.param.service.iframeUrls[metricName] = iframeUrl.getIFrameUrl("metric_" + metricName, hostname, serviceDescription); - surveilStatus.getServiceMetric(hostname, serviceDescription, metricName).then(function(data) { - // TODO: waiting for ORBER BY DESC support in InfluxDB - }); - }); - }); - }); $scope.components = $scope.options.components; }] }; diff --git a/app/components/directive/service/service_graphs/service_graphs.js b/app/components/directive/service/service_graphs/service_graphs.js deleted file mode 100644 index c996153..0000000 --- a/app/components/directive/service/service_graphs/service_graphs.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -angular.module('bansho.service') - .directive('banshoServiceGraphs', function () { - return { - restrict: 'E', - templateUrl: 'components/directive/service/service_graphs/service_graphs.html' - }; - }); diff --git a/app/components/directive/service/service_info/service_info.js b/app/components/directive/service/service_info/service_info.js deleted file mode 100644 index 92145ec..0000000 --- a/app/components/directive/service/service_info/service_info.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -angular.module('bansho.service') - .directive('banshoServiceInfo', function () { - return { - restrict: 'E', - templateUrl: 'components/directive/service/service_info/service_info.html' - }; - }); diff --git a/app/components/directive/service/service_live/service_live.js b/app/components/directive/service/service_live/service_live.js deleted file mode 100644 index 372c0d1..0000000 --- a/app/components/directive/service/service_live/service_live.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -angular.module('bansho.service') - .directive('banshoServiceLive', function () { - return { - restrict: 'E', - templateUrl: 'components/directive/service/service_live/service_live.html' - }; - }); diff --git a/app/components/surveil/config.js b/app/components/surveil/config.js index db57f35..d767fde 100644 --- a/app/components/surveil/config.js +++ b/app/components/surveil/config.js @@ -18,37 +18,40 @@ angular.module('bansho.surveil') var getData = function (fields, filters, endpoint, paging) { var promise = $q.defer(); - if (!queryEndpoint[endpoint]) { + if (!validEndpoint[endpoint]) { throw new Error('getData in surveilConfig : Invalid endpoint ' + endpoint); } - queryEndpoint[endpoint](fields, filters, paging, function (data) { + queryEndpoint(endpoint, fields, filters, paging, function (data) { promise.resolve(data); }); return promise.promise; }; - var queryEndpoint = { - "hosts": function (fields, filters, paging, callback) { - var hostQuery = surveilQuery(fields, filters.hosts, paging), - method = 'POST', - hostUrl = surveilApiConfig.endpoint('config') + '/hosts/'; - - executeQuery(hostUrl, method, hostQuery) - .success(function (hosts) { - var response = []; - - angular.forEach(hosts, function (host) { - response.push(host); - }); - - callback(response); - }); - } + var validEndpoint = { + "hosts": true, + "commands": true }; + var queryEndpoint = function (endpoint, fields, filters, paging, callback) { + var query = surveilQuery(fields, filters[endpoint], paging), + method = 'POST', + url = surveilApiConfig.endpoint('config') + '/' + endpoint + '/'; + + executeQuery(url, method, query) + .success(function (data) { + var response = []; + + angular.forEach(data, function (obj) { + response.push(obj); + }); + + callback(response); + }); + }; + return { getData: getData, getHost: function (hostname) { @@ -59,5 +62,13 @@ angular.module('bansho.surveil') }); return promise.promise; }, + getCommand: function (commandName) { + var promise = $q.defer(), query = {"commands": {"is": {"command_name": [ commandName ] } } }; + getData([], query, "commands") + .then(function (data) { + promise.resolve(data); + }); + return promise.promise; + } }; }]); diff --git a/app/index.html b/app/index.html index 2cdd393..c593bfd 100644 --- a/app/index.html +++ b/app/index.html @@ -72,6 +72,7 @@ + @@ -79,7 +80,7 @@ - + @@ -105,19 +106,17 @@ - - - - - - + + + + + - - - - - - + + + + +