Surveil back-end: getServiceOpenProblems implemented
This commit is contained in:
parent
fb6d5eed96
commit
f4261e117b
@ -86,20 +86,40 @@ angular.module('adagios.live')
|
||||
}])
|
||||
|
||||
// This service is used to count the number of service open problems
|
||||
.service('getServiceOpenProblems', ['$http', 'getObjects',
|
||||
function ($http, getObjects) {
|
||||
.service('getServiceOpenProblems', ['$http', '$q', 'getObjects',
|
||||
function ($http, $q, getObjects) {
|
||||
return function () {
|
||||
var serviceFields = ['host_name', 'state'],
|
||||
serviceFilters = { 'isnot': { 'state': [0] } },
|
||||
serviceAdditionnalFields = { 'acknowledged': 0 },
|
||||
hostFields = ['host_name', 'state'],
|
||||
hostFilters = { 'isnot': { 'state': [2] } },
|
||||
hostAdditionnalFields = {};
|
||||
hostAdditionnalFields = {},
|
||||
responsePromise = $q.defer();
|
||||
|
||||
return getObjects(fields, filters, apiName, additionnalFields)
|
||||
.error(function () {
|
||||
throw new Error('getServiceOpenProblems : POST Request failed');
|
||||
getObjects(hostFields, hostFilters, 'hosts', hostAdditionnalFields)
|
||||
.success(function (hostData) {
|
||||
var hostsResult = {},
|
||||
i;
|
||||
|
||||
// Creates a host dictionnary for performance
|
||||
for (i = 0; i < hostData.length; i += 1) {
|
||||
hostsResult[hostData[i].host_name] = '';
|
||||
}
|
||||
|
||||
getObjects(serviceFields, serviceFilters, 'services', serviceAdditionnalFields)
|
||||
.success(function (serviceData) {
|
||||
var result = [];
|
||||
for (i = 0; i < serviceData.length; i += 1) {
|
||||
if (serviceData[i].host_name in hostsResult) {
|
||||
result.push(serviceData[i]);
|
||||
}
|
||||
}
|
||||
responsePromise.resolve(result);
|
||||
});
|
||||
});
|
||||
|
||||
return responsePromise.promise;
|
||||
};
|
||||
}])
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<table ng-controller="TacticalCurrentHealth"
|
||||
class="current-health"
|
||||
ng-if="hostsRatio != 0 && servicesRatio != 0">
|
||||
ng-if="hostsRatio != undefined && servicesRatio != undefined">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Current health</th>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<table ng-controller="TacticalStatusOverViewCtrl"
|
||||
class="table"
|
||||
ng-if="hostProblems != 0 && totalHosts != 0 && serviceProblems != 0 && totalServices != 0">
|
||||
ng-if="hostProblems != undefined && totalHosts != undefined && serviceProblems != undefined && totalServices != undefined">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Status overview</th>
|
||||
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('adagios.tactical.status_overview', ['ngRoute' ])
|
||||
angular.module('adagios.tactical.status_overview', [])
|
||||
|
||||
.controller('TacticalStatusOverViewCtrl', ['$scope', function ($scope) {
|
||||
angular.noop();
|
||||
|
@ -27,26 +27,26 @@ angular.module('adagios.tactical', ['adagios.live',
|
||||
$scope.currentHealth = tacticalConfig.currentHealth;
|
||||
$scope.topAlertProducers = tacticalConfig.topAlertProducers;
|
||||
|
||||
$scope.hostsRatio = 0;
|
||||
$scope.servicesRatio = 0;
|
||||
$scope.hostProblems = 0;
|
||||
$scope.totalHosts = 0;
|
||||
$scope.serviceProblems = 0;
|
||||
$scope.totalServices = 0;
|
||||
$scope.hostsRatio = undefined;
|
||||
$scope.servicesRatio = undefined;
|
||||
$scope.hostProblems = undefined;
|
||||
$scope.totalHosts = undefined;
|
||||
$scope.serviceProblems = undefined;
|
||||
$scope.totalServices = undefined;
|
||||
|
||||
getData = function () {
|
||||
getHostProblems().success(function (data) {
|
||||
$scope.hostProblems = data.length;
|
||||
getTotalHosts().success(function (data) {
|
||||
$scope.totalHosts = data.length;
|
||||
getHostProblems().success(function (hostProblems) {
|
||||
$scope.hostProblems = hostProblems.length;
|
||||
getTotalHosts().success(function (allHosts) {
|
||||
$scope.totalHosts = allHosts.length;
|
||||
$scope.hostsRatio = ($scope.totalHosts - $scope.hostProblems) / $scope.totalHosts * 100;
|
||||
});
|
||||
});
|
||||
|
||||
getServiceProblems().success(function (data) {
|
||||
$scope.serviceProblems = data.length;
|
||||
getTotalServices().success(function (data) {
|
||||
$scope.totalServices = data.length;
|
||||
getServiceProblems().success(function (serviceProblems) {
|
||||
$scope.serviceProblems = serviceProblems.length;
|
||||
getTotalServices().success(function (allServices) {
|
||||
$scope.totalServices = allServices.length;
|
||||
$scope.servicesRatio = ($scope.totalServices - $scope.serviceProblems) / $scope.totalServices * 100;
|
||||
});
|
||||
});
|
||||
|
@ -44,8 +44,8 @@ angular.module('adagios.view.dashboard', ['ngRoute',
|
||||
getData = function () {
|
||||
getHostOpenProblems().success(function (data) {
|
||||
$scope.nbHostOpenProblems = data.length;
|
||||
getServiceOpenProblems().success(function (data) {
|
||||
$scope.nbServiceOpenProblems = data.length;
|
||||
getServiceOpenProblems().then(function (openProblems) {
|
||||
$scope.nbServiceOpenProblems = openProblems.length;
|
||||
$scope.totalOpenProblems = $scope.nbServiceOpenProblems + $scope.nbHostOpenProblems;
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user