mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-06 16:00:28 +01:00
Adjusted some code for electron version
This commit is contained in:
parent
55f55820c5
commit
96ccb03eea
@ -1,16 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# if [ -z "$(ls -A /etc/wireguard)" ]; then
|
|
||||||
# mv /wg0.conf /etc/wireguard
|
|
||||||
# echo "Moved conf file to /etc/wireguard"
|
|
||||||
# else
|
|
||||||
# rm wg0.conf
|
|
||||||
# echo "Removed unneeded conf file"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# wg-quick up wg0
|
|
||||||
chmod u+x /opt/wgdashboard/wgd.sh
|
|
||||||
if [ ! -f "/opt/wgdashboard/wg-dashboard.ini" ]; then
|
|
||||||
/opt/wgdashboard/wgd.sh install
|
|
||||||
fi
|
|
||||||
/opt/wgdashboard/wgd.sh debug
|
|
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Before Width: | Height: | Size: 180 KiB |
@ -1,14 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<link rel="icon" href="./favicon.png">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>WGDashboard</title>
|
|
||||||
<script type="module" crossorigin src="./assets/index.js"></script>
|
|
||||||
<link rel="stylesheet" crossorigin href="./assets/index.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="app" class="w-100 vh-100"></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
2288
src/static/app/package-lock.json
generated
2288
src/static/app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"build electron": "vite build --mode electron",
|
"build electron": "vite build --mode electron && cd ../../../../WGDashboard-Desktop && electron-builder",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@ -18,6 +18,7 @@
|
|||||||
"bootstrap-icons": "^1.11.2",
|
"bootstrap-icons": "^1.11.2",
|
||||||
"cidr-tools": "^7.0.4",
|
"cidr-tools": "^7.0.4",
|
||||||
"dayjs": "^1.11.12",
|
"dayjs": "^1.11.12",
|
||||||
|
"electron-builder": "^24.13.3",
|
||||||
"fuse.js": "^7.0.0",
|
"fuse.js": "^7.0.0",
|
||||||
"i": "^0.3.7",
|
"i": "^0.3.7",
|
||||||
"is-cidr": "^5.0.3",
|
"is-cidr": "^5.0.3",
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { RouterView } from 'vue-router'
|
import { RouterView } from 'vue-router'
|
||||||
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
||||||
import {watch} from "vue";
|
import {computed, watch} from "vue";
|
||||||
const store = DashboardConfigurationStore();
|
const store = DashboardConfigurationStore();
|
||||||
store.initCrossServerConfiguration();
|
store.initCrossServerConfiguration();
|
||||||
|
if (window.IS_WGDASHBOARD_DESKTOP){
|
||||||
|
store.IsElectronApp = true;
|
||||||
|
store.CrossServerConfiguration.Enable = true;
|
||||||
|
}
|
||||||
|
|
||||||
watch(store.CrossServerConfiguration, () => {
|
watch(store.CrossServerConfiguration, () => {
|
||||||
store.syncCrossServerConfiguration()
|
store.syncCrossServerConfiguration()
|
||||||
@ -11,16 +15,22 @@ watch(store.CrossServerConfiguration, () => {
|
|||||||
deep: true
|
deep: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getActiveCrossServer = computed(() => {
|
||||||
|
if (store.ActiveServerConfiguration){
|
||||||
|
return store.CrossServerConfiguration.ServerList[store.ActiveServerConfiguration]
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<nav class="navbar bg-dark sticky-top" data-bs-theme="dark">
|
<nav class="navbar bg-dark sticky-top" data-bs-theme="dark">
|
||||||
<div class="container-fluid d-flex text-body">
|
<div class="container-fluid d-flex text-body align-items-center">
|
||||||
<span class="navbar-brand mb-0 h1">WGDashboard</span>
|
<span class="navbar-brand mb-0 h1">WGDashboard</span>
|
||||||
<span class="ms-auto" v-if="store.getActiveCrossServer() !== undefined">
|
<small class="ms-auto text-muted" v-if="getActiveCrossServer !== undefined">
|
||||||
<i class="bi bi-server me-2"></i>{{store.getActiveCrossServer().host}}
|
<i class="bi bi-server me-2"></i>{{getActiveCrossServer.host}}
|
||||||
</span>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
<Suspense>
|
<Suspense>
|
||||||
|
@ -27,8 +27,9 @@ export default {
|
|||||||
<RemoteServer v-for="(server, key) in this.store.CrossServerConfiguration.ServerList"
|
<RemoteServer v-for="(server, key) in this.store.CrossServerConfiguration.ServerList"
|
||||||
@setActiveServer="this.store.setActiveCrossServer(key)"
|
@setActiveServer="this.store.setActiveCrossServer(key)"
|
||||||
@delete="this.store.deleteCrossServerConfiguration(key)"
|
@delete="this.store.deleteCrossServerConfiguration(key)"
|
||||||
|
:key="key"
|
||||||
:server="server"></RemoteServer>
|
:server="server"></RemoteServer>
|
||||||
<h6 class="text-muted m-auto" v-if="this.store.CrossServerConfiguration.ServerList.length === 0">
|
<h6 class="text-muted m-auto" v-if="Object.keys(this.store.CrossServerConfiguration.ServerList).length === 0">
|
||||||
Click<i class="bi bi-plus-circle-fill mx-1"></i>to add your server</h6>
|
Click<i class="bi bi-plus-circle-fill mx-1"></i>to add your server</h6>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,16 +14,23 @@ export const DashboardConfigurationStore = defineStore('DashboardConfigurationSt
|
|||||||
CrossServerConfiguration:{
|
CrossServerConfiguration:{
|
||||||
Enable: false,
|
Enable: false,
|
||||||
ServerList: {}
|
ServerList: {}
|
||||||
}
|
},
|
||||||
|
ActiveServerConfiguration: undefined,
|
||||||
|
IsElectronApp: false
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
initCrossServerConfiguration(){
|
initCrossServerConfiguration(){
|
||||||
const currentConfiguration = localStorage.getItem('CrossServerConfiguration');
|
const currentConfiguration = localStorage.getItem('CrossServerConfiguration');
|
||||||
|
if (localStorage.getItem("ActiveCrossServerConfiguration") !== null){
|
||||||
|
this.ActiveServerConfiguration = localStorage.getItem("ActiveCrossServerConfiguration");
|
||||||
|
}
|
||||||
if (currentConfiguration === null){
|
if (currentConfiguration === null){
|
||||||
localStorage.setItem('CrossServerConfiguration', JSON.stringify(this.CrossServerConfiguration))
|
localStorage.setItem('CrossServerConfiguration', JSON.stringify(this.CrossServerConfiguration))
|
||||||
}else{
|
}else{
|
||||||
this.CrossServerConfiguration = JSON.parse(currentConfiguration)
|
this.CrossServerConfiguration = JSON.parse(currentConfiguration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
syncCrossServerConfiguration(){
|
syncCrossServerConfiguration(){
|
||||||
localStorage.setItem('CrossServerConfiguration', JSON.stringify(this.CrossServerConfiguration))
|
localStorage.setItem('CrossServerConfiguration', JSON.stringify(this.CrossServerConfiguration))
|
||||||
@ -42,9 +49,11 @@ export const DashboardConfigurationStore = defineStore('DashboardConfigurationSt
|
|||||||
return undefined
|
return undefined
|
||||||
},
|
},
|
||||||
setActiveCrossServer(key){
|
setActiveCrossServer(key){
|
||||||
|
this.ActiveServerConfiguration = key;
|
||||||
localStorage.setItem('ActiveCrossServerConfiguration', key)
|
localStorage.setItem('ActiveCrossServerConfiguration', key)
|
||||||
},
|
},
|
||||||
removeActiveCrossServer(){
|
removeActiveCrossServer(){
|
||||||
|
this.ActiveServerConfiguration = undefined;
|
||||||
localStorage.removeItem('ActiveCrossServerConfiguration')
|
localStorage.removeItem('ActiveCrossServerConfiguration')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ export const fetchGet = async (url, params=undefined, callback=undefined) => {
|
|||||||
if (!x.ok){
|
if (!x.ok){
|
||||||
if (x.status !== 200){
|
if (x.status !== 200){
|
||||||
if (x.status === 401){
|
if (x.status === 401){
|
||||||
router.push({path: '/signin'})
|
|
||||||
store.newMessage("WGDashboard", "Session Ended", "warning")
|
store.newMessage("WGDashboard", "Session Ended", "warning")
|
||||||
}
|
}
|
||||||
throw new Error(x.statusText)
|
throw new Error(x.statusText)
|
||||||
@ -42,6 +42,7 @@ export const fetchGet = async (url, params=undefined, callback=undefined) => {
|
|||||||
}
|
}
|
||||||
}).then(x => callback ? callback(x) : undefined).catch(x => {
|
}).then(x => callback ? callback(x) : undefined).catch(x => {
|
||||||
console.log(x)
|
console.log(x)
|
||||||
|
router.push({path: '/signin'})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ export const fetchPost = async (url, body, callback) => {
|
|||||||
if (!x.ok){
|
if (!x.ok){
|
||||||
if (x.status !== 200){
|
if (x.status !== 200){
|
||||||
if (x.status === 401){
|
if (x.status === 401){
|
||||||
router.push({path: '/signin'})
|
|
||||||
store.newMessage("WGDashboard", "Session Ended", "warning")
|
store.newMessage("WGDashboard", "Session Ended", "warning")
|
||||||
}
|
}
|
||||||
throw new Error(x.statusText)
|
throw new Error(x.statusText)
|
||||||
@ -65,5 +66,6 @@ export const fetchPost = async (url, body, callback) => {
|
|||||||
}
|
}
|
||||||
}).then(x => callback ? callback(x) : undefined).catch(x => {
|
}).then(x => callback ? callback(x) : undefined).catch(x => {
|
||||||
console.log(x)
|
console.log(x)
|
||||||
|
router.push({path: '/signin'})
|
||||||
})
|
})
|
||||||
}
|
}
|
@ -9,14 +9,17 @@ export default {
|
|||||||
components: {RemoteServerList, Message},
|
components: {RemoteServerList, Message},
|
||||||
async setup(){
|
async setup(){
|
||||||
const store = DashboardConfigurationStore()
|
const store = DashboardConfigurationStore()
|
||||||
let theme = ""
|
let theme = "dark"
|
||||||
let totpEnabled = false;
|
let totpEnabled = false;
|
||||||
await fetchGet("/api/getDashboardTheme", {}, (res) => {
|
if (!store.IsElectronApp){
|
||||||
theme = res.data
|
await fetchGet("/api/getDashboardTheme", {}, (res) => {
|
||||||
});
|
theme = res.data
|
||||||
await fetchGet("/api/isTotpEnabled", {}, (res) => {
|
});
|
||||||
totpEnabled = res.data
|
await fetchGet("/api/isTotpEnabled", {}, (res) => {
|
||||||
});
|
totpEnabled = res.data
|
||||||
|
});
|
||||||
|
}
|
||||||
|
store.removeActiveCrossServer();
|
||||||
return {store, theme, totpEnabled}
|
return {store, theme, totpEnabled}
|
||||||
},
|
},
|
||||||
data(){
|
data(){
|
||||||
@ -132,7 +135,7 @@ export default {
|
|||||||
</form>
|
</form>
|
||||||
<RemoteServerList v-else></RemoteServerList>
|
<RemoteServerList v-else></RemoteServerList>
|
||||||
|
|
||||||
<div class="d-flex mt-3">
|
<div class="d-flex mt-3" v-if="!this.store.IsElectronApp">
|
||||||
<div class="form-check form-switch ms-auto">
|
<div class="form-check form-switch ms-auto">
|
||||||
<input
|
<input
|
||||||
v-model="this.store.CrossServerConfiguration.Enable"
|
v-model="this.store.CrossServerConfiguration.Enable"
|
||||||
|
@ -20,13 +20,8 @@ export default defineConfig(({mode}) => {
|
|||||||
'@': fileURLToPath(new URL('./src', import.meta.url))
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
server:{
|
|
||||||
proxy: {
|
|
||||||
'/api': proxy
|
|
||||||
}
|
|
||||||
},
|
|
||||||
build: {
|
build: {
|
||||||
outDir: 'electron',
|
outDir: '../../../../WGDashboard-Desktop',
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: {
|
output: {
|
||||||
entryFileNames: `assets/[name].js`,
|
entryFileNames: `assets/[name].js`,
|
||||||
|
Loading…
Reference in New Issue
Block a user