Added toggle for client side app

This commit is contained in:
Donald Zou
2025-09-05 16:39:59 +08:00
parent 44af7eba11
commit 030c1bdcba
6 changed files with 43 additions and 26 deletions

View File

@@ -45,6 +45,9 @@ def createClientBlueprint(wireguardConfigurations: dict[WireguardConfiguration],
@client.before_request
def clientBeforeRequest():
if not dashboardConfig.GetConfig("Clients", "enable")[1]:
abort(404)
if request.method.lower() == 'options':
return ResponseObject(True)

View File

@@ -1342,6 +1342,14 @@ def API_OIDC_Status():
'''
Client Controller
'''
@app.get(f'{APP_PREFIX}/api/clients/toggleStatus')
def API_Clients_ToggleStatus():
DashboardConfig.SetConfig("Clients", "enable",
not DashboardConfig.GetConfig("Clients", "enable")[1])
return ResponseObject(data=DashboardConfig.GetConfig("Clients", "enable")[1])
@app.get(f'{APP_PREFIX}/api/clients/allClients')
def API_Clients_AllClients():
return ResponseObject(data=DashboardClients.GetAllClients())

View File

@@ -81,7 +81,7 @@ class DashboardConfig:
"client_enable": "false"
},
"Clients": {
"allow_local_sign_up": "true"
"enable": "true",
},
"WireGuardConfiguration": {
"autostart": ""

View File

@@ -8,13 +8,13 @@
"short_name": "WGDashboard",
"screenshots": [
{
"src": "https://donaldzou.github.io/WGDashboard-Documentation/images/sign-in.png",
"src": "https://wgdashboard-resources.tor1.cdn.digitaloceanspaces.com/Documentation%20Images/sign-in.png",
"sizes": "2880x1826",
"type": "image/png",
"form_factor": "wide"
},
{
"src": "https://donaldzou.github.io/WGDashboard-Documentation/images/sign-in.png",
"src": "https://wgdashboard-resources.tor1.cdn.digitaloceanspaces.com/Documentation%20Images/index.png",
"sizes": "2880x1826",
"type": "image/png"
}

View File

@@ -2,13 +2,23 @@
import { ref, reactive } from "vue"
import LocaleText from "@/components/text/localeText.vue";
import OidcSettings from "@/components/clientComponents/clientSettingComponents/oidcSettings.vue";
import { fetchGet } from "@/utilities/fetch.js"
const emits = defineEmits(['close'])
import { DashboardConfigurationStore } from "@/stores/DashboardConfigurationStore"
const dashboardConfigurationStore = DashboardConfigurationStore()
const loading = ref(false)
const values = reactive({
allow_local_sign_up: dashboardConfigurationStore.Configuration.Clients.allow_local_sign_up
enableClients: dashboardConfigurationStore.Configuration.Clients.enable
})
const toggling = ref(false)
const toggleClientSideApp = async () => {
toggling.value = true
await fetchGet("/api/clients/toggleStatus", {}, (res) => {
values.enableClients = res.data
})
toggling.value = false
}
</script>
<template>
@@ -20,27 +30,23 @@ const values = reactive({
</h4>
<button type="button" class="btn-close ms-auto" @click="emits('close')"></button>
</div>
<div class="card-body px-4">
<div class="py-2">
<OidcSettings mode="Client"></OidcSettings>
<!-- <hr>-->
<!-- <div>-->
<!-- <div class="d-flex">-->
<!-- <h6 class="mb-0">-->
<!-- <LocaleText t="Allow Local Accounts Sign Up"></LocaleText>-->
<!-- </h6>-->
<!-- <div class="form-check form-switch ms-auto">-->
<!-- <label class="form-check-label" for="allow_local_sign_up">-->
<!-- <LocaleText :t="values.allow_local_sign_up ? 'Enabled':'Disabled'"></LocaleText>-->
<!-- </label>-->
<!-- <input-->
<!-- :disabled="loading"-->
<!-- v-model="values.allow_local_sign_up"-->
<!-- class="form-check-input" type="checkbox" role="switch" id="allow_local_sign_up">-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<div class="card-body px-4 d-flex gap-3 flex-column">
<div class="d-flex align-items-center">
<h6 class="mb-0">
<LocaleText t="Client Side App"></LocaleText>
</h6>
<div class="form-check form-switch ms-auto">
<label class="form-check-label" for="oidc_switch">
<LocaleText :t="values.enableClients ? 'Enabled':'Disabled'"></LocaleText>
</label>
<input
:disabled="oidcStatusLoading"
v-model="values.enableClients"
@change="toggleClientSideApp()"
class="form-check-input" type="checkbox" role="switch" id="oidc_switch">
</div>
</div>
<OidcSettings mode="Client"></OidcSettings>
</div>
</div>
</div>

View File

@@ -115,8 +115,8 @@ const deleteSuccess = async () => {
@refresh="getAssignedPeers()"
:clientAssignedPeers="clientAssignedPeers"
:client="client"></ClientAssignedPeers>
<ClientResetPassword
:client="client" v-if="client.ClientGroup === 'Local'"></ClientResetPassword>
<!-- <ClientResetPassword-->
<!-- :client="client" v-if="client.ClientGroup === 'Local'"></ClientResetPassword>-->
<ClientDelete
@deleteSuccess="deleteSuccess()"
:client="client"></ClientDelete>