Personal blog written from scratch using Node.js, Bootstrap, and MySQL. https://jrtechs.net
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.

50 lines
1.4 KiB

  1. /**
  2. * Renders the admin page contents
  3. */
  4. //file IO
  5. const utils = require('../utils/utils.js');
  6. module.exports=
  7. {
  8. /**
  9. * Method calls the admin widgets it correct order
  10. *
  11. * @param request
  12. * @return {*|Promise}
  13. */
  14. main: function(request)
  15. {
  16. return new Promise(function(resolve, reject)
  17. {
  18. if(request.session && request.session.user)
  19. {
  20. utils.getPostData(request).then(function (postData)
  21. {
  22. Promise.all([require("./posts/newPost.js").main(postData),
  23. require("./category/addCategory.js").main(postData),
  24. require("./posts/editPost.js").main(postData),
  25. require("./downloads/manageDownloads.js").main(postData)])
  26. .then(function(content)
  27. {
  28. resolve(content.join(''));
  29. }).catch(function(error)
  30. {
  31. reject(error);
  32. });
  33. });
  34. }
  35. else
  36. {
  37. require("./login/login.js").main(request).then(function(html)
  38. {
  39. resolve(html);
  40. }).catch(function(err)
  41. {
  42. console.log(err);
  43. reject(err);
  44. })
  45. }
  46. });
  47. }
  48. };