Skip to content

Commit 4c0e8b8

Browse files
wip
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent fce7e3a commit 4c0e8b8

File tree

6 files changed

+87
-47
lines changed

6 files changed

+87
-47
lines changed

core/frontend/src/components/wifi/WifiInterfaceManager.vue

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,14 @@
1111
WiFi - {{ interfaceName }}
1212
</v-toolbar-title>
1313
<v-spacer />
14-
<v-chip
15-
v-if="interface_data?.connected"
16-
color="success"
17-
small
18-
class="mr-2"
19-
>
20-
{{ interface_data?.ssid }}
21-
</v-chip>
22-
<v-chip
23-
v-else
24-
color="grey"
25-
small
26-
class="mr-2"
14+
<v-btn
15+
v-if="is_hotspot_interface"
16+
v-tooltip="'Hotspot settings'"
17+
icon
18+
@click="show_settings_dialog = true"
2719
>
28-
Disconnected
29-
</v-chip>
20+
<v-icon>mdi-cog</v-icon>
21+
</v-btn>
3022
<v-btn
3123
v-if="is_hotspot_interface"
3224
v-tooltip="'Toggle hotspot'"
@@ -41,6 +33,8 @@
4133
</v-btn>
4234
</v-app-bar>
4335

36+
<wifi-settings-dialog v-model="show_settings_dialog" />
37+
4438
<v-sheet>
4539
<v-sheet
4640
max-height="600"
@@ -62,7 +56,7 @@
6256
:key="key"
6357
class="available-network"
6458
:network="network"
65-
:connected="interface_data?.ssid === network.ssid && interface_data?.connected"
59+
:connected="isNetworkConnected(network)"
6660
@click="openConnectionDialog(network)"
6761
/>
6862
</div>
@@ -100,12 +94,13 @@ import Vue from 'vue'
10094
import Notifier from '@/libs/notifier'
10195
import wifi from '@/store/wifi'
10296
import { wifi_service } from '@/types/frontend_services'
103-
import { Network, WifiInterface } from '@/types/wifi'
97+
import { Network, WifiInterfaceStatus } from '@/types/wifi'
10498
import back_axios from '@/utils/api'
10599
106100
import SpinningLogo from '../common/SpinningLogo.vue'
107101
import InterfaceConnectionDialog from './InterfaceConnectionDialog.vue'
108102
import WifiNetworkCard from './WifiNetworkCard.vue'
103+
import WifiSettingsDialog from './WifiSettingsDialog.vue'
109104
110105
const notifier = new Notifier(wifi_service)
111106
@@ -115,6 +110,7 @@ export default Vue.extend({
115110
WifiNetworkCard,
116111
SpinningLogo,
117112
InterfaceConnectionDialog,
113+
WifiSettingsDialog,
118114
},
119115
props: {
120116
interfaceName: {
@@ -126,13 +122,14 @@ export default Vue.extend({
126122
return {
127123
selected_network: null as Network | null,
128124
show_connection_dialog: false,
125+
show_settings_dialog: false,
129126
hotspot_status_loading: false,
130127
ssid_filter: undefined as string | undefined,
131128
}
132129
},
133130
computed: {
134-
interface_data(): WifiInterface | undefined {
135-
return wifi.wifi_interfaces.find((iface) => iface.name === this.interfaceName)
131+
connection_status(): WifiInterfaceStatus | undefined {
132+
return wifi.interface_status.get(this.interfaceName)
136133
},
137134
networks(): Network[] | null {
138135
const result = wifi.interface_scan_results.get(this.interfaceName)
@@ -162,6 +159,16 @@ export default Vue.extend({
162159
},
163160
},
164161
methods: {
162+
isNetworkConnected(network: Network): boolean {
163+
const status = this.connection_status
164+
if (!status || status.state !== 'connected') return false
165+
// Match by BSSID for exact AP identification
166+
if (status.bssid && network.bssid) {
167+
return status.bssid.toLowerCase() === network.bssid.toLowerCase()
168+
}
169+
// Fallback to SSID only if BSSID not available
170+
return status.ssid === network.ssid
171+
},
165172
openConnectionDialog(network: Network): void {
166173
this.selected_network = network
167174
this.show_connection_dialog = true

core/frontend/src/components/wifi/WifiInterfaceTrayMenu.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,6 @@
2525
>
2626
{{ wifi_icon }}
2727
</v-icon>
28-
<span
29-
v-if="showLabel"
30-
class="white--text text-caption ml-1"
31-
style="font-size: 0.65rem !important;"
32-
>
33-
{{ interfaceName }}
34-
</span>
3528
</v-card>
3629
</template>
3730
<wifi-interface-manager
@@ -60,10 +53,6 @@ export default Vue.extend({
6053
type: String,
6154
required: true,
6255
},
63-
showLabel: {
64-
type: Boolean,
65-
default: false,
66-
},
6756
},
6857
computed: {
6958
interface_data(): WifiInterface | undefined {

core/frontend/src/components/wifi/WifiNetworkCard.vue

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@
2323
</span>
2424
</v-col>
2525

26-
<v-col :cols="1">
26+
<v-col
27+
:cols="1"
28+
class="d-flex justify-center"
29+
>
2730
<v-chip
28-
x-small
31+
small
2932
:color="frequency_band_color"
3033
class="frequency-chip"
34+
label
3135
>
3236
{{ frequency_band }}
3337
</v-chip>
@@ -123,9 +127,11 @@ export default Vue.extend({
123127
background-color: #2174aa;
124128
}
125129
.frequency-chip {
126-
font-size: 10px !important;
127-
height: 18px !important;
128-
padding: 0 6px !important;
130+
font-size: 11px !important;
131+
height: 20px !important;
132+
min-width: 32px !important;
133+
padding: 0 4px !important;
129134
font-weight: 600;
135+
justify-content: center;
130136
}
131137
</style>

core/frontend/src/components/wifi/WifiTrayMenu.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
v-for="iface in wifi_interfaces"
99
:key="iface.name"
1010
:interface-name="iface.name"
11-
:show-label="wifi_interfaces.length > 1"
1211
class="mr-1"
1312
/>
1413
</template>

core/frontend/src/components/wifi/WifiUpdater.vue

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { OneMoreTime } from '@/one-more-time'
1010
import wifi from '@/store/wifi'
1111
import { wifi_service } from '@/types/frontend_services'
1212
import {
13-
Network, SavedNetwork, WifiInterfaceList, WifiInterfaceScanResult, WPANetwork,
13+
Network, SavedNetwork, WifiInterfaceList, WifiInterfaceScanResult, WifiInterfaceStatus, WPANetwork,
1414
} from '@/types/wifi'
1515
import back_axios, { isBackendOffline } from '@/utils/api'
1616
@@ -28,6 +28,7 @@ export default Vue.extend({
2828
// Multi-interface v2 API tasks
2929
fetch_interfaces_task: new OneMoreTime({ delay: 5000, disposeWith: this }),
3030
fetch_interface_scans_task: new OneMoreTime({ delay: 20000, disposeWith: this }),
31+
fetch_interface_status_task: new OneMoreTime({ delay: 5000, disposeWith: this }),
3132
}
3233
},
3334
mounted() {
@@ -39,6 +40,7 @@ export default Vue.extend({
3940
// Multi-interface v2 API
4041
this.fetch_interfaces_task.setAction(this.fetchInterfaces)
4142
this.fetch_interface_scans_task.setAction(this.fetchInterfaceScans)
43+
this.fetch_interface_status_task.setAction(this.fetchInterfaceStatus)
4244
},
4345
methods: {
4446
async fetchNetworkStatus(): Promise<void> {
@@ -206,6 +208,29 @@ export default Vue.extend({
206208
}
207209
})
208210
},
211+
async fetchInterfaceStatus(): Promise<void> {
212+
// Fetch connection status for all interfaces (includes bssid)
213+
await back_axios({
214+
method: 'get',
215+
url: `${wifi.API_URL_V2}/wifi/status`,
216+
timeout: 10000,
217+
})
218+
.then((response) => {
219+
const results = response.data as WifiInterfaceStatus[]
220+
for (const status of results) {
221+
wifi.setInterfaceStatus({
222+
interface_name: status.interface,
223+
status,
224+
})
225+
}
226+
})
227+
.catch((error) => {
228+
// Silently fail - v2 API might not be available
229+
if (!isBackendOffline(error)) {
230+
console.debug('v2 status API not available:', error.message)
231+
}
232+
})
233+
},
209234
},
210235
})
211236
</script>

core/frontend/src/utils/wifi.ts

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,35 @@
11
import { Network } from '@/types/wifi'
22

3-
export function wifi_strenght_icon(signal_db: number): string {
3+
export function wifi_strenght_icon(signal: number): string {
44
/*eslint-disable */
5+
// Signal can be in two formats:
6+
// 1. Percentage (0-100) from NetworkManager
7+
// 2. dBm (negative values like -30 to -90) from wpa_supplicant
8+
//
59
// | Signal Strength | TL;DR | Description |
610
// |-----------------|-----------|--------------------------------------------------------------------------------------------------------------------------------------------|
7-
// | -30 dBm | Amazing | Max achievable signal strength. The client can only be a few feet from the AP to achieve this. Not typical or desirable in the real world. |
8-
// | -67 dBm | Very Good | Minimum signal strength for applications that require very reliable, timely delivery of data packets. |
9-
// | -70 dBm | Okay | Minimum signal strength for reliable packet delivery. |
10-
// | -80 dBm | Not Good | Minimum signal strength for basic connectivity. Packet delivery may be unreliable. |
11-
// | -90 dBm | Unusable | Approaching or drowning in the noise floor. Any functionality is highly unlikely. |
11+
// | -30 dBm / 100% | Amazing | Max achievable signal strength. The client can only be a few feet from the AP to achieve this. Not typical or desirable in the real world. |
12+
// | -67 dBm / 75% | Very Good | Minimum signal strength for applications that require very reliable, timely delivery of data packets. |
13+
// | -70 dBm / 50% | Okay | Minimum signal strength for reliable packet delivery. |
14+
// | -80 dBm / 25% | Not Good | Minimum signal strength for basic connectivity. Packet delivery may be unreliable. |
15+
// | -90 dBm / 0% | Unusable | Approaching or drowning in the noise floor. Any functionality is highly unlikely. |
1216
// Reference: metageek.com/training/resources/wifi-signal-strength-basics.html
1317
/* eslint-enable */
1418

15-
if (signal_db >= -30) return 'mdi-wifi-strength-4'
16-
if (signal_db >= -67) return 'mdi-wifi-strength-3'
17-
if (signal_db >= -70) return 'mdi-wifi-strength-2'
18-
if (signal_db >= -80) return 'mdi-wifi-strength-1'
19+
// Handle percentage format (0-100, positive values)
20+
if (signal >= 0) {
21+
if (signal >= 75) return 'mdi-wifi-strength-4'
22+
if (signal >= 50) return 'mdi-wifi-strength-3'
23+
if (signal >= 25) return 'mdi-wifi-strength-2'
24+
if (signal >= 10) return 'mdi-wifi-strength-1'
25+
return 'mdi-wifi-strength-alert-outline'
26+
}
27+
28+
// Handle dBm format (negative values)
29+
if (signal >= -30) return 'mdi-wifi-strength-4'
30+
if (signal >= -67) return 'mdi-wifi-strength-3'
31+
if (signal >= -70) return 'mdi-wifi-strength-2'
32+
if (signal >= -80) return 'mdi-wifi-strength-1'
1933
return 'mdi-wifi-strength-alert-outline'
2034
}
2135

0 commit comments

Comments
 (0)