Drupal dashboard

Change-Id: Ia2e1da7f09dfda0f8b94479f5b5271af960f9250
This commit is contained in:
Frédéric Vachon 2015-05-13 16:08:01 -04:00
parent 9f483b442a
commit bc2a419f53
9 changed files with 339 additions and 7 deletions

View File

@ -16,7 +16,9 @@ angular.module('bansho', [
'bansho.view.dashboard',
'bansho.view.singleTable',
'bansho.view.host',
'bansho.view.service'
'bansho.view.service',
'bansho.view.drupalDashboard',
'bansho.view.drupal'
])
.config(['$routeProvider', function ($routeProvider) {

View File

@ -60,3 +60,4 @@
// TEMPORARY MODULES
//----------------------------------*/
@import 'temporary';
@import 'temporary/temporary';

View File

@ -0,0 +1,68 @@
.tile__main {
background: $_color_dark_beta none repeat scroll 0 0;
//border: 1px solid;
float: left;
margin: 20px;
padding: 10px;
text-align: center;
width: 400px;
}
.tile__main label {
color: #FFFFFF;
width: 100%;
}
.btn-success {
background-color: #5cb85c;
border-color: #4cae4c;
color: #fff;
}
.btn-warning {
background-color: #f0ad4e;
border-color: #eea236;
color: #fff;
}
.btn-danger {
background-color: #d9534f;
border-color: #d43f3a;
color: #fff;
}
.btn {
-moz-user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
cursor: pointer;
display: inline-block;
font-size: 14px;
font-weight: 400;
line-height: 1.42857;
margin-bottom: 0;
margin: 2px;
text-align: center;
vertical-align: middle;
white-space: nowrap;
}
.drupal-warn {
background-color: $_color_warning;
}
.drupal-ok {
background-color: $_color_ok;
}
.drupal-critical {
background-color: $_color_error;
}
.drupal__dashboard__title {
margin-bottom: 15px;
margin-left: 15px;
padding: 0 15px;
color: #FFFFFF;
}

View File

@ -249,13 +249,38 @@
]
},
"host": {
"title": "Host",
"refreshInterval": 0,
"template": "host"
"title": "Host",
"refreshInterval": 0,
"template": "host"
},
"service": {
"title": "Service",
"refreshInterval": 0,
"template": "service"
"title": "Service",
"refreshInterval": 0,
"template": "service"
},
"drupal": {
"title": "Drupal",
"refreshInterval": 0,
"template": "drupal"
},
"drupalDashboard": {
"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
}
}

View File

@ -87,6 +87,8 @@
<script src="templates/single_table/single_table.js"></script>
<script src="templates/host/host.js"></script>
<script src="templates/service/service.js"></script>
<script src="templates/drupal_dashboard/drupal_dashboard.js"></script>
<script src="templates/drupal/drupal.js"></script>
<!-- endbuild -->
</head>

View File

@ -0,0 +1,116 @@
<article ng-controller="DrupalViewCtrl">
<h1 class="drupal__dashboard__title">{{drupal_id}}</h1>
<div>
<div class="tile__main">
<h1>General informations</h1>
<table class="data-table">
<tbody>
<tr>
<td>Core version :</td>
<td>7.37</td>
</tr>
<tr>
<td>Core up-to-date :</td>
<td>YES</td>
</tr>
<tr class="btn-success">
<td>Vulnerable core :</td>
<td>NO</td>
</tr>
<tr>
<td>JQuery version:</td>
<td>2.1.4</td>
</tr>
<tr>
<td>Database :</td>
<td>MySQL</td>
</tr>
<tr>
<td>Database version :</td>
<td>5.6.23</td>
</tr>
<tr>
<td>Database state :</td>
<td>OK</td>
</tr>
<tr>
<td>Cache activated :</td>
<td>YES</td>
</tr>
</tbody>
</table>
</div>
<div class="tile__main">
<h1>Database <span class="btn-success">100%</span></h1>
<table class="data-table">
<tbody>
<tr>
<td>Total size</td>
<td>35.54 Mb</td>
</tr>
<tr>
<td>Collations</td>
<td>Every tables are using UTF-8</td>
</tr>
<tr>
<td>Storage Engines</td>
<td>All tables are using innoDB</td>
</tr>
<tr>
<td>Tables over 1000 rows</td>
<td>20</td>
</tr>
</tbody>
</table>
</div>
<div class="tile__main">
<h1>Cache <span class="btn-danger">17%</span></h1>
<table class="data-table">
<tbody>
<tr class="btn-danger">
<td>Anonymous caching</td>
<td>Not enabled</td>
</tr>
<tr>
<td>Minimum cache lifetime</td>
<td>None</td>
</tr>
<tr class="btn-danger">
<td>Expiration of cached pages</td>
<td>Not set</td>
</tr>
<tr class="btn-danger">
<td>Aggregate and compress CSS</td>
<td>Not enabled</td>
</tr>
<tr class="btn-danger">
<td>Aggregate Javascript</td>
<td>Not enabled</td>
</tr>
</tbody>
</table>
</div>
<div class="tile__main">
<h1>Cron jobs <span class="btn-success">100%</span></h1>
<table class="data-table">
<tbody>
<tr>
<td>Crontab status</td>
<td>Enabled</td>
</tr>
<tr>
<td>Running</td>
<td>No</td>
</tr>
<tr>
<td>Last run</td>
<td>24 min 51 sec ago</td>
</tr>
</tbody>
</table>
</div>
</div>
</article>

View File

@ -0,0 +1,12 @@
"use strict";
angular.module("bansho.view.drupal", [])
.controller("DrupalViewCtrl", ["$scope", "$routeParams",
function ($scope, $routeParams) {
if (!!$routeParams.id) {
$scope.drupal_id = $routeParams.id;
} else {
throw new Error("ERROR: 'id' GET parameter required");
}
}]);

View File

@ -0,0 +1,40 @@
<article ng-controller="DrupalDashboardViewCtrl">
<h1 class="drupal__dashboard__title">Drupal dashboard</h1>
<span ng-repeat="host in data">
<a href="#/view?view=drupal&id=Drupal">
<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>
</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>

View File

@ -0,0 +1,66 @@
"use strict";
angular.module("bansho.view.drupalDashboard", [])
.controller("DrupalDashboardViewCtrl", ["$scope", "$routeParams", 'surveilStatus', 'configManager',
function ($scope, $routeParams, surveilStatus, configManager) {
var out_data = [],
config = configManager.readConfig()[$routeParams.view],
hostsMap = config.hostsMap,
servicesMap = config.servicesMap,
hideStatusOk = config.hideStatusOk,
filters = {},
hosts = [];
angular.forEach(hostsMap, function (host_text, host_name) {
hosts.push(host_name);
});
filters = {'is': {'host_name': hosts}};
surveilStatus.getObjects([], filters, 'services').success(function (services) {
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 = '';
}
}
$scope.data = out_data;
});
}]);