Host submodules display data

This commit is contained in:
Frédéric Vachon 2015-03-27 16:37:43 -04:00
parent baffe13df6
commit dea9bd6521
10 changed files with 106 additions and 24 deletions

View File

@ -1,17 +1,9 @@
<article ng-controller="HostCtrl">
<section class="main__content tabpanel">
<h2 class="main__overview__title">{{hostName}}</h2>
<table class="data-table">
<tbody >
<tr ng-repeat="(key, value) in data.live">
<td>{{key}}</td>
<td>{{value}}</td>
</tr>
<tr ng-repeat="(key, value) in data.config">
<td>{{key}}</td>
<td>{{value}}</td>
</tr>
</tbody>
</table>
<section class="main__content tabpanel" ng-if="data.live && data.config">
<adg-host-main></adg-host-main>
<adg-host-services-list></adg-host-services-list>
<adg-host-load></adg-host-load>
<adg-host-cpu></adg-host-cpu>
<adg-host-info></adg-host-info>
</section>
</article>

View File

@ -1,6 +1,11 @@
'use strict';
angular.module('adagios.host', ['adagios.live'])
angular.module('adagios.host', ['adagios.live',
'adagios.host.main',
'adagios.host.load',
'adagios.host.cpu',
'adagios.host.info',
'adagios.host.services_list'])
.value('hostConfig', {})
@ -9,6 +14,7 @@ angular.module('adagios.host', ['adagios.live'])
objectIdentifier = {};
objectIdentifier.host_name = hostConfig.hostName;
$scope.hostName = hostConfig.hostName;
$scope.data = {};
addObjectToScope(objectType, objectIdentifier, $scope);

View File

@ -0,0 +1,7 @@
<div ng-controller="HostCpuCtrl">
<ul>
<li>{{cpuData.state}}</li>
<li>{{cpuData.description}}</li>
<li>{{cpuData.plugin_output}}</li>
</ul>
</div>

View File

@ -2,8 +2,18 @@
angular.module('adagios.host.cpu', [])
.controller('TableCtrl', ['$scope', function ($scope) {
angular.noop();
.controller('HostCpuCtrl', ['$scope', 'getObjects', function ($scope, getObjects) {
var hostName = $scope.hostName,
service = 'cpu',
fields = ['state', 'description', 'plugin_output'],
filters = {},
apiName = 'services',
additionnalFields = {'host_name': hostName, 'description': service};
getObjects(fields, filters, apiName, additionnalFields)
.success(function (data) {
$scope.cpuData = data[0];
});
}])
.directive('adgHostCpu', function () {

View File

@ -0,0 +1,34 @@
<div ng-controller="HostInfoCtrl">
<table class="data-table">
<tbody>
<tr>
<td>Last check</td>
<td>{{data.live.last_check | timeElapsed}}</td>
</tr>
<tr>
<td>Check period</td>
<td>{{data.config.check_period}}</td>
</tr>
<tr>
<td>Notification period</td>
<td>{{data.config.notification_period}}</td>
</tr>
<tr>
<td>Active checks</td>
<td>{{active_checks}}</td>
</tr>
<tr>
<td>Notifications</td>
<td>{{notifications_enabled}}</td>
</tr>
<tr>
<td>Event Handler</td>
<td>{{event_handler_enabled}}</td>
</tr>
<tr>
<td>Flag detection</td>
<td>{{flap_detection_enabled}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -1,14 +1,17 @@
'use strict';
angular.module('adagios.host.cpu', [])
angular.module('adagios.host.info', [])
.controller('HostCpuCtrl', ['$scope', function ($scope) {
angular.noop();
.controller('HostInfoCtrl', ['$scope', function ($scope) {
$scope.active_checks = ($scope.data.live.active_checks_enabled === '1') ? 'Enabled': 'Disabled';
$scope.notifications_enabled = ($scope.data.config.notifications_enabled === '1') ? 'Enabled': 'Disabled';
$scope.event_handler_enabled = ($scope.data.config.event_handler_enabled === '1') ? 'Enabled': 'Disabled';
$scope.flap_detection_enabled = ($scope.data.config.flap_detection_enabled === '1') ? 'Enabled': 'Disabled';
}])
.directive('adgHostCpu', function () {
.directive('adgHostInfo', function () {
return {
restrict: 'E',
templateUrl: 'components/host/host_cpu/host_cpu.html'
templateUrl: 'components/host/host_info/host_info.html'
};
});

View File

@ -0,0 +1,7 @@
<div ng-controller="HostLoadCtrl">
<ul>
<li>{{loadData.state}}</li>
<li>{{loadData.description}}</li>
<li>{{loadData.plugin_output}}</li>
</ul>
</div>

View File

@ -2,8 +2,18 @@
angular.module('adagios.host.load', [])
.controller('HostLoadCtrl', ['$scope', function ($scope) {
angular.noop();
.controller('HostLoadCtrl', ['$scope', 'getObjects', function ($scope, getObjects) {
var hostName = $scope.hostName,
service = 'load',
fields = ['state', 'description', 'plugin_output'],
filters = {},
apiName = 'services',
additionnalFields = {'host_name': hostName, 'description': service};
getObjects(fields, filters, apiName, additionnalFields)
.success(function (data) {
$scope.loadData = data[0];
});
}])
.directive('adgHostLoad', function () {

View File

@ -0,0 +1,8 @@
<div ng-controller="HostMainCtrl">
<ul>
<li>{{hostName}}</li>
<li>{{data.live.state}}</li>
<li>{{data.config.alias}}</li>
<li>{{data.live.plugin_output}}</li>
</ul>
</div>

View File

@ -0,0 +1,5 @@
<div>
<ul>
<li ng-repeat="service in data.live.services">{{service}}</li>
</ul>
</div>