Actualiser js/admin.js
This commit is contained in:
+48
-9
@@ -392,9 +392,6 @@ async function openConfigModal() {
|
||||
|
||||
// Réinitialise les placeholders
|
||||
document.getElementById('tmdb-key-input').placeholder = 'Pour les critiques (réalisateur, streaming)';
|
||||
document.getElementById('worldcat-key-input').placeholder = 'Recherche par EAN/ISBN (Vidéothèque)';
|
||||
document.getElementById('amazon-key-input').placeholder = 'Recherche par code-barres (Vidéothèque)';
|
||||
document.getElementById('ebay-key-input').placeholder = 'Recherche par code-barres (Vidéothèque)';
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_URL}?action=get_config_keys`, {
|
||||
@@ -402,9 +399,6 @@ async function openConfigModal() {
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.tmdb_api_key) document.getElementById('tmdb-key-input').placeholder = '✅ Clé configurée (laisser vide pour ne pas changer)';
|
||||
if (data.worldcat_api_key) document.getElementById('worldcat-key-input').placeholder = '✅ Clé configurée (laisser vide pour ne pas changer)';
|
||||
if (data.amazon_api_key) document.getElementById('amazon-key-input').placeholder = '✅ Clé configurée (laisser vide pour ne pas changer)';
|
||||
if (data.ebay_api_key) document.getElementById('ebay-key-input').placeholder = '✅ Clé configurée (laisser vide pour ne pas changer)';
|
||||
} catch(e) { console.error(e); }
|
||||
}
|
||||
function closeConfigModal() { document.getElementById('config-modal').classList.remove('open'); }
|
||||
@@ -495,9 +489,6 @@ async function handleCsvUpload(input) {
|
||||
async function saveConfigKeys() {
|
||||
const keys = {
|
||||
'tmdb_api_key': document.getElementById('tmdb-key-input')?.value || '',
|
||||
'worldcat_api_key': document.getElementById('worldcat-key-input')?.value || '',
|
||||
'amazon_api_key': document.getElementById('amazon-key-input')?.value || '',
|
||||
'ebay_api_key': document.getElementById('ebay-key-input')?.value || ''
|
||||
};
|
||||
|
||||
let successCount = 0;
|
||||
@@ -572,3 +563,51 @@ function updateProgressModal(current, total) {
|
||||
function closeProgressModal() {
|
||||
document.getElementById('progress-overlay').classList.remove('open');
|
||||
}
|
||||
|
||||
// --- NOUVELLE FONCTION RECHERCHE EAN (UPCitemDB + TMDB) ---
|
||||
async function fetchInfoFromEAN() {
|
||||
const eanInput = document.getElementById('f-ean');
|
||||
const ean = eanInput.value.trim();
|
||||
|
||||
if (!ean || ean.length < 8) {
|
||||
alert("Veuillez saisir un code EAN valide.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Feedback visuel de chargement
|
||||
const btn = eanInput.nextElementSibling;
|
||||
const originalHtml = btn.innerHTML;
|
||||
btn.innerHTML = '<i class="ti ti-loader"></i>';
|
||||
btn.disabled = true;
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_URL}?action=search_ean_full&ean=${ean}`, {
|
||||
headers: { 'Authorization': localStorage.getItem('token') }
|
||||
});
|
||||
const json = await res.json();
|
||||
|
||||
if (json.success && json.data) {
|
||||
const d = json.data;
|
||||
// Remplissage automatique des champs
|
||||
if (d.title) document.getElementById('f-title').value = d.title;
|
||||
if (d.director) document.getElementById('f-director').value = d.director;
|
||||
if (d.year) document.getElementById('f-year').value = d.year;
|
||||
if (d.poster) document.getElementById('f-poster').value = d.poster;
|
||||
if (d.publisher) document.getElementById('f-publisher').value = d.publisher;
|
||||
if (d.format) document.getElementById('f-format').value = d.format;
|
||||
if (d.length) document.getElementById('f-length').value = d.length;
|
||||
if (d.number_of_discs) document.getElementById('f-discs').value = d.number_of_discs;
|
||||
if (d.aspect_ratio) document.getElementById('f-aspect').value = d.aspect_ratio;
|
||||
|
||||
} else {
|
||||
alert("Aucune information trouvée pour ce code EAN.");
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Erreur de recherche EAN:", e);
|
||||
alert("Erreur réseau lors de la recherche du code EAN.");
|
||||
} finally {
|
||||
// Restaure le bouton
|
||||
btn.innerHTML = originalHtml;
|
||||
btn.disabled = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user