Dateien
Hetzner-Backup/v2_adminpanel/templates/license_config.html
2025-06-18 22:48:22 +02:00

239 Zeilen
10 KiB
HTML

{% extends "base.html" %}
{% block title %}Lizenzserver Konfiguration{% endblock %}
{% block content %}
<div class="row mb-4">
<div class="col-12">
<h1 class="h3">Lizenzserver Konfiguration</h1>
</div>
</div>
<!-- Feature Flags -->
<div class="row mb-4">
<div class="col-md-6">
<div class="card">
<div class="card-header">
<h5 class="mb-0">Feature Flags</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Feature</th>
<th>Beschreibung</th>
<th>Status</th>
<th>Aktion</th>
</tr>
</thead>
<tbody>
{% for flag in feature_flags %}
<tr>
<td><strong>{{ flag[1] }}</strong></td>
<td><small>{{ flag[2] }}</small></td>
<td>
{% if flag[3] %}
<span class="badge bg-success">Aktiv</span>
{% else %}
<span class="badge bg-secondary">Inaktiv</span>
{% endif %}
</td>
<td>
<form method="post" action="{{ url_for('admin.toggle_feature_flag', flag_id=flag[0]) }}" style="display: inline;">
<button type="submit" class="btn btn-sm {% if flag[3] %}btn-danger{% else %}btn-success{% endif %}">
{% if flag[3] %}Deaktivieren{% else %}Aktivieren{% endif %}
</button>
</form>
</td>
</tr>
{% else %}
<tr>
<td colspan="4" class="text-center text-muted">Keine Feature Flags konfiguriert</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- API Clients -->
<div class="col-md-6">
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">API Clients</h5>
<button class="btn btn-sm btn-primary" data-bs-toggle="modal" data-bs-target="#newApiClientModal">
<i class="bi bi-plus"></i> Neuer Client
</button>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>API Key</th>
<th>Status</th>
<th>Erstellt</th>
</tr>
</thead>
<tbody>
{% for client in api_clients %}
<tr>
<td>{{ client[1] }}</td>
<td>
<code>{{ client[2][:12] }}...</code>
<button class="btn btn-sm btn-link" onclick="copyToClipboard('{{ client[2] }}')">
<i class="bi bi-clipboard"></i>
</button>
</td>
<td>
{% if client[3] %}
<span class="badge bg-success">Aktiv</span>
{% else %}
<span class="badge bg-danger">Inaktiv</span>
{% endif %}
</td>
<td>{{ client[4].strftime('%d.%m.%Y') if client[4] else '-' }}</td>
</tr>
{% else %}
<tr>
<td colspan="4" class="text-center text-muted">Keine API Clients vorhanden</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Rate Limits -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h5 class="mb-0">Rate Limits</h5>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>API Key</th>
<th>Requests/Minute</th>
<th>Requests/Stunde</th>
<th>Requests/Tag</th>
<th>Burst Size</th>
<th>Aktionen</th>
</tr>
</thead>
<tbody>
{% for limit in rate_limits %}
<tr>
<td><code>{{ limit[1][:12] }}...</code></td>
<td>{{ limit[2] }}</td>
<td>{{ limit[3] }}</td>
<td>{{ limit[4] }}</td>
<td>{{ limit[5] }}</td>
<td>
<button class="btn btn-sm btn-warning" onclick="editRateLimit('{{ limit[0] }}', {{ limit[2] }}, {{ limit[3] }}, {{ limit[4] }})">
Bearbeiten
</button>
</td>
</tr>
{% else %}
<tr>
<td colspan="6" class="text-center text-muted">Keine Rate Limits konfiguriert</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- New API Client Modal -->
<div class="modal fade" id="newApiClientModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form method="post" action="/lizenzserver/config/api-client">
<div class="modal-header">
<h5 class="modal-title">Neuer API Client</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Name</label>
<input type="text" name="name" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Beschreibung</label>
<textarea name="description" class="form-control" rows="2"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
<button type="submit" class="btn btn-primary">Erstellen</button>
</div>
</form>
</div>
</div>
</div>
<!-- Edit Rate Limit Modal -->
<div class="modal fade" id="editRateLimitModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<form id="editRateLimitForm" method="post">
<div class="modal-header">
<h5 class="modal-title">Rate Limit bearbeiten</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body">
<div class="mb-3">
<label class="form-label">Requests pro Minute</label>
<input type="number" name="requests_per_minute" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Requests pro Stunde</label>
<input type="number" name="requests_per_hour" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Requests pro Tag</label>
<input type="number" name="requests_per_day" class="form-control" required>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
<button type="submit" class="btn btn-primary">Speichern</button>
</div>
</form>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(function() {
alert('API Key wurde in die Zwischenablage kopiert!');
});
}
function editRateLimit(id, rpm, rph, rpd) {
const form = document.getElementById('editRateLimitForm');
form.action = `/lizenzserver/config/rate-limit/${id}`;
form.requests_per_minute.value = rpm;
form.requests_per_hour.value = rph;
form.requests_per_day.value = rpd;
new bootstrap.Modal(document.getElementById('editRateLimitModal')).show();
}
</script>
{% endblock %}