feat: ajout de la fonctionnalité de suppression des chapitres avec mise à jour de l'API et des composants associés pour gérer la suppression des chapitres et des fichiers CBZ.

This commit is contained in:
ext.jeremy.guillot@maxicoffee.domains
2025-06-29 23:04:57 +02:00
parent 37e1b202c2
commit 8692fa14c6
6 changed files with 563 additions and 552 deletions

View File

@@ -197,6 +197,18 @@ export const useMangaStore = defineStore('manga', {
console.error('Erreur lors de la recherche du chapitre:', error); console.error('Erreur lors de la recherche du chapitre:', error);
throw error; throw error;
} }
},
// --- Delete Chapter Action ---
async deleteChapter(chapterId) {
try {
await mangaRepository.deleteChapter(chapterId);
// Mettre à jour l'état du chapitre pour refléter qu'il n'est plus disponible
this.updateChapterAvailability(chapterId, false);
} catch (error) {
console.error('Erreur lors de la suppression du chapitre:', error);
throw error;
}
} }
} }
}); });

View File

@@ -173,4 +173,19 @@ export class ApiMangaRepository {
throw error; throw error;
} }
} }
async deleteChapter(chapterId) {
try {
const response = await fetch(`/api/manga/chapters/${chapterId}/cbz`, {
method: 'DELETE'
});
if (!response.ok) {
throw new Error('Failed to delete chapter');
}
return true;
} catch (error) {
console.error('API Error:', error);
throw error;
}
}
} }

View File

@@ -87,8 +87,12 @@
}; };
const handleDelete = async () => { const handleDelete = async () => {
// TODO: Implémenter la suppression du chapitre try {
console.log('Suppression du chapitre:', props.chapter.id); console.log(`MangaChapter: Suppression du chapitre ${props.chapter.number} (ID: ${props.chapter.id})`);
await store.deleteChapter(props.chapter.id);
} catch (error) {
console.error('Erreur lors de la suppression du chapitre:', error);
}
}; };
const handleDownload = async () => { const handleDownload = async () => {

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,8 @@ use App\Domain\Manga\Domain\Contract\Repository\ChapterRepositoryInterface;
use App\Domain\Manga\Domain\Contract\Service\FileServiceInterface; use App\Domain\Manga\Domain\Contract\Service\FileServiceInterface;
use App\Domain\Manga\Domain\Exception\ChapterNotFoundException; use App\Domain\Manga\Domain\Exception\ChapterNotFoundException;
use App\Domain\Manga\Domain\Exception\CbzFileNotFoundException; use App\Domain\Manga\Domain\Exception\CbzFileNotFoundException;
use App\Domain\Manga\Domain\Model\Chapter;
use App\Domain\Manga\Domain\Model\ValueObject\ChapterId;
use App\Domain\Shared\Domain\Contract\CommandHandlerInterface; use App\Domain\Shared\Domain\Contract\CommandHandlerInterface;
use App\Domain\Shared\Domain\Contract\CommandInterface; use App\Domain\Shared\Domain\Contract\CommandInterface;
@@ -37,14 +39,14 @@ readonly class DeleteCbzHandler implements CommandHandlerInterface
// For now, we'll just mark the chapter as not available // For now, we'll just mark the chapter as not available
// Update chapter to mark CBZ as not available // Update chapter to mark CBZ as not available
$updatedChapter = new \App\Domain\Manga\Domain\Model\Chapter( $updatedChapter = new Chapter(
new \App\Domain\Manga\Domain\Model\ValueObject\ChapterId($chapter->getId()), new ChapterId($chapter->getId()),
$chapter->getMangaId(), $chapter->getMangaId(),
$chapter->getNumber(), $chapter->getNumber(),
$chapter->getTitle(), $chapter->getTitle(),
$chapter->getVolume(), $chapter->getVolume(),
$chapter->isVisible(), $chapter->isVisible(),
false, // isAvailable = false (CBZ removed) null,
$chapter->getCreatedAt() $chapter->getCreatedAt()
); );

View File

@@ -41,11 +41,11 @@ readonly class DownloadChapterHandler
$preferredSources = $manga->getPreferredSources()->toArray(); $preferredSources = $manga->getPreferredSources()->toArray();
$allSources = $this->contentSourceRepository->findAll(); $allSources = $this->contentSourceRepository->findAll();
// $filteredSources = array_udiff($allSources, $preferredSources, function ($a, $b) { $filteredSources = array_udiff($allSources, $preferredSources, function ($a, $b) {
// return $a->getId() - $b->getId(); return $a->getId() - $b->getId();
// }); });
//
// $sources = array_merge($preferredSources, $filteredSources); $sources = array_merge($preferredSources, $filteredSources);
if (count($preferredSources) > 0) { if (count($preferredSources) > 0) {
$sources = $preferredSources; $sources = $preferredSources;
@@ -53,12 +53,12 @@ readonly class DownloadChapterHandler
$sources = $allSources; $sources = $allSources;
} }
$sources[] = // $sources[] =
(new ContentSource()) // (new ContentSource())
->setBaseUrl('https://api.mangadex.org/') // ->setBaseUrl('https://api.mangadex.org/')
->setImageSelector('img') // ->setImageSelector('img')
->setChapterUrlFormat('at-home/server/%s') // ->setChapterUrlFormat('at-home/server/%s')
->setScrapingType('mangadex'); // ->setScrapingType('mangadex');
// (new ContentSource()) // (new ContentSource())
// ->setBaseUrl('https://lelscans.net') // ->setBaseUrl('https://lelscans.net')