Service view uses adg-service

This commit is contained in:
Frédéric Vachon 2015-03-30 17:10:23 -04:00
parent f3eb0fa831
commit fff43cd26f
8 changed files with 84 additions and 17 deletions

View File

@ -115,10 +115,12 @@ module.exports = function (grunt) {
'<%= project.app %>/components/host/host_load/host_load.js', '<%= project.app %>/components/host/host_load/host_load.js',
'<%= project.app %>/components/host/host_main/host_main.js', '<%= project.app %>/components/host/host_main/host_main.js',
'<%= project.app %>/components/host/host_services_list/host_services_list.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 %>/routing_view/routing_view.js',
'<%= project.app %>/templates/dashboard/dashboard.js', '<%= project.app %>/templates/dashboard/dashboard.js',
'<%= project.app %>/templates/single_table/single_table.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: { 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_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_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/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 %>/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/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/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' : [ '<%= 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_load/host_load.js',
'<%= project.build %>/components/host/host_main/host_main.js', '<%= project.build %>/components/host/host_main/host_main.js',
'<%= project.build %>/components/host/host_services_list/host_services_list.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 %>/routing_view/routing_view.js',
'<%= project.build %>/templates/dashboard/dashboard.js', '<%= project.build %>/templates/dashboard/dashboard.js',
'<%= project.build %>/templates/single_table/single_table.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'
] ]
} }
], ],

View File

@ -19,10 +19,12 @@ angular.module('adagios', [
'adagios.topbar', 'adagios.topbar',
'adagios.sidebar', 'adagios.sidebar',
'adagios.host', 'adagios.host',
'adagios.service',
'adagios.view', 'adagios.view',
'adagios.view.dashboard', 'adagios.view.dashboard',
'adagios.view.singleTable', 'adagios.view.singleTable',
'adagios.view.host' 'adagios.view.host',
'adagios.view.service'
]) ])
.config(['$routeProvider', function ($routeProvider) { .config(['$routeProvider', function ($routeProvider) {

View File

@ -210,5 +210,10 @@
"title": "Host", "title": "Host",
"refreshInterval": 0, "refreshInterval": 0,
"template": "host" "template": "host"
},
"service": {
"title": "Service",
"refreshInterval": 0,
"template": "service"
} }
} }

View File

@ -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 // This service is used to count the number of host open problems
.service('getHostOpenProblems', ['$http', 'getObjects', .service('getHostOpenProblems', ['$http', 'getObjects',
function ($http, getObjects) { function ($http, getObjects) {

View File

@ -0,0 +1,5 @@
<article ng-controller="ServiceCtrl">
<section class="main__content tabpanel">
<h2>{{data}}</h2>
</section>
</article>

View File

@ -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('<adg-service> "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);
});
};
}
};
}]);

View File

@ -1,7 +1,7 @@
<td class="data-table__service {{state}}" ng-controller="CellServiceCheckCtrl"> <td class="data-table__service {{state}}" ng-controller="CellServiceCheckCtrl">
<dl class="data-table__data"> <dl class="data-table__data">
<dt class="data-table__service__name"> <dt class="data-table__service__name">
<a href="#/object_view?object_type=service&host_name={{entry.host_name}}&description={{entry.description}}">{{entry.description}}</a> <a href="#/view?view=service&host_name={{entry.host_name}}&description={{entry.description}}">{{entry.description}}</a>
</dt> </dt>
<dd class="data-table__service__summary">{{entry.plugin_output}}</dd> <dd class="data-table__service__summary">{{entry.plugin_output}}</dd>
</dl> </dl>

View File

@ -1,13 +1,6 @@
'use strict'; "use strict";
angular.module('adagios.view.service', ['adagios.live']) 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");
.controller('ServiceViewCtrl', ['$scope', '$routeParams', $scope.hostName = $routeParams.host_name, $scope.description = $routeParams.description;
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");
}
}]);