diff --git a/admin/analytics.js b/admin/analytics.js index 3877d51..727f3e7 100644 --- a/admin/analytics.js +++ b/admin/analytics.js @@ -50,17 +50,17 @@ module.exports= * Fetches context information for the admin blog page and handles post * data sent regarding editing blog. * - * @param postData posted by user * @param templateContext json object used as the template context * @returns {Promise} renders the template used for this page */ - main: function(postData, templateContext) + main: function(templateContext) { return new Promise(function(resolve, reject) { Promise.all([includes.fetchTemplate(TEMPLATE_FILE), generateData(templateContext)]).then(function(template) { - resolve(template[0]); + templateContext.adminPage = template[0]; + resolve(); }).catch(function(error) { console.log("error in add admin blog.js"); diff --git a/admin/users.js b/admin/users.js index 74fecde..72b6139 100644 --- a/admin/users.js +++ b/admin/users.js @@ -154,17 +154,15 @@ module.exports= * @param templateContext json object used as the template context * @returns {Promise} renders the template used for this page */ - main: function(postData, templateContext) + main: function(templateContext) { return new Promise(function(resolve, reject) { Promise.all([includes.fetchTemplate(TEMPLATE_FILE), - addUserPostData(postData), - removeUserPost(postData), - editUserPost(postData, templateContext), getUserInformation(templateContext)]).then(function(template) { - resolve(template[0]); + templateContext.adminPage = template[0]; + resolve(); }).catch(function(error) { console.log("error in users.js"); @@ -173,7 +171,7 @@ module.exports= }); }, - processPostData: function(postData, templateContext) + processPostData: function(templateContext, postData) { return new Promise(function(resolve, reject) { @@ -183,7 +181,8 @@ module.exports= editUserPost(postData, templateContext), getUserInformation(templateContext)]).then(function(template) { - resolve(template[0]); + templateContext.adminPage = template[0]; + resolve(); }).catch(function(error) { console.log("error in users.js"); diff --git a/routes/admin/analytics.js b/routes/admin/analytics.js index 5c68232..14b0e06 100644 --- a/routes/admin/analytics.js +++ b/routes/admin/analytics.js @@ -1,8 +1,10 @@ const routes = require('express').Router(); +const utils = require('../../utils/utils.js'); + routes.get('/', (request, result) => { - + utils.constructAdminPage(request, result, require("../../admin/analytics").main) }); module.exports = routes; \ No newline at end of file diff --git a/routes/admin/users.js b/routes/admin/users.js index 5c68232..b9048ec 100644 --- a/routes/admin/users.js +++ b/routes/admin/users.js @@ -1,8 +1,15 @@ const routes = require('express').Router(); +const utils = require('../../utils/utils.js'); + routes.get('/', (request, result) => { + utils.constructAdminPage(request, result, require("../../admin/users").main) +}); +routes.post('/', (request, result) => +{ + utils.adminPostPageWithOutput(request, result ,require("../../admin/users").processPostData) }); module.exports = routes; \ No newline at end of file diff --git a/utils/utils.js b/utils/utils.js index 07c3efb..ed982e6 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -192,6 +192,7 @@ module.exports= }); }, + adminPostRoute: function(request, templateFiller) { return new Promise(function(resolve, reject) @@ -207,7 +208,6 @@ module.exports= reject(e); }) }) - },