mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2026-04-20 11:46:18 +00:00
Add preshared key default toggle (#1207)
* Add previous PR changes
* Import lowercase dayjs
* Build dist
* Revert "Build dist"
This reverts commit 152da2ca10
Dist not to be built at @DaanSelen request
This commit is contained in:
@@ -51,7 +51,8 @@ class DashboardConfig:
|
|||||||
"peer_display_mode": "grid",
|
"peer_display_mode": "grid",
|
||||||
"remote_endpoint": GetRemoteEndpoint(),
|
"remote_endpoint": GetRemoteEndpoint(),
|
||||||
"peer_MTU": "1420",
|
"peer_MTU": "1420",
|
||||||
"peer_keep_alive": "21"
|
"peer_keep_alive": "21",
|
||||||
|
"peer_preshared_key_default": "false"
|
||||||
},
|
},
|
||||||
"Other": {
|
"Other": {
|
||||||
"welcome_session": "true"
|
"welcome_session": "true"
|
||||||
|
|||||||
@@ -6,18 +6,27 @@ export default {
|
|||||||
components: {LocaleText},
|
components: {LocaleText},
|
||||||
props: {
|
props: {
|
||||||
data: Object,
|
data: Object,
|
||||||
saving: Boolean
|
saving: Boolean,
|
||||||
|
defaultEnabled: Boolean
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
return{
|
return{
|
||||||
enable: false
|
enable: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
const hasKey = !!(this.data && this.data.preshared_key && this.data.preshared_key.length > 0)
|
||||||
|
if (hasKey || this.defaultEnabled){
|
||||||
|
this.enable = true
|
||||||
|
}
|
||||||
|
},
|
||||||
watch:{
|
watch:{
|
||||||
enable(){
|
enable(){
|
||||||
if (this.enable){
|
if (this.enable) {
|
||||||
this.data.preshared_key = window.wireguard.generateKeypair().presharedKey
|
if (!this.data.preshared_key){
|
||||||
}else {
|
this.data.preshared_key = window.wireguard.generateKeypair().presharedKey
|
||||||
|
}
|
||||||
|
} else {
|
||||||
this.data.preshared_key = ""
|
this.data.preshared_key = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,4 +57,4 @@ export default {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ const peerData = ref({
|
|||||||
keepalive: parseInt(dashboardStore.Configuration.Peers.peer_keep_alive),
|
keepalive: parseInt(dashboardStore.Configuration.Peers.peer_keep_alive),
|
||||||
mtu: parseInt(dashboardStore.Configuration.Peers.peer_mtu),
|
mtu: parseInt(dashboardStore.Configuration.Peers.peer_mtu),
|
||||||
preshared_key: "",
|
preshared_key: "",
|
||||||
preshared_key_bulkAdd: false,
|
preshared_key_bulkAdd: Boolean(dashboardStore.Configuration.Peers.peer_preshared_key_default),
|
||||||
allowed_ips_validation: true,
|
allowed_ips_validation: true,
|
||||||
})
|
})
|
||||||
const availableIp = ref([])
|
const availableIp = ref([])
|
||||||
@@ -128,7 +128,7 @@ watch(() => {
|
|||||||
<EndpointAllowedIps :saving="saving" :data="peerData"></EndpointAllowedIps>
|
<EndpointAllowedIps :saving="saving" :data="peerData"></EndpointAllowedIps>
|
||||||
<div class="row gy-3">
|
<div class="row gy-3">
|
||||||
<div class="col-sm" v-if="!peerData.bulkAdd">
|
<div class="col-sm" v-if="!peerData.bulkAdd">
|
||||||
<PresharedKeyInput :saving="saving" :data="peerData" :bulk="peerData.bulkAdd"></PresharedKeyInput>
|
<PresharedKeyInput :saving="saving" :data="peerData" :bulk="peerData.bulkAdd" :defaultEnabled="Boolean(dashboardStore.Configuration.Peers.peer_preshared_key_default)"></PresharedKeyInput>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
@@ -177,4 +177,4 @@ watch(() => {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export default {
|
|||||||
keepalive: parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive),
|
keepalive: parseInt(this.dashboardStore.Configuration.Peers.peer_keep_alive),
|
||||||
mtu: parseInt(this.dashboardStore.Configuration.Peers.peer_mtu),
|
mtu: parseInt(this.dashboardStore.Configuration.Peers.peer_mtu),
|
||||||
preshared_key: "",
|
preshared_key: "",
|
||||||
preshared_key_bulkAdd: false,
|
preshared_key_bulkAdd: Boolean(this.dashboardStore.Configuration.Peers.peer_preshared_key_default),
|
||||||
},
|
},
|
||||||
availableIp: undefined,
|
availableIp: undefined,
|
||||||
availableIpSearchString: "",
|
availableIpSearchString: "",
|
||||||
@@ -133,7 +133,7 @@ export default {
|
|||||||
<hr class="mb-0 mt-2">
|
<hr class="mb-0 mt-2">
|
||||||
<div class="row gy-3">
|
<div class="row gy-3">
|
||||||
<div class="col-sm" v-if="!this.data.bulkAdd">
|
<div class="col-sm" v-if="!this.data.bulkAdd">
|
||||||
<PresharedKeyInput :saving="saving" :data="data" :bulk="this.data.bulkAdd"></PresharedKeyInput>
|
<PresharedKeyInput :saving="saving" :data="data" :bulk="this.data.bulkAdd" :defaultEnabled="Boolean(this.dashboardStore.Configuration.Peers.peer_preshared_key_default)"></PresharedKeyInput>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
@@ -187,4 +187,4 @@ div{
|
|||||||
.card{
|
.card{
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ import PeersDefaultSettingsInput from "@/components/settingsComponent/peersDefau
|
|||||||
targetData="peer_mtu" title="MTU"></PeersDefaultSettingsInput>
|
targetData="peer_mtu" title="MTU"></PeersDefaultSettingsInput>
|
||||||
<PeersDefaultSettingsInput
|
<PeersDefaultSettingsInput
|
||||||
targetData="peer_keep_alive" title="Persistent Keepalive"></PeersDefaultSettingsInput>
|
targetData="peer_keep_alive" title="Persistent Keepalive"></PeersDefaultSettingsInput>
|
||||||
|
<PeersDefaultSettingsInput
|
||||||
|
targetData="peer_preshared_key_default" title="Pre-Shared Key Default"></PeersDefaultSettingsInput>
|
||||||
<PeersDefaultSettingsInput
|
<PeersDefaultSettingsInput
|
||||||
targetData="remote_endpoint" title="Peer Remote Endpoint"
|
targetData="remote_endpoint" title="Peer Remote Endpoint"
|
||||||
:warning="true" warningText="This will be changed globally, and will be apply to all peer's QR code and configuration file."
|
:warning="true" warningText="This will be changed globally, and will be apply to all peer's QR code and configuration file."
|
||||||
@@ -34,4 +36,4 @@ import PeersDefaultSettingsInput from "@/components/settingsComponent/peersDefau
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ export default {
|
|||||||
mounted() {
|
mounted() {
|
||||||
this.value = this.store.Configuration.Peers[this.targetData];
|
this.value = this.store.Configuration.Peers[this.targetData];
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
isBoolean(){
|
||||||
|
return typeof this.value === "boolean"
|
||||||
|
}
|
||||||
|
},
|
||||||
methods:{
|
methods:{
|
||||||
async useValidation(){
|
async useValidation(){
|
||||||
if(this.changed){
|
if(this.changed){
|
||||||
@@ -67,7 +72,14 @@ export default {
|
|||||||
<LocaleText :t="this.title"></LocaleText>
|
<LocaleText :t="this.title"></LocaleText>
|
||||||
</small></strong>
|
</small></strong>
|
||||||
</label>
|
</label>
|
||||||
<input type="text" class="form-control"
|
<div v-if="isBoolean" class="form-check form-switch">
|
||||||
|
<input class="form-check-input" type="checkbox" role="switch"
|
||||||
|
v-model="this.value"
|
||||||
|
:id="this.uuid"
|
||||||
|
@change="this.changed = true; useValidation()"
|
||||||
|
:disabled="this.updating">
|
||||||
|
</div>
|
||||||
|
<input v-else type="text" class="form-control"
|
||||||
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
|
:class="{'is-invalid': showInvalidFeedback, 'is-valid': isValid}"
|
||||||
:id="this.uuid"
|
:id="this.uuid"
|
||||||
v-model="this.value"
|
v-model="this.value"
|
||||||
@@ -88,4 +100,4 @@ export default {
|
|||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user