mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
...
This commit is contained in:
@@ -30,6 +30,34 @@
|
||||
|
||||
<div class="mb-3">
|
||||
<!-- Sync Buttons -->
|
||||
{% if source.name == 'jellyfin' %}
|
||||
<!-- Jellyfin-specific sync options -->
|
||||
<div class="d-flex gap-1 mb-2 flex-wrap">
|
||||
<button onclick="startSync({{ source.id }}, 'all')"
|
||||
class="btn btn-primary btn-sm flex-fill">
|
||||
All Content
|
||||
</button>
|
||||
<button onclick="startSync({{ source.id }}, 'movies')"
|
||||
class="btn btn-outline-primary btn-sm flex-fill">
|
||||
Movies Only
|
||||
</button>
|
||||
<button onclick="startSync({{ source.id }}, 'tvshows')"
|
||||
class="btn btn-outline-primary btn-sm flex-fill">
|
||||
TV Shows Only
|
||||
</button>
|
||||
</div>
|
||||
<div class="d-flex gap-1 mb-2">
|
||||
<button onclick="startSync({{ source.id }}, 'full')"
|
||||
class="btn btn-secondary btn-sm flex-fill">
|
||||
Full Sync
|
||||
</button>
|
||||
<button onclick="startSync({{ source.id }}, 'incremental')"
|
||||
class="btn btn-outline-secondary btn-sm flex-fill">
|
||||
Incremental
|
||||
</button>
|
||||
</div>
|
||||
{% else %}
|
||||
<!-- Standard sync options for other sources -->
|
||||
<div class="d-flex gap-2 mb-2">
|
||||
<button onclick="startSync({{ source.id }}, 'full')"
|
||||
class="btn btn-primary btn-sm flex-fill">
|
||||
@@ -40,6 +68,7 @@
|
||||
Incremental
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Last Sync Status -->
|
||||
{% if source.last_sync_at %}
|
||||
@@ -159,6 +188,13 @@
|
||||
progressBar.style.width = '0%';
|
||||
statusDiv.textContent = 'Starting sync...';
|
||||
|
||||
// Disable all sync buttons for this source
|
||||
const buttons = document.querySelectorAll(`[onclick*="startSync(${sourceId},"]`);
|
||||
buttons.forEach(button => {
|
||||
button.disabled = true;
|
||||
button.textContent = 'Syncing...';
|
||||
});
|
||||
|
||||
// Start sync via API
|
||||
fetch(`/admin/sync/${sourceId}?type=${syncType}`, {
|
||||
method: 'POST',
|
||||
@@ -171,19 +207,29 @@
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
// Start monitoring sync status
|
||||
monitorSyncStatus(data.sync_log_id, sourceId, progressBar, statusDiv);
|
||||
monitorSyncStatus(data.sync_log_id, sourceId, progressBar, statusDiv, buttons);
|
||||
} else {
|
||||
statusDiv.textContent = 'Error: ' + (data.message || 'Unknown error');
|
||||
progressDiv.classList.add('d-none');
|
||||
// Re-enable buttons on error
|
||||
buttons.forEach(button => {
|
||||
button.disabled = false;
|
||||
button.textContent = button.textContent.replace('Syncing...', '').trim();
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
statusDiv.textContent = 'Error: ' + error.message;
|
||||
progressDiv.classList.add('d-none');
|
||||
// Re-enable buttons on error
|
||||
buttons.forEach(button => {
|
||||
button.disabled = false;
|
||||
button.textContent = button.textContent.replace('Syncing...', '').trim();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function monitorSyncStatus(syncLogId, sourceId, progressBar, statusDiv) {
|
||||
function monitorSyncStatus(syncLogId, sourceId, progressBar, statusDiv, buttons) {
|
||||
const interval = setInterval(() => {
|
||||
fetch(`/admin/sync/status/${syncLogId}`)
|
||||
.then(response => response.json())
|
||||
@@ -208,6 +254,12 @@
|
||||
// Refresh page to show updated sync log
|
||||
location.reload();
|
||||
}, 2000);
|
||||
} else {
|
||||
// Re-enable buttons on failure
|
||||
buttons.forEach(button => {
|
||||
button.disabled = false;
|
||||
button.textContent = button.textContent.replace('Syncing...', '').trim();
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -215,6 +267,11 @@
|
||||
console.error('Error monitoring sync:', error);
|
||||
clearInterval(interval);
|
||||
delete syncIntervals[sourceId];
|
||||
// Re-enable buttons on error
|
||||
buttons.forEach(button => {
|
||||
button.disabled = false;
|
||||
button.textContent = button.textContent.replace('Syncing...', '').trim();
|
||||
});
|
||||
});
|
||||
}, 1000);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user