adds ending time to activity indicator

This commit is contained in:
2025-02-10 17:33:37 +01:00
parent a44c2bfc04
commit a6292d2d0f
4 changed files with 43 additions and 5 deletions

View File

@@ -4,7 +4,7 @@ class ScraperApp {
this.stopButton = document.getElementById('stopButton');
this.startButton = document.getElementById('startButton');
this.activityIndicator = document.getElementById('activity_indicator');
this.endTimeElement = document.getElementById('end_time');
this.init();
}
@@ -23,18 +23,38 @@ class ScraperApp {
this.activityIndicator.classList.remove('text-bg-danger');
this.activityIndicator.classList.add('text-bg-success');
this.activityIndicator.textContent = 'Active';
this.endTimeElement.classList.remove('d-none');
this.endTimeElement.textContent = data.end_time;
await this.fetchEndTime();
} else {
this.startButton.disabled = false;
this.stopButton.disabled = true;
this.activityIndicator.classList.remove('text-bg-success');
this.activityIndicator.classList.add('text-bg-danger');
this.activityIndicator.textContent = 'Inactive';
this.endTimeElement.textContent = '';
this.endTimeElement.classList.add('d-none');
}
} catch (error) {
console.error('Error checking scraping status:', error);
}
}
async fetchEndTime() {
try {
const response = await fetch('/scraping_get_end_time');
const data = await response.json();
if (data.end_time) {
this.endTimeElement.textContent = `Track until: ${data.end_time}`;
}
} catch (error) {
this.endTimeElement.textContent = 'Error fetching end time';
console.error('Error fetching end time:', error);
}
}
async startScraping(event) {
event.preventDefault(); // Prevent the default form submission
const formData = new FormData(this.form);