From ffe31c6af96a411b0a9f88b5adb912f6bf6fa35c Mon Sep 17 00:00:00 2001 From: flifloo Date: Mon, 17 Aug 2020 13:22:52 +0200 Subject: [PATCH] Add admin to routes --- app.js | 2 ++ public/stylesheets/style.css | 12 +++++++++--- routes/admin.js | 11 +++++++++++ views/admin.pug | 24 ++++++++++++++++++++++++ views/index.pug | 4 ++-- 5 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 routes/admin.js create mode 100644 views/admin.pug diff --git a/app.js b/app.js index 8b78032..4946f2f 100644 --- a/app.js +++ b/app.js @@ -11,6 +11,7 @@ let logoutRouter = require("./routes/logout"); let commandRouter = require("./routes/command"); let ordersRouter = require("./routes/orders"); let sandwichesRouter = require("./routes/sandwiches"); +let adminRouter = require("./routes/admin"); let app = express(); let sess = { @@ -40,6 +41,7 @@ app.use("/logout", logoutRouter); app.use("/command", commandRouter); app.use("/orders", ordersRouter); app.use("/sandwiches", sandwichesRouter); +app.use("/admin", adminRouter); // catch 404 and forward to error handler app.use((req, res) => { diff --git a/public/stylesheets/style.css b/public/stylesheets/style.css index a8bd797..e790b26 100644 --- a/public/stylesheets/style.css +++ b/public/stylesheets/style.css @@ -27,7 +27,7 @@ body { box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2); } -h1, h2, p, label { +h1, h2, h3, p, label { display: block; text-align: center; } @@ -56,7 +56,8 @@ a { font-size: 100%; } -.field input[type="text"], .field input[type="list"], .field input[type="date"] { +.field input[type="text"], .field input[type="list"], .field input[type="date"], .field input[type="number"], +.field input[type="checkbox"] { height: 2.5vh; border-top: none; border-left: none; @@ -101,7 +102,7 @@ a { text-decoration: underline; } -#about, #contact { +.popup { position: fixed; top: 0; left: 0; @@ -159,6 +160,11 @@ p.before-link a::before { margin-left: 1em; } +.buttons { + display: flex; + justify-content: space-around; +} + @media (hover: none) and (pointer: coarse) { body { font-size: xx-large; diff --git a/routes/admin.js b/routes/admin.js new file mode 100644 index 0000000..5fff6dd --- /dev/null +++ b/routes/admin.js @@ -0,0 +1,11 @@ +let express = require("express"); +let router = express.Router(); +let sessionCheck = require("../middlewares/sessionCheck"); +let models = require("../models"); + + +router.get("/", sessionCheck(3), async (req, res) => { + res.render("admin", {title: "SOD", sandwiches: await models.Sandwich.findAll(), users: await models.User.findAll()}); +}); + +module.exports = router; diff --git a/views/admin.pug b/views/admin.pug new file mode 100644 index 0000000..93599cf --- /dev/null +++ b/views/admin.pug @@ -0,0 +1,24 @@ +extends layout + +block content + div.card + h1 Administration + div + h2 Order management + div.buttons + a(href="/admin/orders/date") + button Orders date + a(href="/admin/order") + button Manage orders + + div + h2 Sandwich management + div.buttons + a(href="/admin/sandwiches") + button Manage sandwiches + + div + h2 User management + div.buttons + a(href="/admin/users") + button Manage users diff --git a/views/index.pug b/views/index.pug index 7db53c8..d807c5c 100644 --- a/views/index.pug +++ b/views/index.pug @@ -44,7 +44,7 @@ block content a Contact div#dark.hide - div#about.card.hide + div#about.popup.card.hide h1 About p This software respond to the COVID-19 health crisis for the following students' offices food supply div.images @@ -68,7 +68,7 @@ block content p IT student office p.before-link Made with ❤️ by a(href="https://www.linkedin.com/in/florian-charlaix" target="_blank") Florian Charlaix - div#contact.card.hide + div#contact.popup.card.hide h1 Contact p.before-link Order issue: a(href="mailto: ") test@test.fr