mirror of
https://github.com/Terranom674/Piwigo_Bratonien_Tools.git
synced 2026-09-19 15:14:34 +00:00
Add manual Piwigo cache build controls directly to template
This commit is contained in:
@@ -47,6 +47,16 @@
|
||||
.bratonien-rule-table th { color:#d7d7d7; }
|
||||
.bratonien-effective { white-space:nowrap; }
|
||||
.bratonien-muted { color:#a9a9a9; }
|
||||
.bratonien-main-cache { margin-top:16px; padding-top:14px; border-top:1px solid rgba(255,255,255,.1); }
|
||||
.bratonien-main-cache__warning { margin:10px 0; color:#d6ae62; font-size:12px; line-height:1.45; }
|
||||
.bratonien-main-cache__progress { display:none; margin-top:14px; }
|
||||
.bratonien-main-cache__head { display:flex; justify-content:space-between; gap:12px; margin-bottom:7px; }
|
||||
.bratonien-main-cache__track { height:18px; overflow:hidden; border:1px solid rgba(255,255,255,.16); border-radius:4px; background:rgba(0,0,0,.25); }
|
||||
.bratonien-main-cache__bar { width:0; height:100%; background:#66a845; transition:width .25s ease; }
|
||||
.bratonien-main-cache__progress.is-error .bratonien-main-cache__bar { background:#c95b5b; }
|
||||
.bratonien-main-cache__progress.is-queued .bratonien-main-cache__bar { background:#a7834d; }
|
||||
.bratonien-main-cache__details { margin-top:8px; color:#a9a9a9; line-height:1.45; }
|
||||
.bratonien-main-cache__current { margin-top:4px; font-size:12px; color:#8f8f8f; overflow-wrap:anywhere; }
|
||||
@media (max-width:850px) {
|
||||
.bratonien-grid,.bratonien-scale-grid { grid-template-columns:1fr; }
|
||||
.bratonien-form-grid,.bratonien-scale-fields { grid-template-columns:1fr; }
|
||||
@@ -103,7 +113,25 @@
|
||||
|
||||
<section class="bratonien-section" id="regeln"><h3>Regeln</h3><p class="bratonien-section__intro">Standardregeln und Album-Ausnahmen gemeinsam verwalten.</p><div class="bratonien-card"><h4>Globale Standardregeln</h4><form method="post"><input type="hidden" name="pwg_token" value="{$PWG_TOKEN|escape:html}"><div class="bratonien-form-grid"><label>Öffentliche Alben</label><select name="public_profile"><option value="">Kein Wasserzeichen</option>{foreach from=$WATERMARK_PROFILES item=profile}{if $profile.active}<option value="{$profile.id}" {if $WATERMARK_DEFAULTS.public_profile == $profile.id}selected{/if}>{$profile.name|escape:html}</option>{/if}{/foreach}</select><label>Private Alben</label><select name="private_profile"><option value="">Kein Wasserzeichen</option>{foreach from=$WATERMARK_PROFILES item=profile}{if $profile.active}<option value="{$profile.id}" {if $WATERMARK_DEFAULTS.private_profile == $profile.id}selected{/if}>{$profile.name|escape:html}</option>{/if}{/foreach}</select></div><div class="bratonien-actions"><button class="buttonLike" type="submit" name="bratonien_tool" value="watermark_defaults">Standardregeln speichern</button></div></form></div><div class="bratonien-card" style="margin-top:16px;"><h4>Album-Ausnahmen</h4><p class="bratonien-muted">Erben verwendet die nächste explizite Regel eines Elternalbums und danach den globalen Standard.</p><table class="bratonien-rule-table"><thead><tr><th>Album</th><th>Sichtbarkeit</th><th>Regel</th><th>Profil</th><th>Wirksam</th><th></th></tr></thead><tbody>{foreach from=$WATERMARK_CATEGORIES item=category}<tr><form method="post"><input type="hidden" name="pwg_token" value="{$PWG_TOKEN|escape:html}"><input type="hidden" name="category_id" value="{$category.id}"><td><strong>{$category.display_name|escape:html}</strong></td><td>{$category.status|escape:html}</td><td><select name="rule_mode"><option value="inherit" {if $category.rule.mode == 'inherit'}selected{/if}>Erben</option><option value="disabled" {if $category.rule.mode == 'disabled'}selected{/if}>Kein Wasserzeichen</option><option value="profile" {if $category.rule.mode == 'profile'}selected{/if}>Profil verwenden</option></select></td><td><select name="rule_profile"><option value="">Profil wählen</option>{foreach from=$WATERMARK_PROFILES item=profile}{if $profile.active}<option value="{$profile.id}" {if $category.rule.profile_id == $profile.id}selected{/if}>{$profile.name|escape:html}</option>{/if}{/foreach}</select></td><td class="bratonien-effective"><strong>{$category.effective_label|escape:html}</strong> <span class="bratonien-muted">({$category.effective.source|escape:html})</span></td><td><button class="buttonLike" type="submit" name="bratonien_tool" value="watermark_rule">Speichern</button></td></form></tr>{/foreach}</tbody></table></div></section>
|
||||
|
||||
<section class="bratonien-section" id="wartung"><h3>Wartung</h3><p class="bratonien-section__intro">Werkzeuge, die nicht zur täglichen Konfiguration gehören.</p><div class="bratonien-card"><h4>Bildcache</h4><p>Löscht alle erzeugten Piwigo- und Bratonien-Bildderivate. Originalbilder bleiben erhalten. Benötigte Varianten werden beim nächsten Aufruf automatisch neu erzeugt.</p><form method="post"><input type="hidden" name="pwg_token" value="{$PWG_TOKEN|escape:html}"><button class="buttonLike" type="submit" name="bratonien_tool" value="image_cache_clear" onclick="return confirm('Wirklich den gesamten Bildcache leeren? Benötigte Varianten werden anschließend bei Bedarf neu erzeugt.');">Bildcache leeren</button></form></div></section>
|
||||
<section class="bratonien-section" id="wartung">
|
||||
<h3>Wartung</h3><p class="bratonien-section__intro">Werkzeuge, die nicht zur täglichen Konfiguration gehören.</p>
|
||||
<div class="bratonien-card">
|
||||
<h4>Bildcache</h4>
|
||||
<p>Löscht alle erzeugten Piwigo- und Bratonien-Bildderivate. Originalbilder bleiben erhalten. Benötigte Varianten werden beim nächsten Aufruf automatisch neu erzeugt.</p>
|
||||
<form method="post"><input type="hidden" name="pwg_token" value="{$PWG_TOKEN|escape:html}"><button class="buttonLike" type="submit" name="bratonien_tool" value="image_cache_clear" onclick="return confirm('Wirklich den gesamten Bildcache leeren? Benötigte Varianten werden anschließend bei Bedarf neu erzeugt.');">Bildcache leeren</button></form>
|
||||
<div class="bratonien-main-cache">
|
||||
<h4>Piwigo-Bildcache vorbereiten</h4>
|
||||
<p>Erzeugt die normalen Piwigo-Bildgrößen vorab. Bratonien-Wasserzeichen werden weiterhin nur bei Bedarf erzeugt.</p>
|
||||
<p class="bratonien-main-cache__warning"><strong>Experimentell:</strong> Der manuelle Cache-Aufbau nutzt vier parallele Worker und kann CPU, Arbeitsspeicher und Datenträger des LXC deutlich belasten. Diese Warnung wird entfernt, sobald der Ablauf im Dauerbetrieb stabil ist.</p>
|
||||
<form method="post"><input type="hidden" name="pwg_token" value="{$PWG_TOKEN|escape:html}"><button class="buttonLike" type="submit" name="bratonien_tool" value="image_cache_build">Piwigo-Bildcache aufbauen</button></form>
|
||||
<div class="bratonien-main-cache__progress" data-main-cache-progress data-status-url="{$MAIN_CACHE_STATUS_URL|escape:html}">
|
||||
<div class="bratonien-main-cache__head"><strong data-cache-title>Cache-Aufbau</strong><strong data-cache-percent>0 %</strong></div>
|
||||
<div class="bratonien-main-cache__track" role="progressbar" aria-label="Piwigo-Bildcache" aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" data-cache-track><div class="bratonien-main-cache__bar" data-cache-bar></div></div>
|
||||
<div class="bratonien-main-cache__details" data-cache-details></div><div class="bratonien-main-cache__current" data-cache-current></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
@@ -123,6 +151,23 @@ function initWatermarkEditor(form){
|
||||
fileSelect.addEventListener('change',function(){applyPercent(percentInput.value||100);});percentInput.addEventListener('input',function(){applyPercent(percentInput.value);});widthInput.addEventListener('input',applyWidth);heightInput.addEventListener('input',applyHeight);if(opacityInput)opacityInput.addEventListener('input',function(){applyPercent(percentInput.value);});applyPercent(percentInput.value||100);
|
||||
}
|
||||
document.querySelectorAll('[data-watermark-editor]').forEach(initWatermarkEditor);
|
||||
|
||||
function initMainCacheProgress(){
|
||||
var box=document.querySelector('[data-main-cache-progress]');if(!box)return;
|
||||
var url=box.getAttribute('data-status-url'),title=box.querySelector('[data-cache-title]'),percentEl=box.querySelector('[data-cache-percent]'),details=box.querySelector('[data-cache-details]'),current=box.querySelector('[data-cache-current]'),bar=box.querySelector('[data-cache-bar]'),track=box.querySelector('[data-cache-track]'),timer=null,hideTimer=null;
|
||||
function schedule(ms){if(timer)clearTimeout(timer);timer=setTimeout(load,ms);}
|
||||
function render(data){
|
||||
var state=data.state||'idle',total=Math.max(0,parseInt(data.total,10)||0),completed=Math.max(0,parseInt(data.completed,10)||0),percent=total>0?Math.min(100,Math.round(completed/total*100)):(state==='complete'?100:0);
|
||||
box.classList.toggle('is-error',state==='error');box.classList.toggle('is-queued',state==='queued');bar.style.width=percent+'%';track.setAttribute('aria-valuenow',String(percent));percentEl.textContent=percent+' %';
|
||||
var labels={queued:'Cache-Aufbau wartet',running:'Cache-Aufbau läuft',complete:'Cache-Aufbau fertig',error:'Cache-Aufbau mit Fehlern'};title.textContent=labels[state]||'Cache-Aufbau';
|
||||
details.textContent=(data.message||'')+(total>0?' · '+completed+' / '+total+' Varianten · '+(parseInt(data.generated,10)||0)+' neu · '+(parseInt(data.cached,10)||0)+' vorhanden · '+(parseInt(data.skipped,10)||0)+' übersprungen · '+(parseInt(data.errors,10)||0)+' Fehler':'');current.textContent=data.current?('Aktuell: '+data.current):'';
|
||||
if(state==='queued'||state==='running'||state==='error'){if(hideTimer){clearTimeout(hideTimer);hideTimer=null;}box.style.display='block';}
|
||||
if(state==='queued'||state==='running'){schedule(1000);}else if(state==='complete'){box.style.display='block';if(hideTimer)clearTimeout(hideTimer);hideTimer=setTimeout(function(){box.style.display='none';},5000);}else if(state==='idle'){box.style.display='none';}
|
||||
}
|
||||
function load(){fetch(url+(url.indexOf('?')===-1?'?':'&')+'_='+(Date.now()),{credentials:'same-origin',cache:'no-store'}).then(function(r){if(!r.ok)throw new Error('HTTP '+r.status);return r.json();}).then(render).catch(function(){box.style.display='block';box.classList.add('is-error');details.textContent='Cache-Status konnte nicht geladen werden.';});}
|
||||
load();
|
||||
}
|
||||
initMainCacheProgress();
|
||||
})();
|
||||
{/literal}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user