adds ending time to activity indicator
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user