fixy i usprwnienia

This commit is contained in:
Mateusz Gruszczyński
2025-03-06 14:12:48 +01:00
parent c4b753d4bd
commit cae5ed787d
9 changed files with 329 additions and 35 deletions

View File

@ -60,6 +60,12 @@
.btn-logout {
color: #fff;
}
/* Zmniejszenie rozmiaru czcionki w navbarze */
.navbar {
font-size: 0.9rem; /* zmniejszony rozmiar czcionki */
}
</style>
{% block extra_css %}{% endblock %}
</head>
@ -94,9 +100,16 @@
<li class="nav-item">
<a class="nav-link" href="{{ url_for('clear_server') }}">Wyczyść /etc/hosts</a>
</li>
<!-- Edytuj /etc/hosts -->
<li class="nav-item">
<a class="nav-link" href="{{ url_for('edit_local_hosts') }}">Edytuj /etc/hosts</a>
<!-- Edytuj /etc/hosts z podsekcjami -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="editHostsDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Edytj domyśny /etc/hosts
</a>
<ul class="dropdown-menu" aria-labelledby="editHostsDropdown">
<li><a class="dropdown-item" href="{{ url_for('edit_local_hosts') }}">Edytuj /etc/hosts</a></li>
<li><a class="dropdown-item" href="{{ url_for('default_hostfile_versions') }}">Historia wersji</a></li>
<!-- Opcjonalnie: dodaj inne akcje, np. diff wersji -->
</ul>
</li>
<!-- Sieci CIDR / Regex -->
<li class="nav-item dropdown">

View File

