feat: integrate watchlist as tab on /web page

This commit is contained in:
root
2026-02-26 16:06:21 +00:00
parent 36ec4a0eee
commit e22bc4191c
8 changed files with 494 additions and 358 deletions
+187
View File
@@ -1366,3 +1366,190 @@
justify-content: flex-start;
}
}
/* ===================================
Watchlist Page Styles
=================================== */
.watchlist-body {
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
min-height: 100vh;
color: #e0e0e0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.watchlist-header {
background: rgba(217, 255, 0.1);
border: 1px solid rgba(0, 217, 255, 0.3);
border-radius: 12px;
padding: 30px;
margin-bottom: 30px;
text-align: center;
}
.watchlist-header h1 {
color: #00d9ff;
margin: 0 0 10px 0;
font-size: 28px;
font-weight: 600;
}
.watchlist-header p {
color: #999;
margin: 0;
font-size: 14px;
}
.watchlist-controls {
display: flex;
gap: 15px;
justify-content: center;
margin-bottom: 30px;
flex-wrap: wrap;
}
.watchlist-container {
max-width: 1200px;
margin: 0 auto;
padding: 0 20px 40px;
}
.scheduler-status {
background: rgba(0, 217, 255, 0.05);
border: 1px solid rgba(0, 217, 255, 0.2);
border-radius: 10px;
padding: 20px;
margin-bottom: 30px;
}
.scheduler-status-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15px;
}
.scheduler-status h3 {
margin: 0;
color: #00d9ff;
font-size: 18px;
}
.scheduler-controls {
display: flex;
gap: 10px;
}
.status-indicator {
display: inline-flex;
align-items: center;
gap: 8px;
padding: 5px 12px;
border-radius: 12px;
font-size: 13px;
}
.status-indicator.running {
background: rgba(76, 175, 80, 0.2);
color: #4caf50;
}
.status-indicator.stopped {
background: rgba(244, 67, 54, 0.2);
color: #f44;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
}
.status-dot.running {
background: #4caf50;
animation: watchlist-pulse 2s infinite;
}
.status-dot.stopped {
background: #f44;
}
@keyframes watchlist-pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.next-run-info {
font-size: 13px;
color: #999;
margin-top: 10px;
}
.filter-tabs {
display: flex;
gap: 10px;
margin-bottom: 20px;
justify-content: center;
}
.filter-tab {
padding: 8px 16px;
background: rgba(255, 255, 255, 0.05);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
color: #ccc;
cursor: pointer;
transition: all 0.2s;
}
.filter-tab:hover {
background: rgba(255, 255, 255, 0.1);
}
.filter-tab.active {
background: rgba(0, 217, 255, 0.2);
border-color: rgba(0, 217, 255, 0.5);
color: #00d9ff;
}
.watchlist-loading {
text-align: center;
padding: 60px;
color: #999;
}
.empty-watchlist {
text-align: center;
padding: 80px 20px;
}
.watchlist-error-message {
text-align: center;
padding: 40px;
color: #f44;
}
.watchlist-item {
transition: all 0.3s ease;
}
.watchlist-item:hover {
background: rgba(255, 255, 255, 0.08);
transform: translateY(-2px);
}
.watchlist-btn-small {
padding: 6px 12px;
font-size: 12px;
}
.watchlist-header-back-btn {
margin-top: 15px;
}
.watchlist-modal-action-btn {
flex: 1;
padding: 12px;
font-size: 14px;
cursor: pointer;
}
+3
View File
@@ -228,6 +228,9 @@ function switchTab(tabName) {
} else if (tabType === 'providers' && tabName === 'providers') {
// Static providers tab
btn.classList.add('active');
} else if (tabType === 'watchlist' && tabName === 'watchlist') {
// Static watchlist tab
btn.classList.add('active');
} else if (tabType === 'anime' && btn.getAttribute('data-provider') === tabName.replace('anime-', '')) {
btn.classList.add('active');
} else if (tabType === 'series' && btn.getAttribute('data-provider') === tabName.replace('series-', '')) {
+33 -2
View File
@@ -147,6 +147,7 @@ async function loadSeriesRecommendations() {
} else {
container.innerHTML = '<div class="no-results">Aucune recommandation trouvée</div>';
}
} catch (error) {
console.error('Error loading series recommendations:', error);
const container = document.getElementById('seriesRecommendationsList');
@@ -360,10 +361,22 @@ window.showDownloadInfo = showDownloadInfo;
document.addEventListener('DOMContentLoaded', () => {
// Wait for main.js to be loaded
setTimeout(() => {
// Watchlist auto-refresh interval
let watchlistRefreshInterval = null;
// Initialize watchlist tab flag
window.watchlistTabLoaded = false;
// Override switchTab to load content when opening new tabs
const originalSwitchTab = window.switchTab;
if (originalSwitchTab) {
window.switchTab = function(tabName) {
// Clear watchlist interval when switching away from watchlist
if (tabName !== 'watchlist' && watchlistRefreshInterval) {
clearInterval(watchlistRefreshInterval);
watchlistRefreshInterval = null;
}
// Call original switchTab first
originalSwitchTab(tabName);
@@ -386,8 +399,26 @@ document.addEventListener('DOMContentLoaded', () => {
window.providersTabLoaded = true;
}
} else if (tabName === 'watchlist') {
// Watchlist is handled by its own page
window.location.href = '/watchlist';
// Clear any existing interval before starting new one
if (watchlistRefreshInterval) {
clearInterval(watchlistRefreshInterval);
watchlistRefreshInterval = null;
}
if (!window.watchlistTabLoaded) {
// Load watchlist content
if (typeof displayWatchlist === 'function') {
displayWatchlist();
}
window.watchlistTabLoaded = true;
}
// Start 30-second auto-refresh interval for watchlist
if (typeof displayWatchlist === 'function') {
watchlistRefreshInterval = setInterval(() => {
displayWatchlist();
}, 30000);
}
}
}, 100);
};
+166
View File
@@ -321,6 +321,169 @@ async function handleCheckAll() {
}
}
/**
* Create settings modal HTML
*/
function createSettingsModal(settings) {
const modalHtml = `
<div id="settingsModal" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 1000;">
<div style="background: linear-gradient(135deg, #1e1e2e 0%, #2d1b69 100%); border-radius: 16px; padding: 30px; max-width: 500px; width: 90%; border: 1px solid rgba(0, 217, 255, 0.3);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px;">
<h2 style="margin: 0; color: #00d9ff;">⚙️ Paramètres Watchlist</h2>
<button onclick="closeSettingsModal()" style="background: none; border: none; color: #999; font-size: 24px; cursor: pointer;">×</button>
</div>
<div style="display: flex; flex-direction: column; gap: 20px;">
<!-- Check Interval -->
<div>
<label style="display: block; color: #fff; margin-bottom: 8px; font-weight: 500;">
🔄 Fréquence de vérification (heures)
</label>
<input type="number" id="checkInterval" value="${settings.check_interval_hours}" min="1" max="168"
style="width: 100%; padding: 10px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; color: #fff; font-size: 14px;">
<p style="font-size: 12px; color: #999; margin-top: 5px;">Entre 1 et 168 heures (1 semaine)</p>
</div>
<!-- Auto-download enabled -->
<div style="display: flex; align-items: center; justify-content: space-between;">
<div>
<div style="color: #fff; font-weight: 500;">📥 Téléchargement automatique</div>
<p style="font-size: 12px; color: #999; margin: 0;">Télécharger automatiquement les nouveaux épisodes</p>
</div>
<label class="switch">
<input type="checkbox" id="autoDownloadEnabled" ${settings.auto_download_enabled ? 'checked' : ''}>
<span class="slider"></span>
</label>
</div>
<!-- Max concurrent downloads -->
<div>
<label style="display: block; color: #fff; margin-bottom: 8px; font-weight: 500;">
⚡ Téléchargements simultanés max
</label>
<input type="number" id="maxConcurrent" value="${settings.max_concurrent_auto_downloads}" min="1" max="5"
style="width: 100%; padding: 10px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.2); border-radius: 8px; color: #fff; font-size: 14px;">
<p style="font-size: 12px; color: #999; margin-top: 5px;">Maximum 5 téléchargements en parallèle</p>
</div>
<!-- Notifications -->
<div style="display: flex; align-items: center; justify-content: space-between;">
<div>
<div style="color: #fff; font-weight: 500;">🔔 Notifications</div>
<p style="font-size: 12px; color: #999; margin: 0;">Être notifié des nouveaux épisodes</p>
</div>
<label class="switch">
<input type="checkbox" id="notifyEnabled" ${settings.notify_on_new_episodes ? 'checked' : ''}>
<span class="slider"></span>
</label>
</div>
</div>
<div style="display: flex; gap: 10px; margin-top: 30px;">
<button class="btn-primary modal-action-btn" onclick="saveSettings()">
💾 Enregistrer
</button>
<button class="btn-secondary modal-action-btn" onclick="closeSettingsModal()">
Annuler
</button>
</div>
</div>
</div>
<style>
.switch {
position: relative;
display: inline-block;
width: 50px;
height: 26px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255,255,255,0.2);
transition: .4s;
border-radius: 26px;
}
.slider:before {
position: absolute;
content: "";
height: 20px;
width: 20px;
left: 3px;
bottom: 3px;
background-color: white;
transition: .4s;
border-radius: 50%;
}
input:checked + .slider {
background-color: #00d9ff;
}
input:checked + .slider:before {
transform: translateX(24px);
}
</style>
`;
return modalHtml;
}
/**
* Close settings modal
*/
function closeSettingsModal() {
const modal = document.getElementById('settingsModal');
if (modal) {
modal.remove();
}
}
/**
* Save settings
*/
async function saveSettings() {
try {
const checkInterval = parseInt(document.getElementById('checkInterval').value);
const autoDownloadEnabled = document.getElementById('autoDownloadEnabled').checked;
const maxConcurrent = parseInt(document.getElementById('maxConcurrent').value);
const notifyEnabled = document.getElementById('notifyEnabled').checked;
const settings = {
check_interval_hours: checkInterval,
auto_download_enabled: autoDownloadEnabled,
max_concurrent_auto_downloads: maxConcurrent,
notify_on_new_episodes: notifyEnabled
};
await updateWatchlistSettings(settings);
// Restart scheduler if it's running to apply new interval
const status = await getSchedulerStatus();
if (status.running) {
await stopScheduler();
await startScheduler();
}
closeSettingsModal();
alert('✅ Paramètres enregistrés avec succès!');
await loadSchedulerStatus();
} catch (error) {
console.error('Error saving settings:', error);
alert(`❌ Erreur: ${error.message}`);
}
}
// Make functions available globally
window.displayWatchlist = displayWatchlist;
window.handleAddToWatchlist = handleAddToWatchlist;
@@ -329,3 +492,6 @@ window.handleResumeWatchlist = handleResumeWatchlist;
window.handleCheckItem = handleCheckItem;
window.handleDeleteWatchlist = handleDeleteWatchlist;
window.handleCheckAll = handleCheckAll;
window.createSettingsModal = createSettingsModal;
window.closeSettingsModal = closeSettingsModal;
window.saveSettings = saveSettings;