actor sync

This commit is contained in:
Lars Behrends
2025-11-06 13:08:02 +01:00
parent 3f56625205
commit a44c311e89
14 changed files with 773 additions and 9 deletions

View File

@@ -85,6 +85,28 @@
Cleanup
</button>
</div>
{% elseif source.name == 'stash' %}
<!-- Stash-specific sync options -->
<div class="d-flex gap-2 mb-2">
<button onclick="startSync({{ source.id }}, 'full')"
class="btn btn-primary btn-sm flex-fill"
data-source-id="{{ source.id }}">
Full Sync
</button>
<button onclick="startSync({{ source.id }}, 'incremental')"
class="btn btn-secondary btn-sm flex-fill"
data-source-id="{{ source.id }}">
Incremental
</button>
</div>
<!-- Stash Performer Sync Button -->
<div class="mb-2">
<button onclick="syncStashPerformers()"
class="btn btn-info btn-sm w-100"
id="stash-performer-sync-btn">
<i class="bi bi-person-lines-fill me-1"></i>Sync Performers
</button>
</div>
{% else %}
<!-- Standard sync options for other sources -->
<div class="d-flex gap-2 mb-2">
@@ -487,6 +509,43 @@
}
}
function syncStashPerformers() {
const button = document.getElementById('stash-performer-sync-btn');
const originalText = button.innerHTML;
// Show loading state
button.disabled = true;
button.innerHTML = '<span class="spinner-border spinner-border-sm me-2" role="status" aria-hidden="true"></span>Syncing...';
// Make AJAX request to sync performers
fetch('/api/actors/sync-existing-stash', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content')
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert(`Stash performer sync completed!\n\nProcessed: ${data.results.processed}\nUpdated: ${data.results.updated}\nSkipped: ${data.results.skipped}\nNot found in Stash: ${data.results.not_found_in_stash.length}\n\nCheck the logs for detailed information.`);
} else {
alert('Error syncing performers: ' + (data.error || 'Unknown error'));
}
// Re-enable button
button.disabled = false;
button.innerHTML = originalText;
})
.catch(error => {
alert('Failed to sync performers: ' + error.message);
// Re-enable button
button.disabled = false;
button.innerHTML = originalText;
});
}
// Cleanup intervals on page unload
window.addEventListener('beforeunload', () => {
Object.values(syncIntervals).forEach(interval => clearInterval(interval));