dark mode

This commit is contained in:
Mateusz Gruszczyński 2025-02-25 12:37:57 +01:00
parent e5b787213d
commit d684c331bd
3 changed files with 131 additions and 46 deletions

2
app.py
View File

@ -771,7 +771,7 @@ def advanced_schedule():
@app.route('/toggle_dark_mode') @app.route('/toggle_dark_mode')
def toggle_dark_mode(): def toggle_dark_mode():
current_mode = session.get('dark_mode', False) current_mode = session.get('dark_mode', True)
session['dark_mode'] = not current_mode session['dark_mode'] = not current_mode
return redirect(request.referrer or url_for('index')) return redirect(request.referrer or url_for('index'))

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="pl" class="{% if session.dark_mode %}dark-mode{% endif %}"> <html lang="pl" class="{% if session.get('dark_mode', True) %}dark-mode{% endif %}">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Backup RouterOS App</title> <title>Backup RouterOS App</title>
@ -7,49 +7,135 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
<style> <style>
/* Ogólne style trybu ciemnego */
.dark-mode body { .dark-mode body {
background-color: #222; background-color: #111111;
color: #ffffff; color: #ffffff;
} }
.dark-mode a, .dark-mode a:hover { .dark-mode a,
.dark-mode a:hover {
color: #ddd; color: #ddd;
} }
.dark-mode .navbar, .dark-mode .table {
/* Nawigacja i menu */
.dark-mode .navbar,
.dark-mode .navbar-nav,
.dark-mode .dropdown-menu {
background-color: #333 !important; background-color: #333 !important;
color: #fff; color: #fff;
} }
.dark-mode .navbar-nav .nav-link {
color: #ddd !important;
}
.dark-mode .navbar-nav .nav-link:hover {
color: #fff !important;
}
/* Tabele */
.dark-mode .table {
background-color: #333 !important;
border-color: #444;
}
.dark-mode .table thead th {
background-color: #444;
color: #fff;
border: 1px solid #555;
}
.dark-mode .table tbody td {
color: #ddd;
border: 1px solid #555;
}
/* Pola formularzy */
.dark-mode input,
.dark-mode textarea,
.dark-mode select {
background-color: #333;
color: #fff;
border: 1px solid #555;
}
.dark-mode ::placeholder {
color: #ccc;
}
/* Przyciski - poprawiony kontrast dla btn-warning */
.dark-mode .btn-warning {
background-color: #d39e00;
border-color: #b38600;
color: #fff;
}
.dark-mode .btn-secondary {
background-color: #444;
border-color: #555;
color: #fff;
}
/* Bloki (np. zawartość kontenera, karty) */
.dark-mode .block, .dark-mode .card {
background-color: #171717;
color: #fff;
}
/* Stopka */
.dark-mode footer {
background-color: #333 !important;
color: #fff !important;
}
/* Alerty pozostają bez zmian */
.diff-add { color: green; } .diff-add { color: green; }
.diff-rem { color: red; } .diff-rem { color: red; }
</style>
<!-- Blok head umożliwiający dołączenie dodatkowych stylów --> /* Dodatkowe nadpisanie styli diff2html w trybie ciemnym */
{% block head %}{% endblock %} .dark-mode .d2h-wrapper,
.dark-mode .d2h-file-header,
.dark-mode .d2h-file-info,
.dark-mode .d2h-file-diff,
.dark-mode .d2h-diff-table,
.dark-mode .d2h-code-line,
.dark-mode .d2h-code-line-ctn,
.dark-mode .d2h-code-side-linenumber {
background-color: #333 !important;
color: #ddd !important;
border-color: #444 !important;
}
</style>
<!-- Blok head umożliwiający dołączenie dodatkowych stylów -->
{% block head %}{% endblock %}
</head> </head>
<body> <body>
<nav class="navbar navbar-expand navbar-dark bg-dark mb-4"> <nav class="navbar navbar-expand navbar-dark bg-dark mb-4">
<div class="container-fluid"> <div class="container-fluid">
<a href="{{ url_for('index') }}" class="navbar-brand">RouterOS Backup</a> <a href="{{ url_for('index') }}" class="navbar-brand">RouterOS Backup</a>
<div> <div class="d-flex align-items-center">
{% if session.user_id %} {% if session.user_id %}
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary me-2">Dashboard</a> <a href="{{ url_for('dashboard') }}" class="btn btn-secondary me-2">Dashboard</a>
<a href="{{ url_for('routers_list') }}" class="btn btn-secondary me-2">Urządzenia</a> <a href="{{ url_for('routers_list') }}" class="btn btn-secondary me-2">Urządzenia</a>
<a href="{{ url_for('diff_selector') }}" class="btn btn-secondary me-2">Diff selector</a> <a href="{{ url_for('diff_selector') }}" class="btn btn-secondary me-2">Diff selector</a>
<a href="{{ url_for('all_files') }}" class="btn btn-secondary me-2">Wszystkie pliki</a> <a href="{{ url_for('all_files') }}" class="btn btn-secondary me-2">Wszystkie pliki</a>
<a href="{{ url_for('logs_page') }}" class="btn btn-secondary me-2">Logi</a> <a href="{{ url_for('logs_page') }}" class="btn btn-secondary me-2">Logi</a>
<a href="{{ url_for('settings_view') }}" class="btn btn-secondary me-2">Ustawienia</a> <a href="{{ url_for('settings_view') }}" class="btn btn-secondary me-2">Ustawienia</a>
<a href="{{ url_for('advanced_schedule') }}" class="btn btn-secondary me-2">Harmonogram</a> <a href="{{ url_for('advanced_schedule') }}" class="btn btn-secondary me-2">Harmonogram</a>
<a href="{{ url_for('change_password') }}" class="btn btn-secondary me-2">Zmiana hasła</a> <a href="{{ url_for('change_password') }}" class="btn btn-secondary me-2">Zmiana hasła</a>
<a href="{{ url_for('toggle_dark_mode') }}" class="btn btn-warning me-2">
{% if session.get('dark_mode', True) %}Jasny tryb{% else %}Ciemny tryb{% endif %}
</a>
<a href="{{ url_for('logout') }}" class="btn btn-secondary me-2">Wyloguj</a> <a href="{{ url_for('logout') }}" class="btn btn-secondary me-2">Wyloguj</a>
{% else %} {% else %}
<a href="{{ url_for('login') }}" class="btn btn-secondary me-2">Zaloguj</a> <a href="{{ url_for('login') }}" class="btn btn-secondary me-2">Zaloguj</a>
<a href="{{ url_for('register') }}" class="btn btn-secondary me-2">Utwórz konto</a> <a href="{{ url_for('register') }}" class="btn btn-secondary me-2">Utwórz konto</a>
<a href="{{ url_for('toggle_dark_mode') }}" class="btn btn-warning me-2">
{% if session.get('dark_mode', True) %}Jasny tryb{% else %}Ciemny tryb{% endif %}
</a>
{% endif %} {% endif %}
<!--<a href="{{ url_for('toggle_dark_mode') }}" class="btn btn-warning">Toggle Dark Mode</a>-->
</div> </div>
</div> </div>
</nav> </nav>
<div class="container"> <div class="container">
{% with messages = get_flashed_messages() %} {% with messages = get_flashed_messages() %}
{% if messages %} {% if messages %}
@ -64,27 +150,26 @@
{% block content %}{% endblock %} {% block content %}{% endblock %}
</div> </div>
<!-- Modal Test Połączenia --> <!-- Modal Test Połączenia -->
<div class="modal fade" id="testConnectionModal" tabindex="-1" aria-labelledby="testConnectionModalLabel" aria-hidden="true"> <div class="modal fade" id="testConnectionModal" tabindex="-1" aria-labelledby="testConnectionModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title" id="testConnectionModalLabel">Test Połączenia</h5> <h5 class="modal-title" id="testConnectionModalLabel">Test Połączenia</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Zamknij"></button> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Zamknij"></button>
</div> </div>
<div class="modal-body" id="testConnectionModalBody"> <div class="modal-body" id="testConnectionModalBody">
<!-- Zawartość zostanie załadowana przez AJAX --> <!-- Zawartość zostanie załadowana przez AJAX -->
</div>
</div> </div>
</div> </div>
</div> </div>
</div>
<footer class="footer bg-light py-3 mt-auto"> <footer class="footer py-3 mt-auto">
<div class="container text-center"> <div class="container text-center">
<span class="text-muted">&copy; 2025 RouterOS Backup</span> <span>&copy; 2025 Mateusz Gruszczyński, linuxiarz.pl</span>
</div> </div>
</footer> </footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
<script> <script>
@ -97,7 +182,6 @@
.then(data => { .then(data => {
if(data.status === "success"){ if(data.status === "success"){
alert("Eksport wykonany: " + data.message); alert("Eksport wykonany: " + data.message);
// Możesz też zaktualizować część strony dynamicznie
} else { } else {
alert("Błąd eksportu: " + data.message); alert("Błąd eksportu: " + data.message);
} }
@ -107,22 +191,22 @@
alert("Wystąpił błąd."); alert("Wystąpił błąd.");
}); });
} }
</script> </script>
<script> <script>
function openTestConnectionModal(routerId) { function openTestConnectionModal(routerId) {
fetch('/router/' + routerId + '/test_connection?modal=1') fetch('/router/' + routerId + '/test_connection?modal=1')
.then(response => response.text()) .then(response => response.text())
.then(html => { .then(html => {
document.getElementById('testConnectionModalBody').innerHTML = html; document.getElementById('testConnectionModalBody').innerHTML = html;
var myModal = new bootstrap.Modal(document.getElementById('testConnectionModal')); var myModal = new bootstrap.Modal(document.getElementById('testConnectionModal'));
myModal.show(); myModal.show();
}) })
.catch(error => { .catch(error => {
console.error("Błąd ładowania modalu: ", error); console.error("Błąd ładowania modalu: ", error);
alert("Wystąpił błąd podczas ładowania danych."); alert("Wystąpił błąd podczas ładowania danych.");
}); });
} }
</script> </script>
<!-- Blok scripts umożliwiający dołączenie dodatkowych skryptów --> <!-- Blok scripts umożliwiający dołączenie dodatkowych skryptów -->
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
</body> </body>

View File

@ -26,3 +26,4 @@
}); });
</script> </script>
{% endblock %} {% endblock %}
GET | 200 | 45 ms