Adapt to new live API

Change-Id: I59a1027a60f7d40c1a6db34e3b2c5588ed608540
This commit is contained in:
aviau 2015-05-11 17:07:51 -04:00
parent 8be28e0fa5
commit 990f60c8cd
8 changed files with 61 additions and 50 deletions

View File

@ -18,7 +18,7 @@
{
"type": "table",
"config": {
"title": "Hosts",
"title": "Open Hosts problems",
"cells": {
"text": [
"Host",
@ -36,9 +36,16 @@
]
},
"apiName": "hosts",
"additionnalQueryFields": {
"acknowledged": 0,
"state": 1
"filters": {
"is": {
"acknowledged": [
false
],
"state": [
"DOWN",
"UNREACHABLE"
]
}
},
"isWrappable": false,
"noRepeatCell": ""
@ -47,7 +54,7 @@
{
"type": "table",
"config": {
"title": "Service problems",
"title": "Open Service problems",
"cells": {
"text": [
"Host",
@ -66,16 +73,19 @@
"filters": {
"isnot": {
"state": [
0
"OK"
],
"host_state": [
2
"DOWN",
"UNREACHABLE"
]
},
"is": {
"acknowledged": [
false
]
}
},
"additionnalQueryFields": {
"acknowledged": 0
},
"isWrappable": true,
"noRepeatCell": "host"
}
@ -83,7 +93,7 @@
{
"type": "table",
"config": {
"title": "Hosts",
"title": "Hosts problems",
"cells": {
"text": [
"Host",
@ -104,7 +114,7 @@
"filters": {
"isnot": {
"state": [
0
"UP"
]
}
},
@ -115,7 +125,7 @@
{
"type": "table",
"config": {
"title": "Service problems",
"title": "Services problems",
"cells": {
"text": [
"Host",
@ -134,7 +144,7 @@
"filters": {
"isnot": {
"state": [
0
"OK"
]
}
},

View File

@ -40,7 +40,7 @@ angular.module('bansho.live', [])
}
if (fields.length > 0) {
query.fields = JSON.stringify(fields);
query.fields = fields;
}
query.filters = JSON.stringify(filters);
@ -58,8 +58,13 @@ angular.module('bansho.live', [])
var getService = function (hostName, description) {
var fields = [],
filters = {},
additionnalFields = {'host_name': hostName, 'description': description};
filters = {
'is': {
'host_name': [hostName],
'description': [description]
}
},
additionnalFields = {};
return this.getObjects(fields, filters, 'services', additionnalFields)
.error(function () {
@ -69,9 +74,14 @@ angular.module('bansho.live', [])
var getHostOpenProblems = function () {
var fields = ['state'],
filters = {},
filters = {
'is': {
'state': ['DOWN', 'UNREACHABLE'],
'acknowledged': [false]
}
},
apiName = 'hosts',
additionnalFields = {'acknowledged': 0, 'state': 1};
additionnalFields = {};
return getObjects(fields, filters, apiName, additionnalFields)
.error(function () {
@ -81,10 +91,17 @@ angular.module('bansho.live', [])
var getServiceOpenProblems = function () {
var serviceFields = ['host_name', 'state'],
serviceFilters = {'isnot': {'state': [0]}},
serviceAdditionnalFields = {'acknowledged': 0},
serviceFilters = {
'isnot': {
'state': ['OK']
},
'is': {
'acknowledged': [false]
}
},
serviceAdditionnalFields = {},
hostFields = ['host_name', 'state'],
hostFilters = {'isnot': {'state': [2]}},
hostFilters = {'isnot': {'state': ['DOWN', 'UNREACHABLE']}},
hostAdditionnalFields = {},
responsePromise = $q.defer();
@ -115,7 +132,7 @@ angular.module('bansho.live', [])
var getHostProblems = function () {
var fields = ['state'],
filters = {'isnot': {'state': [0]}},
filters = {'isnot': {'state': ['UP']}},
apiName = 'hosts',
additionnalFields = {};
@ -128,7 +145,7 @@ angular.module('bansho.live', [])
// This service is used to count the number of service problems
var getServiceProblems = function () {
var fields = ['state'],
filters = {'isnot': {'state': [0]}},
filters = {'isnot': {'state': ['OK']}},
apiName = 'services',
additionnalFields = {};

View File

@ -2,6 +2,7 @@
<ul>
<li>{{data.0.host_name}}</li>
<li>{{data.0.description}}</li>
<li>{{data.0.state}}</li>
<li>{{data.0.plugin_output}}</li>
<li>{{data.0.backend}}</li>
<li>{{data.0.status}}</li>

View File

@ -5,9 +5,9 @@ angular.module('bansho.table.cell_host', ['bansho.table'])
.controller('CellHostCtrl', ['$scope', function ($scope) {
$scope.cell_name = 'host';
if ($scope.entry.host_state === 0) {
if ($scope.entry.host_state === 'UP') {
$scope.state = 'state--ok';
} else if ($scope.entry.host_state === 1) {
} else if ($scope.entry.host_state === 'WARNING') {
$scope.state = 'state--warning';
} else if ($scope.entry.host_state === '') {
$scope.state = '';

View File

@ -1,3 +1,3 @@
<td class="{{alert_level}}" ng-controller="CellHostStatusCtrl">
<span class="data-table__data">{{entry.host_status}}</span>
<td ng-controller="CellHostStatusCtrl">
<span class="data-table__data">{{entry.host_state}}</span>
</td>

View File

@ -3,24 +3,7 @@
angular.module('bansho.table.cell_host_status', ['bansho.table'])
.controller('CellHostStatusCtrl', ['$scope', function ($scope) {
$scope.entry.host_status = "";
$scope.alert_level = "";
if ($scope.entry.last_check === 0) {
$scope.alert_level = "alert alert-info";
$scope.entry.host_status = "Pending";
} else if ($scope.entry.host_state === 0) {
$scope.alert_level = "alert alert-success";
$scope.entry.host_status = "Host UP";
} else {
$scope.alert_level = "alert alert-danger";
if ($scope.entry.parents.length === 0) {
$scope.entry.host_status = "Host down";
} else {
$scope.entry.host_status = "Network outage";
}
}
angular.noop();
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {

View File

@ -1,7 +1,7 @@
<td class="data-table__service {{state}}" ng-controller="CellServiceCheckCtrl">
<dl class="data-table__data">
<dt class="data-table__service__name">
<a href="#/view?view=service&host_name={{entry.host_name}}&description={{entry.description}}">{{entry.description}}</a>
<a href="#/view?view=service&host_name={{entry.host_name}}&description={{entry.service_description}}">{{entry.service_description}}</a>
</dt>
<dd class="data-table__service__summary">{{entry.plugin_output}}</dd>
</dl>

View File

@ -3,9 +3,9 @@
angular.module('bansho.table.cell_service_check', ['bansho.table'])
.controller('CellServiceCheckCtrl', ['$scope', function ($scope) {
if ($scope.entry.state === 0) {
if ($scope.entry.state === 'OK') {
$scope.state = 'state--ok';
} else if ($scope.entry.state === 1) {
} else if ($scope.entry.state === 'WARNING') {
$scope.state = 'state--warning';
} else {
$scope.state = 'state--error';
@ -13,5 +13,5 @@ angular.module('bansho.table.cell_service_check', ['bansho.table'])
}])
.run(['tableGlobalConfig', function (tableGlobalConfig) {
tableGlobalConfig.cellToFieldsMap.service_check = ['state', 'description', 'plugin_output'];
tableGlobalConfig.cellToFieldsMap.service_check = ['state', 'service_description', 'plugin_output'];
}]);