Added Hosts view

This commit is contained in:
Frédéric Vachon 2015-02-05 16:22:59 -05:00
parent b05de63ea8
commit 0244f80edd
12 changed files with 99 additions and 3 deletions

View File

@ -6,6 +6,7 @@ angular.element(document).ready(function () {
angular.module('adagios.config').config(['readConfigProvider', function (readConfigProvider) {
readConfigProvider.setDashboardConfig(data.dashboardConfig);
readConfigProvider.setHostsConfig(data.hostsConfig);
}]);
angular.bootstrap(document, ['adagios']);
@ -20,7 +21,8 @@ angular.module('adagios', [
'adagios.tactical',
'adagios.table',
'adagios.filters',
'adagios.config'
'adagios.config',
'adagios.view.hosts'
])
.config(['$routeProvider', function ($routeProvider) {

View File

@ -2,5 +2,9 @@
"dashboardConfig": {
"cells": ["host", "service_check", "duration", "last_check"],
"apiName": "services"
},
"hostsConfig": {
"cells": ["hosts_host", "host_address", "duration", "last_check", "host_status"],
"apiName": "hosts"
}
}

View File

@ -0,0 +1 @@
<div ng-controller="CellHostAddressCtrl">{{entry.address}}</div>

View File

@ -0,0 +1,11 @@
'use strict';
angular.module('adagios.table.cell_host_address', ['adagios.table'])
.controller('CellHostAddressCtrl', ['$scope', function ($scope) {
angular.noop();
}])
.run(['tableConfig', function (tableConfig) {
tableConfig.cellToFieldsMap.host_address = ['host_address'];
}]);

View File

@ -0,0 +1 @@
<div class="{{alert_level}}" ng-controller="CellHostStatusCtrl">{{entry.host_status}}</div>

View File

@ -0,0 +1,28 @@
'use strict';
angular.module('adagios.table.cell_host_status', ['adagios.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.state === 0) {
$scope.alert_level = "alert alert-success";
$scope.entry.host_status = "Host UP";
} else {
$scope.alert_level = "alert alert-danger";
if ($scope.entry.childs.length !== 0) {
$scope.entry.host_status = "Network outage";
} else {
$scope.entry.host_status = "Host down";
}
}
}])
.run(['tableConfig', function (tableConfig) {
tableConfig.cellToFieldsMap.host_status = ['state', 'last_check', 'childs'];
}]);

View File

@ -0,0 +1 @@
<div ng-controller="CellHostsHostCtrl">{{entry.name}}</div>

View File

@ -0,0 +1,11 @@
'use strict';
angular.module('adagios.table.cell_hosts_host', ['adagios.table'])
.controller('CellHostsHostCtrl', ['$scope', function ($scope) {
angular.noop();
}])
.run(['tableConfig', function (tableConfig) {
tableConfig.cellToFieldsMap.hosts_host = ['name'];
}]);

View File

@ -4,7 +4,10 @@ angular.module('adagios.table', ['adagios.live',
'adagios.table.cell_host',
'adagios.table.cell_duration',
'adagios.table.cell_service_check',
'adagios.table.cell_last_check'
'adagios.table.cell_last_check',
'adagios.table.cell_hosts_host',
'adagios.table.cell_host_address',
'adagios.table.cell_host_status'
])
.value('tableConfig', { cells: [],
@ -17,7 +20,6 @@ angular.module('adagios.table', ['adagios.live',
filters = {};
$scope.cells = tableConfig.cells;
angular.forEach($scope.cells, function (key, value) {
angular.forEach(tableConfig.cellToFieldsMap[key], function (_value) {
requestFields.push(_value);

7
app/hosts/hosts.html Normal file
View File

@ -0,0 +1,7 @@
<div ng-controller="HostsCtrl" id="tactical" class="">
<h2>Hosts</h2>
<adg-table cells="{{hostsCells}}" api-name="{{hostsApiName}}"></adg-table>
</div>

24
app/hosts/hosts.js Normal file
View File

@ -0,0 +1,24 @@
'use strict';
angular.module('adagios.view.hosts', ['ngRoute',
'adagios.table'
])
.value('hostsConfig', {})
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.when('/hosts', {
templateUrl: 'hosts/hosts.html',
controller: 'HostsCtrl'
});
}])
.controller('HostsCtrl', ['$scope', 'hostsConfig', function ($scope, hostsConfig) {
$scope.hostsCells = hostsConfig.cells.join();
$scope.hostsApiName = hostsConfig.apiName;
}])
.run(['readConfig', 'hostsConfig', function (readConfig, hostsConfig) {
hostsConfig.cells = readConfig.hostsConfig.cells;
hostsConfig.apiName = readConfig.hostsConfig.apiName;
}]);

View File

@ -44,12 +44,16 @@
<script src="components/table/cell_host/cell_host.js"></script>
<script src="components/table/cell_last_check/cell_last_check.js"></script>
<script src="components/table/cell_service_check/cell_service_check.js"></script>
<script src="components/table/cell_hosts_host/cell_hosts_host.js"></script>
<script src="components/table/cell_host_address/cell_host_address.js"></script>
<script src="components/table/cell_host_status/cell_host_status.js"></script>
<script src="bower_components/html5-boilerplate/js/vendor/modernizr-2.6.2.min.js"></script>
<script src="bower_components/moment/moment.js"></script>
<!-- VIEWS -->
<script src="dashboard/dashboard.js"></script>
<script src="hosts/hosts.js"></script>
</head>
<body class="layout color-scheme--dark">