diff --git a/openpilot/starpilot/galaxy/web/css/galaxy.css b/openpilot/starpilot/galaxy/web/css/galaxy.css index 321732ed90..0c40980642 100644 --- a/openpilot/starpilot/galaxy/web/css/galaxy.css +++ b/openpilot/starpilot/galaxy/web/css/galaxy.css @@ -915,6 +915,8 @@ padding: 4px 9px; line-height: 1.2; vertical-align: middle; } +.gx-chip--phone i, .gx-section__header .gx-chip--phone i { color: inherit; font-size: 1em; } +.gx-chip--phone { gap: 5px; color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 40%, transparent); } button.gx-chip { -webkit-appearance: none; appearance: none; diff --git a/openpilot/starpilot/galaxy/web/js/networks.js b/openpilot/starpilot/galaxy/web/js/networks.js index 34ac676338..04a4d27823 100644 --- a/openpilot/starpilot/galaxy/web/js/networks.js +++ b/openpilot/starpilot/galaxy/web/js/networks.js @@ -33,9 +33,14 @@ export const NetworksPage = { components: { WikiHelp, GxNotice, GxState, GalaxySettingRow, GalaxyHotspot, GxDialog, ConnectionLogs, BluetoothTabs }, props: { go: { type: Function, required: true }, mode: { type: String, required: true }, unauthorized: { type: Function, required: true } }, data: () => ({ snapshot: null, busy: false, error: '', openUuid: null, adding: false, joiningSsid: '', joinPassword: '', - hiddenOpen: false, hiddenSsid: '', showJoinPassword: false, forgetUuid: null, timer: null, controller: null, generation: 0, active: false }), + hiddenOpen: false, hiddenSsid: '', showJoinPassword: false, forgetUuid: null, timer: null, controller: null, generation: 0, active: false, phone: null }), computed: { linkName() { return LINKS[this.snapshot?.link.link] || 'Unknown' }, + phoneDetail() { + if (!this.phone?.connected) return '' + return this.phone.active ? `Active · ${(this.phone.bytes / 1048576).toFixed(1)} MB of the phone's mobile data today` + : 'Ready. The comma uses it only when it has no Wi-Fi or cellular internet of its own.' + }, availableNetworks() { return this.snapshot?.available || [] }, joining() { return this.snapshot?.lastJoin?.state === 'joining' }, joinOpen() { return this.hiddenOpen || !!this.joiningSsid }, @@ -64,7 +69,7 @@ export const NetworksPage = { start() { if (this.mode === 'local') { this.active = true; this.refresh() } }, stop() { this.active = false; this.generation++; clearTimeout(this.timer); this.controller?.abort() - this.snapshot = null; this.openUuid = null; this.forgetUuid = null; this.adding = false; this.cancelJoin(); this.busy = false + this.snapshot = null; this.phone = null; this.openUuid = null; this.forgetUuid = null; this.adding = false; this.cancelJoin(); this.busy = false }, adopt(value) { if (!validNetworks(value)) throw new Error('Invalid network status') @@ -133,9 +138,12 @@ export const NetworksPage = { const generation = ++this.generation this.controller = new AbortController() try { - const value = await requestJson('./api/galaxy/networks', { request: { signal: this.controller.signal } }) + const signal = this.controller.signal + const [value, phone] = await Promise.all([requestJson('./api/galaxy/networks', { request: { signal } }), + requestJson('./api/companion/status', { request: { signal } }).catch(() => null)]) if (!this.active || generation !== this.generation) return this.adopt(value); this.error = '' + this.phone = phone?.protocol === 1 && Number.isSafeInteger(phone.bytes) ? phone : null } catch (error) { if (!this.active || generation !== this.generation) return if (error.status === 401) { this.stop(); this.unauthorized(); return } @@ -186,7 +194,8 @@ export const NetworksPage = { Joining {{ snapshot.lastJoin.ssid }}. The Galaxy hotspot pauses for up to 30 seconds; your phone should reconnect on its own and this page will update. Joined {{ snapshot.lastJoin.ssid }}. Couldn't join {{ snapshot.lastJoin.ssid }}. {{ snapshot.lastJoin.error }} -
Connection{{ linkName }}
+
Connection Internet from Android app{{ linkName }}
+
Android phone internet{{ phoneDetail }}