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.

51 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. console.log(postData);
  23. Promise.all([require("./posts/newPost.js").main(postData),
  24. require("./category/addCategory.js").main(postData),
  25. require("./posts/editPost.js").main(postData),
  26. require("./downloads/manageDownloads.js").main(postData)])
  27. .then(function(content)
  28. {
  29. resolve(content.join(''));
  30. }).catch(function(error)
  31. {
  32. reject(error);
  33. });
  34. });
  35. }
  36. else
  37. {
  38. require("./login/login.js").main(request).then(function(html)
  39. {
  40. resolve(html);
  41. }).catch(function(err)
  42. {
  43. console.log(err);
  44. reject(err);
  45. })
  46. }
  47. });
  48. }
  49. };