Skip to content

Commit

Permalink
core: frontend: Update BeaconTray network checks
Browse files Browse the repository at this point in the history
* Updat BeaconTrayMenu to consider cases where a unknown network is
  listed to avoid cases where interfaces are classified mistakenly
  • Loading branch information
JoaoMario109 authored and patrickelectric committed Mar 25, 2024
1 parent 97e2f99 commit 364bfd4
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions core/frontend/src/components/beacon/BeaconTrayMenu.vue
@@ -1,6 +1,6 @@
<template>
<v-menu
v-if="is_connected_to_wifi"
v-if="should_warn_user"
:close-on-content-click="false"
nudge-left="150"
nudge-bottom="25"
Expand All @@ -15,11 +15,9 @@
v-on="on"
>
<v-icon
v-tooltip="is_connected_to_wifi
? 'Connected through a wireless connection, expect degraded performance'
: 'Connected through a wired connection'"
class="px-1 white-shadow"
:color="is_connected_to_wifi ? 'yellow' : 'white'"
:v-tooltip="tooltip_text"
:color="should_warn_user ? 'yellow' : 'white'"
>
mdi-ethernet-cable
</v-icon>
Expand Down Expand Up @@ -70,22 +68,43 @@ export default Vue.extend({
},
computed: {
wired_interface_domains(): Domain[] {
return beacon.available_domains.filter((entry) => entry.interface_type === InterfaceType.WIRED)
return beacon.available_domains.filter(
(entry) => entry.interface_type === InterfaceType.WIRED || entry.interface_type === InterfaceType.USB,
)
},
wireless_interface_domains(): Domain[] {
return beacon.available_domains.filter(
(entry) => entry.interface_type === InterfaceType.WIFI || entry.interface_type === InterfaceType.HOTSPOT,
)
},
is_connected_to_wired(): boolean {
return this.wired_interface_domains.some((domain) => domain.ip === beacon.nginx_ip_address)
},
is_connected_to_wifi(): boolean {
const is_on_wifi = this.wireless_interface_domains.some((domain) => domain.ip === beacon.nginx_ip_address)
const is_on_wired = this.wired_interface_domains.some((domain) => domain.ip === beacon.nginx_ip_address)
if (is_on_wifi && is_on_wired) {
if (is_on_wifi && this.is_connected_to_wired) {
console.debug('Unexpected behavior. There are both Wired and Wireless interfaces sharing the same IP address.')
}
return is_on_wifi && !is_on_wired
return is_on_wifi && !this.is_connected_to_wired
},
is_connected_to_unknown_interface(): boolean {
return !this.is_connected_to_wifi && !this.is_connected_to_wired
},
should_warn_user(): boolean {
return this.is_connected_to_wifi || this.is_connected_to_unknown_interface
},
tooltip_text(): string {
if (this.is_connected_to_wifi) {
return 'Connected through a wireless connection, expect degraded performance'
}
if (this.is_connected_to_wired) {
return 'Connected through a wired connection'
}
return 'It looks like you are reaching BlueOS using a complex network. '
+ 'Degraded performance can happen in this case.'
},
},
mounted() {
Expand Down

0 comments on commit 364bfd4

Please sign in to comment.