Browse Source

Updated analytics and users page to work with routes.

pull/61/head
jrtechs 5 years ago
parent
commit
44c9a28403
5 changed files with 20 additions and 12 deletions
  1. +3
    -3
      admin/analytics.js
  2. +6
    -7
      admin/users.js
  3. +3
    -1
      routes/admin/analytics.js
  4. +7
    -0
      routes/admin/users.js
  5. +1
    -1
      utils/utils.js

+ 3
- 3
admin/analytics.js View File

@ -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");

+ 6
- 7
admin/users.js View File

@ -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");

+ 3
- 1
routes/admin/analytics.js View File

@ -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;

+ 7
- 0
routes/admin/users.js View File

@ -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;

+ 1
- 1
utils/utils.js View File

@ -192,6 +192,7 @@ module.exports=
});
},
adminPostRoute: function(request, templateFiller)
{
return new Promise(function(resolve, reject)
@ -207,7 +208,6 @@ module.exports=
reject(e);
})
})
},

Loading…
Cancel
Save