Actualiser js/admin.js
This commit is contained in:
+38
-7
@@ -337,8 +337,18 @@ async function openConfigModal() {
|
||||
try {
|
||||
const res = await fetch(`${API_URL}?action=get_config_keys`, { headers: { 'Authorization': localStorage.getItem('token') } });
|
||||
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); }
|
||||
}
|
||||
|
||||
@@ -477,12 +487,33 @@ function updateImportModal(current, total) {
|
||||
function closeImportModal() { document.getElementById('import-progress-modal').classList.remove('open'); }
|
||||
|
||||
async function saveConfigKeys() {
|
||||
const keyValue = document.getElementById('tmdb-key-input').value.trim();
|
||||
if (!keyValue) { closeConfigModal(); return; }
|
||||
const tmdbKeyValue = document.getElementById('tmdb-key-input').value.trim();
|
||||
const fanartKeyValue = document.getElementById('fanart-key-input').value.trim();
|
||||
|
||||
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 }) });
|
||||
alert('✅ Clé sauvegardée !'); closeConfigModal();
|
||||
} catch (err) { alert('Erreur serveur.'); }
|
||||
if (tmdbKeyValue) {
|
||||
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: 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() {
|
||||
|
||||
Reference in New Issue
Block a user