pfannkuchen/stream-control/templates/dashboard.html

76 lines
6.9 KiB
HTML

{% extends 'base.html' %}{% block content %}
{% set limits=state.get('limits',{}) %}{% set tc=state.get('tc',{}) %}{% set policy=state.get('policy',{}) %}
<section class="kpi-grid">
<article class="kpi"><span>REGION-PROFIL</span><strong>{{ limits.get('ch','—') }} Mbit</strong><small>tc: {{ tc.get('ch','—') }} Mbit</small></article>
<article class="kpi"><span>CLOUD-PROFIL</span><strong>{{ limits.get('vpn','—') }} Mbit</strong><small>tc: {{ tc.get('vpn','—') }} Mbit</small></article>
<article class="kpi"><span>SESSIONS</span><strong>{{ state.get('active_sessions','—') }}</strong><small>{{ state.get('active_blocks',0) }} aktive Sperren</small></article>
<article class="kpi"><span>POLICY</span><strong>{{ ('AUS' if not policy.get('enabled') else policy.get('mode','—')|upper) }}</strong><small>ab {{ policy.get('min_sessions','—') }} Streams</small></article>
</section>
{% set host=state.get('host',{}) %}{% set tc_detail=state.get('tc_detail',{}) %}
<section class="detail-strip">
<div><span>OVH Uptime</span><strong>{{ host.get('uptime_seconds',0)|duration }}</strong></div>
<div><span>Load 1/5/15</span><strong>{{ (host.get('load') or ['—','—','—'])|join(' / ') }}</strong></div>
<div><span>RAM</span><strong>{{ host.get('memory_used',0)|bytes }} / {{ host.get('memory_total',0)|bytes }}</strong></div>
<div><span>Root-Disk</span><strong>{{ host.get('disk_used',0)|bytes }} / {{ host.get('disk_total',0)|bytes }}</strong></div>
<div><span>Historie</span><strong>{{ state.get('totals',{}).get('sessions',0) }} Sessions · {{ state.get('totals',{}).get('known_ips',0) }} IPs</strong></div>
</section>
{% if state.get('sessions') %}
<section class="panel"><div class="panel-head"><div><p class="eyebrow">LIVE</p><h2>Aktive Sessions</h2></div><a class="text-link" href="/history#sessions">vollständige History →</a></div>
<div class="table-wrap"><table><thead><tr><th>Benutzer</th><th>Titel</th><th>Gerät</th><th>Standort</th><th>IP</th><th>Seit</th></tr></thead><tbody>
{% for s in state.get('sessions',[]) %}<tr><td><strong>{{ s.user_name }}</strong></td><td>{{ s.series or s.title }}{% if s.series %}<small class="cell-sub">{{ s.title }}</small>{% endif %}</td><td>{{ s.device }}<small class="cell-sub">{{ s.client }}</small></td><td>{{ [s.city,s.country]|select|join(', ') }}<small class="cell-sub">{{ s.asn }}</small></td><td class="mono">{{ s.ip }}</td><td>{{ s.started_at|dt }}</td></tr>{% endfor %}
</tbody></table></div>
</section>
{% endif %}
<section class="panel"><div class="panel-head"><div><p class="eyebrow">SCHNELLWAHL</p><h2>Traffic-Profile</h2></div><small>Wirkt sofort auf die aktiven tc-Klassen am OVH</small></div>
<div class="profile-grid control-profiles">
{% for key,p in profiles.items() %}
<form method="post" action="{{ url_for('apply_profile',name=key) }}" class="profile-card" style="--accent:{{ p.color }}">
<input type="hidden" name="csrf" value="{{ csrf_token() }}"><span class="profile-dot"></span><h3>{{ p.label }}</h3><strong>{{ p.ch }} / {{ p.vpn }} Mbit</strong><small>Region / Cloud</small><button type="submit">Aktivieren</button>
</form>
{% endfor %}
</div>
</section>
<section class="grid two">
<article class="panel"><div class="panel-head"><div><p class="eyebrow">MANUELL</p><h2>Bandbreiten</h2></div></div>
<form method="post" action="{{ url_for('custom_limits') }}" class="form-grid compact-form">
<input type="hidden" name="csrf" value="{{ csrf_token() }}">
<label>Region Mbit<input type="number" name="ch" min="0.1" max="100" step="0.1" value="{{ limits.get('ch',1) }}" required></label>
<label>Cloud Mbit<input type="number" name="vpn" min="0.1" max="100" step="0.1" value="{{ limits.get('vpn',1) }}" required></label>
<button class="full" type="submit">Limits anwenden</button>
</form>
</article>
<article class="panel"><div class="panel-head"><div><p class="eyebrow">SESSION POLICY</p><h2>Mehrfachnutzung</h2></div></div>
<form method="post" action="{{ url_for('policy') }}" class="form-grid compact-form">
<input type="hidden" name="csrf" value="{{ csrf_token() }}">
<label>Modus<select name="mode"><option value="off" {{ 'selected' if not policy.get('enabled') }}>Aus</option><option value="monitor" {{ 'selected' if policy.get('enabled') and policy.get('mode')=='monitor' }}>Nur beobachten</option><option value="block" {{ 'selected' if policy.get('enabled') and policy.get('mode')=='block' }}>Blockieren</option></select></label>
<label>Ab Streams<input type="number" name="min_sessions" min="2" max="8" value="{{ policy.get('min_sessions',2) }}"></label>
<label>Sperre Minuten<input type="number" name="block_minutes" min="1" max="1440" value="{{ policy.get('block_minutes',10) }}"></label>
<button class="full" type="submit">Policy speichern</button>
</form>
</article>
</section>
<section class="grid two">
<article class="panel"><div class="panel-head"><div><p class="eyebrow">RUNTIME</p><h2>Dienste & Regeln</h2></div></div>
<div class="table-wrap"><table><tbody>
{% for name,status in state.get('services',{}).items() %}<tr><td>{{ name }}</td><td><span class="badge {{ 'active' if status=='active' else 'danger' }}">{{ status }}</span></td></tr>{% endfor %}
<tr><td>Markierungsregeln</td><td><strong>{{ state.get('mark_rules','—') }}</strong></td></tr>
<tr><td>Region-Netze</td><td><strong>{{ state.get('ipsets',{}).get('geo-a-v4',0)+state.get('ipsets',{}).get('geo-a-v6',0) }}</strong></td></tr>
<tr><td>Cloud-Netze</td><td><strong>{{ state.get('ipsets',{}).get('cloud-v4',0)+state.get('ipsets',{}).get('cloud-v6',0) }}</strong></td></tr>
{% for key,label in [('ch','Region-Traffic'),('vpn','Cloud-Traffic'),('default','Standard-Traffic')] %}{% set c=tc_detail.get(key,{}) %}<tr><td>{{ label }}</td><td><strong>{{ c.get('bytes',0)|bytes }}</strong><small class="cell-sub">{{ c.get('packets',0) }} Pakete · {{ c.get('drops',0) }} Drops</small></td></tr>{% endfor %}
</tbody></table></div>
<div class="action-row">
{% for action,label,cls in [('refresh','Netzlisten aktualisieren','ghost'),('worker','Worker neu starten','ghost'),('admin','Admin neu starten','ghost')] %}<form method="post" action="{{ url_for('maintenance',action=action) }}"><input type="hidden" name="csrf" value="{{ csrf_token() }}"><button class="{{ cls }}">{{ label }}</button></form>{% endfor %}
</div>
</article>
<article class="panel"><div class="panel-head"><div><p class="eyebrow">EREIGNISSE</p><h2>Letzte Policy-Aktionen</h2></div></div>
<div class="event-list">{% for e in state.get('recent_events',[]) %}<div class="event"><span class="event-kind">{{ e.kind }}</span><div><strong>{{ e.user_name or 'System' }}</strong><small>{{ e.detail }}</small></div></div>{% else %}<p class="muted">Keine Ereignisse vorhanden.</p>{% endfor %}</div>
</article>
</section>
{% if state.get('error') %}<div class="notice error"><strong>!</strong><p>{{ state.error }}</p></div>{% endif %}
{% endblock %}