1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-22 15:20:09 +01:00

CORS SUCCESS!!!

This commit is contained in:
Donald Zou 2024-08-10 19:23:50 -04:00
parent 54142b73fb
commit a650e628e5

View File

@ -15,28 +15,30 @@ export default {
}, },
methods: { methods: {
handshake(){ handshake(){
this.startTime = undefined; if (this.server.host && this.server.apiKey){
this.endTime = undefined; this.startTime = undefined;
this.endTime = undefined;
this.startTime = dayjs()
fetch(`${this.server.host}/api/handshake`, {
headers: {
"content-type": "application/json",
"wg-dashboard-apikey": this.server.apiKey
},
method: "GET",
signal: AbortSignal.timeout(5000)
}).then(res => res.json()).then(res => {
this.active = true;
this.endTime = dayjs()
}).catch((res) => {
this.startTime = undefined;
this.endTime = undefined;
})
}
this.startTime = dayjs()
fetch(`//${this.server.host}/api/handshake`, {
headers: {
"content-type": "application/json",
"wg-dashboard-apikey": this.server.apiKey
},
method: "GET",
signal: AbortSignal.timeout(5000)
}).then(res => res.json()).then(res => {
this.active = true;
this.endTime = dayjs()
}).catch((res) => {
console.log(res)
})
} }
}, },
mounted() { mounted() {
this.handshake() this.handshake()
}, },
computed: { computed: {
getHandshakeTime(){ getHandshakeTime(){
@ -56,19 +58,22 @@ export default {
<div class="d-flex gap-3 w-100"> <div class="d-flex gap-3 w-100">
<div class="d-flex gap-3 align-items-center flex-grow-1"> <div class="d-flex gap-3 align-items-center flex-grow-1">
<i class="bi bi-server"></i> <i class="bi bi-server"></i>
<input class="form-control form-control-sm" <input class="form-control form-control-sm"
@blur="this.handshake()"
v-model="this.server.host" v-model="this.server.host"
type="url"> type="url">
</div> </div>
<div class="d-flex gap-3 align-items-center flex-grow-1"> <div class="d-flex gap-3 align-items-center flex-grow-1">
<i class="bi bi-key-fill"></i> <i class="bi bi-key-fill"></i>
<input class="form-control form-control-sm" <input class="form-control form-control-sm"
@blur="this.handshake()"
v-model="this.server.apiKey" v-model="this.server.apiKey"
type="text"> type="text">
</div> </div>
<div class="d-flex gap-2"> <div class="d-flex gap-2">
<button <button
@click="this.$emit('delete')" @click="this.$emit('delete')"
class="ms-auto btn btn-sm bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle"> class="ms-auto btn btn-sm bg-danger-subtle text-danger-emphasis border-1 border-danger-subtle">
<i class="bi bi-trash"></i> <i class="bi bi-trash"></i>
</button> </button>