hosts_app/templates/base.html
Mateusz Gruszczyński 5c7a404c3b refactor
2025-02-24 23:20:50 +01:00

221 lines
7.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 do trybu ciemnego -->
<style>
/* Ogólne style trybu ciemnego */
body.dark-mode {
background-color: #121212;
color: #e0e0e0;
}
/* Navbar i stopka */
body.dark-mode .navbar,
body.dark-mode footer {
background-color: #1e1e1e !important;
}
body.dark-mode .navbar-brand,
body.dark-mode .nav-link,
body.dark-mode .dropdown-item {
color: #e0e0e0 !important;
}
/* Dropdown menu */
body.dark-mode .dropdown-menu {
background-color: #1e1e1e !important;
border-color: #333;
}
/* Tabele rozszerzone style dla trybu ciemnego */
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 i pola wejściowe */
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;
}
/* Uwaga: Styl alertów nie jest modyfikowany, dzięki czemu pozostają kolorowe. */
/* Styl przycisku wyloguj w trybie ciemnym */
body.dark-mode .btn-logout {
background-color: transparent;
border: 2px solid #dc3545;
color: #dc3545;
}
body.dark-mode .btn-logout:hover {
background-color: #dc3545;
color: #ffffff;
}
</style>
{% block extra_css %}
<!-- Dodatkowe style CSS można dodać tutaj -->
{% endblock %}
</head>
<body class="dark-mode">
<!-- Pasek nawigacyjny -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<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">
<li class="nav-item"><a class="nav-link" href="{{ url_for('dashboard') }}">Dashboard</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('manage_hosts') }}">Hosts</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('list_hosts_files') }}">Hosts Files</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('clear_all_hosts') }}">Clear Hosts</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('edit_local_hosts') }}">Edit Local Hosts</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('list_regex_hosts') }}">Regex Hosts</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('backups') }}">Backups</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('settings') }}">Settings</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" checked>
<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" href="{{ url_for('change_password') }}">Zmień hasło</a></li>
<li class="nav-item">
<a class="nav-link btn btn-outline-danger text-white ms-2 btn-logout" href="{{ url_for('logout') }}">Wyloguj</a>
</li>
{% else %}
<li class="nav-item">
<a class="nav-link btn btn-success text-white 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');
}
});
}
// Ustawienie trybu ciemnego na podstawie ciasteczka lub domyślnie (dark mode)
const darkModeToggle = document.getElementById('darkModeToggle');
if (getCookie('darkMode') === 'disabled') {
document.body.classList.remove('dark-mode');
darkModeToggle.checked = false;
} else {
// Domyślnie ustawiamy dark mode
document.body.classList.add('dark-mode');
darkModeToggle.checked = true;
setCookie('darkMode', 'enabled', 30);
}
// Na starcie dopasuj tabele
applyDarkModeTables();
// Obsługa przełącznika dark mode
darkModeToggle.addEventListener('change', function() {
if (this.checked) {
document.body.classList.add('dark-mode');
setCookie('darkMode', 'enabled', 30);
} else {
document.body.classList.remove('dark-mode');
setCookie('darkMode', 'disabled', 30);
}
applyDarkModeTables();
});
</script>
{% endblock %}
</body>
</html>