Added:
- fix progressbar
- {slug} {chapterNumber} in Url
- activity toolbar
This commit is contained in:
@@ -35,7 +35,6 @@ export default class extends Controller {
|
||||
|
||||
eventSource.onmessage = (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
console.log(data);
|
||||
if (data.processing !== undefined && data.pending !== undefined) {
|
||||
let totalActivities = data.processing.length + data.pending.length;
|
||||
this.activityTarget.innerHTML = totalActivities;
|
||||
|
||||
@@ -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}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
// assets/controllers/toolbar_controller.js
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import { visit } from "@hotwired/turbo"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["dropdown", "icon"]
|
||||
static values = {
|
||||
currentSort: String,
|
||||
currentOrder: String,
|
||||
currentStatus: String
|
||||
currentStatus: String,
|
||||
mangaId: Number
|
||||
}
|
||||
|
||||
connect() {
|
||||
window.addEventListener('alert:show', this.stopLoading.bind(this));
|
||||
}
|
||||
|
||||
stopLoading() {
|
||||
this.iconTarget.classList.remove('fa-spin');
|
||||
stopLoading(event) {
|
||||
if(event.currentTarget.dataset !== undefined){
|
||||
this.iconTarget.classList.remove('fa-spin');
|
||||
}
|
||||
}
|
||||
|
||||
refreshMetadata(event) {
|
||||
@@ -65,6 +69,36 @@ export default class extends Controller {
|
||||
document.dispatchEvent(event);
|
||||
}
|
||||
|
||||
confirmDelete(event) {
|
||||
event.preventDefault();
|
||||
const url = `/manga/delete/${this.mangaIdValue}`;
|
||||
|
||||
fetch(url, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
visit('/', {});
|
||||
} else {
|
||||
throw new Error(data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
// Show error message to user
|
||||
});
|
||||
}
|
||||
|
||||
showOptions() {
|
||||
console.log("Showing options...");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user