From e30ecec170593aa90ccc45d567c52c05e16447c4 Mon Sep 17 00:00:00 2001 From: jrtechs Date: Mon, 4 Mar 2019 21:44:10 -0500 Subject: [PATCH] Updated downloads page to work with routes. --- admin/adminDownloads.js | 7 ++++--- routes/admin/downloads.js | 10 ++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/admin/adminDownloads.js b/admin/adminDownloads.js index 717a43d..e96583f 100644 --- a/admin/adminDownloads.js +++ b/admin/adminDownloads.js @@ -116,7 +116,8 @@ module.exports= Promise.all([includes.fetchTemplate(TEMPLATE_FILE), displayDownloads(templateContext)]).then(function(template) { - resolve(template[0]); + templateContext.adminPage = template[0]; + resolve(); }).catch(function(error) { console.log("error in add downloads.js"); @@ -125,7 +126,7 @@ module.exports= }); }, - processPostData: function(postData, templateContext) + processPostData: function(postData) { return new Promise(function(resolve, reject) { @@ -135,7 +136,7 @@ module.exports= resolve(); }).catch(function(error) { - console.log(error); + console.log("Error in admin downloads"); reject(error); }) }) diff --git a/routes/admin/downloads.js b/routes/admin/downloads.js index 5c68232..73ad62b 100644 --- a/routes/admin/downloads.js +++ b/routes/admin/downloads.js @@ -1,8 +1,18 @@ const routes = require('express').Router(); +const utils = require('../../utils/utils.js'); + routes.get('/', (request, result) => { + utils.constructAdminPage(request, result, require("../../admin/adminDownloads").main) +}); +routes.post('/', (request, result) => +{ + utils.adminPostRoute(request ,require("../../admin/adminDownloads").processPostData).then(function() + { + result.redirect('/admin/downloads'); + }) }); module.exports = routes; \ No newline at end of file