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() {
|
async function openConfigModal() {
|
||||||
document.getElementById('config-modal').classList.add('open');
|
document.getElementById('config-modal').classList.add('open');
|
||||||
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();
|
||||||
|
|
||||||
const tmdbInput = document.getElementById('tmdb-key-input');
|
const tmdbInput = document.getElementById('tmdb-key-input');
|
||||||
@@ -494,7 +496,10 @@ async function saveConfigKeys() {
|
|||||||
if (tmdbKeyValue) {
|
if (tmdbKeyValue) {
|
||||||
await fetch(`${API_URL}?action=save_config`, {
|
await fetch(`${API_URL}?action=save_config`, {
|
||||||
method: 'POST',
|
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 })
|
body: JSON.stringify({ key_name: 'tmdb_api_key', key_value: tmdbKeyValue })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -502,14 +507,15 @@ async function saveConfigKeys() {
|
|||||||
if (fanartKeyValue) {
|
if (fanartKeyValue) {
|
||||||
await fetch(`${API_URL}?action=save_config`, {
|
await fetch(`${API_URL}?action=save_config`, {
|
||||||
method: 'POST',
|
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 })
|
body: JSON.stringify({ key_name: 'fanart_api_key', key_value: fanartKeyValue })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tmdbKeyValue || fanartKeyValue) {
|
|
||||||
alert('✅ Clés sauvegardées !');
|
alert('✅ Clés sauvegardées !');
|
||||||
}
|
|
||||||
closeConfigModal();
|
closeConfigModal();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert('Erreur serveur.');
|
alert('Erreur serveur.');
|
||||||
|
|||||||
Reference in New Issue
Block a user