forked from dbroqua/MusicTopus
- #68 - Unifier les vues pour la liste des albums - #77 - Je suis capable de trier ma collection par date d'ajout - #74 - Lors du changement de page on connait l'ordre de tri - #73 - Savoir sur quelle page on est - #76 - Avoir plus de détails sur le support physique sur la modale d'ajout - #75 - Numérotation de la tracklist Co-authored-by: dbroqua <contact@darkou.fr> Reviewed-on: https://git.darkou.fr/dbroqua/MusicTopus/pulls/78
55 lines
1.3 KiB
JavaScript
55 lines
1.3 KiB
JavaScript
import express from "express";
|
|
import { ensureLoggedIn } from "connect-ensure-login";
|
|
|
|
import Albums from "../middleware/Albums";
|
|
|
|
import render from "../libs/format";
|
|
|
|
// eslint-disable-next-line new-cap
|
|
const router = express.Router();
|
|
|
|
router.route("/").get(ensureLoggedIn("/connexion"), async (req, res, next) => {
|
|
try {
|
|
const page = new Albums(req, "collection");
|
|
|
|
await page.loadMyCollection();
|
|
|
|
if (page.getPageContent("artists").length > 0) {
|
|
render(res, page);
|
|
} else {
|
|
res.redirect("/ajouter-un-album");
|
|
}
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
});
|
|
|
|
router
|
|
.route("/exporter")
|
|
.get(ensureLoggedIn("/connexion"), async (req, res, next) => {
|
|
try {
|
|
const page = new Albums(req, "mon-compte/ma-collection/exporter");
|
|
|
|
page.setPageTitle("Exporter ma collection");
|
|
|
|
render(res, page);
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
});
|
|
|
|
router
|
|
.route("/:itemId")
|
|
.get(ensureLoggedIn("/connexion"), async (req, res, next) => {
|
|
try {
|
|
const page = new Albums(req, "mon-compte/ma-collection/details");
|
|
|
|
await page.loadItem();
|
|
|
|
render(res, page);
|
|
} catch (err) {
|
|
next(err);
|
|
}
|
|
});
|
|
|
|
export default router;
|