diff --git a/Gruntfile.js b/Gruntfile.js index 9cb1ba2..92fb1a9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -115,10 +115,12 @@ module.exports = function (grunt) { '<%= project.app %>/components/host/host_load/host_load.js', '<%= project.app %>/components/host/host_main/host_main.js', '<%= project.app %>/components/host/host_services_list/host_services_list.js', + '<%= project.app %>/components/service/service.js', '<%= project.app %>/routing_view/routing_view.js', '<%= project.app %>/templates/dashboard/dashboard.js', '<%= project.app %>/templates/single_table/single_table.js', - '<%= project.app %>/templates/host/host.js' + '<%= project.app %>/templates/host/host.js', + '<%= project.app %>/templates/service/service.js' ] }], options: { @@ -157,11 +159,13 @@ module.exports = function (grunt) { '<%= project.build %>/components/host/host_load/host_load.js': '<%= project.app %>/components/host/host_load/host_load.js', '<%= project.build %>/components/host/host_main/host_main.js': '<%= project.app %>/components/host/host_main/host_main.js', '<%= project.build %>/components/host/host_services_list/host_services_list.js': '<%= project.app %>/components/host/host_services_list/host_services_list.js', + '<%= project.build %>/components/service/service.js': '<%= project.app %>/components/service/service.js', '<%= project.build %>/routing_view/routing_view.js': '<%= project.app %>/routing_view/routing_view.js', '<%= project.build %>/templates/dashboard/dashboard.js': '<%= project.app %>/templates/dashboard/dashboard.js', '<%= project.build %>/templates/single_table/single_table.js' : '<%= project.app %>/templates/single_table/single_table.js', - '<%= project.build %>/templates/host/host.js' : '<%= project.app %>/templates/host/host.js' + '<%= project.build %>/templates/host/host.js': '<%= project.app %>/templates/host/host.js', + '<%= project.build %>/templates/service/service.js': '<%= project.app %>/templates/service/service.js' }, { '<%= project.build %>/js/adagios.min.js' : [ @@ -193,10 +197,12 @@ module.exports = function (grunt) { '<%= project.build %>/components/host/host_load/host_load.js', '<%= project.build %>/components/host/host_main/host_main.js', '<%= project.build %>/components/host/host_services_list/host_services_list.js', + '<%= project.build %>/components/service/service.js', '<%= project.build %>/routing_view/routing_view.js', '<%= project.build %>/templates/dashboard/dashboard.js', '<%= project.build %>/templates/single_table/single_table.js', - '<%= project.build %>/templates/host/host.js' + '<%= project.build %>/templates/host/host.js', + '<%= project.build %>/templates/service/service.js' ] } ], diff --git a/app/app.js b/app/app.js index 2e5ae44..819e913 100644 --- a/app/app.js +++ b/app/app.js @@ -19,10 +19,12 @@ angular.module('adagios', [ 'adagios.topbar', 'adagios.sidebar', 'adagios.host', + 'adagios.service', 'adagios.view', 'adagios.view.dashboard', 'adagios.view.singleTable', - 'adagios.view.host' + 'adagios.view.host', + 'adagios.view.service' ]) .config(['$routeProvider', function ($routeProvider) { diff --git a/app/components/config/config.json b/app/components/config/config.json index 47eab9c..2907cba 100644 --- a/app/components/config/config.json +++ b/app/components/config/config.json @@ -210,5 +210,10 @@ "title": "Host", "refreshInterval": 0, "template": "host" + }, + "service": { + "title": "Service", + "refreshInterval": 0, + "template": "service" } } diff --git a/app/components/live/get_objects.js b/app/components/live/get_objects.js index 4a2483c..6997261 100644 --- a/app/components/live/get_objects.js +++ b/app/components/live/get_objects.js @@ -53,6 +53,16 @@ angular.module('adagios.live') }; }]) + .service('getService', ['$http', + function ($http) { + return function (hostName, description) { + return $http.get('/rest/status/json/services/?host_name=' + hostName + '&description=' + description) + .error(function () { + throw new Error('getService : GET Request failed'); + }); + } + }]) + // This service is used to count the number of host open problems .service('getHostOpenProblems', ['$http', 'getObjects', function ($http, getObjects) { diff --git a/app/components/service/service.html b/app/components/service/service.html new file mode 100644 index 0000000..06df942 --- /dev/null +++ b/app/components/service/service.html @@ -0,0 +1,5 @@ +
+
+

{{data}}

+
+
diff --git a/app/components/service/service.js b/app/components/service/service.js new file mode 100644 index 0000000..914d3f9 --- /dev/null +++ b/app/components/service/service.js @@ -0,0 +1,46 @@ +'use strict'; + +angular.module('adagios.service', ['adagios.live']) + + .value('serviceConfig', {}) + + .controller('ServiceCtrl', ['$scope', 'serviceConfig', 'getService', + function ($scope, serviceConfig, getService) { + var objectType = 'service', + hostName = serviceConfig.hostName, + description = serviceConfig.description; + + getService(hostName, description).success(function (data) { + $scope.data = data; + console.log($scope.data); + }); + }]) + + .directive('adgService', ['$http', '$compile', 'serviceConfig', + function ($http, $compile, serviceConfig) { + return { + restrict: 'E', + compile: function () { + return function (scope, element, attrs) { + + var template = 'components/service/service.html'; + + if (!attrs.hostName && !!attrs.description) { + throw new Error(' "host-name" and "description" attributes must be defined'); + } + + serviceConfig.hostName = ''; + serviceConfig.hostName = attrs.hostName; + + serviceConfig.description = ''; + serviceConfig.description = attrs.description; + + $http.get(template, { cache: true }) + .success(function (data) { + var elem = $compile(data)(scope); + element.append(elem); + }); + }; + } + }; + }]); diff --git a/app/components/table/cell_service_check/cell_service_check.html b/app/components/table/cell_service_check/cell_service_check.html index 5ce7545..554b086 100644 --- a/app/components/table/cell_service_check/cell_service_check.html +++ b/app/components/table/cell_service_check/cell_service_check.html @@ -1,7 +1,7 @@
- {{entry.description}} + {{entry.description}}
{{entry.plugin_output}}
diff --git a/app/templates/service/service.js b/app/templates/service/service.js index a7b4f88..c89a510 100644 --- a/app/templates/service/service.js +++ b/app/templates/service/service.js @@ -1,13 +1,6 @@ -'use strict'; +"use strict"; -angular.module('adagios.view.service', ['adagios.live']) - - .controller('ServiceViewCtrl', ['$scope', '$routeParams', - function ($scope, $routeParams) { - if (!!$routeParams.host_name && !!$routeParams.description) { - $scope.hostName = $routeParams.host_name; - $scope.description = $routeParams.description; - } else { - throw new Error("ERROR :'host_name' and 'description' GET parameters must be set"); - } - }]); +angular.module("adagios.view.service", [ "adagios.live" ]).controller("ServiceViewCtrl", [ "$scope", "$routeParams", function($scope, $routeParams) { + if (!$routeParams.host_name || !$routeParams.description) throw new Error("ERROR :'host_name' and 'description' GET parameters must be set"); + $scope.hostName = $routeParams.host_name, $scope.description = $routeParams.description; +} ]); \ No newline at end of file