Gallery: add prune button (behold 100), webhook automation, shell_command
This commit is contained in:
@@ -56,6 +56,9 @@ html = f"""<!DOCTYPE html>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Expires" content="0">
|
||||
<style>
|
||||
.prune-btn{{display:inline-block;margin-left:12px;padding:3px 10px;font-size:11px;border:1px solid #c44;background:transparent;color:#c88;border-radius:12px;cursor:pointer;vertical-align:middle;transition:background .15s,color .15s}}
|
||||
.prune-btn:hover{{background:#c44;color:#fff}}
|
||||
.prune-btn:disabled{{opacity:.4;cursor:default}}
|
||||
*{{box-sizing:border-box;margin:0;padding:0}}
|
||||
body{{background:#111;color:#ddd;font-family:sans-serif;padding:10px}}
|
||||
h2{{padding:8px 0 14px;font-size:13px;opacity:.5;font-weight:normal}}
|
||||
@@ -79,7 +82,9 @@ html = f"""<!DOCTYPE html>
|
||||
.reload-badge{{position:fixed;bottom:14px;right:14px;background:#1a73e8;color:#fff;padding:6px 14px;border-radius:20px;font-size:12px;cursor:pointer;display:none;z-index:9998}}
|
||||
</style>
|
||||
</head><body>
|
||||
<h2>Viser {len(files)} person-snapshots – Indkorsel</h2>
|
||||
<h2>Viser {len(files)} person-snapshots – Indkorsel
|
||||
<button class="prune-btn" id="pruneBtn" onclick="pruneSnapshots()" title="Slet alle undtagen de 100 nyeste">Behold sidste 100</button>
|
||||
</h2>
|
||||
{"<div class='grid'>" + items_html + "</div>" if files else "<div class='empty'>Ingen snapshots endnu.</div>"}
|
||||
<div id="reload-badge" class="reload-badge" onclick="window.location.reload(true)">Nye billeder – tryk for at opdatere</div>
|
||||
<div class="modal" id="modal">
|
||||
@@ -124,6 +129,21 @@ html = f"""<!DOCTYPE html>
|
||||
document.getElementById('modal').addEventListener('click', function(e){{
|
||||
if(e.target === this) closeModal();
|
||||
}});
|
||||
function pruneSnapshots(){{
|
||||
if(!confirm('Slet alle undtagen de 100 nyeste billeder?')) return;
|
||||
const btn = document.getElementById('pruneBtn');
|
||||
btn.disabled = true;
|
||||
btn.textContent = 'Sletter...';
|
||||
fetch('/api/webhook/indkorsel_prune_100', {{method:'POST'}})
|
||||
.then(() => {{
|
||||
btn.textContent = 'Færdig – genindlæser...';
|
||||
setTimeout(() => window.location.reload(true), 3500);
|
||||
}})
|
||||
.catch(() => {{
|
||||
btn.disabled = false;
|
||||
btn.textContent = 'Fejl – prøv igen';
|
||||
}});
|
||||
}}
|
||||
// Tjek hvert 60 sek om der er en nyere version af galleriet
|
||||
setInterval(() => {{
|
||||
fetch('/local/snapshots/indkorsel_loader.html?_=' + Date.now())
|
||||
|
||||
Reference in New Issue
Block a user