Add X button for delete on images list
This commit is contained in:
parent
8dca471571
commit
bb5ea716c6
3 changed files with 16 additions and 2 deletions
|
@ -94,3 +94,15 @@ header {
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.image_box {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.remove {
|
||||||
|
position: absolute;
|
||||||
|
top: 0.2em;
|
||||||
|
right: 0.2em;
|
||||||
|
text-decoration: none;
|
||||||
|
color: initial;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ let fs = require("fs");
|
||||||
router.get("/:name", isAuth, (req, res, next) => {
|
router.get("/:name", isAuth, (req, res, next) => {
|
||||||
if ("name" in req.params && fs.existsSync("./images/"+req.params.name)) {
|
if ("name" in req.params && fs.existsSync("./images/"+req.params.name)) {
|
||||||
fs.unlinkSync("./images/"+req.params.name);
|
fs.unlinkSync("./images/"+req.params.name);
|
||||||
res.redirect("/");
|
res.redirect("/list");
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,5 +3,7 @@ block content
|
||||||
h1 Images List
|
h1 Images List
|
||||||
div.images
|
div.images
|
||||||
each image in images
|
each image in images
|
||||||
|
div.image_box
|
||||||
|
a.remove(href=`/remove/${image}`) X
|
||||||
img.image(src=`/images/${image}`)
|
img.image(src=`/images/${image}`)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue