From 94b88729c311eabfc52cf680c148bc4701dce815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Vachon?= Date: Tue, 24 Mar 2015 13:47:02 -0400 Subject: [PATCH] Number of problems display real data --- app/components/live/get_services.js | 58 ++++++++++++++++++++++++++++- app/dashboard/dashboard.html | 21 ++++++++--- app/dashboard/dashboard.js | 32 ++++++++++------ 3 files changed, 94 insertions(+), 17 deletions(-) diff --git a/app/components/live/get_services.js b/app/components/live/get_services.js index 4d1e6cc..2a1558c 100644 --- a/app/components/live/get_services.js +++ b/app/components/live/get_services.js @@ -12,7 +12,7 @@ angular.module('adagios.live') regex: '__regex' }) - .factory('getServices', ['$http', 'filterSuffixes', + .service('getServices', ['$http', 'filterSuffixes', function ($http, filterSuffixes) { return function (columns, filters, apiName, additionnalFields) { var filtersQuery = '', @@ -51,4 +51,60 @@ angular.module('adagios.live') throw new Error('getServices : GET Request failed'); }); }; + }]) + + // This service is used to count the number of host open problems + .service('getHostOpenProblems', ['$http', 'getServices', + function ($http, getServices) { + var fields = ['state'], + filters = {}, + apiName = 'hosts', + additionnalQueryFields = {'acknowledged': 0, 'state': 1}; + + return getServices(fields, filters, apiName, additionnalQueryFields) + .error(function () { + throw new Error('getServices : GET Request failed'); + }); + }]) + + // This service is used to count the number of service open problems + .service('getServiceOpenProblems', ['$http', 'getServices', + function ($http, getServices) { + var fields = ['state'], + filters = { "isnot": { "state": [ "0" ], "host_state": [ "2" ] }}, + apiName = 'services', + additionnalQueryFields = {'acknowledged': 0}; + + return getServices(fields, filters, apiName, additionnalQueryFields) + .error(function () { + throw new Error('getServices : GET Request failed'); + }); + }]) + + // This service is used to count the number of host problems + .service('getHostProblems', ['$http', 'getServices', + function ($http, getServices) { + var fields = ['state'], + filters = { 'isnot': {'state': [0]} }, + apiName = 'hosts', + additionnalQueryFields = {}; + + return getServices(fields, filters, apiName, additionnalQueryFields) + .error(function () { + throw new Error('getServices : GET Request failed'); + }); + }]) + + // This service is used to count the number of service problems + .service('getServiceProblems', ['$http', 'getServices', + function ($http, getServices) { + var fields = ['state'], + filters = { 'isnot': {'state': [0]} }, + apiName = 'services', + additionnalQueryFields = {}; + + return getServices(fields, filters, apiName, additionnalQueryFields) + .error(function () { + throw new Error('getServices : GET Request failed'); + }); }]); diff --git a/app/dashboard/dashboard.html b/app/dashboard/dashboard.html index 6ad534d..4db0a83 100644 --- a/app/dashboard/dashboard.html +++ b/app/dashboard/dashboard.html @@ -40,7 +40,10 @@

{{dashboardTables[0].title}}

-

There are {{nbHostProblems}} host problems.

+

+ There are {{nbHostOpenProblems}} host + +

{{dashboardTables[1].title}}

-

There are {{nbHostProblems}} host problems.

+

+ There are {{nbServiceOpenProblems}} host + +

{{dashboardTables[2].title}}

-

There are {{nbHostProblems}} host problems.

+

+ There are {{nbHostProblems}} host + +

{{dashboardTables[3].title}}

-

There are {{nbHostProblems}} host problems.

+

+ There are {{nbServiceProblems}} service + +

-

Pas de tableaux encore pour All problems.

diff --git a/app/dashboard/dashboard.js b/app/dashboard/dashboard.js index eae2367..000712b 100644 --- a/app/dashboard/dashboard.js +++ b/app/dashboard/dashboard.js @@ -15,13 +15,12 @@ angular.module('adagios.view.dashboard', ['ngRoute', }); }]) - .controller('DashboardCtrl', ['$scope', '$routeParams', 'dashboardConfig', 'getServices', 'tableConfig', 'TableConfigObj', 'TacticalConfigObj', - function ($scope, $routeParams, dashboardConfig, getServices, tableConfig, TableConfigObj, TacticalConfigObj) { - - var fields = ['state'], - filters = {'isnot' : { 'state' : ['0'] }}, - apiName = 'hosts', - components = [], + .controller('DashboardCtrl', ['$scope', '$routeParams', 'dashboardConfig', 'getServices', 'tableConfig', + 'TableConfigObj', 'TacticalConfigObj', 'getHostOpenProblems', 'getServiceOpenProblems', 'getHostProblems', + 'getServiceProblems', + function ($scope, $routeParams, dashboardConfig, getServices, tableConfig, TableConfigObj, + TacticalConfigObj, getHostOpenProblems, getServiceOpenProblems, getHostProblems, getServiceProblems) { + var components = [], component, config, viewName, @@ -55,10 +54,21 @@ angular.module('adagios.view.dashboard', ['ngRoute', } } - getServices(fields, filters, apiName) - .success(function (data) { - $scope.nbHostProblems = data.length; - }); + getHostOpenProblems.success(function (data) { + $scope.nbHostOpenProblems = data.length; + }); + + getServiceOpenProblems.success(function (data) { + $scope.nbServiceOpenProblems = data.length; + }); + + getHostProblems.success(function (data) { + $scope.nbHostProblems = data.length; + }); + + getServiceProblems.success(function (data) { + $scope.nbServiceProblems = data.length; + }); }]) .run(['readConfig', 'dashboardConfig', function (readConfig, dashboardConfig) {