From 49d11776dc2b96cf93e04d15c11a02f880fa8941 Mon Sep 17 00:00:00 2001 From: HumairAK Date: Thu, 21 Jul 2016 21:57:36 -0400 Subject: made further changes to admin panel and index.js --- app.js | 2 +- assets/css/style.css | 12 +++- node_simple.js | 2 +- routes/index.js | 18 +++++- views/admin.hbs | 161 ++++++++++++++++++++++++++++------------------- views/layouts/layout.hbs | 2 +- 6 files changed, 126 insertions(+), 71 deletions(-) diff --git a/app.js b/app.js index 139abc8..8b469f9 100644 --- a/app.js +++ b/app.js @@ -21,7 +21,7 @@ app.engine('.hbs', hbs({extname: '.hbs', defaultLayout: 'layout', partialsDir: __dirname + '/views/partials'})); // Set directory for partials app.set('views', path.join(__dirname, 'views')); // Our view path -app.set('view engine', '.hbs'); +app.set('view engine', 'hbs'); // Middleware initialization, make sure everything is initialized in proper order app.use(bodyParser.json()); diff --git a/assets/css/style.css b/assets/css/style.css index e81046d..b4fafb1 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -32,7 +32,6 @@ main { justify-content: center; flex-flow: column; /* Makes it grow vertically */ } - /*** INDEX.HTML ***/ main .search { background-color: rgba(235,235,235, 0.7); @@ -405,7 +404,7 @@ section.exam-info em { } /*** ABOUT PAGE END ***/ -/************************** Pop-up Window *********************************************/ +/************************** Pop-up Window ************************************/ .login-window, .registration-window { display: inline-block; @@ -424,4 +423,13 @@ section.exam-info em { .login-window .modal-header, .registration-window .modal-header { text-align: center; } +/** Form Pages for Admin **/ + +.admin-form{ + padding: 3px; + margin: 3px; + border-radius: 10px; + background-color: rgba(197, 197, 197, 0.6); + +} diff --git a/node_simple.js b/node_simple.js index 7e9c736..033beb7 100644 --- a/node_simple.js +++ b/node_simple.js @@ -746,4 +746,4 @@ exports.get_exam_byID = function (id) { } ); }); - });*/ \ No newline at end of file + });*/ diff --git a/routes/index.js b/routes/index.js index 1e3f1e0..da9ec8d 100644 --- a/routes/index.js +++ b/routes/index.js @@ -38,8 +38,8 @@ router.get('/admin', function(req,res){ res.render('admin', {csrfToken: req.csrfToken()}); }); - -router.post('/admin/update', function(req,res){ +/* Adds exam from front-end */ +router.post('/admin/update/exam', function(req,res){ var course_code = req.body.course_code, year = req.body.year, type = req.body.type, @@ -73,6 +73,20 @@ router.post('/admin/update', function(req,res){ res.redirect('/admin'); }); +/* Adds course from front-end */ +router.post('/admin/update/course', function(req,res){ + var course_code = req.body.course_code, + title = req.body.title; + dbFile.add_course(course_code, title, function(courseAdded, statusMessage){ + if(courseAdded){ + console.log("Success!"); + }else{ + console.log("Failure!"); + } + console.log("Status message: " + statusMessage) + }); + res.redirect('/admin'); +}); //EXAMPLE EXPECTED DATA GIVEN BELOW: /*[ {courseCode: 'CSC240', diff --git a/views/admin.hbs b/views/admin.hbs index ecbd46e..da33f41 100644 --- a/views/admin.hbs +++ b/views/admin.hbs @@ -1,69 +1,102 @@
-
-

Add Exam

-
-
- +
\ No newline at end of file diff --git a/views/layouts/layout.hbs b/views/layouts/layout.hbs index 667860c..62e9134 100644 --- a/views/layouts/layout.hbs +++ b/views/layouts/layout.hbs @@ -1,4 +1,4 @@ -!doctype html> + -- cgit v1.2.3