276 lines
11 KiB
HTML
276 lines
11 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="pl" data-bs-theme="dark">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>{% block title %}/etc/hosts Manager{% endblock %}</title>
|
||
<!-- Bootstrap CSS (Bootstrap 5.3.0) -->
|
||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
||
<!-- Dodatkowe style -->
|
||
<style>
|
||
/* Style trybu ciemnego – stosujemy je tylko, gdy body ma klasę dark-mode */
|
||
body.dark-mode {
|
||
background-color: #121212;
|
||
color: #e0e0e0;
|
||
}
|
||
body.dark-mode footer {
|
||
background-color: #1e1e1e !important;
|
||
}
|
||
/* Tabele – style ciemnego motywu */
|
||
body.dark-mode .table {
|
||
color: #e0e0e0;
|
||
background-color: #1e1e1e;
|
||
border: 1px solid #444;
|
||
}
|
||
body.dark-mode .table th,
|
||
body.dark-mode .table td {
|
||
border: 1px solid #444;
|
||
}
|
||
body.dark-mode .table-striped tbody tr:nth-of-type(odd) {
|
||
background-color: #2e2e2e;
|
||
}
|
||
body.dark-mode .table-striped tbody tr:nth-of-type(even) {
|
||
background-color: #1e1e1e;
|
||
}
|
||
body.dark-mode .table thead {
|
||
background-color: #333;
|
||
color: #e0e0e0;
|
||
}
|
||
/* Karty */
|
||
body.dark-mode .card {
|
||
background-color: #1e1e1e;
|
||
color: #e0e0e0;
|
||
border-color: #333;
|
||
}
|
||
/* Formularze */
|
||
body.dark-mode .form-control,
|
||
body.dark-mode .form-select {
|
||
background-color: #2e2e2e;
|
||
color: #e0e0e0;
|
||
border: 1px solid #444;
|
||
}
|
||
body.dark-mode .form-control:focus,
|
||
body.dark-mode .form-select:focus {
|
||
background-color: #2e2e2e;
|
||
color: #e0e0e0;
|
||
border-color: #777;
|
||
box-shadow: none;
|
||
}
|
||
/* Przycisk Wyloguj – solidny przycisk, by był czytelny */
|
||
.btn-logout {
|
||
color: #fff;
|
||
}
|
||
|
||
/* Zmniejszenie rozmiaru czcionki w navbarze */
|
||
.navbar {
|
||
font-size: 0.9rem; /* zmniejszony rozmiar czcionki */
|
||
}
|
||
|
||
</style>
|
||
{% block extra_css %}{% endblock %}
|
||
</head>
|
||
<body class="dark-mode">
|
||
<!-- Pasek nawigacyjny -->
|
||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||
<div class="container-fluid">
|
||
<a class="navbar-brand" href="{{ url_for('dashboard') }}">/etc/hosts Manager</a>
|
||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown"
|
||
aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Przełącz nawigację">
|
||
<span class="navbar-toggler-icon"></span>
|
||
</button>
|
||
<div class="collapse navbar-collapse" id="navbarNavDropdown">
|
||
{% if session.get('user_id') %}
|
||
<ul class="navbar-nav me-auto">
|
||
<!-- Dashboard -->
|
||
<li class="nav-item">
|
||
<a class="nav-link" href="{{ url_for('dashboard') }}">Dashboard</a>
|
||
</li>
|
||
<!-- Serwery -->
|
||
<li class="nav-item dropdown">
|
||
<a class="nav-link dropdown-toggle" href="#" id="serversDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||
Serwery
|
||
</a>
|
||
<ul class="dropdown-menu" aria-labelledby="serversDropdown">
|
||
<li><a class="dropdown-item" href="{{ url_for('add_server') }}">Dodaj serwer</a></li>
|
||
<li><a class="dropdown-item" href="{{ url_for('server_list') }}">Lista serwerów</a></li>
|
||
<li><a class="dropdown-item" href="{{ url_for('import_servers') }}">Importuj serwery z CSV</a></li>
|
||
</ul>
|
||
</li>
|
||
<!-- WYczysc /etc/hosts -->
|
||
<li class="nav-item">
|
||
<a class="nav-link" href="{{ url_for('clear_server') }}">Wyczyść /etc/hosts</a>
|
||
</li>
|
||
<!-- 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">
|
||
<a class="nav-link dropdown-toggle" href="#" id="regexDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||
Sieci CIDR / Regex
|
||
</a>
|
||
<ul class="dropdown-menu" aria-labelledby="regexDropdown">
|
||
<li><a class="dropdown-item" href="{{ url_for('list_regex_hosts') }}">Lista wpisów</a></li>
|
||
<li><a class="dropdown-item" href="{{ url_for('new_regex_host') }}">Nowy CIDR</a></li>
|
||
</ul>
|
||
</li>
|
||
<!-- Pliki /etc/hosts -->
|
||
<li class="nav-item dropdown">
|
||
<a class="nav-link dropdown-toggle" href="#" id="filesDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||
Pliki /etc/hosts (beta)
|
||
</a>
|
||
<ul class="dropdown-menu" aria-labelledby="filesDropdown">
|
||
<li><a class="dropdown-item" href="{{ url_for('list_hosts_files') }}">Lista plików</a></li>
|
||
<li><a class="dropdown-item" href="{{ url_for('new_hosts_file') }}">Utwórz nowy /etc/hosts</a></li>
|
||
</ul>
|
||
</li>
|
||
<!-- Kopie zapasowe -->
|
||
<li class="nav-item dropdown">
|
||
<a class="nav-link dropdown-toggle" href="#" id="backupsDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||
Kopie zapasowe
|
||
</a>
|
||
<ul class="dropdown-menu" aria-labelledby="backupsDropdown">
|
||
<li><a class="dropdown-item" href="{{ url_for('backups') }}">Lista kopii</a></li>
|
||
</ul>
|
||
</li>
|
||
<!-- Ustawienia -->
|
||
<li class="nav-item">
|
||
<a class="nav-link" href="{{ url_for('settings') }}">Ustawienia</a>
|
||
</li>
|
||
</ul>
|
||
{% endif %}
|
||
<ul class="navbar-nav ms-auto align-items-center">
|
||
<li class="nav-item me-2">
|
||
<!-- Przełącznik trybu ciemnego -->
|
||
<div class="form-check form-switch">
|
||
<input class="form-check-input" type="checkbox" id="darkModeToggle">
|
||
<label class="form-check-label" for="darkModeToggle">Dark Mode</label>
|
||
</div>
|
||
</li>
|
||
{% if session.get('user_id') %}
|
||
<li class="nav-item">
|
||
<a class="nav-link btn btn-alert ms-2 btn-logout" href="{{ url_for('change_password') }}">Zmień hasło</a>
|
||
</li>
|
||
<li class="nav-item">
|
||
<a class="nav-link btn btn-danger ms-2 btn-logout" href="{{ url_for('logout') }}">Wyloguj</a>
|
||
</li>
|
||
{% else %}
|
||
<li class="nav-item">
|
||
<a class="nav-link btn btn-success ms-2" href="{{ url_for('login') }}">Zaloguj</a>
|
||
</li>
|
||
{% endif %}
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<!-- Główny kontener treści -->
|
||
<div class="container mt-4">
|
||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||
{% if messages %}
|
||
{% for category, message in messages %}
|
||
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
|
||
{{ message }}
|
||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Zamknij"></button>
|
||
</div>
|
||
{% endfor %}
|
||
{% endif %}
|
||
{% endwith %}
|
||
{% block content %}{% endblock %}
|
||
</div>
|
||
|
||
<!-- Stopka -->
|
||
<footer class="bg-light text-center text-lg-start mt-5 py-3">
|
||
<div class="container">
|
||
<span class="text-muted">© 2025 Mateusz Gruszczyński, linuxiarz.pl</span>
|
||
</div>
|
||
</footer>
|
||
|
||
<!-- Bootstrap JS Bundle (Bootstrap 5.3.0) -->
|
||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
|
||
{% block extra_js %}
|
||
<script>
|
||
// Funkcje obsługi ciasteczek
|
||
function setCookie(name, value, days) {
|
||
var expires = "";
|
||
if (days) {
|
||
var date = new Date();
|
||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||
expires = "; expires=" + date.toUTCString();
|
||
}
|
||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||
}
|
||
function getCookie(name) {
|
||
var nameEQ = name + "=";
|
||
var ca = document.cookie.split(';');
|
||
for (var i = 0; i < ca.length; i++) {
|
||
var c = ca[i].trim();
|
||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
// Funkcja do dynamicznego dodawania/usuwania klasy table-dark do tabel
|
||
function applyDarkModeTables() {
|
||
const isDark = document.body.classList.contains('dark-mode');
|
||
document.querySelectorAll('table').forEach(tbl => {
|
||
if (isDark) {
|
||
tbl.classList.add('table-dark');
|
||
} else {
|
||
tbl.classList.remove('table-dark');
|
||
}
|
||
});
|
||
}
|
||
|
||
// Funkcja do aktualizacji navbaru w zależności od motywu
|
||
function updateNavbarTheme() {
|
||
const navbar = document.querySelector('.navbar');
|
||
if (document.body.classList.contains('dark-mode')) {
|
||
navbar.classList.remove('navbar-light', 'bg-light');
|
||
navbar.classList.add('navbar-dark', 'bg-dark');
|
||
} else {
|
||
navbar.classList.remove('navbar-dark', 'bg-dark');
|
||
navbar.classList.add('navbar-light', 'bg-light');
|
||
}
|
||
}
|
||
|
||
// Ustawienie trybu ciemnego na podstawie ciasteczka lub domyślnie (domyślnie ciemny)
|
||
const darkModeToggle = document.getElementById('darkModeToggle');
|
||
if (getCookie('darkMode') === 'disabled') {
|
||
document.body.classList.remove('dark-mode');
|
||
darkModeToggle.checked = false;
|
||
document.documentElement.setAttribute('data-bs-theme', 'light');
|
||
} else {
|
||
document.body.classList.add('dark-mode');
|
||
darkModeToggle.checked = true;
|
||
document.documentElement.setAttribute('data-bs-theme', 'dark');
|
||
setCookie('darkMode', 'enabled', 30);
|
||
}
|
||
applyDarkModeTables();
|
||
updateNavbarTheme();
|
||
|
||
darkModeToggle.addEventListener('change', function() {
|
||
if (this.checked) {
|
||
document.body.classList.add('dark-mode');
|
||
document.documentElement.setAttribute('data-bs-theme', 'dark');
|
||
setCookie('darkMode', 'enabled', 30);
|
||
} else {
|
||
document.body.classList.remove('dark-mode');
|
||
document.documentElement.setAttribute('data-bs-theme', 'light');
|
||
setCookie('darkMode', 'disabled', 30);
|
||
}
|
||
applyDarkModeTables();
|
||
updateNavbarTheme();
|
||
});
|
||
</script>
|
||
{% endblock %}
|
||
</body>
|
||
</html>
|