Drupal detailed view

Change-Id: I5a5d93247dc5b9210f4ca7e4eafeb41f1239fac2
This commit is contained in:
Frédéric Vachon 2015-05-29 16:26:53 -04:00
parent 98bf716699
commit e0f1606a5a
8 changed files with 270 additions and 125 deletions

View File

@ -12,6 +12,8 @@ angular.module('bansho', [
'bansho.surveil', 'bansho.surveil',
'bansho.host', 'bansho.host',
'bansho.service', 'bansho.service',
'bansho.drupal',
'bansho.drupal.tile',
'bansho.view', 'bansho.view',
'bansho.view.dashboard', 'bansho.view.dashboard',
'bansho.view.singleTable', 'bansho.view.singleTable',
@ -27,11 +29,11 @@ angular.module('bansho', [
}]) }])
// Reinitialise objects on url change // Reinitialise objects on url change
.run(['$rootScope', 'promisesManager', 'reinitTables', 'themeManager', .run(['$rootScope', 'promisesManager', 'reinitTables', 'reinitDrupalTiles',
function ($rootScope, promisesManager, reinitTables, themeManager) { function ($rootScope, promisesManager, reinitTables, reinitDrupalTiles) {
themeManager.setTheme();
$rootScope.$on('$locationChangeStart', function () { $rootScope.$on('$locationChangeStart', function () {
reinitTables(); reinitTables();
reinitDrupalTiles();
promisesManager.clearAllPromises(); promisesManager.clearAllPromises();
}); });
}]); }]);

View File

