Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement Network Connection Detection in BeaconTray #2440

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Expand Up @@ -53,7 +53,9 @@ export default Vue.extend({
return this.has_accessible_rtsp_streams || this.has_accessible_udp_streams
},
wireless_interface_domains(): Domain[] {
return beacon.available_domains.filter((entry) => entry.interface_type !== InterfaceType.WIRED)
return beacon.available_domains.filter(
(entry) => entry.interface_type === InterfaceType.WIFI || entry.interface_type === InterfaceType.HOTSPOT,
)
},
is_connected_to_wifi(): boolean {
return this.wireless_interface_domains.some((domain) => domain.ip === beacon.nginx_ip_address)
Expand Down
1 change: 1 addition & 0 deletions core/frontend/src/types/beacon.ts
Expand Up @@ -3,6 +3,7 @@ export enum InterfaceType {
WIFI = 'WIFI',
HOTSPOT = 'HOTSPOT',
UNKNOWN = 'UNKNOWN',
USB = 'USB',
}
export interface Domain {
ip: string
Expand Down