diff --git a/static_files/custom_styles.css b/static_files/custom_styles.css index 39a052c..8f55a99 100644 --- a/static_files/custom_styles.css +++ b/static_files/custom_styles.css @@ -27,3 +27,99 @@ body.layout-boxed .wrapper { 50% { opacity: 0.3; transform: scale(1.1); } 100% { opacity: 1; transform: scale(1); } } + + +/* ── Peer list ── */ +.peer-extra-info { + display: none; +} +.callout.position-relative { + padding: 0 !important; +} +#inviteTextContainer { + border: 1px solid #ccc; + padding: 10px; + margin-bottom: 10px; + background-color: #f9f9f9; +} +#inviteText { + white-space: pre-line; + text-align: left; +} +.div-peer-text-information { + top: 0; + left: 0; + background: linear-gradient(to right, white, transparent); + width: 100%; + height: 100%; +} +.peer-lock-icon { + position: absolute; + right: 15px; + top: 48px; + opacity: 0.75; +} + + +/* ── Dark mode ── */ +body.dark-mode.layout-boxed { + background: radial-gradient(circle at center, #1c2025 0%, #272c31 60%, #2d3238 100%); +} +body.dark-mode.layout-boxed .wrapper { + background-color: #343a40; + box-shadow: 0 0 20px rgba(0,0,0,0.6); +} + +body.dark-mode pre { + background-color: #2d3035; + color: #dee2e6; + border: 1px solid #4b545c; +} + +body.dark-mode .btn-primary { + background-color: #3d8bcd; + border-color: #3d8bcd; + color: #fff; +} +body.dark-mode .btn-primary:hover, +body.dark-mode .btn-primary:focus { + background-color: #4d9eff; + border-color: #4d9eff; + color: #fff; +} +body.dark-mode .btn-outline-primary { + color: #3d8bcd; + border-color: #3d8bcd; +} +body.dark-mode .btn-outline-primary:hover, +body.dark-mode .btn-outline-primary:focus { + background-color: #3d8bcd; + border-color: #3d8bcd; + color: #fff; +} +body.dark-mode .text-primary { + color: #3d8bcd !important; +} +body.dark-mode a { + color: #3d8bcd; +} +body.dark-mode a:hover { + color: #4d9eff; +} +body.dark-mode .card-primary.card-outline { + border-top-color: #3d8bcd; +} +body.dark-mode .nav-pills .nav-link.active, +body.dark-mode .nav-pills .show > .nav-link { + background-color: #3d8bcd; +} + +body.dark-mode .div-peer-text-information { + background: linear-gradient(to right, #3f474e, transparent); +} +body.dark-mode .div-peer-text-information h5 a { + color: #dee2e6; +} +body.dark-mode .div-peer-text-information h5 a:hover { + color: #fff; +} diff --git a/templates/accounts/login.html b/templates/accounts/login.html index 602abe1..51c92ca 100644 --- a/templates/accounts/login.html +++ b/templates/accounts/login.html @@ -31,12 +31,16 @@
{% trans 'Instance Traffic' %}
-
{% trans 'IP Address' %}: {{ wireguard_instance.address }}/{{ wireguard_instance.netmask }}
{% trans 'Public Address' %}: {{ wireguard_instance.hostname }}
diff --git a/wgrrd/views.py b/wgrrd/views.py
index 17d80cd..3cd1c76 100644
--- a/wgrrd/views.py
+++ b/wgrrd/views.py
@@ -1,18 +1,17 @@
+import base64
+import os
import subprocess
+import tempfile
from django.contrib.auth.decorators import login_required
from django.core.exceptions import PermissionDenied
from django.http import Http404, HttpResponse
-from django.shortcuts import render, get_object_or_404
+from django.shortcuts import get_object_or_404
from user_manager.models import UserAcl
from wgwadmlibrary.tools import user_has_access_to_peer
from wireguard.models import Peer, WireGuardInstance
-import base64
-import tempfile
-import os
-
@login_required
def view_rrd_graph(request):
@@ -45,21 +44,44 @@ def view_rrd_graph(request):
if not (period[:-1].isdigit() and period[-1] in ['h', 'd']):
period = '6h'
+ dark_mode = request.GET.get('dark') == '1'
+
command = [
"rrdtool", "graph", graph_file,
"--start", f"-{period}",
"--title", f"{graph_title}",
"--vertical-label", "Value",
+ ]
+
+ if dark_mode:
+ command += [
+ "--color", "BACK#2d3035",
+ "--color", "CANVAS#353a40",
+ "--color", "SHADEA#2d3035",
+ "--color", "SHADEB#2d3035",
+ "--color", "GRID#555c63",
+ "--color", "MGRID#6c7580",
+ "--color", "FONT#c8c8c8",
+ "--color", "FRAME#2d3035",
+ "--color", "ARROW#c8c8c8",
+ ]
+ tx_color = "4a9eff"
+ rx_color = "ff6b6b"
+ else:
+ tx_color = "0000FF"
+ rx_color = "FF0000"
+
+ command += [
f"DEF:txdata={rrd_file_path}:tx:AVERAGE",
f"DEF:rxdata={rrd_file_path}:rx:AVERAGE",
"CDEF:tx_mb=txdata,1048576,/",
"CDEF:rx_mb=rxdata,1048576,/",
"VDEF:tx_total=tx_mb,TOTAL",
"VDEF:rx_total=rx_mb,TOTAL",
- "LINE1:txdata#0000FF:Transmitted ",
+ f"LINE1:txdata#{tx_color}:Transmitted ",
"GPRINT:tx_total:%6.2lf MB",
"COMMENT:\\n",
- "LINE1:rxdata#FF0000:Received ",
+ f"LINE1:rxdata#{rx_color}:Received ",
"GPRINT:rx_total:%6.2lf MB",
"COMMENT:\\n"
]