fix loading icon
This commit is contained in:
@@ -896,30 +896,45 @@ class AniWorldApp {
|
||||
const statusDot = statusElement.querySelector('.status-dot');
|
||||
if (!statusDot) return;
|
||||
|
||||
// Remove all status classes
|
||||
// Remove all status classes from both dot and element
|
||||
statusDot.classList.remove('idle', 'running', 'error');
|
||||
statusElement.classList.remove('running', 'error', 'idle');
|
||||
|
||||
// Capitalize process name for display
|
||||
const displayName = processName.charAt(0).toUpperCase() + processName.slice(1);
|
||||
|
||||
if (hasError) {
|
||||
statusDot.classList.add('error');
|
||||
statusElement.title = `${processName} error - click for details`;
|
||||
statusElement.classList.add('error');
|
||||
statusElement.title = `${displayName} error - click for details`;
|
||||
} else if (isRunning) {
|
||||
statusDot.classList.add('running');
|
||||
statusElement.title = `${processName} is running...`;
|
||||
statusElement.classList.add('running');
|
||||
statusElement.title = `${displayName} is running...`;
|
||||
} else {
|
||||
statusDot.classList.add('idle');
|
||||
statusElement.title = `${processName} is idle`;
|
||||
statusElement.classList.add('idle');
|
||||
statusElement.title = `${displayName} is idle`;
|
||||
}
|
||||
}
|
||||
|
||||
async checkProcessLocks() {
|
||||
try {
|
||||
const response = await this.makeAuthenticatedRequest('/api/process/locks/status');
|
||||
if (!response) return;
|
||||
if (!response) {
|
||||
// If no response, set status as idle
|
||||
this.updateProcessStatus('rescan', false);
|
||||
this.updateProcessStatus('download', false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if response is actually JSON and not HTML (login page)
|
||||
const contentType = response.headers.get('content-type');
|
||||
if (!contentType || !contentType.includes('application/json')) {
|
||||
console.warn('Process locks API returned non-JSON response, likely authentication issue');
|
||||
// Set status as idle if we can't get proper response
|
||||
this.updateProcessStatus('rescan', false);
|
||||
this.updateProcessStatus('download', false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -935,25 +950,40 @@ class AniWorldApp {
|
||||
if (rescanBtn) {
|
||||
if (locks.rescan?.is_locked) {
|
||||
rescanBtn.disabled = true;
|
||||
rescanBtn.querySelector('span').textContent = 'Scanning...';
|
||||
const span = rescanBtn.querySelector('span');
|
||||
if (span) span.textContent = 'Scanning...';
|
||||
} else {
|
||||
rescanBtn.disabled = false;
|
||||
rescanBtn.querySelector('span').textContent = 'Rescan';
|
||||
const span = rescanBtn.querySelector('span');
|
||||
if (span) span.textContent = 'Rescan';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If API returns error, set status as idle
|
||||
console.warn('Process locks API returned error:', data.error);
|
||||
this.updateProcessStatus('rescan', false);
|
||||
this.updateProcessStatus('download', false);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error checking process locks:', error);
|
||||
// On error, set status as idle
|
||||
this.updateProcessStatus('rescan', false);
|
||||
this.updateProcessStatus('download', false);
|
||||
}
|
||||
}
|
||||
|
||||
startProcessStatusMonitoring() {
|
||||
// Initial check on page load
|
||||
this.checkProcessLocks();
|
||||
|
||||
// Check process status every 5 seconds
|
||||
setInterval(() => {
|
||||
if (this.isConnected) {
|
||||
this.checkProcessLocks();
|
||||
}
|
||||
}, 5000);
|
||||
|
||||
console.log('Process status monitoring started');
|
||||
}
|
||||
|
||||
async showConfigModal() {
|
||||
|
||||
Reference in New Issue
Block a user