mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-10-03 15:56:17 +00:00
Added peer selections for client
This commit is contained in:
@@ -1260,7 +1260,6 @@ def API_Clients_AssignedClients():
|
|||||||
@app.get(f'{APP_PREFIX}/api/clients/allConfigurationsPeers')
|
@app.get(f'{APP_PREFIX}/api/clients/allConfigurationsPeers')
|
||||||
def API_Clients_AllConfigurationsPeers():
|
def API_Clients_AllConfigurationsPeers():
|
||||||
c = {}
|
c = {}
|
||||||
|
|
||||||
for (key, val) in WireguardConfigurations.items():
|
for (key, val) in WireguardConfigurations.items():
|
||||||
c[key] = list(map(lambda x : {
|
c[key] = list(map(lambda x : {
|
||||||
"id": x.id,
|
"id": x.id,
|
||||||
@@ -1271,6 +1270,17 @@ def API_Clients_AllConfigurationsPeers():
|
|||||||
data=c
|
data=c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@app.get(f'{APP_PREFIX}/api/clients/assignedPeers')
|
||||||
|
def API_Clients_AssignedPeers():
|
||||||
|
data = request.args
|
||||||
|
clientId = data.get("ClientID")
|
||||||
|
if not clientId:
|
||||||
|
return ResponseObject(False, "Please provide ClientID")
|
||||||
|
|
||||||
|
d = DashboardClients.GetClientAssignedPeers(clientId)
|
||||||
|
if d is None:
|
||||||
|
return ResponseObject(False, "Client does not exist")
|
||||||
|
return ResponseObject(data=d)
|
||||||
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
@@ -330,6 +330,12 @@ class DashboardClients:
|
|||||||
a.Client = self.GetClient(a.ClientID)
|
a.Client = self.GetClient(a.ClientID)
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
def GetClientAssignedPeers(self, ClientID):
|
||||||
|
client = self.GetClient(ClientID)
|
||||||
|
if client is not None:
|
||||||
|
return self.DashboardClientsPeerAssignment.GetAssignedPeers(ClientID)
|
||||||
|
return None
|
||||||
|
|
||||||
def AssignClient(self, ConfigurationName, PeerID, ClientID) -> tuple[bool, dict[str, str]] | tuple[bool, None]:
|
def AssignClient(self, ConfigurationName, PeerID, ClientID) -> tuple[bool, dict[str, str]] | tuple[bool, None]:
|
||||||
return self.DashboardClientsPeerAssignment.AssignClient(ClientID, ConfigurationName, PeerID)
|
return self.DashboardClientsPeerAssignment.AssignClient(ClientID, ConfigurationName, PeerID)
|
||||||
|
|
||||||
|
3019
src/static/app/package-lock.json
generated
3019
src/static/app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -11,32 +11,32 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@vue/language-server": "^2.1.10",
|
"@vue/language-server": "^3.0.3",
|
||||||
"@vuepic/vue-datepicker": "^9.0.1",
|
"@vuepic/vue-datepicker": "^11.0.2",
|
||||||
"@vueuse/core": "^10.9.0",
|
"@vueuse/core": "^13.5.0",
|
||||||
"@vueuse/shared": "^10.9.0",
|
"@vueuse/shared": "^13.5.0",
|
||||||
"animate.css": "^4.1.1",
|
"animate.css": "^4.1.1",
|
||||||
"bootstrap": "^5.3.2",
|
"bootstrap": "^5.3.2",
|
||||||
"bootstrap-icons": "^1.11.3",
|
"bootstrap-icons": "^1.11.3",
|
||||||
"cidr-tools": "^7.0.4",
|
"cidr-tools": "^11.0.3",
|
||||||
"dayjs": "^1.11.12",
|
"dayjs": "^1.11.12",
|
||||||
"electron-builder": "^24.13.3",
|
"electron-builder": "^26.0.12",
|
||||||
"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",
|
||||||
"npm": "^10.5.0",
|
"npm": "^10.5.0",
|
||||||
"ol": "^10.2.1",
|
"ol": "^10.2.1",
|
||||||
"pinia": "^2.1.7",
|
"pinia": "^3.0.3",
|
||||||
"qrcode": "^1.5.3",
|
"qrcode": "^1.5.3",
|
||||||
"qrcodejs": "^1.0.0",
|
"qrcodejs": "^1.0.0",
|
||||||
"simple-code-editor": "^2.0.9",
|
"simple-code-editor": "^2.0.9",
|
||||||
"uuid": "^9.0.1",
|
"uuid": "^11.1.0",
|
||||||
"vue": "^3.4.29",
|
"vue": "^3.5.17",
|
||||||
"vue-chartjs": "^5.3.0",
|
"vue-chartjs": "^5.3.0",
|
||||||
"vue-router": "^4.2.5"
|
"vue-router": "^4.2.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vitejs/plugin-vue": "^5.0.0",
|
"@vitejs/plugin-vue": "^6.0.0",
|
||||||
"vite": "^5.0.10"
|
"vite": "^7.0.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,62 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import {onMounted, watch, watchEffect} from "vue";
|
||||||
|
import { fetchGet } from "@/utilities/fetch.js"
|
||||||
|
import {DashboardClientAssignmentStore} from "@/stores/DashboardClientAssignmentStore.js";
|
||||||
|
|
||||||
|
const props = defineProps(['client'])
|
||||||
|
watchEffect(async () => {
|
||||||
|
const clientId = props.client.ClientID;
|
||||||
|
await fetchGet('/api/clients/assignedPeers', {
|
||||||
|
ClientID: clientId
|
||||||
|
}, (res) => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
const assignmentStore = DashboardClientAssignmentStore()
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="border w-100 d-flex " style="height: 400px">
|
||||||
|
<div style="flex: 1 0 0; overflow: scroll">
|
||||||
|
<div class="card rounded-0 border-0" v-for="(peers, configuration) in assignmentStore.allConfigurationsPeers">
|
||||||
|
<div class="card-header sticky-top z-5 bg-body-secondary border-0 rounded-0 shadow border-bottom btn-brand text-white">
|
||||||
|
<samp>{{ configuration }}</samp>
|
||||||
|
</div>
|
||||||
|
<div class="card-body p-0">
|
||||||
|
<div class="list-group list-group-flush" >
|
||||||
|
<button
|
||||||
|
class="list-group-item d-flex flex-column border-bottom list-group-item-action"
|
||||||
|
v-for="peer in peers" >
|
||||||
|
<small class="text-body">
|
||||||
|
{{ peer.id }}
|
||||||
|
</small>
|
||||||
|
<small class="text-muted">
|
||||||
|
{{ client.name ? client.name : 'Untitled Peer'}}
|
||||||
|
</small>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="px-3 border-start border-end d-flex flex-column justify-content-center gap-3">
|
||||||
|
<button class="btn">
|
||||||
|
<i class="bi bi-chevron-left"></i>
|
||||||
|
</button>
|
||||||
|
<button class="btn">
|
||||||
|
<i class="bi bi-chevron-right"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div style="flex: 1 0 0">
|
||||||
|
hi
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
div .list-group-item:last-child{
|
||||||
|
border-bottom: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
@@ -1,18 +1,18 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts" async>
|
||||||
import {useRoute} from "vue-router";
|
import {useRoute} from "vue-router";
|
||||||
|
import { fetchGet } from "@/utilities/fetch.js"
|
||||||
|
|
||||||
|
|
||||||
import {DashboardClientAssignmentStore} from "@/stores/DashboardClientAssignmentStore.js";
|
import {DashboardClientAssignmentStore} from "@/stores/DashboardClientAssignmentStore.js";
|
||||||
import {computed} from "vue";
|
import {computed} from "vue";
|
||||||
import LocaleText from "@/components/text/localeText.vue";
|
import LocaleText from "@/components/text/localeText.vue";
|
||||||
|
import ClientAssignedPeers from "@/components/clientComponents/clientAssignedPeers.vue";
|
||||||
const assignmentStore = DashboardClientAssignmentStore()
|
const assignmentStore = DashboardClientAssignmentStore()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
const client = computed(() => {
|
const client = computed(() => {
|
||||||
return assignmentStore.getClientById(route.params.id)
|
return assignmentStore.getClientById(route.params.id)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -34,9 +34,10 @@ const client = computed(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="px-4">
|
<div class="px-4">
|
||||||
<h5>
|
<h5 class="mb-3">
|
||||||
<LocaleText t="Assigned Peers"></LocaleText>
|
<LocaleText t="Assign Peers"></LocaleText>
|
||||||
</h5>
|
</h5>
|
||||||
|
<ClientAssignedPeers :client="client"></ClientAssignedPeers>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="d-flex w-100 h-100 text-muted">
|
<div v-else class="d-flex w-100 h-100 text-muted">
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import {defineStore} from "pinia";
|
import {defineStore} from "pinia";
|
||||||
import {computed, ref} from "vue";
|
import {ref} from "vue";
|
||||||
import {fetchGet, fetchPost} from "@/utilities/fetch.js";
|
import {fetchGet, fetchPost} from "@/utilities/fetch.js";
|
||||||
|
|
||||||
export const DashboardClientAssignmentStore =
|
export const DashboardClientAssignmentStore =
|
||||||
defineStore('DashboardClientAssignmentStore', () => {
|
defineStore('DashboardClientAssignmentStore', () => {
|
||||||
|
const allConfigurationsPeers = ref({})
|
||||||
const assignments = ref([])
|
const assignments = ref([])
|
||||||
const clients = ref({})
|
const clients = ref({})
|
||||||
const clientsRaw = ref([])
|
const clientsRaw = ref([])
|
||||||
@@ -64,6 +65,12 @@ export const DashboardClientAssignmentStore =
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getAllConfigurationsPeers = async () => {
|
||||||
|
await fetchGet("/api/clients/allConfigurationsPeers", {}, (res) => {
|
||||||
|
allConfigurationsPeers.value = res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
assignments,
|
assignments,
|
||||||
getAssignedClients,
|
getAssignedClients,
|
||||||
@@ -75,6 +82,8 @@ export const DashboardClientAssignmentStore =
|
|||||||
getClientById,
|
getClientById,
|
||||||
unassigning,
|
unassigning,
|
||||||
assigning,
|
assigning,
|
||||||
clientsRaw
|
clientsRaw,
|
||||||
|
allConfigurationsPeers,
|
||||||
|
getAllConfigurationsPeers
|
||||||
}
|
}
|
||||||
})
|
})
|
@@ -5,9 +5,10 @@ import {ref} from "vue";
|
|||||||
const assignmentStore = DashboardClientAssignmentStore()
|
const assignmentStore = DashboardClientAssignmentStore()
|
||||||
import {GetLocale} from "@/utilities/locale.js";
|
import {GetLocale} from "@/utilities/locale.js";
|
||||||
import ClientGroup from "@/components/clientComponents/clientGroup.vue";
|
import ClientGroup from "@/components/clientComponents/clientGroup.vue";
|
||||||
import * as sea from "node:sea";
|
import { fetchGet } from "@/utilities/fetch.js"
|
||||||
|
|
||||||
await assignmentStore.getClients();
|
await assignmentStore.getClients();
|
||||||
|
assignmentStore.getAllConfigurationsPeers();
|
||||||
|
|
||||||
const searchString = ref("")
|
const searchString = ref("")
|
||||||
</script>
|
</script>
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import {parse} from "cidr-tools";
|
import {parseCidr} from "cidr-tools";
|
||||||
import '@/utilities/wireguard.js'
|
import '@/utilities/wireguard.js'
|
||||||
import {WireguardConfigurationsStore} from "@/stores/WireguardConfigurationsStore.js";
|
import {WireguardConfigurationsStore} from "@/stores/WireguardConfigurationsStore.js";
|
||||||
import {fetchGet, fetchPost} from "@/utilities/fetch.js";
|
import {fetchGet, fetchPost} from "@/utilities/fetch.js";
|
||||||
@@ -142,7 +142,7 @@ export default {
|
|||||||
if (newVal.trim().split("/").filter(x => x.length > 0).length !== 2){
|
if (newVal.trim().split("/").filter(x => x.length > 0).length !== 2){
|
||||||
throw Error()
|
throw Error()
|
||||||
}
|
}
|
||||||
let p = parse(newVal);
|
let p = parseCidr(newVal);
|
||||||
let i = p.end - p.start;
|
let i = p.end - p.start;
|
||||||
this.numberOfAvailableIPs = i.toLocaleString();
|
this.numberOfAvailableIPs = i.toLocaleString();
|
||||||
ele.classList.add("is-valid")
|
ele.classList.add("is-valid")
|
||||||
|
Reference in New Issue
Block a user