Add admin to routes
This commit is contained in:
parent
43851413ea
commit
ffe31c6af9
5 changed files with 48 additions and 5 deletions
2
app.js
2
app.js
|
@ -11,6 +11,7 @@ let logoutRouter = require("./routes/logout");
|
||||||
let commandRouter = require("./routes/command");
|
let commandRouter = require("./routes/command");
|
||||||
let ordersRouter = require("./routes/orders");
|
let ordersRouter = require("./routes/orders");
|
||||||
let sandwichesRouter = require("./routes/sandwiches");
|
let sandwichesRouter = require("./routes/sandwiches");
|
||||||
|
let adminRouter = require("./routes/admin");
|
||||||
|
|
||||||
let app = express();
|
let app = express();
|
||||||
let sess = {
|
let sess = {
|
||||||
|
@ -40,6 +41,7 @@ app.use("/logout", logoutRouter);
|
||||||
app.use("/command", commandRouter);
|
app.use("/command", commandRouter);
|
||||||
app.use("/orders", ordersRouter);
|
app.use("/orders", ordersRouter);
|
||||||
app.use("/sandwiches", sandwichesRouter);
|
app.use("/sandwiches", sandwichesRouter);
|
||||||
|
app.use("/admin", adminRouter);
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use((req, res) => {
|
app.use((req, res) => {
|
||||||
|
|
|
@ -27,7 +27,7 @@ body {
|
||||||
box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2);
|
box-shadow: 0.5em 0.5em 0.5em rgba(0, 0, 255, .2);
|
||||||
}
|
}
|
||||||
|
|
||||||
h1, h2, p, label {
|
h1, h2, h3, p, label {
|
||||||
display: block;
|
display: block;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,8 @@ a {
|
||||||
font-size: 100%;
|
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;
|
height: 2.5vh;
|
||||||
border-top: none;
|
border-top: none;
|
||||||
border-left: none;
|
border-left: none;
|
||||||
|
@ -101,7 +102,7 @@ a {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
#about, #contact {
|
.popup {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
@ -159,6 +160,11 @@ p.before-link a::before {
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
|
||||||
@media (hover: none) and (pointer: coarse) {
|
@media (hover: none) and (pointer: coarse) {
|
||||||
body {
|
body {
|
||||||
font-size: xx-large;
|
font-size: xx-large;
|
||||||
|
|
11
routes/admin.js
Normal file
11
routes/admin.js
Normal file
|
@ -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;
|
24
views/admin.pug
Normal file
24
views/admin.pug
Normal file
|
@ -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
|
|
@ -44,7 +44,7 @@ block content
|
||||||
a Contact
|
a Contact
|
||||||
|
|
||||||
div#dark.hide
|
div#dark.hide
|
||||||
div#about.card.hide
|
div#about.popup.card.hide
|
||||||
h1 About
|
h1 About
|
||||||
p This software respond to the COVID-19 health crisis for the following students' offices food supply
|
p This software respond to the COVID-19 health crisis for the following students' offices food supply
|
||||||
div.images
|
div.images
|
||||||
|
@ -68,7 +68,7 @@ block content
|
||||||
p IT student office
|
p IT student office
|
||||||
p.before-link Made with ❤️ by
|
p.before-link Made with ❤️ by
|
||||||
a(href="https://www.linkedin.com/in/florian-charlaix" target="_blank") Florian Charlaix
|
a(href="https://www.linkedin.com/in/florian-charlaix" target="_blank") Florian Charlaix
|
||||||
div#contact.card.hide
|
div#contact.popup.card.hide
|
||||||
h1 Contact
|
h1 Contact
|
||||||
p.before-link Order issue:
|
p.before-link Order issue:
|
||||||
a(href="mailto: ") test@test.fr
|
a(href="mailto: ") test@test.fr
|
||||||
|
|
Reference in a new issue