added admin functions
This commit is contained in:
+97
-16
@@ -4,27 +4,108 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="container my-5">
|
||||
<h1>Admin-Bereich</h1>
|
||||
<p class="lead mb-4">Konfigurationen verwalten, Logs einsehen, etc.</p>
|
||||
<h1 class="mb-4">Admin-Bereich</h1>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col">
|
||||
<a href="{{ url_for('admin_logs') }}" class="btn btn-outline-info">
|
||||
<i class="bi bi-journal-text me-2"></i>Logs ansehen
|
||||
</a>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<a href="#" class="btn btn-outline-success" data-bs-toggle="modal" data-bs-target="#newConfigModal">
|
||||
<i class="bi bi-plus-circle me-2"></i>Neue Konfiguration
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="mt-5 mb-3">Vorhandene Konfigurationen</h3>
|
||||
|
||||
<h3>Vorhandene Konfigurationen</h3>
|
||||
{% if configs %}
|
||||
<ul class="list-group">
|
||||
{% for cfg in configs %}
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
{{ cfg.name }} ({{ cfg.filename }})
|
||||
<span>
|
||||
<a href="#" class="btn btn-sm btn-outline-primary">Bearbeiten</a>
|
||||
</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Hub-ID</th>
|
||||
<th>Datei</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for cfg in configs %}
|
||||
<tr>
|
||||
<td>{{ cfg.name }}</td>
|
||||
<td>{{ cfg.hub_id | default('–') }}</td>
|
||||
<td><code>{{ cfg.filename }}</code></td>
|
||||
<td>
|
||||
<a href="{{ url_for('admin_edit_config', filename=cfg.filename) }}"
|
||||
class="btn btn-sm btn-primary">
|
||||
<i class="bi bi-pencil"></i> Bearbeiten
|
||||
</a>
|
||||
<button class="btn btn-sm btn-danger delete-config-btn"
|
||||
data-filename="{{ cfg.filename }}"
|
||||
data-name="{{ cfg.name }}">
|
||||
<i class="bi bi-trash"></i> Löschen
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="alert alert-info">Noch keine Konfigurationen vorhanden.</div>
|
||||
<div class="alert alert-info">
|
||||
Noch keine Konfigurationen vorhanden. Erstelle eine neue.
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="mt-5">
|
||||
<a href="{{ url_for('index') }}" class="btn btn-secondary">Zurück zur Übersicht</a>
|
||||
<!-- Modal für neue Config (Platzhalter – später ausbauen) -->
|
||||
<div class="modal fade" id="newConfigModal" tabindex="-1" aria-labelledby="newConfigModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="newConfigModalLabel">Neue Konfiguration anlegen</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Hier könnte später ein Formular kommen (Name, Hub-ID, Kanäle...).<br>
|
||||
Für den Moment: Erstelle einfach eine .json-Datei im <code>configs/</code>-Ordner.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Schließen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
document.querySelectorAll('.delete-config-btn').forEach(btn => {
|
||||
btn.addEventListener('click', async () => {
|
||||
const filename = btn.dataset.filename;
|
||||
const name = btn.dataset.name;
|
||||
|
||||
if (!confirm(`Sicher löschen: ${name} (${filename}) ?`)) return;
|
||||
|
||||
try {
|
||||
const res = await fetch(`/admin/delete/${filename}`, { method: 'POST' });
|
||||
const data = await res.json();
|
||||
if (data.success) {
|
||||
alert('Gelöscht');
|
||||
location.reload();
|
||||
} else {
|
||||
alert('Fehler: ' + data.message);
|
||||
}
|
||||
} catch (err) {
|
||||
alert('Netzwerkfehler beim Löschen');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user