feat: Media Streaming - Admin Cache-Clear Button pro Anbieter
This commit is contained in:
@@ -459,6 +459,28 @@ function StreamingGrid({ onOpenModal, xrelIds, onXrelLoaded, favIds: favIdsProp,
|
||||
const [data, setData] = useState(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState('');
|
||||
const [clearing, setClearing] = useState(false);
|
||||
|
||||
const isAdmin = (() => {
|
||||
try { return JSON.parse(atob(localStorage.getItem('sk_token').split('.')[1])).role === 'admin'; }
|
||||
catch { return false; }
|
||||
})();
|
||||
|
||||
const clearCache = async () => {
|
||||
if (!activeProvider || clearing) return;
|
||||
setClearing(true);
|
||||
try {
|
||||
await api(`/tools/media/streaming/${activeProvider}/clear-cache`, { method:'POST', body:{} });
|
||||
// Neu laden
|
||||
setData(null); setLoading(true);
|
||||
const path = subTab === 'new'
|
||||
? `/tools/media/streaming/${activeProvider}/new`
|
||||
: `/tools/media/streaming/${activeProvider}`;
|
||||
const d = await api(path);
|
||||
setData(d);
|
||||
} catch(e) { setError(e.message); }
|
||||
finally { setClearing(false); setLoading(false); }
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
api('/tools/media/streaming/providers')
|
||||
@@ -498,6 +520,15 @@ function StreamingGrid({ onOpenModal, xrelIds, onXrelLoaded, favIds: favIdsProp,
|
||||
}}>🆕 Neuerscheinungen</button>
|
||||
</div>
|
||||
|
||||
{isAdmin && activeProvider && (
|
||||
<button onClick={clearCache} disabled={clearing || loading}
|
||||
style={{background:'rgba(255,255,255,0.05)',border:'1px solid rgba(255,255,255,0.1)',
|
||||
borderRadius:7,padding:'4px 10px',color:'rgba(255,255,255,0.4)',fontFamily:'monospace',
|
||||
fontSize:10,cursor:'pointer',marginBottom:10,display:'block'}}>
|
||||
{clearing ? '⏳ Leere…' : '🗑 Cache leeren'}
|
||||
</button>
|
||||
)}
|
||||
|
||||
{subTab === 'top10' ? (
|
||||
<div style={{color:'rgba(255,255,255,0.35)',fontFamily:'monospace',fontSize:11,marginBottom:12,lineHeight:1.6}}>
|
||||
Top 10 Filme & Serien pro Anbieter (DE) · nur Titel ab {new Date().getFullYear()-1} · sortiert nach Popularität (Näherung, keine offiziellen Anbieter-Daten)<br/>
|
||||
|
||||
Reference in New Issue
Block a user