fix: resolve missing JS functions and CSS class names for watchlist tab
This commit is contained in:
@@ -10,7 +10,7 @@ async function displayWatchlist(status = null) {
|
|||||||
if (!container) return;
|
if (!container) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
container.innerHTML = '<div class="loading">Chargement de la watchlist...</div>';
|
container.innerHTML = '<div class="watchlist-loading">Chargement de la watchlist...</div>';
|
||||||
|
|
||||||
const items = await getWatchlist(status);
|
const items = await getWatchlist(status);
|
||||||
const stats = await getWatchlistStats();
|
const stats = await getWatchlistStats();
|
||||||
|
|||||||
@@ -316,3 +316,136 @@ window.getWatchlistStats = getWatchlistStats;
|
|||||||
window.getSchedulerStatus = getSchedulerStatus;
|
window.getSchedulerStatus = getSchedulerStatus;
|
||||||
window.startScheduler = startScheduler;
|
window.startScheduler = startScheduler;
|
||||||
window.stopScheduler = stopScheduler;
|
window.stopScheduler = stopScheduler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Current filter state
|
||||||
|
*/
|
||||||
|
let currentFilter = 'all';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter watchlist
|
||||||
|
*/
|
||||||
|
async function filterWatchlist(status, tabElement) {
|
||||||
|
currentFilter = status;
|
||||||
|
|
||||||
|
// Update tab styles
|
||||||
|
document.querySelectorAll('.filter-tab').forEach(tab => {
|
||||||
|
tab.classList.remove('active');
|
||||||
|
});
|
||||||
|
tabElement.classList.add('active');
|
||||||
|
|
||||||
|
// Reload with filter
|
||||||
|
await displayWatchlist(status === 'all' ? null : status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle start scheduler
|
||||||
|
*/
|
||||||
|
async function handleStartScheduler() {
|
||||||
|
try {
|
||||||
|
await startScheduler();
|
||||||
|
await loadSchedulerStatus();
|
||||||
|
alert('✅ Planificateur démarré!');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error starting scheduler:', error);
|
||||||
|
alert(`❌ Erreur: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle stop scheduler
|
||||||
|
*/
|
||||||
|
async function handleStopScheduler() {
|
||||||
|
try {
|
||||||
|
await stopScheduler();
|
||||||
|
await loadSchedulerStatus();
|
||||||
|
alert('✅ Planificateur arrêté!');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error stopping scheduler:', error);
|
||||||
|
alert(`❌ Erreur: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle check all
|
||||||
|
*/
|
||||||
|
async function handleCheckAll() {
|
||||||
|
try {
|
||||||
|
await checkAllWatchlistItems();
|
||||||
|
await loadSchedulerStatus();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error checking all:', error);
|
||||||
|
alert(`❌ Erreur: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle open settings
|
||||||
|
*/
|
||||||
|
async function handleOpenSettings() {
|
||||||
|
try {
|
||||||
|
const settings = await getWatchlistSettings();
|
||||||
|
const modalHtml = createSettingsModal(settings);
|
||||||
|
|
||||||
|
// Add modal to body
|
||||||
|
const modalContainer = document.createElement('div');
|
||||||
|
modalContainer.innerHTML = modalHtml;
|
||||||
|
document.body.appendChild(modalContainer);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error loading settings:', error);
|
||||||
|
alert(`❌ Erreur: ${error.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make functions available globally
|
||||||
|
window.filterWatchlist = filterWatchlist;
|
||||||
|
window.handleStartScheduler = handleStartScheduler;
|
||||||
|
window.handleStopScheduler = handleStopScheduler;
|
||||||
|
window.handleCheckAll = handleCheckAll;
|
||||||
|
window.handleOpenSettings = handleOpenSettings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load scheduler status
|
||||||
|
*/
|
||||||
|
async function loadSchedulerStatus() {
|
||||||
|
try {
|
||||||
|
const status = await getSchedulerStatus();
|
||||||
|
updateSchedulerUI(status);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error loading scheduler status:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update scheduler UI
|
||||||
|
*/
|
||||||
|
function updateSchedulerUI(status) {
|
||||||
|
const startBtn = document.getElementById('startSchedulerBtn');
|
||||||
|
const stopBtn = document.getElementById('stopSchedulerBtn');
|
||||||
|
const nextRunInfo = document.getElementById('nextRunInfo');
|
||||||
|
|
||||||
|
if (!startBtn || !stopBtn || !nextRunInfo) return;
|
||||||
|
|
||||||
|
if (status.running) {
|
||||||
|
startBtn.style.display = 'none';
|
||||||
|
stopBtn.style.display = 'inline-block';
|
||||||
|
|
||||||
|
if (status.next_run) {
|
||||||
|
const nextRun = new Date(status.next_run);
|
||||||
|
nextRunInfo.innerHTML = `✓ En cours<br>Prochaine vérification: ${nextRun.toLocaleString('fr-FR')}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
startBtn.style.display = 'inline-block';
|
||||||
|
stopBtn.style.display = 'none';
|
||||||
|
nextRunInfo.innerHTML = '⏸️ Arrêté';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
window.loadSchedulerStatus = loadSchedulerStatus;
|
||||||
|
window.updateSchedulerUI = updateSchedulerUI;
|
||||||
|
window.filterWatchlist = filterWatchlist;
|
||||||
|
window.handleStartScheduler = handleStartScheduler;
|
||||||
|
window.handleStopScheduler = handleStopScheduler;
|
||||||
|
window.handleCheckAll = handleCheckAll;
|
||||||
|
window.handleOpenSettings = handleOpenSettings;
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="watchlist-header">
|
<div class="watchlist-header">
|
||||||
<h1>📋 Ma Watchlist</h1>
|
<h1>📋 Ma Watchlist</h1>
|
||||||
<p>Suivez vos animes préférés et téléchargez automatiquement les nouveaux épisodes</p>
|
<p>Suivez vos animes préférés et téléchargez automatiquement les nouveaux épisodes</p>
|
||||||
<button type="button" class="btn-secondary header-back-btn" onclick="window.location.href = '/web'">
|
<button type="button" class="btn-secondary watchlist-header-back-btn" onclick="window.location.href = '/web'">
|
||||||
← Retour à l'accueil
|
← Retour à l'accueil
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -42,5 +42,5 @@
|
|||||||
|
|
||||||
<!-- Watchlist Items -->
|
<!-- Watchlist Items -->
|
||||||
<div id="watchlistContainer">
|
<div id="watchlistContainer">
|
||||||
<div class="loading">Chargement de la watchlist...</div>
|
<div class="watchlist-loading">Chargement de la watchlist...</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user