Drupal dashboard
Change-Id: Ib33878960646aae789062980c8b6fdebeaafb98c
This commit is contained in:
parent
2f7b56e588
commit
07bb737512
@ -270,20 +270,8 @@
|
||||
"title": "Drupal dashboard",
|
||||
"refreshInterval": 0,
|
||||
"template": "drupal_dashboard",
|
||||
"servicesMap": {
|
||||
"drupal_cache": "Drupal cache",
|
||||
"drupal_codebase": "Drupal codebase",
|
||||
"drupal_cron": "Drupal cron",
|
||||
"drupal_database": "Drupal Database",
|
||||
"drupal_extensions": "Drupal Extensions",
|
||||
"drupal_logging": "Drupal logging",
|
||||
"drupal_security": "Drupal security",
|
||||
"drupal_status": "Drupal status",
|
||||
"drupal_views": "Drupal views"
|
||||
},
|
||||
"hostsMap": {
|
||||
"drupal": "Wonderful Drupal Website"
|
||||
},
|
||||
"hideStatusOk": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,29 @@
|
||||
<article ng-controller="DrupalDashboardViewCtrl">
|
||||
<h1 class="drupal__dashboard__title">Drupal dashboard</h1>
|
||||
<h1 class="drupal__dashboard__title">{{title}}</h1>
|
||||
|
||||
<span ng-repeat="host in data">
|
||||
<a href="#/view?view=drupal&id=Drupal">
|
||||
<span ng-repeat="(host_name, host_obj) in data">
|
||||
<a href="#/view?view=drupal&id={{host_name}}">
|
||||
<div class="tile__main">
|
||||
<h3>{{host.host_text}}</h3>
|
||||
<label ng-repeat="service in data[0].services"
|
||||
ng-hide="{{service.hide}}"
|
||||
class="btn {{service.state}}">{{service.description}}
|
||||
</label>
|
||||
<h3>{{host_obj.host_name}}</h3>
|
||||
<table class="data-table">
|
||||
<tr>
|
||||
<td style="text-align:center;">Address</td>
|
||||
<td style="text-align:center;">{{host_obj.address}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:center;">Core version</td>
|
||||
<td style="text-align:center;">{{host_obj.core_version}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align:center;">PHP version</td>
|
||||
<td style="text-align:center;">{{host_obj.php_version}}</td>
|
||||
</tr>
|
||||
<tr ng-class="host_obj.security_class">
|
||||
<td style="text-align:center;">Security updates</td>
|
||||
<td style="text-align:center;">{{host_obj.security}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<a href="#/view?view=drupal&id=Drupal">
|
||||
<div class="tile__main">
|
||||
<h3>Site B</h3>
|
||||
<label class="btn btn-success">Bandwith Ok</label>
|
||||
<label class="btn btn-warning">Cache Warning</label>
|
||||
<label class="btn btn-danger">Security update Critical</label>
|
||||
</div>
|
||||
</a>
|
||||
<a href="#/view?view=drupal&id=Drupal">
|
||||
<div class="tile__main">
|
||||
<h3>Site C</h3>
|
||||
<label class="btn btn-success">Bandwith Ok</label>
|
||||
<label class="btn btn-warning">Cache Warning</label>
|
||||
<label class="btn btn-danger">Security update Critical</label>
|
||||
</div>
|
||||
</a>
|
||||
<a href="#/view?view=drupal&id=Drupal">
|
||||
<div class="tile__main">
|
||||
<h3>Site D</h3>
|
||||
<label class="btn btn-success">Bandwith Ok</label>
|
||||
<label class="btn btn-warning">Cache Warning</label>
|
||||
<label class="btn btn-danger">Security update Critical</label>
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
|
@ -4,63 +4,57 @@ angular.module("bansho.view.drupalDashboard", [])
|
||||
|
||||
.controller("DrupalDashboardViewCtrl", ["$scope", "$routeParams", 'surveilStatus', 'configManager',
|
||||
function ($scope, $routeParams, surveilStatus, configManager) {
|
||||
var out_data = [],
|
||||
config = configManager.readConfig()[$routeParams.view],
|
||||
var config = configManager.readConfig()[$routeParams.view],
|
||||
hostsMap = config.hostsMap,
|
||||
servicesMap = config.servicesMap,
|
||||
hideStatusOk = config.hideStatusOk,
|
||||
filters = {},
|
||||
filters_host, filters_service,
|
||||
hosts = [];
|
||||
|
||||
$scope.title = config.title;
|
||||
angular.forEach(hostsMap, function (host_text, host_name) {
|
||||
hosts.push(host_name);
|
||||
});
|
||||
|
||||
filters = {'is': {'host_name': hosts}};
|
||||
filters_host = {'is': {'host_name': hosts}};
|
||||
filters_service = {'is': {'host_name': hosts,
|
||||
'service_description': ['drupal_status']}};
|
||||
|
||||
surveilStatus.getObjects([], filters, 'services').success(function (services) {
|
||||
surveilStatus.getObjects([], filters_host, 'hosts').success(function (host_objects) {
|
||||
var out_dict = {};
|
||||
|
||||
for (var i = 0; i < services.length; i++) {
|
||||
var index,
|
||||
service = services[i],
|
||||
service_out = {};
|
||||
|
||||
// Look if host_name already in the array
|
||||
for (var j = 0; j < out_data.length; j++) {
|
||||
if (service.host_name === out_data[j].host_name) {
|
||||
index = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index === undefined) {
|
||||
out_data.push({'host_name': service.host_name});
|
||||
index = out_data.length - 1;
|
||||
out_data[index].host_text = hostsMap[service.host_name];
|
||||
}
|
||||
|
||||
if (!('services' in out_data[index])) {
|
||||
out_data[index].services = [];
|
||||
}
|
||||
|
||||
out_data[index].services.push({});
|
||||
service_out = out_data[index].services[out_data[index].services.length - 1];
|
||||
service_out.description = servicesMap[service.service_description];
|
||||
|
||||
if (service.state === 'CRITICAL') {
|
||||
service_out.state = 'btn-danger';
|
||||
} else if (service.state === 'WARNING') {
|
||||
service_out.state = 'btn-warning';
|
||||
} else if (service.state === 'OK') {
|
||||
if (hideStatusOk) {
|
||||
service_out.hide = true;
|
||||
}
|
||||
service_out.state = 'btn-success';
|
||||
} else {
|
||||
service_out.state = '';
|
||||
}
|
||||
for (var i = 0; i < host_objects.length; i++) {
|
||||
var obj = {};
|
||||
obj.address = host_objects[i].address;
|
||||
obj.host_name = hostsMap[host_objects[i].host_name];
|
||||
out_dict[host_objects[i].host_name] = obj;
|
||||
}
|
||||
|
||||
$scope.data = out_data;
|
||||
|
||||
surveilStatus.getObjects([], filters_service, 'services').success(function (status) {
|
||||
for (var i = 0; i < status.length; i++) {
|
||||
var stat = status[i],
|
||||
obj = out_dict[stat.host_name],
|
||||
long_out;
|
||||
|
||||
if (stat.plugin_output.indexOf('SECURITY UPDATE available') !== -1) {
|
||||
obj.security = 'Available';
|
||||
obj.security_class = 'btn-danger';
|
||||
} else {
|
||||
obj.security = 'None';
|
||||
}
|
||||
|
||||
long_out = stat.long_output.split('\n');
|
||||
|
||||
for (var j = 0; j < long_out.length; j++) {
|
||||
if (long_out[j].indexOf('Drupal Core version') !== -1) {
|
||||
obj.core_version = long_out[j].split(';')[1];
|
||||
} else if (long_out[j].indexOf('PHP version') !== -1) {
|
||||
obj.php_version = long_out[j].split(';')[1];
|
||||
}
|
||||
}
|
||||
|
||||
out_dict[stat.host_name] = obj;
|
||||
}
|
||||
$scope.data = out_dict;
|
||||
});
|
||||
});
|
||||
}]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user