Number of problems display real data

This commit is contained in:
Frédéric Vachon 2015-03-24 13:47:02 -04:00
parent dd0db2a0dc
commit 94b88729c3
3 changed files with 94 additions and 17 deletions

View File

@ -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');
});
}]);

View File

@ -40,7 +40,10 @@
<div role="tabpanel" class="problems tab-pane active" id="openProblems">
<header class="main__content__header clearfix">
<h2 class="main__content__title">{{dashboardTables[0].title}}</h2>
<p class="main__content__alert state--error">There are {{nbHostProblems}} host problems.</p>
<p class="main__content__alert state--error">
There are {{nbHostOpenProblems}} host
<ng-pluralize count="nbHostOpenProblems" when="{'0':'problem', '1': 'problem', 'other': 'problems'}"/>
</p>
</header>
<adg-table cells-text="{{dashboardTables[0].CellsText}}"
@ -55,7 +58,10 @@
<header class="main__content__header clearfix">
<h2 class="main__content__title">{{dashboardTables[1].title}}</h2>
<p class="main__content__alert state--error">There are {{nbHostProblems}} host problems.</p>
<p class="main__content__alert state--error">
There are {{nbServiceOpenProblems}} host
<ng-pluralize count="nbServiceOpenProblems" when="{'0':'problem', '1': 'problem', 'other': 'problems'}"/>
</p>
</header>
<adg-table cells-text="{{dashboardTables[1].CellsText}}"
@ -73,7 +79,10 @@
<div role="tabpanel" class="problems tab-pane" id="allProblems">
<header class="main__content__header clearfix">
<h2 class="main__content__title">{{dashboardTables[2].title}}</h2>
<p class="main__content__alert state--error">There are {{nbHostProblems}} host problems.</p>
<p class="main__content__alert state--error">
There are {{nbHostProblems}} host
<ng-pluralize count="nbHostProblems" when="{'0':'problem', '1': 'problem', 'other': 'problems'}"/>
</p>
</header>
<adg-table cells-text="{{dashboardTables[2].CellsText}}"
@ -87,7 +96,10 @@
<header class="main__content__header clearfix">
<h2 class="main__content__title">{{dashboardTables[3].title}}</h2>
<p class="main__content__alert state--error">There are {{nbHostProblems}} host problems.</p>
<p class="main__content__alert state--error">
There are {{nbServiceProblems}} service
<ng-pluralize count="nbServiceProblems" when="{'0':'problem', '1': 'problem', 'other': 'problems'}"/>
</p>
</header>
<adg-table cells-text="{{dashboardTables[3].CellsText}}"
@ -98,7 +110,6 @@
no-repeat-cell="{{dashboardTables[3].NoRepeatCell}}"
refresh-interval="{{dashboardRefreshInterval}}"
table-id="3"></adg-table>
<p>Pas de tableaux encore pour All problems.</p>
</div>
</div>

View File

@ -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) {