mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
fully completed #4658
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
"html-to-text": "2.0.0",
|
||||
"ip": "1.1.2",
|
||||
"jimp": "0.2.21",
|
||||
"json-2-csv": "^2.0.22",
|
||||
"less": "^2.0.0",
|
||||
"logrotate-stream": "^0.2.3",
|
||||
"lru-cache": "4.0.0",
|
||||
@@ -49,8 +50,8 @@
|
||||
"nconf": "~0.8.2",
|
||||
"nodebb-plugin-composer-default": "3.0.31",
|
||||
"nodebb-plugin-dbsearch": "1.0.1",
|
||||
"nodebb-plugin-emoji-one": "1.1.3",
|
||||
"nodebb-plugin-emoji-extended": "1.1.0",
|
||||
"nodebb-plugin-emoji-one": "1.1.3",
|
||||
"nodebb-plugin-markdown": "5.1.5",
|
||||
"nodebb-plugin-mentions": "1.1.1",
|
||||
"nodebb-plugin-soundpack-default": "0.1.6",
|
||||
|
||||
@@ -5,6 +5,23 @@ define('admin/advanced/errors', ['Chart'], function(Chart) {
|
||||
var Errors = {};
|
||||
|
||||
Errors.init = function() {
|
||||
Errors.setupCharts();
|
||||
|
||||
$('[data-action="clear"]').on('click', Errors.clear404);
|
||||
};
|
||||
|
||||
Errors.clear404 = function() {
|
||||
bootbox.confirm('Are you sure you wish to clear the 404 error logs?', function(ok) {
|
||||
if (ok) {
|
||||
socket.emit('admin.errors.clear', {}, function(err) {
|
||||
ajaxify.refresh();
|
||||
app.alertSuccess('"404 Not Found" errors cleared');
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Errors.setupCharts = function() {
|
||||
var notFoundCanvas = document.getElementById('not-found'),
|
||||
tooBusyCanvas = document.getElementById('toobusy'),
|
||||
dailyLabels = utils.getDaysArray();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var async = require('async'),
|
||||
json2csv = require('json-2-csv').json2csv;
|
||||
|
||||
var meta = require('../../meta'),
|
||||
analytics = require('../../analytics');
|
||||
@@ -9,12 +10,21 @@ var errorsController = {};
|
||||
|
||||
errorsController.get = function(req, res) {
|
||||
async.parallel({
|
||||
'not-found': async.apply(meta.errors.get),
|
||||
'not-found': async.apply(meta.errors.get, true),
|
||||
analytics: async.apply(analytics.getErrorAnalytics)
|
||||
}, function(err, data) {
|
||||
res.render('admin/advanced/errors', data);
|
||||
});
|
||||
};
|
||||
|
||||
errorsController.export = function(req, res) {
|
||||
async.waterfall([
|
||||
async.apply(meta.errors.get, false),
|
||||
async.apply(json2csv)
|
||||
], function(err, csv) {
|
||||
res.set('Content-Type', 'text/csv').set('Content-Disposition', 'attachment; filename="404.csv"').send(csv);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = errorsController;
|
||||
@@ -18,10 +18,10 @@ module.exports = function(Meta) {
|
||||
db.sortedSetIncrBy('errors:404', 1, route, callback);
|
||||
};
|
||||
|
||||
Meta.errors.get = function(callback) {
|
||||
Meta.errors.get = function(escape, callback) {
|
||||
db.getSortedSetRevRangeByScoreWithScores('errors:404', 0, -1, '+inf', '-inf', function(err, data) {
|
||||
data = data.map(function(nfObject) {
|
||||
nfObject.value = validator.escape(nfObject.value);
|
||||
nfObject.value = escape ? validator.escape(nfObject.value) : nfObject.value;
|
||||
return nfObject;
|
||||
});
|
||||
|
||||
@@ -30,7 +30,6 @@ module.exports = function(Meta) {
|
||||
};
|
||||
|
||||
Meta.errors.clear = function(callback) {
|
||||
console.log('clear errors');
|
||||
callback();
|
||||
db.delete('errors:404', callback);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -83,6 +83,7 @@ function addRoutes(router, middleware, controllers) {
|
||||
router.get('/advanced/events', middlewares, controllers.admin.events.get);
|
||||
router.get('/advanced/logs', middlewares, controllers.admin.logs.get);
|
||||
router.get('/advanced/errors', middlewares, controllers.admin.errors.get);
|
||||
router.get('/advanced/errors/export', middlewares, controllers.admin.errors.export);
|
||||
router.get('/advanced/post-cache', middlewares, controllers.admin.postCache.get);
|
||||
|
||||
router.get('/development/logger', middlewares, controllers.admin.logger.get);
|
||||
|
||||
@@ -33,7 +33,8 @@ var async = require('async'),
|
||||
settings: {},
|
||||
email: {},
|
||||
analytics: {},
|
||||
logs: {}
|
||||
logs: {},
|
||||
errors: {}
|
||||
};
|
||||
|
||||
SocketAdmin.before = function(socket, method, data, next) {
|
||||
@@ -255,6 +256,11 @@ SocketAdmin.logs.clear = function(socket, data, callback) {
|
||||
meta.logs.clear(callback);
|
||||
};
|
||||
|
||||
SocketAdmin.errors.clear = function(socket, data, callback) {
|
||||
console.log('clearing errors?');
|
||||
meta.errors.clear(callback);
|
||||
};
|
||||
|
||||
SocketAdmin.getMoreEvents = function(socket, next, callback) {
|
||||
var start = parseInt(next, 10);
|
||||
if (start < 0) {
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
<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>
|
||||
<a class="btn btn-info" target="_top" href="{config.relative_path}/admin/advanced/errors/export"><i class="fa fa-download"></i> Export Error Log (CSV)</a>
|
||||
<button class="btn btn-danger" data-action="clear"><i class="fa fa-trash"></i> Clear Error Log</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user