- fix progressbar
- {slug} {chapterNumber} in Url
- activity toolbar
This commit is contained in:
Jérémy Guillot
2024-07-07 15:25:12 +02:00
parent 54c581b229
commit 4672886a67
15 changed files with 183 additions and 59 deletions

View File

@@ -6,6 +6,7 @@ use App\Entity\ContentSource;
use App\Form\ContentSourceType;
use App\Repository\ContentSourceRepository;
use App\Service\MangaScraperService;
use App\Service\NotificationService;
use Doctrine\ORM\EntityManagerInterface;
use GuzzleHttp\Exception\GuzzleException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -18,7 +19,8 @@ class SettingsController extends AbstractController
{
public function __construct(
private MangaScraperService $mangaScraperService,
private EntityManagerInterface $entityManager
private EntityManagerInterface $entityManager,
private NotificationService $notificationService
)
{
@@ -70,7 +72,7 @@ class SettingsController extends AbstractController
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->persist($contentSource);
$this->entityManager->flush();
$this->addFlash('success', ($isNew ? 'New scrapper configuration saved' : 'Scrapper configuration updated') . ' successfully.');
$this->notificationService->sendUpdate(['status' => 'success', 'message' => ($isNew ? 'New scrapper configuration saved' : 'Scrapper configuration updated') . ' successfully.']);
return $this->redirectToRoute('app_settings_scrappers_list');
}
@@ -94,7 +96,15 @@ class SettingsController extends AbstractController
$mangaSlug = $request->request->get('mangaSlug');
$chapterNumber = $request->request->get('chapterNumber');
$scrapedData = $this->mangaScraperService->testScrapingHtml($mangaSlug, $chapterNumber, $contentSource);
try {
$scrapedData = $this->mangaScraperService->testScrapingHtml($mangaSlug, $chapterNumber, $contentSource);
}catch (\Exception $e){
$this->notificationService->sendUpdate(['status' => 'error', 'message' => $e->getMessage()]);
return new JsonResponse([
'success' => false,
'message' => $e->getMessage(),
]);
}
return new JsonResponse([
'success' => true,