chore: rename variable

This commit is contained in:
DaanSelen
2026-03-09 16:26:27 +01:00
parent 7b81d5faeb
commit 6b094e8f8e
26 changed files with 236 additions and 108 deletions
+5 -5
View File
@@ -13,12 +13,12 @@ debug_enabled = True
wg_conf_path = /etc/wireguard wg_conf_path = /etc/wireguard
awg_conf_path = /etc/amnezia/amneziawg awg_conf_path = /etc/amnezia/amneziawg
app_prefix = app_prefix =
auth_req = True authentication_required = True
version = v5.0.0 version = v5.0.0
dashboard_refresh_interval = 60000 wgdashboard_refresh_interval = 60000
dashboard_peer_list_display = grid wgdashboard_peer_list_display = grid
dashboard_sort = status wgdashboard_sort = status
dashboard_theme = dark wgdashboard_theme = dark
wgdashboard_apikey = true wgdashboard_apikey = true
#wgdashboard_language = nl-NL #wgdashboard_language = nl-NL
wgdashboard_language = en-US wgdashboard_language = en-US
+2
View File
@@ -40,6 +40,7 @@ if __name__ == '__main__':
# Configure the Flask app # Configure the Flask app
app = flask.Flask("WGDashboard", app = flask.Flask("WGDashboard",
static_url_path="",
template_folder=os.path.abspath("./static/dist/WGDashboardAdmin"), template_folder=os.path.abspath("./static/dist/WGDashboardAdmin"),
static_folder=os.path.abspath("./static/dist/WGDashboardAdmin") static_folder=os.path.abspath("./static/dist/WGDashboardAdmin")
) )
@@ -57,6 +58,7 @@ if __name__ == '__main__':
debug_enabled = config_server.get('debug_enabled', False) debug_enabled = config_server.get('debug_enabled', False)
hostname = config_server.get('hostname', '0.0.0.0') hostname = config_server.get('hostname', '0.0.0.0')
port = config_server.get('port', '10086') port = config_server.get('port', '10086')
app.run( app.run(
debug=debug_enabled, debug=debug_enabled,
host=hostname, host=hostname,
+6 -1
View File
@@ -9,6 +9,7 @@ from .schema import Base
from .schema import Apikeys from .schema import Apikeys
class functions(): class functions():
@staticmethod
def retrieve_api_keys(session: sqlalchemy.orm.Session) -> tuple[list[dict], list[dict]]: def retrieve_api_keys(session: sqlalchemy.orm.Session) -> tuple[list[dict], list[dict]]:
""" AI GENERATED """ AI GENERATED
Retrieve all API keys from the database and separate them into valid and expired keys. Retrieve all API keys from the database and separate them into valid and expired keys.
@@ -59,4 +60,8 @@ class functions():
print("VALID:", json.dumps(valid_keys,indent=4)) print("VALID:", json.dumps(valid_keys,indent=4))
print("INVALID", json.dumps(expired_keys, indent=4)) print("INVALID", json.dumps(expired_keys, indent=4))
return valid_keys, expired_keys return valid_keys, expired_keys
@staticmethod
def retrieve_users(session: sqlalchemy.orm.Session):
print("Wanting to check users")
+10 -8
View File
@@ -3,13 +3,15 @@
import flask import flask
import json import json
def make_resp_obj(message: str = "", data: dict = {}, http_code: int = 200) -> flask.wrappers.Response: def make_resp_obj(status=True, message=None, data=None, http_code=200):
resp_json_data = json.dumps({ if data is None:
'message': message, data = {}
'data': data
})
response = flask.make_response(resp_json_data, http_code)
response.mimetype = 'application/json'
resp_json_data = json.dumps({
"status": status,
"message": message,
"data": data
})
response = flask.make_response(resp_json_data, http_code)
response.mimetype = "application/json"
return response return response
+147 -30
View File
@@ -2,10 +2,13 @@
import logging as log import logging as log
import bcrypt
import flask import flask
import hashlib
import json import json
import os import os
import werkzeug import werkzeug
from datetime import datetime
from .response import make_resp_obj from .response import make_resp_obj
from .utilities import helpers from .utilities import helpers
@@ -33,13 +36,13 @@ white_list = [
] ]
@routes.before_request @routes.before_request
def auth_required(): def authentication_required():
if flask.request.method.lower() == "options": if flask.request.method.lower() == "options":
return make_resp_obj("", {"status": True}, 200) return make_resp_obj(True, "", {"status": True}, 200)
ok, config_server = config.filter(flask.current_app.wgd_config, 'SERVER') ok, config_server = config.filter(flask.current_app.wgd_config, 'SERVER')
if not ok: if not ok:
return make_resp_obj("Internal error", {}, 500) return make_resp_obj(False, "Internal error", {}, 500)
auth_required_flag = config_server.get('auth_req', True) auth_required_flag = config_server.get('auth_req', True)
api_key_enabled = config_server.get("wgdashboard_apikey", False) api_key_enabled = config_server.get("wgdashboard_apikey", False)
@@ -54,7 +57,7 @@ def auth_required():
if helpers.is_valid_api_key(api_key): if helpers.is_valid_api_key(api_key):
return return
else: else:
return make_resp_obj("WGDashboard API-key does not exist or is invalid/expired", {}, 401) return make_resp_obj(False, "WGDashboard API-key does not exist or is invalid/expired", {}, 401)
if flask.session.get("role") == "admin": if flask.session.get("role") == "admin":
return return
@@ -62,59 +65,173 @@ def auth_required():
if helpers.is_path_allowed(path, white_list, flask.session): if helpers.is_path_allowed(path, white_list, flask.session):
return return
return make_resp_obj("Unauthorized access", {}, 401) return make_resp_obj(False, "Unauthorized access", {}, 401)
@routes.route('/api/authenticate', methods=["POST"]) @routes.route('/api/authenticate', methods=["POST"])
def api_authenticate(): def api_authenticate():
ok, config_server = config.filter(flask.current_app.wgd_config, 'SERVER') ok, config_server = config.filter(flask.current_app.wgd_config, 'SERVER')
if not ok: if not ok:
return make_resp_obj("Internal error", {}, 500) return make_resp_obj(False, "Internal error", {}, 500)
auth_required_flag = config_server.get('auth_req', True) auth_required_flag = config_server.get('authentication_required', True)
# Authentication disabled
if not auth_required_flag: if not auth_required_flag:
ok, config_other = config.filter(flask.current_app.wgd_config, 'OTHER') ok, config_other = config.filter(flask.current_app.wgd_config, 'OTHER')
if not ok: if not ok:
return make_resp_obj("Internal error", {}, 500) return make_resp_obj(False, "Internal error", {}, 500)
return make_resp_obj( return make_resp_obj(True, "Login successful, no authentication required", {"welcome_session": config_other.get("welcome_session", False)}, 200)
"Login successful, no authentication required",
{"welcome_session": config_other.get("welcome_session", False)}, # API key authentication
200 api_key = flask.request.headers.get("wgdashboard-apikey")
) api_key_enabled = config_server.get("wgdashboard_apikey", False)
if api_key and api_key_enabled:
if helpers.is_valid_api_key(api_key):
auth_token = hashlib.sha256(f"{api_key}{datetime.now()}".encode()).hexdigest()
flask.session['role'] = 'admin'
flask.session['username'] = auth_token
resp = make_resp_obj(True,"Login successful", {}, 200)
resp.set_cookie("authToken", auth_token)
flask.session.permanent = True
return resp
else:
return make_resp_obj(False, "API key invalid", {}, 401)
# Load account config
ok, config_account = config.filter(flask.current_app.wgd_config, 'ACCOUNT')
if not ok:
return make_resp_obj(False, "Internal error", {}, 500)
data = flask.request.get_json() data = flask.request.get_json()
if not data: if not data:
return make_resp_obj("Invalid request body", {}, 400) return make_resp_obj(False, "Invalid request body", {}, 400)
username = data.get("username")
password = data.get("password")
totp_code = data.get("totp")
stored_username = config_account.get("username")
stored_password = config_account.get("password")
totp_enabled = config_account.get("enable_totp", False)
totp_key = config_account.get("totp_key")
# Validate password
valid = bcrypt.checkpw(
password.encode("utf-8"),
stored_password.encode("utf-8")
)
# Validate TOTP
totp_valid = False
if totp_enabled:
totp_valid = pyotp.TOTP(totp_key).now() == totp_code
if (
valid
and username == stored_username
and ((totp_enabled and totp_valid) or not totp_enabled)
):
# Generate a session token
auth_token = hashlib.sha256(f"{username}{datetime.now()}".encode()).hexdigest()
flask.session['role'] = 'admin'
flask.session['username'] = auth_token
flask.session.permanent = True
# Log success via your helper if available
log.info(f"Login success: {username} from {flask.request.remote_addr}")
ok, config_other = config.filter(flask.current_app.wgd_config, 'OTHER')
welcome_msg = config_other.get("welcome_session", "Welcome back!") if ok else "Welcome!"
resp = make_resp_obj(True, {"status": True}, 200)
resp.set_cookie("authToken", auth_token, httponly=True, samesite='Lax')
return resp
# Log failure
log.warning(f"Login failed: {username} from {flask.request.remote_addr}")
return make_resp_obj("Authentication required", {}, 401) error_msg = "Invalid username, password, or OTP." if totp_enabled else "Invalid username or password."
return make_resp_obj(False, error_msg, {"status": False}, 401)
@routes.route('/', defaults={'path': ''}) if totp_enabled:
@routes.route('/<path:path>') return make_resp_obj(
def index_handler(path): False,
static_folder = flask.current_app.static_folder "Sorry, your username, password or OTP is incorrect.",
try: {},
safe_path = werkzeug.utils.safe_join(static_folder, path) 401
if not safe_path or not os.path.exists(safe_path): )
raise Exception() else:
rel_path = os.path.relpath(safe_path, static_folder) return make_resp_obj(
return flask.send_from_directory(flask.current_app.static_folder, rel_path) False,
"Sorry, your username or password is incorrect.",
{},
401
)
except Exception: @routes.route('/')
print(f"ROUTE NOT INPLEMENTED: {path}") def index_handler():
return flask.send_from_directory(flask.current_app.static_folder, "index.html") return flask.render_template("index.html")
@routes.route('/api/locale') @routes.route('/api/locale')
def api_locale_handler(): def api_locale_handler():
locale_manager = localeman() locale_manager = localeman()
locale_data = locale_manager.get_language() locale_data = locale_manager.get_language()
return make_resp_obj("", locale_data, 200) return make_resp_obj(True, "", locale_data, 200)
@routes.route('/api/validateAuthentication')
def api_validate_auth():
ok, config_server = config.filter(flask.current_app.wgd_config, 'SERVER')
if not ok:
return make_resp_obj(False, 'Internal error', {}, 500)
auth_required_flag = config_server.get('auth_req', True)
token = flask.request.cookies.get("authToken")
if auth_required_flag:
if token is None or token == "" or flask.session.get("username") != token:
return make_resp_obj(False, "Invalid authentication", {}, 200)
return make_resp_obj()
@routes.route('/api/getDashboardVersion')
def api_retrieve_dashboard_version():
ok, config_server = config.filter(flask.current_app.wgd_config, 'SERVER')
if not ok:
return make_resp_obj(False, 'Internal error', {}, 500)
return make_resp_obj(True, "", config_server.get("version"))
@routes.route('/api/getDashboardTheme')
def api_retrieve_dashboard_theme():
ok, config_server = config.filter(flask.current_app.wgd_config, 'SERVER')
if not ok:
return make_resp_obj(False, 'Internal error', {}, 500)
return make_resp_obj(True, "", config_server.get("wgdashboard_theme"), 200)
@routes.route('/api/getDashboardConfiguration')
def api_retrieve_dashboard_config():
return make_resp_obj(data=flask.current_app.wgd_config)
@routes.route('/api/isTotpEnabled')
def api_totp_status():
ok, config_account = config.filter(flask.current_app.wgd_config, 'ACCOUNT')
if not ok:
return make_resp_obj(False, 'Internal error', {}, 500)
data = config_account.get('enable_totp') and config_account.get('totp_verified')
return make_resp_obj(True, "", data, 200)
@routes.route('/health', methods=["GET"]) @routes.route('/health', methods=["GET"])
@routes.route('/healthz', methods=["GET"]) @routes.route('/healthz', methods=["GET"])
def health_handler(): def health_handler():
return make_resp_obj( return make_resp_obj(True,
"Health Endpoint", "Health Endpoint",
{"status": "ok"}, {"status": "ok"},
200 200
+2
View File
@@ -1,4 +1,6 @@
bcrypt==5.0.0
configparser==7.2.0 configparser==7.2.0
gunicorn==25.1.0
sqlalchemy==2.0.48 sqlalchemy==2.0.48
Flask==3.1.3 Flask==3.1.3
Werkzeug==3.1.6 Werkzeug==3.1.6
+1 -1
View File
@@ -29,7 +29,7 @@ const route = useRoute()
</script> </script>
<template> <template>
<div class="h-100 bg-body" :data-bs-theme="store.Configuration?.Server.dashboard_theme"> <div class="h-100 bg-body" :data-bs-theme="store.Configuration?.Server.wgdashboard_theme">
<div style="z-index: 9999; height: 5px" class="position-absolute loadingBar top-0 start-0"></div> <div style="z-index: 9999; height: 5px" class="position-absolute loadingBar top-0 start-0"></div>
<nav class="navbar bg-dark sticky-top" data-bs-theme="dark" v-if="!route.meta.hideTopNav"> <nav class="navbar bg-dark sticky-top" data-bs-theme="dark" v-if="!route.meta.hideTopNav">
<div class="container-fluid d-flex text-body align-items-center"> <div class="container-fluid d-flex text-body align-items-center">
@@ -52,7 +52,7 @@ const toggle = async () => {
<!-- <div>--> <!-- <div>-->
<!-- <div class="alert alert-dark rounded-3 mb-0">--> <!-- <div class="alert alert-dark rounded-3 mb-0">-->
<!-- <LocaleText t="Due to security reason, in order to edit OIDC configuration, you will need to edit "></LocaleText>--> <!-- <LocaleText t="Due to security reason, in order to edit OIDC configuration, you will need to edit "></LocaleText>-->
<!-- <code>wg-dashboard-oidc-providers.json</code> <LocaleText t="directly, then restart WGDashboard to apply the latest settings."></LocaleText>--> <!-- <code>wgdashboard-oidc-providers.json</code> <LocaleText t="directly, then restart WGDashboard to apply the latest settings."></LocaleText>-->
<!-- </div>--> <!-- </div>-->
<!-- </div>--> <!-- </div>-->
</div> </div>
@@ -70,7 +70,7 @@ const saveRaw = async () => {
:disabled="true" :disabled="true"
:read-only="saving" :read-only="saving"
v-model="content" v-model="content"
:theme="dashboardStore.Configuration.Server.dashboard_theme === 'dark' ? 'github-dark':'github'" :theme="dashboardStore.Configuration.Server.wgdashboard_theme === 'dark' ? 'github-dark':'github'"
:languages="[['ini', path]]" :languages="[['ini', path]]"
width="100%" height="600px"> width="100%" height="600px">
</CodeEditor> </CodeEditor>
@@ -50,7 +50,7 @@ export default {
<div <div
style="font-size: 0.8rem; color: #28a745" style="font-size: 0.8rem; color: #28a745"
class="d-flex align-items-center" class="d-flex align-items-center"
v-if="dashboardStore.Configuration.Server.dashboard_peer_list_display === 'list' && Peer.status === 'running'"> v-if="dashboardStore.Configuration.Server.wgdashboard_peer_list_display === 'list' && Peer.status === 'running'">
<i class="bi bi-box-arrow-in-right me-2"></i> <i class="bi bi-box-arrow-in-right me-2"></i>
<span> <span>
{{ Peer.endpoint }} {{ Peer.endpoint }}
@@ -84,8 +84,8 @@ export default {
{{Peer.name ? Peer.name : GetLocale('Untitled Peer')}} {{Peer.name ? Peer.name : GetLocale('Untitled Peer')}}
</h6> </h6>
<div class="d-flex" <div class="d-flex"
:class="[dashboardStore.Configuration.Server.dashboard_peer_list_display === 'grid' ? 'gap-1 flex-column' : 'flex-row gap-3']"> :class="[dashboardStore.Configuration.Server.wgdashboard_peer_list_display === 'grid' ? 'gap-1 flex-column' : 'flex-row gap-3']">
<div :class="{'d-flex gap-2 align-items-center' : dashboardStore.Configuration.Server.dashboard_peer_list_display === 'list'}"> <div :class="{'d-flex gap-2 align-items-center' : dashboardStore.Configuration.Server.wgdashboard_peer_list_display === 'list'}">
<small class="text-muted"> <small class="text-muted">
<LocaleText t="Public Key"></LocaleText> <LocaleText t="Public Key"></LocaleText>
</small> </small>
@@ -93,7 +93,7 @@ export default {
<samp>{{Peer.id}}</samp> <samp>{{Peer.id}}</samp>
</small> </small>
</div> </div>
<div :class="{'d-flex gap-2 align-items-center' : dashboardStore.Configuration.Server.dashboard_peer_list_display === 'list'}"> <div :class="{'d-flex gap-2 align-items-center' : dashboardStore.Configuration.Server.wgdashboard_peer_list_display === 'list'}">
<small class="text-muted"> <small class="text-muted">
<LocaleText t="Allowed IPs"></LocaleText> <LocaleText t="Allowed IPs"></LocaleText>
</small> </small>
@@ -102,7 +102,7 @@ export default {
</small> </small>
</div> </div>
<div class="d-flex align-items-center gap-1" <div class="d-flex align-items-center gap-1"
:class="{'ms-auto': dashboardStore.Configuration.Server.dashboard_peer_list_display === 'list'}" :class="{'ms-auto': dashboardStore.Configuration.Server.wgdashboard_peer_list_display === 'list'}"
> >
<PeerTagBadge :BackgroundColor="group.BackgroundColor" :GroupName="group.GroupName" :Icon="'bi-' + group.Icon" <PeerTagBadge :BackgroundColor="group.BackgroundColor" :GroupName="group.GroupName" :Icon="'bi-' + group.Icon"
v-for="group in Object.values(ConfigurationInfo.Info.PeerGroups).filter(x => x.Peers.includes(Peer.id))" v-for="group in Object.values(ConfigurationInfo.Info.PeerGroups).filter(x => x.Peers.includes(Peer.id))"
@@ -186,7 +186,7 @@ export default {
} }
} }
}, },
'dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval'(){ 'dashboardConfigurationStore.Configuration.Server.wgdashboard_refresh_interval'(){
clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval); clearInterval(this.dashboardConfigurationStore.Peers.RefreshInterval);
this.setPeerInterval(); this.setPeerInterval();
} }
@@ -282,7 +282,7 @@ export default {
setPeerInterval(){ setPeerInterval(){
this.dashboardConfigurationStore.Peers.RefreshInterval = setInterval(() => { this.dashboardConfigurationStore.Peers.RefreshInterval = setInterval(() => {
this.getPeers() this.getPeers()
}, parseInt(this.dashboardConfigurationStore.Configuration.Server.dashboard_refresh_interval)) }, parseInt(this.dashboardConfigurationStore.Configuration.Server.wgdashboard_refresh_interval))
}, },
}, },
computed: { computed: {
@@ -405,14 +405,14 @@ export default {
x.allowed_ip.includes(this.wireguardConfigurationStore.searchString) x.allowed_ip.includes(this.wireguardConfigurationStore.searchString)
}) : this.configurationPeers; }) : this.configurationPeers;
if (this.dashboardConfigurationStore.Configuration.Server.dashboard_sort === "restricted"){ if (this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort === "restricted"){
return result.sort((a, b) => { return result.sort((a, b) => {
if ( a[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort] if ( a[this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort]
< b[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort] ){ < b[this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort] ){
return 1; return 1;
} }
if ( a[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort] if ( a[this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort]
> b[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]){ > b[this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort]){
return -1; return -1;
} }
return 0; return 0;
@@ -420,12 +420,12 @@ export default {
} }
return result.sort((a, b) => { return result.sort((a, b) => {
if ( a[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort] if ( a[this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort]
< b[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort] ){ < b[this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort] ){
return -1; return -1;
} }
if ( a[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort] if ( a[this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort]
> b[this.dashboardConfigurationStore.Configuration.Server.dashboard_sort]){ > b[this.dashboardConfigurationStore.Configuration.Server.wgdashboard_sort]){
return 1; return 1;
} }
return 0; return 0;
@@ -108,7 +108,7 @@ const setFetchPeerListInterval = () => {
clearInterval(fetchPeerListInterval.value) clearInterval(fetchPeerListInterval.value)
fetchPeerListInterval.value = setInterval(async () => { fetchPeerListInterval.value = setInterval(async () => {
await fetchPeerList() await fetchPeerList()
}, parseInt(dashboardStore.Configuration.Server.dashboard_refresh_interval)) }, parseInt(dashboardStore.Configuration.Server.wgdashboard_refresh_interval))
} }
setFetchPeerListInterval() setFetchPeerListInterval()
onBeforeUnmount(() => { onBeforeUnmount(() => {
@@ -118,7 +118,7 @@ onBeforeUnmount(() => {
}) })
watch(() => { watch(() => {
return dashboardStore.Configuration.Server.dashboard_refresh_interval return dashboardStore.Configuration.Server.wgdashboard_refresh_interval
}, () => { }, () => {
setFetchPeerListInterval() setFetchPeerListInterval()
}) })
@@ -191,14 +191,14 @@ const searchPeers = computed(() => {
wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags || (!wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags && taggedPeers.value.includes(x.id)) wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags || (!wireguardConfigurationStore.Filter.ShowAllPeersWhenHiddenTags && taggedPeers.value.includes(x.id))
)); ));
if (dashboardStore.Configuration.Server.dashboard_sort === "restricted"){ if (dashboardStore.Configuration.Server.wgdashboard_sort === "restricted"){
return result.sort((a, b) => { return result.sort((a, b) => {
if ( a[dashboardStore.Configuration.Server.dashboard_sort] if ( a[dashboardStore.Configuration.Server.wgdashboard_sort]
< b[dashboardStore.Configuration.Server.dashboard_sort] ){ < b[dashboardStore.Configuration.Server.wgdashboard_sort] ){
return 1; return 1;
} }
if ( a[dashboardStore.Configuration.Server.dashboard_sort] if ( a[dashboardStore.Configuration.Server.wgdashboard_sort]
> b[dashboardStore.Configuration.Server.dashboard_sort]){ > b[dashboardStore.Configuration.Server.wgdashboard_sort]){
return -1; return -1;
} }
return 0; return 0;
@@ -207,26 +207,26 @@ const searchPeers = computed(() => {
let re = [] let re = []
if (dashboardStore.Configuration.Server.dashboard_sort === 'allowed_ip'){ if (dashboardStore.Configuration.Server.wgdashboard_sort === 'allowed_ip'){
re = result.sort((a, b) => { re = result.sort((a, b) => {
if ( firstAllowedIPCount(a[dashboardStore.Configuration.Server.dashboard_sort]) if ( firstAllowedIPCount(a[dashboardStore.Configuration.Server.wgdashboard_sort])
< firstAllowedIPCount(b[dashboardStore.Configuration.Server.dashboard_sort]) ){ < firstAllowedIPCount(b[dashboardStore.Configuration.Server.wgdashboard_sort]) ){
return -1; return -1;
} }
if ( firstAllowedIPCount(a[dashboardStore.Configuration.Server.dashboard_sort]) if ( firstAllowedIPCount(a[dashboardStore.Configuration.Server.wgdashboard_sort])
> firstAllowedIPCount(b[dashboardStore.Configuration.Server.dashboard_sort])){ > firstAllowedIPCount(b[dashboardStore.Configuration.Server.wgdashboard_sort])){
return 1; return 1;
} }
return 0; return 0;
}).slice(0, showPeersCount.value) }).slice(0, showPeersCount.value)
}else{ }else{
re = result.sort((a, b) => { re = result.sort((a, b) => {
if ( a[dashboardStore.Configuration.Server.dashboard_sort] if ( a[dashboardStore.Configuration.Server.wgdashboard_sort]
< b[dashboardStore.Configuration.Server.dashboard_sort] ){ < b[dashboardStore.Configuration.Server.wgdashboard_sort] ){
return -1; return -1;
} }
if ( a[dashboardStore.Configuration.Server.dashboard_sort] if ( a[dashboardStore.Configuration.Server.wgdashboard_sort]
> b[dashboardStore.Configuration.Server.dashboard_sort]){ > b[dashboardStore.Configuration.Server.wgdashboard_sort]){
return 1; return 1;
} }
return 0; return 0;
@@ -411,7 +411,7 @@ watch(() => route.query.id, (newValue) => {
</PeerSearch> </PeerSearch>
<TransitionGroup name="peerList" tag="div" class="row gx-2 gy-2 z-0 position-relative"> <TransitionGroup name="peerList" tag="div" class="row gx-2 gy-2 z-0 position-relative">
<div class="col-12" <div class="col-12"
:class="{'col-lg-6 col-xl-4': dashboardStore.Configuration.Server.dashboard_peer_list_display === 'grid'}" :class="{'col-lg-6 col-xl-4': dashboardStore.Configuration.Server.wgdashboard_peer_list_display === 'grid'}"
:key="peer.id" :key="peer.id"
v-for="(peer, order) in searchPeers"> v-for="(peer, order) in searchPeers">
<Peer :Peer="peer" <Peer :Peer="peer"
@@ -80,7 +80,7 @@ const toggleFetchRealtimeTraffic = () => {
if (props.configurationInfo.Status){ if (props.configurationInfo.Status){
fetchRealtimeTrafficInterval.value = setInterval(() => { fetchRealtimeTrafficInterval.value = setInterval(() => {
fetchRealtimeTraffic() fetchRealtimeTraffic()
}, parseInt(dashboardStore.Configuration.Server.dashboard_refresh_interval)) }, parseInt(dashboardStore.Configuration.Server.wgdashboard_refresh_interval))
} }
} }
@@ -92,7 +92,7 @@ watch(() => props.configurationInfo.Status, () => {
toggleFetchRealtimeTraffic() toggleFetchRealtimeTraffic()
}) })
watch(() => dashboardStore.Configuration.Server.dashboard_refresh_interval, () => { watch(() => dashboardStore.Configuration.Server.wgdashboard_refresh_interval, () => {
toggleFetchRealtimeTraffic() toggleFetchRealtimeTraffic()
}) })
@@ -151,7 +151,7 @@ export default {
:clearable="false" :clearable="false"
:disabled="!edit" :disabled="!edit"
v-if="this.job.Field === 'date'" v-if="this.job.Field === 'date'"
:dark="this.store.Configuration.Server.dashboard_theme === 'dark'" :dark="this.store.Configuration.Server.wgdashboard_theme === 'dark'"
/> />
<input class="form-control form-control-sm form-control-dark rounded-3 flex-grow-1" <input class="form-control form-control-sm form-control-dark rounded-3 flex-grow-1"
@@ -47,7 +47,7 @@ export default {
updateSort(sort){ updateSort(sort){
fetchPost("/api/updateDashboardConfigurationItem", { fetchPost("/api/updateDashboardConfigurationItem", {
section: "Server", section: "Server",
key: "dashboard_sort", key: "wgdashboard_sort",
value: sort value: sort
}, (res) => { }, (res) => {
if (res.status){ if (res.status){
@@ -58,7 +58,7 @@ export default {
updateRefreshInterval(refreshInterval){ updateRefreshInterval(refreshInterval){
fetchPost("/api/updateDashboardConfigurationItem", { fetchPost("/api/updateDashboardConfigurationItem", {
section: "Server", section: "Server",
key: "dashboard_refresh_interval", key: "wgdashboard_refresh_interval",
value: refreshInterval value: refreshInterval
}, (res) => { }, (res) => {
if (res.status){ if (res.status){
@@ -69,7 +69,7 @@ export default {
updateDisplay(display){ updateDisplay(display){
fetchPost("/api/updateDashboardConfigurationItem", { fetchPost("/api/updateDashboardConfigurationItem", {
section: "Server", section: "Server",
key: "dashboard_peer_list_display", key: "wgdashboard_peer_list_display",
value: display value: display
}, (res) => { }, (res) => {
if (res.status){ if (res.status){
@@ -98,7 +98,7 @@ export default {
class="btn w-100 btn-sm text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle position-relative"> class="btn w-100 btn-sm text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle position-relative">
<i class="bi bi-sort-up me-2"></i> <i class="bi bi-sort-up me-2"></i>
<LocaleText t="Sort By"></LocaleText> <LocaleText t="Sort By"></LocaleText>
<span class="badge text-bg-primary ms-2">{{this.sort[store.Configuration.Server.dashboard_sort]}}</span> <span class="badge text-bg-primary ms-2">{{this.sort[store.Configuration.Server.wgdashboard_sort]}}</span>
</button> </button>
<ul class="dropdown-menu rounded-3"> <ul class="dropdown-menu rounded-3">
<li v-for="(value, key) in this.sort" > <li v-for="(value, key) in this.sort" >
@@ -108,7 +108,7 @@ export default {
</small> </small>
<small class="ms-auto"> <small class="ms-auto">
<i class="bi bi-check-circle-fill" <i class="bi bi-check-circle-fill"
v-if="store.Configuration.Server.dashboard_sort === key"></i> v-if="store.Configuration.Server.wgdashboard_sort === key"></i>
</small> </small>
</button> </button>
</li> </li>
@@ -120,7 +120,7 @@ export default {
class="btn btn-sm w-100 text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle position-relative"> class="btn btn-sm w-100 text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle position-relative">
<i class="bi bi-arrow-repeat me-2"></i> <i class="bi bi-arrow-repeat me-2"></i>
<LocaleText t="Refresh Interval"></LocaleText> <LocaleText t="Refresh Interval"></LocaleText>
<span class="badge text-bg-primary ms-2">{{this.interval[store.Configuration.Server.dashboard_refresh_interval]}}</span> <span class="badge text-bg-primary ms-2">{{this.interval[store.Configuration.Server.wgdashboard_refresh_interval]}}</span>
</button> </button>
<ul class="dropdown-menu rounded-3"> <ul class="dropdown-menu rounded-3">
<li v-for="(value, key) in this.interval" > <li v-for="(value, key) in this.interval" >
@@ -130,7 +130,7 @@ export default {
</small> </small>
<small class="ms-auto"> <small class="ms-auto">
<i class="bi bi-check-circle-fill" <i class="bi bi-check-circle-fill"
v-if="store.Configuration.Server.dashboard_refresh_interval === key"></i> v-if="store.Configuration.Server.wgdashboard_refresh_interval === key"></i>
</small> </small>
</button> </button>
</li> </li>
@@ -140,9 +140,9 @@ export default {
<button <button
data-bs-toggle="dropdown" data-bs-toggle="dropdown"
class="btn btn-sm w-100 text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle position-relative"> class="btn btn-sm w-100 text-primary-emphasis bg-primary-subtle rounded-3 border-1 border-primary-subtle position-relative">
<i class="bi me-2" :class="'bi-' + store.Configuration.Server.dashboard_peer_list_display"></i> <i class="bi me-2" :class="'bi-' + store.Configuration.Server.wgdashboard_peer_list_display"></i>
<LocaleText t="Display"></LocaleText> <LocaleText t="Display"></LocaleText>
<span class="badge text-bg-primary ms-2">{{this.display[store.Configuration.Server.dashboard_peer_list_display]}}</span> <span class="badge text-bg-primary ms-2">{{this.display[store.Configuration.Server.wgdashboard_peer_list_display]}}</span>
</button> </button>
<ul class="dropdown-menu rounded-3"> <ul class="dropdown-menu rounded-3">
<li v-for="(value, key) in this.display" > <li v-for="(value, key) in this.display" >
@@ -152,7 +152,7 @@ export default {
</small> </small>
<small class="ms-auto"> <small class="ms-auto">
<i class="bi bi-check-circle-fill" <i class="bi bi-check-circle-fill"
v-if="store.Configuration.Server.dashboard_peer_list_display === key"></i> v-if="store.Configuration.Server.wgdashboard_peer_list_display === key"></i>
</small> </small>
</button> </button>
</li> </li>
@@ -155,7 +155,7 @@ export default {
format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss"
preview-format="yyyy-MM-dd HH:mm:ss" preview-format="yyyy-MM-dd HH:mm:ss"
:dark="this.store.Configuration.Server.dashboard_theme === 'dark'" :dark="this.store.Configuration.Server.wgdashboard_theme === 'dark'"
/> />
</div> </div>
<div class="d-flex gap-2 flex-column flex-sm-row"> <div class="d-flex gap-2 flex-column flex-sm-row">
+1 -1
View File
@@ -57,7 +57,7 @@ export default {
<template> <template>
<div class="col-md-3 col-lg-2 d-md-block p-2 navbar-container bg-transparent" <div class="col-md-3 col-lg-2 d-md-block p-2 navbar-container bg-transparent"
:class="{active: this.dashboardConfigurationStore.ShowNavBar}" :class="{active: this.dashboardConfigurationStore.ShowNavBar}"
:data-bs-theme="dashboardConfigurationStore.Configuration.Server.dashboard_theme" :data-bs-theme="dashboardConfigurationStore.Configuration.Server.wgdashboard_theme"
> >
<nav id="sidebarMenu" class=" bg-body-tertiary sidebar border h-100 rounded-3 shadow overflow-y-scroll" > <nav id="sidebarMenu" class=" bg-body-tertiary sidebar border h-100 rounded-3 shadow overflow-y-scroll" >
<div class="sidebar-sticky "> <div class="sidebar-sticky ">
@@ -112,7 +112,7 @@ const uploadReady = computed(() => {
:read-only="true" :read-only="true"
:display-language="true" :display-language="true"
v-model="uploadFiles[t].content" v-model="uploadFiles[t].content"
:theme="dashboardStore.Configuration.Server.dashboard_theme === 'dark' ? 'github-dark':'github'" :theme="dashboardStore.Configuration.Server.wgdashboard_theme === 'dark' ? 'github-dark':'github'"
:languages="[[t, uploadFiles[t].filename]]" :languages="[[t, uploadFiles[t].filename]]"
width="100%" height="500px"> width="100%" height="500px">
</CodeEditor> </CodeEditor>
@@ -15,7 +15,7 @@ export default {
}, },
data(){ data(){
return { return {
value: this.store.Configuration.Server.dashboard_api_key, value: this.store.Configuration.Server.wgdashboard_apikey,
apiKeys: [], apiKeys: [],
newDashboardAPIKey: false newDashboardAPIKey: false
} }
@@ -24,7 +24,7 @@ export default {
async toggleDashboardAPIKeys(){ async toggleDashboardAPIKeys(){
await fetchPost("/api/updateDashboardConfigurationItem", { await fetchPost("/api/updateDashboardConfigurationItem", {
section: "Server", section: "Server",
key: "dashboard_api_key", key: "wgdashboard_apikey",
value: this.value value: this.value
}, (res) => { }, (res) => {
if (res.status){ if (res.status){
@@ -79,7 +79,7 @@ export default {
preview-format="yyyy-MM-dd HH:mm:ss" preview-format="yyyy-MM-dd HH:mm:ss"
:clearable="false" :clearable="false"
:disabled="this.newKeyData.NeverExpire || this.submitting" :disabled="this.newKeyData.NeverExpire || this.submitting"
:dark="this.store.Configuration.Server.dashboard_theme === 'dark'" :dark="this.store.Configuration.Server.wgdashboard_theme === 'dark'"
/> />
</div> </div>
<div class="form-check"> <div class="form-check">
@@ -26,7 +26,7 @@ export default {
lang_id: lang_id lang_id: lang_id
}, (res) => { }, (res) => {
if (res.status){ if (res.status){
this.store.Configuration.Server.dashboard_language = lang_id; this.store.Configuration.Server.wgdashboard_language = lang_id;
this.store.Locale = res.data this.store.Locale = res.data
}else{ }else{
this.store.newMessage("Server", "WGDashboard language update failed", "danger") this.store.newMessage("Server", "WGDashboard language update failed", "danger")
@@ -36,7 +36,7 @@ export default {
}, },
computed:{ computed:{
currentLanguage(){ currentLanguage(){
let lang = this.store.Configuration.Server.dashboard_language; let lang = this.store.Configuration.Server.wgdashboard_language;
return this.languages.find(x => x.lang_id === lang) return this.languages.find(x => x.lang_id === lang)
} }
} }
@@ -18,7 +18,7 @@ export default {
value: value value: value
}, (res) => { }, (res) => {
if (res.status){ if (res.status){
this.dashboardConfigurationStore.Configuration.Server.dashboard_theme = value; this.dashboardConfigurationStore.Configuration.Server.wgdashboard_theme = value;
} }
}); });
} }
@@ -36,13 +36,13 @@ export default {
<div class="d-flex gap-1"> <div class="d-flex gap-1">
<button class="btn bg-primary-subtle text-primary-emphasis flex-grow-1" <button class="btn bg-primary-subtle text-primary-emphasis flex-grow-1"
@click="this.switchTheme('light')" @click="this.switchTheme('light')"
:class="{active: this.dashboardConfigurationStore.Configuration.Server.dashboard_theme === 'light'}"> :class="{active: this.dashboardConfigurationStore.Configuration.Server.wgdashboard_theme === 'light'}">
<i class="bi bi-sun-fill me-2"></i> <i class="bi bi-sun-fill me-2"></i>
<LocaleText t="Light"></LocaleText> <LocaleText t="Light"></LocaleText>
</button> </button>
<button class="btn bg-primary-subtle text-primary-emphasis flex-grow-1" <button class="btn bg-primary-subtle text-primary-emphasis flex-grow-1"
@click="this.switchTheme('dark')" @click="this.switchTheme('dark')"
:class="{active: this.dashboardConfigurationStore.Configuration.Server.dashboard_theme === 'dark'}"> :class="{active: this.dashboardConfigurationStore.Configuration.Server.wgdashboard_theme === 'dark'}">
<i class="bi bi-moon-fill me-2"></i> <i class="bi bi-moon-fill me-2"></i>
<LocaleText t="Dark"></LocaleText> <LocaleText t="Dark"></LocaleText>
</button> </button>
@@ -63,7 +63,7 @@ export default {
<template> <template>
<div class="container-fluid login-container-fluid d-flex main pt-5 overflow-scroll" <div class="container-fluid login-container-fluid d-flex main pt-5 overflow-scroll"
:data-bs-theme="this.store.Configuration.Server.dashboard_theme"> :data-bs-theme="this.store.Configuration.Server.wgdashboard_theme">
<div class="m-auto text-body" style="width: 500px"> <div class="m-auto text-body" style="width: 500px">
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<div> <div>
@@ -86,7 +86,7 @@ export default {
getHeaders(){ getHeaders(){
let headers = { let headers = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'wg-dashboard-apikey': this.server.apiKey 'wgdashboard-apikey': this.server.apiKey
} }
if (this.server.headers){ if (this.server.headers){
for (let header of Object.values(this.server.headers)){ for (let header of Object.values(this.server.headers)){
+1 -1
View File
@@ -19,7 +19,7 @@ export default {
</script> </script>
<template> <template>
<div class="container-fluid flex-grow-1 main" :data-bs-theme="this.dashboardConfigurationStore.Configuration.Server.dashboard_theme"> <div class="container-fluid flex-grow-1 main" :data-bs-theme="this.dashboardConfigurationStore.Configuration.Server.wgdashboard_theme">
<div class="row h-100"> <div class="row h-100">
<Navbar></Navbar> <Navbar></Navbar>
<main class="col-md-9 col-lg-10 overflow-y-scroll mb-0 pt-2"> <main class="col-md-9 col-lg-10 overflow-y-scroll mb-0 pt-2">
+1 -1
View File
@@ -56,7 +56,7 @@ export default {
<template> <template>
<div class="container-fluid login-container-fluid d-flex main pt-5 overflow-scroll" <div class="container-fluid login-container-fluid d-flex main pt-5 overflow-scroll"
:data-bs-theme="this.store.Configuration.Server.dashboard_theme"> :data-bs-theme="this.store.Configuration.Server.wgdashboard_theme">
<div class="m-auto text-body" style="width: 500px"> <div class="m-auto text-body" style="width: 500px">
<span class="dashboardLogo display-4"> <span class="dashboardLogo display-4">
<LocaleText t="Nice to meet you!"></LocaleText> <LocaleText t="Nice to meet you!"></LocaleText>