Actualiser js/admin.js
This commit is contained in:
+11
-5
@@ -335,7 +335,9 @@ function closeAdminModal() { document.getElementById('admin-modal').classList.re
|
||||
async function openConfigModal() {
|
||||
document.getElementById('config-modal').classList.add('open');
|
||||
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 tmdbInput = document.getElementById('tmdb-key-input');
|
||||
@@ -494,7 +496,10 @@ async function saveConfigKeys() {
|
||||
if (tmdbKeyValue) {
|
||||
await fetch(`${API_URL}?action=save_config`, {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': localStorage.getItem('token'), 'Content-Type': 'application/json' },
|
||||
headers: {
|
||||
'Authorization': localStorage.getItem('token'),
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ key_name: 'tmdb_api_key', key_value: tmdbKeyValue })
|
||||
});
|
||||
}
|
||||
@@ -502,14 +507,15 @@ async function saveConfigKeys() {
|
||||
if (fanartKeyValue) {
|
||||
await fetch(`${API_URL}?action=save_config`, {
|
||||
method: 'POST',
|
||||
headers: { 'Authorization': localStorage.getItem('token'), 'Content-Type': 'application/json' },
|
||||
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.');
|
||||
|
||||
Reference in New Issue
Block a user