Added service filter engine
This commit is contained in:
parent
998d30e72f
commit
c68d470f5d
@ -2,12 +2,30 @@
|
||||
|
||||
angular.module('adagios.live')
|
||||
|
||||
.factory('GetServices', ['$http', function ($http, columns) {
|
||||
.constant('searchFields', { host_name: 'host_name__contains',
|
||||
description: 'description__contains',
|
||||
plugin_output: 'plugin_output__contains',
|
||||
host_address: 'host_address__contains' })
|
||||
|
||||
return function (columns) {
|
||||
return $http.get('/rest/status/json/services/?fields=' + columns)
|
||||
.error(function (data, status, headers, config) {
|
||||
console.error('GetServices : GET Request failed');
|
||||
});
|
||||
};
|
||||
}]);
|
||||
.factory('GetServices', ['$http', 'searchFields',
|
||||
function ($http, searchFields, columns, filters) {
|
||||
return function (columns, filters) {
|
||||
var filtersQuery = '';
|
||||
|
||||
function createQuery(filters) {
|
||||
angular.forEach(filters, function (value, key) {
|
||||
console.log(key);
|
||||
console.log(searchFields[key]);
|
||||
filtersQuery += '&' + searchFields[key] + '=';
|
||||
filtersQuery += value;
|
||||
});
|
||||
}
|
||||
|
||||
createQuery(filters);
|
||||
|
||||
return $http.get('/rest/status/json/services/?fields=' + columns + filtersQuery)
|
||||
.error(function (data, status, headers, config) {
|
||||
console.error('GetServices : GET Request failed');
|
||||
});
|
||||
};
|
||||
}]);
|
||||
|
@ -6,25 +6,26 @@ angular.module('adagios.table', ['ngRoute',
|
||||
|
||||
.controller('TableCtrl', ['$scope', 'GetServices', function ($scope, GetServices) {
|
||||
|
||||
var requestFields = [];
|
||||
var requestFields = [],
|
||||
filters = { host_name: 'srv', plugin_output: 'SWAP'};
|
||||
|
||||
$scope.cells = ['host', 'service_check', 'duration', 'last_check'];
|
||||
|
||||
// The module directory name must be cell_ + key
|
||||
$scope.cellToFieldsMap = {
|
||||
host: [ 'host_state', 'host_name' ],
|
||||
service_check: ['state', 'description', 'plugin_output' ],
|
||||
service_check: ['state', 'description', 'plugin_output'],
|
||||
duration: ['last_state_change'],
|
||||
last_check: ['last_check']
|
||||
};
|
||||
|
||||
$scope.cells = ['host', 'service_check', 'duration', 'last_check'];
|
||||
|
||||
angular.forEach($scope.cells, function (key, value) {
|
||||
angular.forEach($scope.cellToFieldsMap[key], function (_value) {
|
||||
requestFields.push(_value);
|
||||
});
|
||||
});
|
||||
|
||||
new GetServices(requestFields)
|
||||
new GetServices(requestFields,)
|
||||
.success(function (data) {
|
||||
$scope.entries = data;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user