v1.5.9 (Actuel)
This commit is contained in:
+288
-6
@@ -1,4 +1,5 @@
|
||||
<%- include('partials/header') %>
|
||||
<script src="/sortable.min.js"></script>
|
||||
<%- include('partials/sidebar') %>
|
||||
|
||||
<main class="content-wrapper">
|
||||
@@ -7,6 +8,25 @@
|
||||
<h2>Paramètres</h2>
|
||||
</div>
|
||||
|
||||
<% if (typeof currentUser !== 'undefined' && currentUser && currentUser.role === 'admin') { %>
|
||||
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
|
||||
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; justify-content: space-between;">
|
||||
<span style="display: flex; align-items: center; gap: 8px;"><i data-lucide="refresh-cw"></i> Système & Mises à jour</span>
|
||||
<span style="font-size: 0.75rem; background: rgba(255,255,255,0.1); padding: 4px 8px; border-radius: 4px; font-family: monospace;">v<%= appVersion %></span>
|
||||
</h3>
|
||||
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
|
||||
Vérifiez si une nouvelle version d'Agora est disponible et consultez les instructions de mise à jour.
|
||||
</p>
|
||||
<button id="check-update-btn" class="btn-action" style="padding: 10px 20px; display: flex; align-items: center; justify-content: center; gap: 8px;">
|
||||
<i data-lucide="download-cloud" style="width: 16px; height: 16px;"></i> Vérifier les mises à jour
|
||||
</button>
|
||||
|
||||
<div id="update-results-container" style="display: none; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px dashed var(--border);">
|
||||
<!-- Injecté par JS -->
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
|
||||
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
|
||||
<i data-lucide="database"></i> Sources de Recherche
|
||||
@@ -26,14 +46,113 @@
|
||||
<div id="sources-sortable-container" style="display: flex; flex-direction: column; gap: 10px; margin-bottom: 1rem;">
|
||||
<!-- Les sources ordonnables seront injectées ici par JS -->
|
||||
</div>
|
||||
|
||||
<p id="primary-source-warning" style="font-size: 0.8rem; color: #f59e0b; margin-top: 12px; display: none; align-items: center; gap: 6px; font-weight: 500; background: rgba(245, 158, 11, 0.1); padding: 8px 12px; border-radius: 6px; border: 1px solid rgba(245, 158, 11, 0.2);">
|
||||
<i data-lucide="alert-triangle" style="width: 16px; height: 16px; flex-shrink: 0;"></i>
|
||||
Hydracker est la première source active. Elle peut être très lente à répondre.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if (typeof currentUser !== 'undefined' && currentUser && currentUser.role === 'admin') { %>
|
||||
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
|
||||
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
|
||||
<i data-lucide="server"></i> Hébergeurs Préférés
|
||||
</h3>
|
||||
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
|
||||
Glissez et déposez les hébergeurs pour définir leur ordre de préférence. Les liens de téléchargement seront triés selon cet ordre.
|
||||
</p>
|
||||
<div id="hosters-sortable-container" style="display: flex; flex-direction: column; gap: 10px; margin-bottom: 1rem;">
|
||||
<% if (typeof preferredHosters !== 'undefined' && preferredHosters.length > 0) { %>
|
||||
<% preferredHosters.forEach(function(hoster) {
|
||||
const h = hoster.toLowerCase();
|
||||
let domain = h + '.com';
|
||||
if (h === 'turbobit') domain = 'turbobit.net';
|
||||
if (h === 'rapidgator') domain = 'rapidgator.net';
|
||||
if (h === 'mega') domain = 'mega.nz';
|
||||
if (h === 'gofile') domain = 'gofile.io';
|
||||
if (h === 'nitroflare') domain = 'nitroflare.com';
|
||||
%>
|
||||
<div class="sortable-item" data-hoster="<%= hoster %>" style="display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--bg-main); border: 1px solid var(--border); border-radius: 8px; cursor: grab;">
|
||||
<div style="display: flex; align-items: center; gap: 12px;">
|
||||
<i data-lucide="grip-vertical" style="color: var(--text-sec); width: 18px; height: 18px;"></i>
|
||||
<img src="https://www.google.com/s2/favicons?domain=<%= domain %>&sz=32" alt="logo" style="width: 20px; height: 20px; border-radius: 4px;" onerror="this.style.display='none'; this.nextElementSibling.style.display='inline-block';">
|
||||
<i data-lucide="server" style="color: var(--text-sec); width: 18px; height: 18px; display: none;"></i>
|
||||
<span style="font-weight: 500; text-transform: capitalize;"><%= hoster %></span>
|
||||
</div>
|
||||
</div>
|
||||
<% }); %>
|
||||
<% } %>
|
||||
</div>
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<button id="save-hosters-btn" class="btn-action" style="padding: 10px 20px; display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1;">
|
||||
<i data-lucide="save" style="width: 16px; height: 16px;"></i> Enregistrer l'ordre
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
|
||||
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; display: flex; align-items: center; gap: 8px;">
|
||||
<i data-lucide="plug"></i> Configuration des Plugins
|
||||
</h3>
|
||||
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 1rem;">
|
||||
Modifiez les adresses et clés d'accès des plugins. Les modifications seront appliquées immédiatement sans redémarrage.
|
||||
</p>
|
||||
|
||||
<form id="plugins-config-form">
|
||||
<% if (typeof pluginsToConfigure !== 'undefined' && pluginsToConfigure.length > 0) { %>
|
||||
<% pluginsToConfigure.forEach(function(plugin) { %>
|
||||
<div style="background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem;">
|
||||
<strong style="display: flex; align-items: center; gap: 6px; margin-bottom: 0.8rem; color: var(--text-main); font-size: 0.95rem; text-transform: capitalize;">
|
||||
<i data-lucide="box" style="width: 14px; height: 14px; color: var(--text-sec);"></i>
|
||||
<%= plugin.name %>
|
||||
</strong>
|
||||
<%
|
||||
const urlField = plugin.fields.find(f => f.key.endsWith('_URL'));
|
||||
const urlEmpty = urlField && !urlField.default;
|
||||
%>
|
||||
|
||||
<% if (plugin.name.includes('TMDB')) { %>
|
||||
<p style="font-size: 0.85rem; color: var(--text-sec); margin-bottom: 12px; margin-top: -8px;">
|
||||
<i data-lucide="info" style="width: 14px; height: 14px; vertical-align: middle;"></i>
|
||||
Pour obtenir une clé d'API, créez un compte gratuit sur <a href="https://www.themoviedb.org/settings/api" target="_blank" style="color: var(--primary);">themoviedb.org</a>, générez une clé (API v3 Auth) et collez-la ci-dessous.
|
||||
</p>
|
||||
<% plugin.fields.forEach(function(field) { %>
|
||||
<div style="margin-bottom: 0.8rem;">
|
||||
<label for="config_<%= field.key %>" style="font-size: 0.8rem; color: var(--text-sec); margin-bottom: 4px; display: block;"><%= field.label %></label>
|
||||
<% if (field.key.endsWith('_ENABLED') || field.key === 'JD_FORCED_START') { %>
|
||||
<select id="config_<%= field.key %>" name="<%= field.key %>" style="width: 100%; padding: 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 6px; color: var(--text-main); font-size: 0.9rem;">
|
||||
<option value="true" <%= field.default === 'true' ? 'selected' : '' %>>Activé</option>
|
||||
<option value="false" <%= field.default === 'false' ? 'selected' : '' %>>Désactivé</option>
|
||||
</select>
|
||||
<% } else { %>
|
||||
<input type="text" id="config_<%= field.key %>" name="<%= field.key %>"
|
||||
placeholder="<%= field.placeholder %>" value="<%= field.default || '' %>"
|
||||
style="width: 100%; padding: 10px; background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 6px; color: var(--text-main); font-size: 0.9rem;">
|
||||
<% } %>
|
||||
</div>
|
||||
<% }); %>
|
||||
<% } else { %>
|
||||
<% plugin.fields.forEach(function(field) { %>
|
||||
<div style="margin-bottom: 0.8rem;">
|
||||
<label for="config_<%= field.key %>" style="font-size: 0.8rem; color: var(--text-sec); margin-bottom: 4px; display: block;"><%= field.label %></label>
|
||||
<input type="text" id="config_<%= field.key %>" name="<%= field.key %>"
|
||||
placeholder="<%= field.placeholder %>" value="<%= field.default || '' %>"
|
||||
data-is-url="<%= field.key.endsWith('_URL') ? 'true' : 'false' %>"
|
||||
data-plugin="<%= plugin.name %>"
|
||||
style="padding: 8px; font-size: 0.9rem; width: 100%; border: 1px solid var(--border); background: var(--bg-main); color: var(--text-main); border-radius: 6px;">
|
||||
</div>
|
||||
<% }); %>
|
||||
<% } %>
|
||||
</div>
|
||||
<% }); %>
|
||||
<div style="display: flex; gap: 10px;">
|
||||
<button type="submit" class="btn-action" style="padding: 10px 20px; display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1;">
|
||||
<i data-lucide="save" style="width: 16px; height: 16px;"></i> Enregistrer & Recharger
|
||||
</button>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<p style="font-size: 0.85rem; color: var(--text-sec);">Aucun plugin détecté.</p>
|
||||
<% } %>
|
||||
</form>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div class="form-card" style="max-width: 750px; margin: 0 auto 1.5rem auto;">
|
||||
<h3 style="margin-bottom: 1rem; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;">
|
||||
Page d'accueil par défaut</h3>
|
||||
@@ -118,10 +237,173 @@
|
||||
<div style="text-align: center; margin-top: 3rem; margin-bottom: 1rem;">
|
||||
<p style="font-size: 0.85rem; color: var(--text-sec); display: inline-flex; align-items: center; gap: 6px; background: var(--bg-card); padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);">
|
||||
<i data-lucide="info" style="width: 14px; height: 14px;"></i>
|
||||
Hydr'Hacked v1.4.8
|
||||
Agora v<%= appVersion %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// --- Plugins Config Form ---
|
||||
const form = document.getElementById('plugins-config-form');
|
||||
if (form) {
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const btn = form.querySelector('button[type="submit"]');
|
||||
const origHtml = btn.innerHTML;
|
||||
btn.innerHTML = '<i data-lucide="loader-2" class="spin" style="width: 16px; height: 16px;"></i> Enregistrement...';
|
||||
btn.disabled = true;
|
||||
if (window.lucide) lucide.createIcons();
|
||||
|
||||
const fd = new FormData(form);
|
||||
const config = Object.fromEntries(fd.entries());
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/admin/plugins/save', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ config })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
window.showModal(
|
||||
'Succès',
|
||||
`<div style="padding: 1rem; text-align: center; color: var(--text-main);">
|
||||
<i data-lucide="check-circle" style="color: #10b981; width: 48px; height: 48px; margin-bottom: 1rem;"></i>
|
||||
<p>Configuration enregistrée avec succès.</p>
|
||||
<p style="font-size: 0.9rem; color: var(--text-sec); margin-top: 0.5rem;">Plugins actifs : ${data.activeSources.join(', ')}</p>
|
||||
</div>`
|
||||
);
|
||||
if (window.lucide) lucide.createIcons();
|
||||
setTimeout(() => window.location.reload(), 2000);
|
||||
} else {
|
||||
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>${data.error}</p></div>`);
|
||||
}
|
||||
} catch (err) {
|
||||
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>Erreur lors de la sauvegarde.</p></div>`);
|
||||
console.error(err);
|
||||
} finally {
|
||||
btn.innerHTML = origHtml;
|
||||
btn.disabled = false;
|
||||
if (window.lucide) lucide.createIcons();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// --- Hosters Sorting ---
|
||||
const hostersContainer = document.getElementById('hosters-sortable-container');
|
||||
if (hostersContainer) {
|
||||
Sortable.create(hostersContainer, {
|
||||
animation: 150,
|
||||
handle: '.sortable-item', // Permet de draguer sur tout l'item
|
||||
ghostClass: 'dragging-hoster', // Classe appliquée pendant le drag
|
||||
});
|
||||
|
||||
document.getElementById('save-hosters-btn')?.addEventListener('click', async (e) => {
|
||||
const btn = e.currentTarget;
|
||||
const origHtml = btn.innerHTML;
|
||||
btn.innerHTML = '<i data-lucide="loader-2" class="spin" style="width: 16px; height: 16px;"></i> Enregistrement...';
|
||||
btn.disabled = true;
|
||||
if (window.lucide) lucide.createIcons();
|
||||
|
||||
const order = Array.from(hostersContainer.querySelectorAll('.sortable-item')).map(el => el.dataset.hoster);
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/admin/hosters/save', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ preferredHosters: order })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
window.showModal(
|
||||
'Succès',
|
||||
`<div style="padding: 1rem; text-align: center; color: var(--text-main);">
|
||||
<i data-lucide="check-circle" style="color: #10b981; width: 48px; height: 48px; margin-bottom: 1rem;"></i>
|
||||
<p>Ordre des hébergeurs enregistré avec succès !</p>
|
||||
</div>`
|
||||
);
|
||||
if (window.lucide) lucide.createIcons();
|
||||
} else {
|
||||
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>${data.error}</p></div>`);
|
||||
}
|
||||
} catch (err) {
|
||||
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>Erreur réseau lors de la sauvegarde.</p></div>`);
|
||||
} finally {
|
||||
btn.innerHTML = origHtml;
|
||||
btn.disabled = false;
|
||||
if (window.lucide) lucide.createIcons();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// --- Updates Checking ---
|
||||
const checkUpdateBtn = document.getElementById('check-update-btn');
|
||||
if (checkUpdateBtn) {
|
||||
checkUpdateBtn.addEventListener('click', async () => {
|
||||
const btn = checkUpdateBtn;
|
||||
const origHtml = btn.innerHTML;
|
||||
btn.innerHTML = '<i data-lucide="loader-2" class="spin" style="width: 16px; height: 16px;"></i> Vérification...';
|
||||
btn.disabled = true;
|
||||
if (window.lucide) lucide.createIcons();
|
||||
|
||||
const container = document.getElementById('update-results-container');
|
||||
container.style.display = 'none';
|
||||
container.innerHTML = '';
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/admin/check-update');
|
||||
const data = await res.json();
|
||||
|
||||
if (data.success) {
|
||||
container.style.display = 'block';
|
||||
|
||||
const isNew = data.currentVersion !== data.latestVersion;
|
||||
let html = '';
|
||||
if (isNew) {
|
||||
html += `<div style="background: rgba(16, 185, 129, 0.1); border: 1px solid #10b981; padding: 12px; border-radius: 6px; margin-bottom: 1rem; color: #10b981; font-weight: 600; display: flex; align-items: center; gap: 8px;">
|
||||
<i data-lucide="party-popper" style="width: 20px; height: 20px;"></i> Nouvelle version disponible : ${data.latestVersion} !
|
||||
</div>`;
|
||||
} else {
|
||||
html += `<div style="background: rgba(255, 255, 255, 0.05); border: 1px solid var(--border); padding: 12px; border-radius: 6px; margin-bottom: 1rem; color: var(--text-main); font-weight: 500; display: flex; align-items: center; gap: 8px;">
|
||||
<i data-lucide="check-circle" style="color: #10b981; width: 20px; height: 20px;"></i> Votre système est à jour (v${data.currentVersion}).
|
||||
</div>`;
|
||||
}
|
||||
|
||||
if (data.notes && data.notes.length > 0) {
|
||||
html += `<h4 style="margin-bottom: 8px; font-size: 0.9rem;">Nouveautés :</h4><ul style="margin: 0 0 1rem 0; padding-left: 20px; color: var(--text-sec); font-size: 0.85rem; line-height: 1.5;">`;
|
||||
data.notes.forEach(n => html += `<li>${n}</li>`);
|
||||
html += `</ul>`;
|
||||
}
|
||||
|
||||
html += `<h4 style="margin-bottom: 8px; font-size: 0.9rem;">Comment mettre à jour :</h4>
|
||||
<div style="display: flex; flex-direction: column; gap: 10px;">
|
||||
<div style="background: var(--bg-main); padding: 12px; border-radius: 6px; border: 1px solid var(--border);">
|
||||
<strong style="display: block; font-size: 0.8rem; color: var(--primary); margin-bottom: 4px;">Via Docker</strong>
|
||||
<code style="font-size: 0.85rem; color: var(--text-main); user-select: all; cursor: text;">${data.updateInfo.dockerCmd}</code>
|
||||
</div>
|
||||
<div style="background: var(--bg-main); padding: 12px; border-radius: 6px; border: 1px solid var(--border);">
|
||||
<strong style="display: block; font-size: 0.8rem; color: var(--primary); margin-bottom: 4px;">Installation Manuelle (.zip)</strong>
|
||||
<a href="${data.updateInfo.zipUrl}" target="_blank" style="font-size: 0.85rem; color: var(--text-main); text-decoration: underline;">Télécharger l'archive depuis le site</a>
|
||||
${data.updateInfo.zipSha256 ? `<div style="margin-top: 8px; font-size: 0.8rem; color: var(--text-muted);">Somme de contrôle (SHA-256) :<br><code style="font-size: 0.75rem; user-select: all; background: rgba(0,0,0,0.2); padding: 2px 4px; border-radius: 4px; word-break: break-all;">${data.updateInfo.zipSha256}</code></div>` : ''}
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
container.innerHTML = html;
|
||||
} else {
|
||||
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>${data.error}</p></div>`);
|
||||
}
|
||||
} catch (err) {
|
||||
window.showModal('Erreur', `<div style="padding: 1rem; text-align: center; color: #ef4444;"><p>Erreur réseau lors de la vérification.</p></div>`);
|
||||
} finally {
|
||||
btn.innerHTML = origHtml;
|
||||
btn.disabled = false;
|
||||
if (window.lucide) lucide.createIcons();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</section>
|
||||
</main>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user