refactor web interface

This commit is contained in:
Mateusz Gruszczyński
2025-02-25 09:44:24 +01:00
parent cffc8b3124
commit 4b5d7526ff
3 changed files with 103 additions and 25 deletions

View File

@ -31,6 +31,7 @@
<td>{{ backup.description }}</td>
<td>
<a href="{{ url_for('view_backup', backup_id=backup.id) }}" class="btn btn-sm btn-info">Podgląd</a>
<a href="{{ url_for('restore_backup', backup_id=backup.id) }}" class="btn btn-sm btn-success">Przywróć</a>
<form action="{{ url_for('delete_backup', backup_id=backup.id) }}" method="post" style="display:inline;">
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Czy na pewno usunąć backup?');">Usuń</button>
</form>

View File

@ -12,21 +12,67 @@
{% block content %}
<div class="card mb-4">
<div class="card-header">
<h2>Wyczyść serwery</h2>
<h2>Wyczyść /etc/hosts</h2>
</div>
<div class="card-body">
<form method="POST" action="{{ url_for('clear_server') }}">
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" name="linux" id="linux">
<label class="form-check-label" for="linux">Wyczyść Linux</label>
<div class="mb-3">
<label class="form-label">Opcja czyszczenia:</label>
<div class="form-check">
<input class="form-check-input" type="radio" name="clear_option" id="clear_all" value="all" checked>
<label class="form-check-label" for="clear_all">Wyczyść dla wszystkich hostów</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="clear_option" id="clear_one" value="one">
<label class="form-check-label" for="clear_one">Wybierz serwer</label>
</div>
</div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox" name="mikrotik" id="mikrotik">
<label class="form-check-label" for="mikrotik">Wyczyść Mikrotik</label>
<div class="mb-3" id="host_select_div" style="display: none;">
<label for="host_id" class="form-label">Wybierz serwer:</label>
<select class="form-select" id="host_id" name="host_id">
{% for host in hosts %}
<option value="{{ host.id }}">{{ host.hostname }}</option>
{% endfor %}
</select>
</div>
<button type="submit" class="btn btn-danger">Wyczyść wybrane</button>
<div class="mb-3">
<div class="form-check">
<input class="form-check-input" type="checkbox" name="linux" id="linux">
<label class="form-check-label" for="linux">Wyczyść Linux</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" name="mikrotik" id="mikrotik">
<label class="form-check-label" for="mikrotik">Wyczyść Mikrotik</label>
</div>
</div>
<button type="submit" class="btn btn-danger">Wyczyść</button>
</form>
</div>
</div>
<div class="mt-3 text-center">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Przejdź do pulpitu</a>
</div>
{% endblock %}
{% block extra_js %}
{{ super() }}
<script>
// Pokazuj lub ukrywaj rozwijaną listę w zależności od wybranej opcji
const clearAllRadio = document.getElementById('clear_all');
const clearOneRadio = document.getElementById('clear_one');
const hostSelectDiv = document.getElementById('host_select_div');
function toggleHostSelect() {
if (clearOneRadio.checked) {
hostSelectDiv.style.display = 'block';
} else {
hostSelectDiv.style.display = 'none';
}
}
clearAllRadio.addEventListener('change', toggleHostSelect);
clearOneRadio.addEventListener('change', toggleHostSelect);
// Inicjalnie ustaw stan przy załadowaniu strony
toggleHostSelect();
</script>
{% endblock %}