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.

56 lines
1.6 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, clientAddress, templateContext)
  15. {
  16. return new Promise(function(resolve, reject)
  17. {
  18. //if logged in
  19. if(request.session && request.session.user)
  20. {
  21. templateContext.loggedIn = true;
  22. utils.getPostData(request).then(function (postData)
  23. {
  24. resolve();
  25. // console.log(postData);
  26. // Promise.all([require("./posts/newPost.js").main(postData),
  27. // require("./category/addCategory.js").main(postData),
  28. // require("./posts/editPost.js").main(postData),
  29. // require("./downloads/manageDownloads.js").main(postData)])
  30. // .then(function(content)
  31. // {
  32. // resolve(content.join(''));
  33. // }).catch(function(error)
  34. // {
  35. // reject(error);
  36. // });
  37. });
  38. }
  39. else
  40. {
  41. require("./login/login.js").main(request, clientAddress, templateContext).then(function()
  42. {
  43. resolve();
  44. }).catch(function(err)
  45. {
  46. console.log(err);
  47. reject(err);
  48. })
  49. }
  50. });
  51. }
  52. };