hosts_app/templates/base.html
Mateusz Gruszczyński 52694519d7 remove dynamic hosts
2025-03-10 16:04:57 +01:00

232 lines
9.7 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">
<link rel="stylesheet" href="{{ url_for('static', filename='css/custom.css') }}">
<!-- Dodatkowe style -->
<style>
/* */
</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
</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>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="filesDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Domyślne wpisy
</a>
<ul class="dropdown-menu" aria-labelledby="filesDropdown">
<li><a class="nav-link" href="{{ url_for('local_defaults') }}">Domyślne /etc/hosts</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>