Actualiser js/admin.js

This commit is contained in:
2026-06-25 16:22:23 +02:00
parent d3777007f1
commit 0068a2b722
+38 -7
View File
@@ -337,8 +337,18 @@ async function openConfigModal() {
try { try {
const res = await fetch(`${API_URL}?action=get_config_keys`, { headers: { 'Authorization': localStorage.getItem('token') } }); const res = await fetch(`${API_URL}?action=get_config_keys`, { headers: { 'Authorization': localStorage.getItem('token') } });
const data = await res.json(); const data = await res.json();
document.getElementById('tmdb-key-input').value = '';
document.getElementById('tmdb-key-input').placeholder = data.tmdb_api_key ? '✅ Clé configurée (laisser vide pour garder)' : 'Entrez votre clé TMDB'; const tmdbInput = document.getElementById('tmdb-key-input');
if (tmdbInput) {
tmdbInput.value = '';
tmdbInput.placeholder = data.tmdb_api_key ? '✅ Clé TMDB configurée (laisser vide pour garder)' : 'Entrez votre clé TMDB';
}
const fanartInput = document.getElementById('fanart-key-input');
if (fanartInput) {
fanartInput.value = '';
fanartInput.placeholder = data.fanart_api_key ? '✅ Clé Fanart.tv configurée (laisser vide pour garder)' : 'Entrez votre clé Fanart.tv';
}
} catch(e) { console.error(e); } } catch(e) { console.error(e); }
} }
@@ -477,12 +487,33 @@ function updateImportModal(current, total) {
function closeImportModal() { document.getElementById('import-progress-modal').classList.remove('open'); } function closeImportModal() { document.getElementById('import-progress-modal').classList.remove('open'); }
async function saveConfigKeys() { async function saveConfigKeys() {
const keyValue = document.getElementById('tmdb-key-input').value.trim(); const tmdbKeyValue = document.getElementById('tmdb-key-input').value.trim();
if (!keyValue) { closeConfigModal(); return; } const fanartKeyValue = document.getElementById('fanart-key-input').value.trim();
try { try {
await fetch(`${API_URL}?action=save_config`, { method: 'POST', headers: { 'Authorization': localStorage.getItem('token'), 'Content-Type': 'application/json' }, body: JSON.stringify({ key_name: 'tmdb_api_key', key_value: keyValue }) }); if (tmdbKeyValue) {
alert('✅ Clé sauvegardée !'); closeConfigModal(); await fetch(`${API_URL}?action=save_config`, {
} catch (err) { alert('Erreur serveur.'); } method: 'POST',
headers: { 'Authorization': localStorage.getItem('token'), 'Content-Type': 'application/json' },
body: JSON.stringify({ key_name: 'tmdb_api_key', key_value: tmdbKeyValue })
});
}
if (fanartKeyValue) {
await fetch(`${API_URL}?action=save_config`, {
method: 'POST',
headers: { 'Authorization': localStorage.getItem('token'), 'Content-Type': 'application/json' },
body: JSON.stringify({ key_name: 'fanart_api_key', key_value: fanartKeyValue })
});
}
if (tmdbKeyValue || fanartKeyValue) {
alert('✅ Clés sauvegardées !');
}
closeConfigModal();
} catch (err) {
alert('Erreur serveur.');
}
} }
async function saveNewPassword() { async function saveNewPassword() {