diff --git a/app/components/live/surveil.js b/app/components/live/surveil.js
index 9435c5d..ad071a4 100644
--- a/app/components/live/surveil.js
+++ b/app/components/live/surveil.js
@@ -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;
};
}])
diff --git a/app/components/tactical/current_health/current_health.html b/app/components/tactical/current_health/current_health.html
index 2fa762f..6fb5267 100644
--- a/app/components/tactical/current_health/current_health.html
+++ b/app/components/tactical/current_health/current_health.html
@@ -1,6 +1,6 @@
+ ng-if="hostsRatio != undefined && servicesRatio != undefined">
Current health |
diff --git a/app/components/tactical/status_overview/status_overview.html b/app/components/tactical/status_overview/status_overview.html
index 25dc4db..28191af 100644
--- a/app/components/tactical/status_overview/status_overview.html
+++ b/app/components/tactical/status_overview/status_overview.html
@@ -1,6 +1,6 @@
+ ng-if="hostProblems != undefined && totalHosts != undefined && serviceProblems != undefined && totalServices != undefined">
Status overview |
diff --git a/app/components/tactical/status_overview/status_overview.js b/app/components/tactical/status_overview/status_overview.js
index d668181..9f7c95d 100644
--- a/app/components/tactical/status_overview/status_overview.js
+++ b/app/components/tactical/status_overview/status_overview.js
@@ -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();
diff --git a/app/components/tactical/tactical.js b/app/components/tactical/tactical.js
index 9b1184b..af3b9ed 100644
--- a/app/components/tactical/tactical.js
+++ b/app/components/tactical/tactical.js
@@ -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;
});
});
diff --git a/app/templates/dashboard/dashboard.js b/app/templates/dashboard/dashboard.js
index 6a2d975..d35c515 100644
--- a/app/templates/dashboard/dashboard.js
+++ b/app/templates/dashboard/dashboard.js
@@ -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;
});
});