mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
style changes
This commit is contained in:
@@ -7,76 +7,79 @@ var db = require('../../database');
|
||||
var meta = require('../../meta');
|
||||
var plugins = require('../../plugins');
|
||||
|
||||
var dashboardController = {};
|
||||
|
||||
var dashboardController = module.exports;
|
||||
|
||||
dashboardController.get = function (req, res, next) {
|
||||
async.parallel({
|
||||
stats: function (next) {
|
||||
getStats(next);
|
||||
},
|
||||
notices: function (next) {
|
||||
var notices = [
|
||||
{
|
||||
done: !meta.reloadRequired,
|
||||
doneText: '[[admin/general/dashboard:restart-not-required]]',
|
||||
notDoneText: '[[admin/general/dashboard:restart-required]]',
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
stats: function (next) {
|
||||
getStats(next);
|
||||
},
|
||||
{
|
||||
done: plugins.hasListeners('filter:search.query'),
|
||||
doneText: '[[admin/general/dashboard:search-plugin-installed]]',
|
||||
notDoneText: '[[admin/general/dashboard:search-plugin-not-installed]]',
|
||||
tooltip: '[[admin/general/dashboard:search-plugin-tooltip]]',
|
||||
link: '/admin/extend/plugins',
|
||||
notices: function (next) {
|
||||
var notices = [
|
||||
{
|
||||
done: !meta.reloadRequired,
|
||||
doneText: '[[admin/general/dashboard:restart-not-required]]',
|
||||
notDoneText: '[[admin/general/dashboard:restart-required]]',
|
||||
},
|
||||
{
|
||||
done: plugins.hasListeners('filter:search.query'),
|
||||
doneText: '[[admin/general/dashboard:search-plugin-installed]]',
|
||||
notDoneText: '[[admin/general/dashboard:search-plugin-not-installed]]',
|
||||
tooltip: '[[admin/general/dashboard:search-plugin-tooltip]]',
|
||||
link: '/admin/extend/plugins',
|
||||
},
|
||||
];
|
||||
|
||||
if (global.env !== 'production') {
|
||||
notices.push({
|
||||
done: false,
|
||||
notDoneText: '[[admin/general/dashboard:running-in-development]]',
|
||||
});
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:admin.notices', notices, next);
|
||||
},
|
||||
];
|
||||
|
||||
if (global.env !== 'production') {
|
||||
notices.push({
|
||||
done: false,
|
||||
notDoneText: '[[admin/general/dashboard:running-in-development]]',
|
||||
});
|
||||
}
|
||||
|
||||
plugins.fireHook('filter:admin.notices', notices, next);
|
||||
}, next);
|
||||
},
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
res.render('admin/general/dashboard', {
|
||||
version: nconf.get('version'),
|
||||
notices: results.notices,
|
||||
stats: results.stats,
|
||||
});
|
||||
});
|
||||
function (results) {
|
||||
res.render('admin/general/dashboard', {
|
||||
version: nconf.get('version'),
|
||||
notices: results.notices,
|
||||
stats: results.stats,
|
||||
});
|
||||
},
|
||||
], next);
|
||||
};
|
||||
|
||||
function getStats(callback) {
|
||||
async.parallel([
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
getStatsForSet('ip:recent', 'uniqueIPCount', next);
|
||||
async.parallel([
|
||||
function (next) {
|
||||
getStatsForSet('ip:recent', 'uniqueIPCount', next);
|
||||
},
|
||||
function (next) {
|
||||
getStatsForSet('users:joindate', 'userCount', next);
|
||||
},
|
||||
function (next) {
|
||||
getStatsForSet('posts:pid', 'postCount', next);
|
||||
},
|
||||
function (next) {
|
||||
getStatsForSet('topics:tid', 'topicCount', next);
|
||||
},
|
||||
], next);
|
||||
},
|
||||
function (next) {
|
||||
getStatsForSet('users:joindate', 'userCount', next);
|
||||
},
|
||||
function (next) {
|
||||
getStatsForSet('posts:pid', 'postCount', next);
|
||||
},
|
||||
function (next) {
|
||||
getStatsForSet('topics:tid', 'topicCount', next);
|
||||
},
|
||||
], function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
results[0].name = '[[admin/general/dashboard:unique-visitors]]';
|
||||
results[1].name = '[[admin/general/dashboard:users]]';
|
||||
results[2].name = '[[admin/general/dashboard:posts]]';
|
||||
results[3].name = '[[admin/general/dashboard:topics]]';
|
||||
function (results, next) {
|
||||
results[0].name = '[[admin/general/dashboard:unique-visitors]]';
|
||||
results[1].name = '[[admin/general/dashboard:users]]';
|
||||
results[2].name = '[[admin/general/dashboard:posts]]';
|
||||
results[3].name = '[[admin/general/dashboard:topics]]';
|
||||
|
||||
callback(null, results);
|
||||
});
|
||||
next(null, results);
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
|
||||
function getStatsForSet(set, field, callback) {
|
||||
@@ -108,5 +111,3 @@ function getGlobalField(field, callback) {
|
||||
callback(err, parseInt(count, 10) || 0);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = dashboardController;
|
||||
|
||||
Reference in New Issue
Block a user