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

frontend: disable wifi-updater and let user know if wifi service is disabled #3046

Merged
merged 2 commits into from
Jan 10, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions core/frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@
<div id="tour-center-hook" />
</v-main>
<ethernet-updater />
<wifi-updater />
<mavlink-updater />
<new-version-notificator />
<Wizard />
Expand Down Expand Up @@ -419,7 +418,6 @@ import HealthTrayMenu from './components/health/HealthTrayMenu.vue'
import MavlinkUpdater from './components/mavlink/MavlinkUpdater.vue'
import NotificationTrayButton from './components/notifications/TrayButton.vue'
import WifiTrayMenu from './components/wifi/WifiTrayMenu.vue'
import WifiUpdater from './components/wifi/WifiUpdater.vue'
import menus, { menuItem } from './menus'
import autopilot_data from './store/autopilot'
import Cpu from './widgets/Cpu.vue'
Expand All @@ -436,7 +434,6 @@ export default Vue.extend({
'pirate-mode-tray-menu': PiradeModeTrayMenu,
'theme-tray-menu': ThemeTrayMenu,
'wifi-tray-menu': WifiTrayMenu,
'wifi-updater': WifiUpdater,
'ethernet-tray-menu': EthernetTrayMenu,
'cloud-tray-menu': CloudTrayMenu,
'ethernet-updater': EthernetUpdater,
Expand Down
78 changes: 59 additions & 19 deletions core/frontend/src/components/wifi/WifiTrayMenu.vue
Original file line number Diff line number Diff line change
@@ -1,44 +1,79 @@
<template>
<v-menu
:close-on-content-click="false"
nudge-left="500"
nudge-bottom="25"
>
<template
#activator="{ on, attrs }"
<div>
<wifi-updater v-if="!wifi_service_disabled" />
<v-menu
:close-on-content-click="false"
nudge-left="500"
nudge-bottom="25"
>
<template
#activator="{ on, attrs }"
>
<v-card
id="wifi-tray-menu-button"
class="px-1"
elevation="0"
color="transparent"
v-bind="attrs"
v-on="on"
>
<v-icon
v-tooltip="{
content: wifi_service_disabled ? 'Wifi is disabled' : undefined,
bottom: true,
offset: 5,
}"
color="white"
>
{{ wifi_icon }}
</v-icon>
</v-card>
</template>
<wifi-manager v-if="!wifi_service_disabled" />
<v-card
id="wifi-tray-menu-button"
class="px-1"
elevation="0"
color="transparent"
v-bind="attrs"
v-on="on"
v-else
elevation="1"
width="500"
>
<v-icon color="white">
{{ wifi_icon }}
</v-icon>
<v-card-title class="text-subtitle-1 pa-4">
Wifi is disabled via environment variable. <br>
Re-enable it by removing "wifi" from <code>BLUEOS_DISABLE_SERVICES</code>
in <code>/root/.config/bootstrap/startup.json</code>
</v-card-title>
</v-card>
</template>
<wifi-manager />
</v-menu>
</v-menu>
</div>
</template>

<script lang="ts">
import Vue from 'vue'

import commander from '@/store/commander'
import wifi from '@/store/wifi'
import { wifi_strenght_icon } from '@/utils/wifi'

import WifiManager from './WifiManager.vue'
import WifiUpdater from './WifiUpdater.vue'

export default Vue.extend({
name: 'WifiTrayMenu',
components: {
WifiManager,
WifiUpdater,
},
data() {
return {
disabled_services: undefined as string[] | undefined,
}
},
computed: {
wifi_service_disabled(): boolean {
return this.disabled_services?.includes('wifi') ?? false
},
wifi_icon(): string {
if (this.wifi_service_disabled) {
return 'mdi-wifi-cancel'
}
if (wifi.connectable_networks === null) {
return 'mdi-wifi-sync'
}
Expand All @@ -48,6 +83,11 @@ export default Vue.extend({
return wifi_strenght_icon(wifi.current_network.signal)
},
},
mounted() {
commander.getEnvironmentVariables().then((environment_variables) => {
this.disabled_services = ((environment_variables?.BLUEOS_DISABLE_SERVICES as string) ?? '').split(',') as string[]
})
},
})
</script>

Expand Down
10 changes: 9 additions & 1 deletion core/frontend/src/store/commander.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class CommanderStore {
API_URL = '/commander/v1.0'

private static instance: CommanderStore
// environment variables need a full reboot to take effect, so we should be able to cache them
private environmentVariables: Record<string, unknown> | undefined

public static getInstance(): CommanderStore {
if (!CommanderStore.instance) {
Expand Down Expand Up @@ -145,12 +147,18 @@ class CommanderStore {
}

async getEnvironmentVariables(): Promise<Record<string, unknown> | undefined> {
if (this.environmentVariables) {
return this.environmentVariables
}
return back_axios({
method: 'get',
url: `${this.API_URL}/environment_variables`,
timeout: 5000,
})
.then((response) => response.data)
.then((response) => {
this.environmentVariables = response.data
return response.data
})
.catch((error) => {
if (error === backend_offline_error) {
return undefined
Expand Down
3 changes: 3 additions & 0 deletions core/start-blueos-core
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ RUN_AS_REGULAR_USER="sudo -u blueos"
# Set BlueOS log folder
BLUEOS_LOG_FOLDER_PATH="/var/logs/blueos"

# Replace spaces with commas in the disabled services list
BLUEOS_DISABLE_SERVICES=${BLUEOS_DISABLE_SERVICES// /,}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the replace is necessary here ? the list should be comma separated already

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because some people (@JoaoMario109 ) may be used to type the list with spaces after commas 🤷
this is just a very basic sanitization


# The system may start with full disk, in this case resulting in an unstable behavior.
# As an attempt to recover the system, lets delete the log files before current boot
AVAILABLE_SPACE_MB=$(($(stat -f / --format="%a*%S/1024**2")))
Expand Down
Loading