@ -13,6 +13,22 @@
width: 100%; width: 100%;
} }
.tile__score-critical {
background-color: #d9534f;
border-color: #d43f3a;
border-radius: 5px;
color: #fff;
padding: 5px;
}
.tile__score-warning {
background-color: #f0ad4e;
border-color: #eea236;
color: #fff;
border-radius: 5px;
padding: 5px;
}
.btn-success { .btn-success {
background-color: #5cb85c; background-color: #5cb85c;
border-color: #4cae4c; border-color: #4cae4c;
@ -45,7 +61,6 @@
margin: 2px; margin: 2px;
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
white-space: nowrap;
} }
.drupal-warn { .drupal-warn {

View File

@ -0,0 +1,97 @@
<article ng-controller="DrupalCtrl">
<h1 class="drupal__dashboard__title">{{drupal_id}}</h1>
<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>
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_cache"
title="Cache"
warning="70"
critical="40"></bansho-drupal-tile>
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_cron"
title="Cron"
warning="70"
critical="40"></bansho-drupal-tile>
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_database"
title="Database"
warning="70"
critical="40"></bansho-drupal-tile>
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_codebase"
title="Codebase"
warning="70"
critical="40"></bansho-drupal-tile>
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_extensions"
title="Extensions"
warning="70"
critical="40"></bansho-drupal-tile>
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_logging"
title="Logging"
warning="70"
critical="40"></bansho-drupal-tile>
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_security"
title="Security"
warning="70"
critical="40"></bansho-drupal-tile>
<!--
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_status"
title="Status"
warning="70"
critical="40"></bansho-drupal-tile>
<bansho-drupal-tile host-name="{{hostName}}"
plugin="drupal_views"
title="Views"
warning="70"
critical="40"></bansho-drupal-tile>
-->
</article>

View File

@ -0,0 +1,35 @@
'use strict';
angular.module('bansho.drupal', ['bansho.surveil'])
.value('drupalConfig', {})
.controller('DrupalCtrl', ['$scope', 'drupalConfig', 'surveilStatus',
function ($scope, drupalConfig, surveilStatus) {
$scope.hostName = drupalConfig.hostName;
}])
.directive('banshoDrupal', ['$http', '$compile', 'surveilStatus', 'drupalConfig',
function ($http, $compile, surveilStatus, drupalConfig) {
return {
restrict: 'E',
compile: function () {
return function (scope, element, attrs) {
var template = 'components/drupal/drupal.html';
if (!attrs.hostName) {
throw new Error('<bansho-drupal> "host-name" attribute must be defined');
}
drupalConfig.hostName = {};
drupalConfig.hostName = attrs.hostName;
$http.get(template, { cache: true })
.success(function (data) {
var elem = $compile(data)(scope);
element.append(elem);
});
};
}
};
}]);

View File

@ -0,0 +1,10 @@
<div class="tile__main" ng-controller='DrupalTileCtrl'>
<h1>{{title}} <span ng-class="finalScoreClass">{{finalScore}}</span></h1>
<table class="data-table">
<tbody>
<tr ng-repeat="datum in data">
<td style="text-align:center;" ng-class="datum[1]" title="{{datum[2]}}">{{datum[0]}}</td>
</tr>
</tbody>
</table>
</div>

View File

@ -0,0 +1,99 @@
'use strict';
angular.module('bansho.drupal.tile', [])
.value('DrupalTileConfig', {'nextIndex': 0, 'tileConf': []})
.controller('DrupalTileCtrl', ['$scope', 'surveilStatus', 'DrupalTileConfig',
function ($scope, surveilStatus, DrupalTileConfig) {
var fields = [],
apiName = 'services',
filters = {},
currentIndex = DrupalTileConfig.nextIndex,
tileConfig = DrupalTileConfig.tileConf[currentIndex];
$scope.plugin = tileConfig.plugin;
$scope.title = tileConfig.title;
$scope.hostName = tileConfig.hostName;
filters = {'is': {'host_name': [$scope.hostName],
'service_description': [$scope.plugin]}};
surveilStatus.getObjects(fields, filters, apiName)
.success(function (response) {
var finalScore = response[0].plugin_output.split(' ')[1],
out = [],
data = response[0].long_output.split(';').slice(0, -1);
finalScore = parseInt(finalScore.substring(0, finalScore.length - 4));
$scope.finalScore = isNaN(finalScore) ? '': finalScore + '%';
if (finalScore <= tileConfig.critical) {
$scope.finalScoreClass = 'tile__score-critical';
} else if (finalScore <= tileConfig.warning) {
$scope.finalScoreClass = 'tile__score-warning';
}
// Split data into (metric, score_class, action) tuples
for (var i = 0; i < data.length; i+=3) {
var tuple = [];
tuple.push(data[i]);
var score = parseInt(data[i+1].trim(), 10);
if (score === 1) {
tuple.push('btn-warning');
} else if (score === 0) {
tuple.push('btn-danger');
} else {
tuple.push('');
}
tuple.push(data[i+2]);
out.push(tuple);
}
$scope.data = out;
});
DrupalTileConfig.nextIndex++;
}])
.directive('banshoDrupalTile', ['$http', '$compile', 'DrupalTileConfig',
function ($http, $compile, DrupalTileConfig) {
return {
restrict: 'E',
compile: function () {
return function (scope, element, attrs) {
var template = 'components/drupal/drupal_tile/drupal_tile.html',
currentIndex = DrupalTileConfig.nextIndex,
tileConfig = {};
if (!attrs.hostName || !attrs.plugin || !attrs.warning || !attrs.critical) {
throw new Error('<bansho-drupal-tile> "host-name", ' +
'"plugin", "warning" and "critical" ' +
'attributes must be defined');
}
tileConfig.hostName = attrs.hostName;
tileConfig.plugin = attrs.plugin;
tileConfig.title = attrs.title;
tileConfig.warning = parseInt(attrs.warning, 10);
tileConfig.critical = parseInt(attrs.critical, 10);
DrupalTileConfig.tileConf.push(tileConfig);
$http.get(template, { cache: true })
.success(function (data) {
var elem = $compile(data)(scope);
element.append(elem);
});
};
}
};
}])
.service('reinitDrupalTiles', ['DrupalTileConfig',
function (DrupalTileConfig) {
return function () {
// Reinitialise tile index
DrupalTileConfig.nextIndex = 0;
};
}]);

View File

@ -83,6 +83,8 @@
<script src="components/service/service_live/service_live.js"></script> <script src="components/service/service_live/service_live.js"></script>
<script src="components/service/service_info/service_info.js"></script> <script src="components/service/service_info/service_info.js"></script>
<script src="components/service/service_metrics/service_metrics.js"></script> <script src="components/service/service_metrics/service_metrics.js"></script>
<script src="components/drupal/drupal.js"></script>
<script src="components/drupal/drupal_tile/drupal_tile.js"></script>
<script src="routing_view/routing_view.js"></script> <script src="routing_view/routing_view.js"></script>
<script src="templates/dashboard/dashboard.js"></script> <script src="templates/dashboard/dashboard.js"></script>
<script src="templates/single_table/single_table.js"></script> <script src="templates/single_table/single_table.js"></script>

View File

@ -1,116 +1 @@
<article ng-controller="DrupalViewCtrl"> <bansho-drupal ng-controller="DrupalViewCtrl" host-name="{{drupal_id}}"></bansho-drupal>
<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>