Add section images, larger covers and track tags
Section images:
- A section gets an optional image, set from its new "Modifier" dialog
(name and image), which replaces "Renommer". It goes through the same
conversion as track covers and is deleted with its section.
- Track and section uploads share routes/coverUpload.js. The cover
folder is created again if it went missing, instead of failing.
Larger images: 72 px for tracks (was 48), 96 px for section headers,
160 px in the player and the edit dialog (was 96); smaller on phones.
Tags:
- Library tracks take free tags, edited in the "Modifier" dialog, which
suggests the tags already in use. Case is ignored ("Épique" and
"épique" are one tag); at most 15 tags of 30 characters.
- A tag bar above the library filters it, and the "Tout ajouter"
buttons (global and per section) then only queue its tracks
(enqueue-all takes a tag). The search also matches tags.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
793765fb79
commit
bda95ca946
13 changed files with 601 additions and 165 deletions
|
|
@ -1,10 +1,17 @@
|
|||
/**
|
||||
* @file Routes /api/library/sections : crée, renomme, déplace et supprime les sections de la
|
||||
* bibliothèque.
|
||||
* bibliothèque, et change leur image.
|
||||
*/
|
||||
|
||||
import { Router } from "express";
|
||||
import { createSection, deleteSection, updateSection } from "../storage/librarySections.js";
|
||||
import {
|
||||
createSection,
|
||||
deleteSection,
|
||||
setSectionCover,
|
||||
updateSection,
|
||||
} from "../storage/librarySections.js";
|
||||
import { serializeSection } from "../serializers.js";
|
||||
import { coverUpload, handleCoverUpload } from "./coverUpload.js";
|
||||
|
||||
function librarySectionsRouter({ queue }) {
|
||||
const router = Router();
|
||||
|
|
@ -12,7 +19,7 @@ function librarySectionsRouter({ queue }) {
|
|||
router.post("/", (req, res) => {
|
||||
const section = createSection(req.body?.name);
|
||||
queue.emit("libraryUpdate");
|
||||
res.status(201).json({ section });
|
||||
res.status(201).json({ section: serializeSection(section) });
|
||||
});
|
||||
|
||||
// Corps : name (nouveau nom) et/ou position (nouvel emplacement, 0 en tête).
|
||||
|
|
@ -26,7 +33,26 @@ function librarySectionsRouter({ queue }) {
|
|||
return res.status(404).json({ error: "Section introuvable" });
|
||||
}
|
||||
queue.emit("libraryUpdate");
|
||||
res.json({ section });
|
||||
res.json({ section: serializeSection(section) });
|
||||
});
|
||||
|
||||
// Remplace l'image de la section par celle envoyée (champ « cover »).
|
||||
router.put("/:sectionId/cover", coverUpload, (req, res) =>
|
||||
handleCoverUpload(req, res, (cover) => {
|
||||
const section = setSectionCover(req.params.sectionId, cover);
|
||||
if (!section) return null;
|
||||
queue.emit("libraryUpdate");
|
||||
return { section: serializeSection(section) };
|
||||
})
|
||||
);
|
||||
|
||||
router.delete("/:sectionId/cover", (req, res) => {
|
||||
const section = setSectionCover(req.params.sectionId, null);
|
||||
if (!section) {
|
||||
return res.status(404).json({ error: "Section introuvable" });
|
||||
}
|
||||
queue.emit("libraryUpdate");
|
||||
res.json({ section: serializeSection(section) });
|
||||
});
|
||||
|
||||
router.delete("/:sectionId", (req, res) => {
|
||||
|
|
@ -35,7 +61,7 @@ function librarySectionsRouter({ queue }) {
|
|||
return res.status(404).json({ error: "Section introuvable" });
|
||||
}
|
||||
queue.emit("libraryUpdate");
|
||||
res.json({ removed: section });
|
||||
res.json({ removed: serializeSection(section) });
|
||||
});
|
||||
|
||||
return router;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue