Add buttons on index with image count

This commit is contained in:
Ethanell 2020-04-29 09:31:34 +02:00
parent ce58e25094
commit 8dca471571
4 changed files with 21 additions and 5 deletions

View file

@ -43,7 +43,7 @@ form>div {
margin: 0.3em;
}
.file_button::-webkit-file-upload-button, button, .login, .logout {
.file_button::-webkit-file-upload-button, button, .button {
border-radius: 0.3em;
border-width: 0em;
padding: 0.5em;
@ -78,7 +78,7 @@ header {
margin-right: 1em;
}
.login, .logout {
.button {
background-color: buttonface;
text-decoration: none;
color: initial;
@ -86,3 +86,11 @@ header {
height: fit-content;
}
.buttons {
margin: 2em;
display: flex;
justify-items: center;
align-content: center;
justify-content: center;
}

View file

@ -1,5 +1,6 @@
let router = require("express").Router();
let isAuth = require("../user").isAuth;
let fs = require("fs");
router.get("/", isAuth, (req, res) => {
@ -7,7 +8,11 @@ router.get("/", isAuth, (req, res) => {
if ("invalidType" in req.query) {
invalidType = true;
}
res.render("index", {invalidType: invalidType, session: req.session});
res.render("index", {
invalidType: invalidType,
session: req.session,
count: fs.readdirSync("./images/").length
});
});

View file

@ -6,4 +6,7 @@ block content
form(method="POST", action="/upload", enctype="multipart/form-data")
input.file_button(type="file", name="image", accept="image/*")
button(type="submit") Upload
div.buttons
a.button(href="/list") Image List
p Actually #{count} images uploaded !

View file

@ -11,8 +11,8 @@ html(lang="en")
header
if session.login
p.hy Hy #{session.username} !
a.logout(href="/logout") Logout
a.button(href="/logout") Logout
else
a.login(href="/login") Login
a.button(href="/login") Login
block content