mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-06-25 16:19:19 +02:00
Fix dialog margins, add admin-dialog__body/styles, give trash page horizontal margins
This commit is contained in:
@@ -37,6 +37,12 @@ document.addEventListener('htmx:afterSwap',()=>{document.querySelectorAll('input
|
||||
Corbeille (<?= $trashCount ?>)
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ($tmpTotalCount > 0): ?>
|
||||
<button type="button" class="btn btn--sm btn--secondary" id="tmp-cleanup-btn"
|
||||
onclick="document.getElementById('tmp-cleanup-dialog').showModal(); fetchTmpStats()">
|
||||
Nettoyer (<?= $tmpTotalCount ?>)
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<button type="button" class="btn btn--primary btn--sm" id="import-dialog-btn"
|
||||
onclick="document.getElementById('import-dialog').showModal()">
|
||||
Importer
|
||||
@@ -275,6 +281,125 @@ document.addEventListener('htmx:afterSwap',()=>{document.querySelectorAll('input
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<!-- ══════════════════════════════════════════════════════════════
|
||||
TMP CLEANUP DIALOG
|
||||
══════════════════════════════════════════════════════════════ -->
|
||||
<dialog id="tmp-cleanup-dialog" class="admin-dialog admin-dialog--sm" aria-labelledby="tmp-cleanup-title">
|
||||
<div class="admin-dialog__header">
|
||||
<h2 id="tmp-cleanup-title">Nettoyer les fichiers temporaires</h2>
|
||||
<button type="button" class="admin-dialog__close" aria-label="Fermer"
|
||||
onclick="document.getElementById('tmp-cleanup-dialog').close()">✕</button>
|
||||
</div>
|
||||
<div class="admin-dialog__body">
|
||||
<p>Les fichiers temporaires s'accumulent lorsque des téléversements sont abandonnés (formulaire fermé avant envoi).</p>
|
||||
<div id="tmp-cleanup-stats" class="admin-dialog__stats">
|
||||
Chargement…
|
||||
</div>
|
||||
<p class="admin-dialog__hint">
|
||||
Seuls les fichiers de plus de 2 heures (FilePond) et 30 jours (corbeille) seront supprimés.
|
||||
Les téléversements récents sont conservés.
|
||||
</p>
|
||||
|
||||
<div id="tmp-cleanup-result" style="display:none"></div>
|
||||
</div>
|
||||
<div class="admin-dialog__footer">
|
||||
<button type="button" class="btn btn--danger" id="tmp-cleanup-confirm"
|
||||
onclick="executeTmpCleanup()">
|
||||
Nettoyer
|
||||
</button>
|
||||
<button type="button" class="btn btn--secondary"
|
||||
onclick="document.getElementById('tmp-cleanup-dialog').close()">Annuler</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
async function fetchTmpStats() {
|
||||
const el = document.getElementById('tmp-cleanup-stats');
|
||||
try {
|
||||
const resp = await fetch('/admin/actions/cleanup-stats.php');
|
||||
const data = await resp.json();
|
||||
let html = '';
|
||||
const totalStale = data.filepond_stale_count + data.trash_stale_count;
|
||||
|
||||
if (totalStale === 0) {
|
||||
html = '<p style="margin:0;color:var(--accent-green)">✓ Aucun fichier obsolète à nettoyer.</p>';
|
||||
if ((data.filepond_active_count || 0) + (data.trash_active_count || 0) > 0) {
|
||||
html += '<p style="margin:var(--space-xs) 0 0 0;font-size:0.85em;color:var(--text-secondary)">';
|
||||
if (data.filepond_active_count) html += `📁 ${data.filepond_active_count} téléversement(s) actif(s) (session existante) — ${data.filepond_active_human}<br>`;
|
||||
if (data.trash_active_count) html += `🗑️ ${data.trash_active_count} fichier(s) récent(s) en corbeille — ${data.trash_active_human}`;
|
||||
html += '</p>';
|
||||
}
|
||||
} else {
|
||||
html = `<p style="margin:0 0 var(--space-xs) 0;font-weight:600">⚠️ ${totalStale} élément(s) obsolète(s) à nettoyer :</p>`;
|
||||
if (data.filepond_stale_count) html += `<p style="margin:0 0 var(--space-xs) 0">📁 <strong>Téléversements abandonnés</strong> : ${data.filepond_stale_count} dossier(s) — ${data.filepond_stale_human} <span style="font-size:0.85em;color:var(--text-secondary)">(session expirée ou >2h)</span></p>`;
|
||||
if (data.trash_stale_count) html += `<p style="margin:0 0 var(--space-xs) 0">🗑️ <strong>Fichiers supprimés orphelins</strong> : ${data.trash_stale_count} fichier(s) — ${data.trash_stale_human} <span style="font-size:0.85em;color:var(--text-secondary)">(référence DB disparue ou >30j)</span></p>`;
|
||||
if (data.filepond_active_count || data.trash_active_count) {
|
||||
html += '<p style="margin:var(--space-xs) 0 0 0;font-size:0.85em;color:var(--text-secondary)">Conservés : ';
|
||||
if (data.filepond_active_count) html += `${data.filepond_active_count} téléversement(s) actif(s), `;
|
||||
if (data.trash_active_count) html += `${data.trash_active_count} fichier(s) récent(s)`;
|
||||
html += '</p>';
|
||||
}
|
||||
}
|
||||
el.innerHTML = html;
|
||||
|
||||
if (totalStale === 0) {
|
||||
document.getElementById('tmp-cleanup-confirm').disabled = true;
|
||||
document.getElementById('tmp-cleanup-confirm').textContent = 'Rien à nettoyer';
|
||||
}
|
||||
} catch (e) {
|
||||
el.textContent = 'Erreur lors du chargement des statistiques.';
|
||||
}
|
||||
}
|
||||
|
||||
async function executeTmpCleanup() {
|
||||
const btn = document.getElementById('tmp-cleanup-confirm');
|
||||
const result = document.getElementById('tmp-cleanup-result');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Nettoyage…';
|
||||
try {
|
||||
const resp = await fetch('/admin/actions/cleanup-tmp.php', {
|
||||
method: 'POST',
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||
body: 'csrf_token=' + encodeURIComponent('<?= htmlspecialchars($_SESSION['csrf_token']) ?>')
|
||||
});
|
||||
const data = await resp.json();
|
||||
result.style.display = 'block';
|
||||
if (data.success) {
|
||||
const total = data.filepond_removed + data.trash_removed;
|
||||
if (total === 0) {
|
||||
result.className = 'flash-success';
|
||||
result.innerHTML = '✓ Aucun fichier obsolète trouvé.';
|
||||
} else {
|
||||
result.className = 'flash-success';
|
||||
let msg = `✓ ${total} élément(s) supprimé(s) : `;
|
||||
if (data.filepond_removed) msg += `${data.filepond_removed} téléversement(s) abandonné(s), `;
|
||||
if (data.trash_removed) msg += `${data.trash_removed} fichier(s) orphelin(s)`;
|
||||
result.innerHTML = msg;
|
||||
if (data.details && data.details.length > 0) {
|
||||
result.innerHTML += '<details style="margin-top:var(--space-xs);font-size:0.85em"><summary>Détails (' + data.details.length + ')</summary><ul style="margin:var(--space-xs) 0 0 var(--space-md)">' +
|
||||
data.details.map(d => '<li>' + d + '</li>').join('') + '</ul></details>';
|
||||
}
|
||||
}
|
||||
setTimeout(() => {
|
||||
document.getElementById('tmp-cleanup-dialog').close();
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
} else {
|
||||
result.className = 'flash-error';
|
||||
result.textContent = 'Erreur : ' + (data.error || 'inconnue');
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Réessayer';
|
||||
}
|
||||
} catch (e) {
|
||||
result.style.display = 'block';
|
||||
result.className = 'flash-error';
|
||||
result.textContent = 'Erreur réseau.';
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Réessayer';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php if ($importMessage || !empty($importErrors)): ?>
|
||||
<script>document.getElementById('import-dialog').showModal();</script>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user