wikijs-fork/controllers/admin.js

41 lines
875 B
JavaScript
Raw Normal View History

2016-08-17 03:56:08 +00:00
"use strict";
var express = require('express');
var router = express.Router();
2016-11-21 01:09:50 +00:00
const Promise = require('bluebird');
2016-08-17 03:56:08 +00:00
/**
* Admin
*/
router.get('/', (req, res) => {
2016-11-02 03:02:11 +00:00
res.redirect('/admin/profile');
});
router.get('/profile', (req, res) => {
2016-11-21 01:09:50 +00:00
res.render('pages/admin/profile', { adminTab: 'profile' });
});
router.get('/stats', (req, res) => {
Promise.all([
db.Entry.count(),
db.UplFile.count(),
db.User.count()
]).spread((totalEntries, totalUploads, totalUsers) => {
return res.render('pages/admin/stats', {
totalEntries, totalUploads, totalUsers,
adminTab: 'stats'
}) || true;
}).catch((err) => {
throw err;
});
});
router.get('/users', (req, res) => {
res.render('pages/admin/users', { adminTab: 'users' });
});
router.get('/settings', (req, res) => {
res.render('pages/admin/settings', { adminTab: 'settings' });
2016-08-17 03:56:08 +00:00
});
module.exports = router;