dev #1

Merged
alientim merged 145 commits from dev into main 2025-10-12 13:44:14 +02:00
Showing only changes of commit 81afc82190 - Show all commits

View File

@@ -1,55 +1,112 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block content %} {% block content %}
<h2>Switch Verwaltung</h2>
<h2>Switch-Verwaltung</h2> <!-- Button zum Hinzufügen -->
<button class="btn btn-primary mb-3" data-bs-toggle="modal" data-bs-target="#addSwitchModal">Neuen Switch hinzufügen</button>
<!-- Hinzufügen --> <table class="table table-striped align-middle">
<form method="post" class="mb-3">
<input type="hidden" name="add_switch" value="1">
<div class="row g-2">
<div class="col"><input class="form-control" name="hostname" placeholder="Hostname" required></div>
<div class="col"><input class="form-control" name="ip" placeholder="IP-Adresse" required></div>
<div class="col"><input class="form-control" name="username" placeholder="Benutzername" required></div>
<div class="col"><input class="form-control" name="password" type="password" placeholder="Passwort" required></div>
<div class="col-auto">
<button class="btn btn-primary">Hinzufügen</button>
</div>
</div>
</form>
<!-- Switch-Liste -->
<table class="table table-striped table-hover align-middle">
<thead> <thead>
<tr> <tr>
<th>Hostname</th> <th>Hostname</th>
<th>IP-Adresse</th> <th>IP-Adresse</th>
<th>Benutzername</th> <th>Username</th>
<th>Aktionen</th> <th>Aktionen</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for s in switches %} {% for s in switches %}
<tr> <tr>
<form method="post"> <td>{{ s['hostname'] }}</td>
<input type="hidden" name="edit_switch" value="1"> <td>{{ s['ip'] }}</td>
<input type="hidden" name="old_hostname" value="{{ s['hostname'] }}"> <td>{{ s['username'] }}</td>
<td><input class="form-control form-control-sm" name="hostname" value="{{ s['hostname'] }}"></td>
<td><input class="form-control form-control-sm" name="ip" value="{{ s['ip'] }}"></td>
<td><input class="form-control form-control-sm" name="username" value="{{ s['username'] }}"></td>
<td> <td>
<div class="d-flex gap-1"> <!-- Bearbeiten -->
<input type="password" class="form-control form-control-sm" name="password" placeholder="Neues Passwort"> <button class="btn btn-sm btn-warning" data-bs-toggle="modal" data-bs-target="#editSwitchModal{{ loop.index }}">Bearbeiten</button>
<button class="btn btn-sm btn-success">Speichern</button>
</div> <!-- Löschen -->
</form>
<form method="post" style="display:inline;"> <form method="post" style="display:inline;">
<input type="hidden" name="delete_switch" value="{{ s['hostname'] }}"> <input type="hidden" name="delete_switch" value="{{ s['hostname'] }}">
<button class="btn btn-sm btn-danger ms-1">Löschen</button> <button class="btn btn-sm btn-danger" type="submit">Löschen</button>
</form> </form>
</td> </td>
</tr> </tr>
<!-- Bearbeiten Modal -->
<div class="modal fade" id="editSwitchModal{{ loop.index }}" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title text-dark">Switch bearbeiten</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<form method="post">
<div class="modal-body">
<input type="hidden" name="edit_switch" value="1">
<input type="hidden" name="old_hostname" value="{{ s['hostname'] }}">
<div class="mb-3">
<label class="form-label">Hostname</label>
<input type="text" name="hostname" class="form-control" value="{{ s['hostname'] }}" required>
</div>
<div class="mb-3">
<label class="form-label">IP-Adresse</label>
<input type="text" name="ip" class="form-control" value="{{ s['ip'] }}" required>
</div>
<div class="mb-3">
<label class="form-label">Username</label>
<input type="text" name="username" class="form-control" value="{{ s['username'] }}" required>
</div>
<div class="mb-3">
<label class="form-label">Passwort</label>
<input type="password" name="password" class="form-control" placeholder="Neues Passwort eingeben (optional)">
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
<button class="btn btn-success" type="submit">Speichern</button>
</div>
</form>
</div>
</div>
</div>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
<!-- Hinzufügen Modal -->
<div class="modal fade" id="addSwitchModal" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title text-dark">Neuen Switch hinzufügen</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<form method="post">
<div class="modal-body">
<input type="hidden" name="add_switch" value="1">
<div class="mb-3">
<label class="form-label">Hostname</label>
<input type="text" name="hostname" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">IP-Adresse</label>
<input type="text" name="ip" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Username</label>
<input type="text" name="username" class="form-control" required>
</div>
<div class="mb-3">
<label class="form-label">Passwort</label>
<input type="password" name="password" class="form-control" required>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-secondary" data-bs-dismiss="modal">Abbrechen</button>
<button class="btn btn-primary" type="submit">Hinzufügen</button>
</div>
</form>
</div>
</div>
</div>
{% endblock %} {% endblock %}