- 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

@@ -10,7 +10,6 @@ export default class extends Controller {
connect() {
this.currentPage = 0;
this.totalPages = 0;
this.progressBarElement = this.progressBarTarget.querySelector('.bg-blue-600');
const mercureHubUrl = 'https://localhost/.well-known/mercure';
this.eventSource = new EventSource(`${mercureHubUrl}?topic=activity`);
@@ -26,7 +25,7 @@ export default class extends Controller {
handleMessage(event) {
const data = JSON.parse(event.data);
if (data.status === "Page Scrapping progress" && data.chapterId === this.chapterIdValue) {
if (data.status === "scrapping.progress" && data.chapterId === this.chapterIdValue) {
this.handleProgressUpdate(data);
}
}
@@ -35,16 +34,12 @@ export default class extends Controller {
this.currentPage = data.pageIndex + 1;
this.totalPages = data.totalPages;
if (this.currentPage > 1) {
this.progressBarTarget.classList.remove('hidden');
}
this.updateProgressBar();
}
updateProgressBar() {
const progress = (this.currentPage / this.totalPages) * 100;
this.progressBarElement.style.width = `${progress}%`;
this.progressBarTarget.style.width = `${progress}%`;
this.progressTextTarget.textContent = `${this.currentPage} / ${this.totalPages}`;
}
}