dev #1
@@ -1,74 +1,55 @@
|
||||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<h2>Switche</h2>
|
||||
<h2>Switch-Verwaltung</h2>
|
||||
|
||||
{% if current_user.is_admin %}
|
||||
<h4>Neuen Switch hinzufügen</h4>
|
||||
<form method="post" class="row g-2 mb-4">
|
||||
<!-- Hinzufügen -->
|
||||
<form method="post" class="mb-3">
|
||||
<input type="hidden" name="add_switch" value="1">
|
||||
<input type="text" name="hostname" placeholder="Hostname" class="form-control" required>
|
||||
<input type="text" name="ip" placeholder="IP-Adresse" class="form-control" required>
|
||||
<input type="text" name="username" placeholder="Username" class="form-control" required>
|
||||
<input type="password" name="password" placeholder="Password" class="form-control" required>
|
||||
<button class="btn btn-success w-100">Hinzufügen</button>
|
||||
<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>
|
||||
{% endif %}
|
||||
|
||||
<table class="table table-bordered custom-table">
|
||||
<!-- Switch-Liste -->
|
||||
<table class="table table-striped table-hover align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Hostname</th>
|
||||
<th>IP-Adresse</th>
|
||||
<th>Username</th>
|
||||
<th>Password</th>
|
||||
{% if current_user.is_admin %}<th>Aktionen</th>{% endif %}
|
||||
<th>Benutzername</th>
|
||||
<th>Aktionen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for s in switches %}
|
||||
<tr>
|
||||
{% if current_user.is_admin %}
|
||||
<td><input name="hostname" value="{{ s['hostname'] }}" class="form-control" required disabled></td>
|
||||
<td><input name="ip" value="{{ s['ip'] }}" class="form-control" required disabled></td>
|
||||
<td><input name="username" value="{{ s['username'] }}" class="form-control" required disabled></td>
|
||||
<td><input name="password" value="{{ s['password'] }}" type="password" class="form-control" disabled></td>
|
||||
<td class="custom-actions d-flex gap-1 align-items-center">
|
||||
<!-- Bearbeiten Button -->
|
||||
<button type="button" class="btn btn-warning btn-sm" onclick="enableSwitchEdit(this)">Bearbeiten</button>
|
||||
|
||||
<!-- Speichern Button -->
|
||||
<form method="post" style="display:inline;">
|
||||
<form method="post">
|
||||
<input type="hidden" name="edit_switch" value="1">
|
||||
<input type="hidden" name="old_hostname" value="{{ s['hostname'] }}">
|
||||
<button class="btn btn-primary btn-sm d-none" type="submit">Speichern</button>
|
||||
<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>
|
||||
<div class="d-flex gap-1">
|
||||
<input type="password" class="form-control form-control-sm" name="password" placeholder="Neues Passwort">
|
||||
<button class="btn btn-sm btn-success">Speichern</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Löschen Button -->
|
||||
<form method="post" style="display:inline;">
|
||||
<button name="delete_switch" value="{{ s['hostname'] }}" class="btn btn-danger btn-sm"
|
||||
onclick="return confirm('Willst du den Switch wirklich löschen?');">Löschen</button>
|
||||
<input type="hidden" name="delete_switch" value="{{ s['hostname'] }}">
|
||||
<button class="btn btn-sm btn-danger ms-1">Löschen</button>
|
||||
</form>
|
||||
</td>
|
||||
{% else %}
|
||||
<td>{{ s['hostname'] }}</td>
|
||||
<td>{{ s['ip'] }}</td>
|
||||
<td>{{ s['username'] }}</td>
|
||||
<td>******</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function enableSwitchEdit(btn) {
|
||||
const row = btn.closest('tr');
|
||||
// Inputs aktivieren
|
||||
row.querySelectorAll('input').forEach(el => el.disabled = false);
|
||||
row.querySelector('.btn-primary').classList.remove('d-none'); // Speichern sichtbar
|
||||
btn.classList.add('d-none'); // Bearbeiten ausblenden
|
||||
}
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user