routeros_backup/templates/router_details.html
2025-02-23 00:24:42 +01:00

167 lines
5.8 KiB
HTML

{% extends "base.html" %}
{% block content %}
<div class="text-end mb-3">
{% if current_view == 'v1' %}
<a href="{{ url_for('router_details', router_id=router.id, view='v2') }}" class="btn btn-outline-secondary">Przełącz na widok v2</a>
{% else %}
<a href="{{ url_for('router_details', router_id=router.id, view='v1') }}" class="btn btn-outline-secondary">Przełącz na widok v1</a>
{% endif %}
</div>
<h2>Router: {{ router.name }}</h2>
<p>
<strong>Host:</strong> {{ router.host }} |
<strong>Port:</strong> {{ router.port }} |
<strong>SSH User:</strong> {{ router.ssh_user }}
</p>
<div class="mb-3">
<form action="{{ url_for('router_export', router_id=router.id) }}" method="POST" class="d-inline">
<button type="submit" class="btn btn-primary">Wykonaj /export</button>
</form>
<form action="{{ url_for('router_backup', router_id=router.id) }}" method="POST" class="d-inline">
<button type="submit" class="btn btn-secondary">Wykonaj backup binarny</button>
</form>
<a href="{{ url_for('edit_router', router_id=router.id) }}" class="btn btn-warning">Edytuj ustawienia</a>
</div>
<!-- Sekcja eksportów -->
<h3>Pliki z /export</h3>
{% if export_backups %}
<!-- Tabela z indywidualnymi akcjami -->
<table class="table table-bordered">
<thead>
<tr>
<th>Nazwa pliku</th>
<th>Rozmiar</th>
<th>Data</th>
<th>Diff</th>
<th>Akcje</th>
</tr>
</thead>
<tbody>
{% for b in export_backups %}
<tr>
<td>{{ b.file_path|basename }}</td>
<td>{{ b.file_path|filesize }}</td>
<td>{{ b.created_at }}</td>
<td>
{% if loop.index0 > 0 %}
<a href="{{ url_for('diff_view', backup_id1=b.id, backup_id2=export_backups[0].id) }}" class="btn btn-sm btn-info">Diff</a>
{% else %}
<small>Brak nowszego</small>
{% endif %}
</td>
<td>
<a href="{{ url_for('download_file', filename=b.file_path|basename) }}" class="btn btn-sm btn-info">Pobierz</a>
<a href="{{ url_for('view_export', backup_id=b.id) }}" class="btn btn-sm btn-outline-primary">Podgląd</a>
<form action="{{ url_for('send_by_email', backup_id=b.id) }}" method="POST" style="display: inline;">
<button type="submit" class="btn btn-sm btn-primary">Wyślij mailem</button>
</form>
<form action="{{ url_for('delete_backup', backup_id=b.id) }}" method="POST" class="d-inline" onsubmit="return confirm('Na pewno usunąć backup?');">
<input type="hidden" name="next" value="{{ url_for('router_details', router_id=router.id) }}">
<button type="submit" class="btn btn-sm btn-danger">Usuń</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- Formularz do pobierania ZIP zaznaczonych eksportów -->
<h4>Pobierz wybrane pliki z /export jako zip</h4>
<form action="{{ url_for('download_zip') }}" method="POST">
<table class="table table-bordered">
<thead>
<tr>
<th><input type="checkbox" id="select_all_export_zip"></th>
<th>Nazwa pliku</th>
<th>Rozmiar</th>
<th>Data</th>
</tr>
</thead>
<tbody>
{% for b in export_backups %}
<tr>
<td><input type="checkbox" name="backup_id" value="{{ b.id }}"></td>
<td>{{ b.file_path|basename }}</td>
<td>{{ b.file_path|filesize }}</td>
<td>{{ b.created_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<button type="submit" class="btn btn-success">Pobierz zaznaczone (.zip)</button>
</form>
{% else %}
<p class="text-muted">Pusto</p>
{% endif %}
<br>
<hr>
<br>
<!-- Sekcja backupów binarnych -->
<h3>Pliki binarne (.backup)</h3>
{% if binary_backups %}
<table class="table table-bordered">
<thead>
<tr>
<th>Nazwa pliku</th>
<th>Rozmiar</th>
<th>Data</th>
<th>Akcje</th>
</tr>
</thead>
<tbody>
{% for b in binary_backups %}
<tr>
<td>{{ b.file_path|basename }}</td>
<td>{{ b.file_path|filesize }}</td>
<td>{{ b.created_at }}</td>
<td>
<a href="{{ url_for('download_file', filename=b.file_path|basename) }}" class="btn btn-sm btn-info">Pobierz</a>
<form action="{{ url_for('upload_backup', router_id=router.id, backup_id=b.id) }}" method="POST" class="d-inline">
<button type="submit" class="btn btn-sm btn-secondary">Wgraj do routera</button>
</form>
<form action="{{ url_for('send_by_email', backup_id=b.id) }}" method="POST" style="display:inline;">
<button type="submit" class="btn btn-sm btn-primary">Wyślij mailem</button>
</form>
<form action="{{ url_for('delete_backup', backup_id=b.id) }}" method="POST" class="d-inline" onsubmit="return confirm('Na pewno usunąć backup?');">
<input type="hidden" name="next" value="{{ url_for('router_details', router_id=router.id) }}">
<button type="submit" class="btn btn-sm btn-danger">Usuń</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<!-- Formularz do pobierania ZIP zaznaczonych backupów binarnych -->
<h4>Pobierz wybrane backupy binarne jako zip</h4>
<form action="{{ url_for('download_zip') }}" method="POST">
<table class="table table-bordered">
<thead>
<tr>
<th><input type="checkbox" id="select_all_binary_zip"></th>
<th>Nazwa pliku</th>
<th>Rozmiar</th>
<th>Data</th>
</tr>
</thead>
<tbody>
{% for b in binary_backups %}
<tr>
<td><input type="checkbox" name="backup_id" value="{{ b.id }}"></td>
<td>{{ b.file_path|basename }}</td>
<td>{{ b.file_path|filesize }}</td>
<td>{{ b.created_at }}</td>
</tr>
{% endfor %}
</tbody>
</table>
<button type="submit" class="btn btn-success">Pobierz zaznaczone (.zip)</button>
</form>
{% else %}
<p class="text-muted">Pusto</p>
{% endif %}
{% endblock %}