Skip to content

Commit fd406a4

Browse files
core: frontend: views: MainView: Add dynamic WiFi widgets per interface
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent 3fbe83e commit fd406a4

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

core/frontend/src/views/MainView.vue

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ import { OneMoreTime } from '@/one-more-time'
9797
import helper from '@/store/helper'
9898
import mavlink from '@/store/mavlink'
9999
import video from '@/store/video'
100+
import wifi from '@/store/wifi'
100101
import { InternetConnectionState } from '@/types/helper'
101102
import { StreamStatus } from '@/types/video'
103+
import { WifiInterface } from '@/types/wifi'
102104
import mavlink_store_get from '@/utils/mavlink'
103105
import CPUUsage from '@/widgets/CpuPie.vue'
104106
import Networking from '@/widgets/Networking.vue'
@@ -133,9 +135,45 @@ export default Vue.extend({
133135
apps(): AppItem[] {
134136
return [
135137
...this.baseApps,
138+
...this.wifiWidgets,
136139
...this.videoStreamWidgets,
137140
]
138141
},
142+
wifi_interfaces(): WifiInterface[] {
143+
return wifi.wifi_interfaces
144+
},
145+
wifiWidgets(): AppItem[] {
146+
// If we have detected interfaces from v2 API, show them dynamically
147+
if (this.wifi_interfaces.length > 0) {
148+
return this.wifi_interfaces.map((iface) => ({
149+
icon: 'mdi-wifi',
150+
title: `WiFi - ${iface.name}`,
151+
component: Networking,
152+
size: {
153+
w: 0.1,
154+
h: 0.4,
155+
},
156+
props: {
157+
interface: iface.name,
158+
},
159+
}))
160+
}
161+
// Fallback to wlan0 if no interfaces detected yet
162+
return [
163+
{
164+
icon: 'mdi-wifi',
165+
title: 'WiFi Status',
166+
component: Networking,
167+
size: {
168+
w: 0.1,
169+
h: 0.4,
170+
},
171+
props: {
172+
interface: 'wlan0',
173+
},
174+
},
175+
]
176+
},
139177
baseApps(): AppItem[] {
140178
return [
141179
{
@@ -180,18 +218,6 @@ export default Vue.extend({
180218
interface: 'eth0',
181219
},
182220
},
183-
{
184-
icon: 'mdi-wifi',
185-
title: 'WiFi Status',
186-
component: Networking,
187-
size: {
188-
w: 0.1,
189-
h: 0.4,
190-
},
191-
props: {
192-
interface: 'wlan0',
193-
},
194-
},
195221
]
196222
},
197223
videoStreamWidgets(): AppItem[] {

0 commit comments

Comments
 (0)