closes #4658
parent
458c930bb9
commit
149565169b
@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
/*global config, define, app, socket, ajaxify, bootbox, templates, Chart, utils */
|
||||
|
||||
define('admin/advanced/errors', ['Chart'], function(Chart) {
|
||||
var Errors = {};
|
||||
|
||||
Errors.init = function() {
|
||||
var notFoundCanvas = document.getElementById('not-found'),
|
||||
tooBusyCanvas = document.getElementById('toobusy'),
|
||||
dailyLabels = utils.getDaysArray();
|
||||
|
||||
dailyLabels.length = 7;
|
||||
|
||||
if (utils.isMobile()) {
|
||||
Chart.defaults.global.showTooltips = false;
|
||||
}
|
||||
|
||||
var data = {
|
||||
'not-found': {
|
||||
labels: dailyLabels,
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(186,139,175,0.2)",
|
||||
strokeColor: "rgba(186,139,175,1)",
|
||||
pointColor: "rgba(186,139,175,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(186,139,175,1)",
|
||||
data: ajaxify.data.analytics['not-found']
|
||||
}
|
||||
]
|
||||
},
|
||||
'toobusy': {
|
||||
labels: dailyLabels,
|
||||
datasets: [
|
||||
{
|
||||
label: "",
|
||||
fillColor: "rgba(151,187,205,0.2)",
|
||||
strokeColor: "rgba(151,187,205,1)",
|
||||
pointColor: "rgba(151,187,205,1)",
|
||||
pointStrokeColor: "#fff",
|
||||
pointHighlightFill: "#fff",
|
||||
pointHighlightStroke: "rgba(151,187,205,1)",
|
||||
data: ajaxify.data.analytics['toobusy']
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
notFoundCanvas.width = $(notFoundCanvas).parent().width();
|
||||
tooBusyCanvas.width = $(tooBusyCanvas).parent().width();
|
||||
new Chart(notFoundCanvas.getContext('2d')).Line(data['not-found'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
new Chart(tooBusyCanvas.getContext('2d')).Line(data['toobusy'], {
|
||||
responsive: true,
|
||||
animation: false
|
||||
});
|
||||
};
|
||||
|
||||
return Errors;
|
||||
});
|
@ -0,0 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var meta = require('../../meta'),
|
||||
analytics = require('../../analytics');
|
||||
|
||||
var errorsController = {};
|
||||
|
||||
errorsController.get = function(req, res) {
|
||||
async.parallel({
|
||||
'not-found': async.apply(meta.errors.get),
|
||||
analytics: async.apply(analytics.getErrorAnalytics)
|
||||
}, function(err, data) {
|
||||
res.render('admin/advanced/errors', data);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = errorsController;
|
@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async'),
|
||||
winston = require('winston'),
|
||||
validator = require('validator');
|
||||
|
||||
var db = require('../database'),
|
||||
analytics = require('../analytics');
|
||||
|
||||
module.exports = function(Meta) {
|
||||
|
||||
Meta.errors = {};
|
||||
|
||||
Meta.errors.log404 = function(route, callback) {
|
||||
callback = callback || function() {};
|
||||
route = route.replace(/\/$/, ''); // remove trailing slashes
|
||||
analytics.increment('errors:404');
|
||||
db.sortedSetIncrBy('errors:404', 1, route, callback);
|
||||
};
|
||||
|
||||
Meta.errors.get = function(callback) {
|
||||
db.getSortedSetRevRangeByScoreWithScores('errors:404', 0, -1, '+inf', '-inf', function(err, data) {
|
||||
data = data.map(function(nfObject) {
|
||||
nfObject.value = validator.escape(nfObject.value);
|
||||
return nfObject;
|
||||
});
|
||||
|
||||
callback(null, data);
|
||||
});
|
||||
};
|
||||
|
||||
Meta.errors.clear = function(callback) {
|
||||
console.log('clear errors');
|
||||
callback();
|
||||
};
|
||||
};
|
@ -0,0 +1,61 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-9">
|
||||
<div class="row">
|
||||
<div class="col-sm-6 text-center">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div><canvas id="not-found" height="250"></canvas></div>
|
||||
</div>
|
||||
<div class="panel-footer"><small><strong>Figure 1</strong> – <code>404 Not Found</code> events per day</small></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 text-center">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div><canvas id="toobusy" height="250"></canvas></div>
|
||||
</div>
|
||||
<div class="panel-footer"><small><strong>Figure 2</strong> – <code>503 Service Unavailable</code> events per day</small></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><i class="fa fa-exclamation-triangle"></i> 404 Not Found</div>
|
||||
<div class="panel-body">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<th>Route</th>
|
||||
<th>Count</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- BEGIN not-found -->
|
||||
<tr>
|
||||
<td>{../value}</td>
|
||||
<td>{../score}</td>
|
||||
</tr>
|
||||
<!-- END not-found -->
|
||||
<!-- IF !not-found.length -->
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<div class="alert alert-success">
|
||||
Hooray! There are no routes that were not found.
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- ENDIF !not-found.length -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 acp-sidebar">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Manage Error Log</div>
|
||||
<div class="panel-body">
|
||||
<div class="btn-group-vertical btn-block" role="group">
|
||||
<button class="btn btn-info" data-action="export"><i class="fa fa-download"></i> Export Error Log (CSV)</button>
|
||||
<button class="btn btn-danger" data-action="clear"><i class="fa fa-trash"></i> Clear Error Log</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in New Issue