You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
875 B

8 years ago
  1. "use strict";
  2. var express = require('express');
  3. var router = express.Router();
  4. const Promise = require('bluebird');
  5. /**
  6. * Admin
  7. */
  8. router.get('/', (req, res) => {
  9. res.redirect('/admin/profile');
  10. });
  11. router.get('/profile', (req, res) => {
  12. res.render('pages/admin/profile', { adminTab: 'profile' });
  13. });
  14. router.get('/stats', (req, res) => {
  15. Promise.all([
  16. db.Entry.count(),
  17. db.UplFile.count(),
  18. db.User.count()
  19. ]).spread((totalEntries, totalUploads, totalUsers) => {
  20. return res.render('pages/admin/stats', {
  21. totalEntries, totalUploads, totalUsers,
  22. adminTab: 'stats'
  23. }) || true;
  24. }).catch((err) => {
  25. throw err;
  26. });
  27. });
  28. router.get('/users', (req, res) => {
  29. res.render('pages/admin/users', { adminTab: 'users' });
  30. });
  31. router.get('/settings', (req, res) => {
  32. res.render('pages/admin/settings', { adminTab: 'settings' });
  33. });
  34. module.exports = router;