From d95a0e9918fb029230a1d5c672b53893512e6af5 Mon Sep 17 00:00:00 2001 From: flifloo Date: Fri, 29 May 2020 12:55:56 +0200 Subject: [PATCH] Add routes --- app.js | 10 ++++++++++ package.json | 2 +- routes/commands.js | 9 +++++++++ routes/index.js | 4 ++-- routes/kitchen.js | 9 +++++++++ routes/login.js | 9 +++++++++ routes/logout.js | 9 +++++++++ routes/stocks.js | 9 +++++++++ views/commands.pug | 2 +- views/kitchen.pug | 2 +- views/login.pug | 43 ++++++++++++++++++------------------------- views/service.pug | 2 +- views/stocks.pug | 2 +- 13 files changed, 80 insertions(+), 32 deletions(-) create mode 100644 routes/commands.js create mode 100644 routes/kitchen.js create mode 100644 routes/login.js create mode 100644 routes/logout.js create mode 100644 routes/stocks.js diff --git a/app.js b/app.js index 9c2a0dc..b9ae5a0 100644 --- a/app.js +++ b/app.js @@ -5,6 +5,11 @@ const cookieParser = require("cookie-parser"); const logger = require("morgan"); const indexRouter = require("./routes/index"); +const loginRouter = require("./routes/login") +const logoutRouter = require("./routes/logout") +const commandsRouter = require("./routes/commands") +const kitchenRouter = require("./routes/kitchen") +const stocksRouter = require("./routes/stocks") const app = express(); @@ -19,6 +24,11 @@ app.use(cookieParser()); app.use(express.static(path.join(__dirname, "public"))); app.use("/", indexRouter); +app.use("/login", loginRouter); +app.use("/logout", logoutRouter); +app.use("/commands", commandsRouter); +app.use("/kitchen", kitchenRouter); +app.use("/stocks", stocksRouter); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/package.json b/package.json index 1519d5f..7c1c3bf 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "morgan": "~1.9.1", "pg": "^8.2.1", "pg-hstore": "^2.3.3", - "pug": "2.0.0-beta11", + "pug": "^2.0.0-beta11", "sequelize": "^5.21.11", "sequelize-cli": "^5.5.1", "socket.io": "^2.3.0" diff --git a/routes/commands.js b/routes/commands.js new file mode 100644 index 0000000..9d7feac --- /dev/null +++ b/routes/commands.js @@ -0,0 +1,9 @@ +const express = require("express"); +const router = express.Router(); + +/* GET home page. */ +router.get("/", function(req, res) { + res.render("commands", { title: "Kfet - Commands" }); +}); + +module.exports = router; diff --git a/routes/index.js b/routes/index.js index 3272bf2..eeb4545 100644 --- a/routes/index.js +++ b/routes/index.js @@ -2,8 +2,8 @@ const express = require("express"); const router = express.Router(); /* GET home page. */ -router.get("/", function(req, res, next) { - res.render("index", { title: "Express" }); +router.get("/", function(req, res) { + res.render("index", { title: "Kfet" }); }); module.exports = router; diff --git a/routes/kitchen.js b/routes/kitchen.js new file mode 100644 index 0000000..14722db --- /dev/null +++ b/routes/kitchen.js @@ -0,0 +1,9 @@ +const express = require("express"); +const router = express.Router(); + +/* GET home page. */ +router.get("/", function(req, res) { + res.render("kitchen", { title: "Kfet - Kitchen" }); +}); + +module.exports = router; diff --git a/routes/login.js b/routes/login.js new file mode 100644 index 0000000..d4f7c53 --- /dev/null +++ b/routes/login.js @@ -0,0 +1,9 @@ +const express = require("express"); +const router = express.Router(); + +/* GET home page. */ +router.get("/", function(req, res) { + res.render("login", { title: "Kfet - Login" }); +}); + +module.exports = router; diff --git a/routes/logout.js b/routes/logout.js new file mode 100644 index 0000000..287627c --- /dev/null +++ b/routes/logout.js @@ -0,0 +1,9 @@ +const express = require("express"); +const router = express.Router(); + +/* GET home page. */ +router.get("/", function(req, res) { + res.send("Ok"); +}); + +module.exports = router; diff --git a/routes/stocks.js b/routes/stocks.js new file mode 100644 index 0000000..ef80334 --- /dev/null +++ b/routes/stocks.js @@ -0,0 +1,9 @@ +const express = require("express"); +const router = express.Router(); + +/* GET home page. */ +router.get("/", function(req, res) { + res.render("stocks", { title: "Kfet - Stocks" }); +}); + +module.exports = router; diff --git a/views/commands.pug b/views/commands.pug index 6d54a70..da5a58c 100644 --- a/views/commands.pug +++ b/views/commands.pug @@ -25,7 +25,7 @@ block content a(href="/logout") button.contact2-form-btn Logout - div.bg-contact2#main-container(style="background-image: /images/bg-01.jpg;") + div#main-container.bg-contact2(style="background-image: url(/images/bg-01.jpg);height: 93vh") form.container(action="#") div#dish h1 Dish diff --git a/views/kitchen.pug b/views/kitchen.pug index c38836c..7b298fc 100644 --- a/views/kitchen.pug +++ b/views/kitchen.pug @@ -1,7 +1,7 @@ extends layout block content - div#main-container.bg-contact2(style="background-image: /images/bgcuisine.png") + div#main-container.bg-contact2(style="background-image: url(/images/bgcuisine.png)") div#middle-container div#WIP div#waiting diff --git a/views/login.pug b/views/login.pug index 7a00490..e48a62b 100644 --- a/views/login.pug +++ b/views/login.pug @@ -1,31 +1,24 @@ extends layout block content - div.bg-contact2(style="background-image: /images/bg-01.jpg") + div.bg-contact2(style="background-image: url(/images/bg-01.jpg);") div.container-contact2 div.wrap-contact2 span.contact2-form-title Login - - p Kfet member: - form(action="" method="post" novalidate) - div.wrap-input2.validate-input(data-validate="Username is required") - input.input2(type="text" name="name") - span.focus-input2(data-placeholder="Username") - - div.wrap-input2.validate-input(data-validate="Password required") - input.input2(type="password" name="password") - span.focus-input2(data-placeholder="Password") - - div#fct - input#commi(type="radio" name="dct") - label(for="commi") Commi - - input#pc(type="radio" name="fct") - label(for="pc") PC - - input#guest(type="radio" name fct) - label(for="guest") Guest - - div.contact2-form-btn - div.wrap-contact2-form-btn - button.contact2-form-btn(type="submit") Login + div.wrap-input2.validate-input(data-validate="Username is required") + input.input2(type="text" name="name") + span.focus-input2(data-placeholder="Username") + div.wrap-input2.validate-input(data-validate="Password invalid") + input.input2(type="password" name="password") + span.focus-input2(data-placeholder="Mot de passe") + div#fct + input#commi(type="radio" name="fct") + label(for="commi") Commi + input#pc(type="radio" name="fct") + label(for="pc") PC + input#guest(type="radio" name="fct") + label(for="guest") Guest + div.container-contact2-form-btn + div.wrap-contact2-form-btn + div.contact2-form-bgbtn + button.contact2-form-btn(type="submit") Login diff --git a/views/service.pug b/views/service.pug index 699e388..ba14728 100644 --- a/views/service.pug +++ b/views/service.pug @@ -6,7 +6,7 @@ block content a#gobackpc(onclick="window.close()") li Back to commands - div#main-container.bg-contact2(style="background-image: /images/bg-01.jpg") + div#main-container.bg-contact2(style="background-image: url(/images/bg-01.jpg)") form#stocks.container(action="#") div#teams div#sandwich diff --git a/views/stocks.pug b/views/stocks.pug index 9fbfa63..d9c75ae 100644 --- a/views/stocks.pug +++ b/views/stocks.pug @@ -1,7 +1,7 @@ extends layout block content - div#main-container.bg-contact2(stype="background-image: /images/bg-01.jpg") + div#main-container.bg-contact2(style="background-image: url(/images/bg-01.jpg);") form#stocks.container(action="#") div#dish h1 Dishes