mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2026-03-22 00:16:18 +00:00
add dark mode synchronization script and update image source conditions
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
{% include 'template_parts/dark_mode_active_sync.html' %}
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
|
|
||||||
<!-- Preloader -->
|
<!-- Preloader -->
|
||||||
|
|||||||
@@ -75,6 +75,7 @@
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
{% include 'template_parts/dark_mode_active_sync.html' %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -136,9 +136,11 @@
|
|||||||
if ($('body').hasClass('dark-mode')) {
|
if ($('body').hasClass('dark-mode')) {
|
||||||
$('body').removeClass('dark-mode');
|
$('body').removeClass('dark-mode');
|
||||||
setCookie('darkMode', 'light', 365);
|
setCookie('darkMode', 'light', 365);
|
||||||
|
setCookie('darkModeActive', '0', 365);
|
||||||
} else {
|
} else {
|
||||||
$('body').addClass('dark-mode');
|
$('body').addClass('dark-mode');
|
||||||
setCookie('darkMode', 'dark', 365);
|
setCookie('darkMode', 'dark', 365);
|
||||||
|
setCookie('darkModeActive', '1', 365);
|
||||||
}
|
}
|
||||||
syncDarkModeUI();
|
syncDarkModeUI();
|
||||||
});
|
});
|
||||||
|
|||||||
21
templates/template_parts/dark_mode_active_sync.html
Normal file
21
templates/template_parts/dark_mode_active_sync.html
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<script>
|
||||||
|
(function () {
|
||||||
|
function setCookie(name, value, days) {
|
||||||
|
var d = new Date();
|
||||||
|
d.setTime(d.getTime() + days * 24 * 60 * 60 * 1000);
|
||||||
|
document.cookie = name + '=' + value + ';path=/;expires=' + d.toUTCString();
|
||||||
|
}
|
||||||
|
function getCookie(name) {
|
||||||
|
var m = document.cookie.match(new RegExp('(?:^|; )' + name + '=([^;]*)'));
|
||||||
|
return m ? m[1] : null;
|
||||||
|
}
|
||||||
|
var userPref = getCookie('darkMode');
|
||||||
|
var isDark;
|
||||||
|
if (userPref) {
|
||||||
|
isDark = userPref === 'dark';
|
||||||
|
} else {
|
||||||
|
isDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||||
|
}
|
||||||
|
setCookie('darkModeActive', isDark ? '1' : '0', 365);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<img src="/rrd/graph/?instance={{ instance.uuid }}&period={{ request.GET.period|default:'6h' }}{% if request.COOKIES.darkMode == 'dark' %}&dark=1{% endif %}"
|
<img src="/rrd/graph/?instance={{ instance.uuid }}&period={{ request.GET.period|default:'6h' }}{% if request.COOKIES.darkModeActive == '1' %}&dark=1{% endif %}"
|
||||||
class="img-fluid" alt="RRD Graph">
|
class="img-fluid" alt="RRD Graph">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -148,7 +148,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<center>
|
<center>
|
||||||
<img id="graphImg" src="/rrd/graph/?peer={{ current_peer.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}{% if request.COOKIES.darkMode == 'dark' %}&dark=1{% endif %}"
|
<img id="graphImg" src="/rrd/graph/?peer={{ current_peer.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}{% if request.COOKIES.darkModeActive == '1' %}&dark=1{% endif %}"
|
||||||
class="img-fluid" alt="{% trans 'No traffic history, please wait a few minutes' %}"
|
class="img-fluid" alt="{% trans 'No traffic history, please wait a few minutes' %}"
|
||||||
onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);">
|
onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);">
|
||||||
</center>
|
</center>
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<h3>wg{{ wireguard_instance.instance_id }} {% if wireguard_instance.name %}({{ wireguard_instance.name }}){% endif %}</h3>
|
<h3>wg{{ wireguard_instance.instance_id }} {% if wireguard_instance.name %}({{ wireguard_instance.name }}){% endif %}</h3>
|
||||||
<p><b><i class="fas fa-chart-area nav-icon"></i> {% trans 'Instance Traffic' %}</b></p>
|
<p><b><i class="fas fa-chart-area nav-icon"></i> {% trans 'Instance Traffic' %}</b></p>
|
||||||
<img id="graphImg" src="/rrd/graph/?instance={{ wireguard_instance.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}{% if request.COOKIES.darkMode == 'dark' %}&dark=1{% endif %}" class="img-fluid" alt="No traffic history, please wait a few minutes" onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);">
|
<img id="graphImg" src="/rrd/graph/?instance={{ wireguard_instance.uuid }}{% if request.GET.period %}&period={{ request.GET.period }}{% endif %}{% if request.COOKIES.darkModeActive == '1' %}&dark=1{% endif %}" class="img-fluid" alt="No traffic history, please wait a few minutes" onerror="this.onerror=null; this.style.display='none'; this.insertAdjacentHTML('afterend', this.alt);">
|
||||||
<p>
|
<p>
|
||||||
<b><i class="fas fa-network-wired nav-icon"></i> {% trans 'IP Address' %}: </b>{{ wireguard_instance.address }}/{{ wireguard_instance.netmask }}<br>
|
<b><i class="fas fa-network-wired nav-icon"></i> {% trans 'IP Address' %}: </b>{{ wireguard_instance.address }}/{{ wireguard_instance.netmask }}<br>
|
||||||
<b><i class="fas fa-link nav-icon"></i> {% trans 'Public Address' %}: </b>{{ wireguard_instance.hostname }}<br>
|
<b><i class="fas fa-link nav-icon"></i> {% trans 'Public Address' %}: </b>{{ wireguard_instance.hostname }}<br>
|
||||||
|
|||||||
Reference in New Issue
Block a user