Skip to content

Commit

Permalink
frontend: update network priority changing UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Feb 6, 2025
1 parent 441b958 commit 7709020
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
19 changes: 11 additions & 8 deletions core/frontend/src/components/app/NetworkInterfacePriorityMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,20 @@ export default Vue.extend({
await Promise.all(interfaces.map((iface) => this.checkInterfaceInternet(host, iface)))
},
async setHighestInterface(): Promise<void> {
this.is_loading = true
const interface_priority = this.interfaces.map((inter) => ({ name: inter.name }))
const interface_priorities = this.interfaces.map((inter) => ({ name: inter.name, priority: 0 }))
interface_priorities.forEach((inter, index) => {
inter.priority = index * 1000
})
this.interfaces = []
await back_axios({
method: 'post',
url: `${ethernet.API_URL}/set_interfaces_priority`,
timeout: 10000,
data: interface_priority,
data: interface_priorities,
})
.catch((error) => {
const message = `Could not increase the priority for interface '${interface_priority}', ${error}.`
const message = `Could not set network interface priorities: ${interface_priorities}, error: ${error}`
console.log(interface_priorities)
notifier.pushError('INCREASE_NETWORK_INTERFACE_METRIC_FAIL', message)
})
.then(() => {
Expand All @@ -161,7 +165,6 @@ export default Vue.extend({
this.close()
})
await this.fetchAvailableInterfaces()
this.is_loading = false
},
async fetchAvailableInterfaces(): Promise<void> {
await back_axios({
Expand All @@ -173,9 +176,9 @@ export default Vue.extend({
.then((response) => {
const interfaces = response.data as EthernetInterface[]
interfaces.sort((a, b) => {
if (!a.info) return -1
if (!b.info) return 1
return a.info.priority - b.info.priority
const priorityA = a.priority ?? Number.MAX_SAFE_INTEGER
const priorityB = b.priority ?? Number.MAX_SAFE_INTEGER
return priorityA - priorityB
})
this.interfaces = interfaces
})
Expand Down
1 change: 1 addition & 0 deletions core/frontend/src/types/ethernet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ export interface EthernetInterface {
name: string,
addresses: InterfaceAddress[],
info?: InterfaceInfo,
priority?: number,
}

0 comments on commit 7709020

Please sign in to comment.