@ -0,0 +1,27 @@
{% extends "base.html" %}
{% block title %}Porównanie wersji{% endblock %}
{% block extra_css %}
{{ super() }}
<style>
/* Przykładowe style dla ciemnego motywu w diff */
table.diff {font-family: Courier; border: medium; }
.diff_header {background-color: #444; color: #fff; }
td.diff_header {text-align: center;}
.diff_next {background-color: #333; }
.diff_add {background-color: #008800; color: #fff; }
.diff_chg {background-color: #4444aa; color: #fff; }
.diff_sub {background-color: #aa0000; color: #fff; }
</style>
{% endblock %}
{% block content %}
<div class="card">
<div class="card-header">
<h2>Porównanie wersji</h2>
</div>
<div class="card-body">
{{ diff_html|safe }}
<hr>
<a href="{{ url_for('hostfile_versions', hostfile_id=hostfile_id) }}" class="btn btn-secondary">Powrót do historii</a>
</div>
</div>
{% endblock %}

View File

@ -1,14 +1,5 @@
{% extends "base.html" %}
{% block title %}Edytuj lokalny Hosts - /etc/hosts Manager{% endblock %}
{% block extra_css %}
{{ super() }}
<style>
.tooltip-inner {
max-width: 300px;
text-align: left;
}
</style>
{% endblock %}
{% block content %}
<div class="card mb-4">
<div class="card-header">
@ -24,7 +15,26 @@
</form>
</div>
</div>
{% if hostfile %}
<div class="card mb-4">
<div class="card-header">
<h3>Wersje /etc/hosts File</h3>
</div>
<div class="card-body">
<p>Przeglądaj historię zmian, porównuj aktualną zawartość z najnowszą wersją oraz usuwaj stare wersje.</p>
<a href="{{ url_for('hostfile_versions', hostfile_id=hostfile.id) }}" class="btn btn-info">Historia wersji</a>
<a href="{{ url_for('delete_old_versions', hostfile_id=hostfile.id, days=30) }}" class="btn btn-secondary" onclick="return confirm('Usuń wersje starsze niż 30 dni?');">Usuń wersje starsze niż 30 dni</a>
{% if hostfile.versions|length > 0 %}
<a href="{{ url_for('diff_current_hostfile', hostfile_id=hostfile.id) }}" class="btn btn-warning" onclick="return confirm('Porównaj aktualną zawartość z najnowszą wersją zapisanej historii?');">Diff aktualny vs. najnowsza</a>
{% else %}
<span class="text-muted">Brak zapisanych wersji do diff.</span>
{% endif %}
</div>
</div>
{% endif %}
<div class="mt-3 text-center">
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Przejdź do pulpitu</a>
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Przejdź do dashboardu</a>
</div>
{% endblock %}

View File

@ -0,0 +1,52 @@
{% extends "base.html" %}
{% block title %}Historia wersji hosts{% endblock %}
{% block content %}
<div class="card">
<div class="card-header">
<h2>Historia wersji dla: {{ hostfile.title }}</h2>
</div>
<div class="card-body">
<form method="post" id="bulkDeleteForm">
<table class="table table-striped">
<thead>
<tr>
<th><input type="checkbox" id="select-all"></th>
<th>Data</th>
<th>Fragment treści</th>
<th>Akcje</th>
</tr>
</thead>
<tbody>
{% set latest_id = versions[0].id if versions|length > 0 else None %}
{% for version in versions %}
<tr>
<td><input type="checkbox" name="selected_versions" value="{{ version.id }}"></td>
<td>{{ version.timestamp.strftime("%Y-%m-%d %H:%M:%S") }}</td>
<td>{{ version.content[:50] }}{% if version.content|length > 50 %}...{% endif %}</td>
<td>
<a href="{{ url_for('view_hostfile_version', version_id=version.id) }}" class="btn btn-sm btn-info">Podgląd</a>
<a href="{{ url_for('restore_hostfile_version', version_id=version.id) }}" class="btn btn-sm btn-success" onclick="return confirm('Przywrócić tę wersję?');">Przywróć</a>
{% if latest_id and version.id != latest_id %}
<a href="{{ url_for('diff_hostfile_versions', version1_id=version.id, version2_id=latest_id) }}" class="btn btn-sm btn-warning">Diff z najnowszą</a>
{% else %}
<span class="text-muted">Brak diff</span>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<button type="submit" class="btn btn-danger" onclick="return confirm('Czy na pewno usunąć zaznaczone wersje?');">Usuń zaznaczone</button>
<a href="{{ url_for('delete_old_versions', hostfile_id=hostfile.id, days=30) }}" class="btn btn-secondary" onclick="return confirm('Usuń wersje starsze niż 30 dni?');">Usuń wersje starsze niż 30 dni</a>
</form>
</div>
</div>
<script>
document.getElementById('select-all').addEventListener('change', function(){
var checkboxes = document.querySelectorAll('input[name="selected_versions"]');
checkboxes.forEach(function(checkbox) {
checkbox.checked = document.getElementById('select-all').checked;
});
});
</script>
{% endblock %}

View File

@ -31,6 +31,7 @@
<a href="{{ url_for('edit_hosts_file', file_id=file.id) }}" class="btn btn-sm btn-warning">Edytuj</a>
<a href="{{ url_for('delete_hosts_file', file_id=file.id) }}" class="btn btn-sm btn-danger" onclick="return confirm('Czy na pewno usunąć plik?');">Usuń</a>
<a href="{{ url_for('deploy_hosts_file', file_id=file.id) }}" class="btn btn-sm btn-success">Deploy</a>
<a href="{{ url_for('hostfile_versions', hostfile_id=file.id) }}" class="btn btn-sm btn-info">Historia wersji</a>
</td>
</tr>
{% endfor %}

View File

@ -28,8 +28,25 @@
</form>
</div>
</div>
{% if file %}
<!-- Sekcja zarządzania wersjami -->
<div class="card mb-4">
<div class="card-header">
<h3>Wersje pliku /etc/hosts</h3>
</div>
<div class="card-body">
<p>Przeglądaj historię zmian, porównaj aktualną zawartość z najnowszą wersją zapisanej historii lub usuń stare wersje.</p>
<a href="{{ url_for('hostfile_versions', hostfile_id=file.id) }}" class="btn btn-info">Historia wersji</a>
<a href="{{ url_for('delete_old_versions', hostfile_id=file.id, days=30) }}" class="btn btn-secondary" onclick="return confirm('Usuń wersje starsze niż 30 dni?');">Usuń wersje starsze niż 30 dni</a>
{% if file.versions|length > 0 %}
<a href="{{ url_for('diff_current_hostfile', hostfile_id=file.id) }}" class="btn btn-warning" onclick="return confirm('Porównaj aktualną zawartość z najnowszą wersją zapisanej historii?');">Diff aktualny vs. ostatnia kopia</a>
{% endif %}
</div>
</div>
{% endif %}
<div class="mt-3 text-center">
<a href="{{ url_for('list_hosts_files') }}" class="btn btn-secondary">Lista Hosts Files</a>
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary">Przejdź do pulpitu</a>
</div>
{% endblock %}

View File

@ -0,0 +1,14 @@
{% extends "base.html" %}
{% block title %}Podgląd wersji{% endblock %}
{% block content %}
<div class="card">
<div class="card-header">
<h2>Podgląd wersji z: {{ version.timestamp.strftime("%Y-%m-%d %H:%M:%S") }}</h2>
</div>
<div class="card-body">
<pre>{{ version.content }}</pre>
<a href="{{ url_for('hostfile_versions', hostfile_id=version.hostfile_id) }}" class="btn btn-secondary">Powrót do historii</a>
<a href="{{ url_for('restore_hostfile_version', version_id=version.id) }}" class="btn btn-success" onclick="return confirm('Przywrócić tę wersję?');">Przywróć tę wersję</a>
</div>
</div>
{% endblock %}