Merge remote-tracking branch 'gitea-ai/archy-openwrt'
This commit is contained in:
@@ -49,10 +49,12 @@ export const useHomeStatusStore = defineStore('homeStatus', () => {
|
||||
const bitcoinStale = ref(false)
|
||||
const vpnLoadState = ref<LoadState>('idle')
|
||||
const fipsLoadState = ref<LoadState>('idle')
|
||||
const tollgateLoadState = ref<LoadState>('idle')
|
||||
const lastSystemRefreshAt = ref<number | null>(null)
|
||||
const lastBitcoinRefreshAt = ref<number | null>(null)
|
||||
const lastVpnRefreshAt = ref<number | null>(null)
|
||||
const lastFipsRefreshAt = ref<number | null>(null)
|
||||
const lastTollgateRefreshAt = ref<number | null>(null)
|
||||
|
||||
const vpnStatus = ref<{
|
||||
connected: boolean | null
|
||||
@@ -67,6 +69,9 @@ export const useHomeStatusStore = defineStore('homeStatus', () => {
|
||||
authenticated_peer_count?: number
|
||||
} | null>(null)
|
||||
|
||||
// null = no OpenWrt router configured at all (tile row shows "Not configured").
|
||||
const tollgateStatus = ref<{ installed: boolean; enabled: boolean } | null>(null)
|
||||
|
||||
const systemStatsLoaded = computed(() => systemLoadState.value === 'ready')
|
||||
const bitcoinKnown = computed(() => stats.bitcoinAvailable !== null)
|
||||
const vpnKnown = computed(() => vpnStatus.value.connected !== null)
|
||||
@@ -185,12 +190,37 @@ export const useHomeStatusStore = defineStore('homeStatus', () => {
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshTollgate() {
|
||||
tollgateLoadState.value = tollgateLoadState.value === 'ready' ? 'ready' : 'loading'
|
||||
try {
|
||||
const res = await rpcClient.call<{ tollgate: { installed: boolean; enabled?: boolean } }>({
|
||||
method: 'openwrt.get-status',
|
||||
timeout: 15000,
|
||||
})
|
||||
tollgateStatus.value = { installed: res.tollgate.installed, enabled: res.tollgate.enabled ?? false }
|
||||
tollgateLoadState.value = 'ready'
|
||||
lastTollgateRefreshAt.value = Date.now()
|
||||
} catch (e) {
|
||||
const msg = e instanceof Error ? e.message : String(e)
|
||||
if (msg.includes('No router configured')) {
|
||||
// Not an error — most nodes simply don't have an OpenWrt gateway set up.
|
||||
tollgateStatus.value = null
|
||||
tollgateLoadState.value = 'ready'
|
||||
lastTollgateRefreshAt.value = Date.now()
|
||||
} else {
|
||||
// Transient failure (SSH hiccup, router rebooting) — keep last-known state.
|
||||
tollgateLoadState.value = tollgateStatus.value ? 'ready' : 'error'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function refresh(packages: Record<string, PackageDataEntry>) {
|
||||
await Promise.all([
|
||||
refreshSystemStats(),
|
||||
refreshBitcoin(packages),
|
||||
refreshVpn(packages),
|
||||
refreshFips(),
|
||||
refreshTollgate(),
|
||||
])
|
||||
}
|
||||
|
||||
@@ -201,19 +231,23 @@ export const useHomeStatusStore = defineStore('homeStatus', () => {
|
||||
bitcoinStale,
|
||||
vpnLoadState,
|
||||
fipsLoadState,
|
||||
tollgateLoadState,
|
||||
systemStatsLoaded,
|
||||
bitcoinKnown,
|
||||
vpnKnown,
|
||||
vpnStatus,
|
||||
fipsStatus,
|
||||
tollgateStatus,
|
||||
lastSystemRefreshAt,
|
||||
lastBitcoinRefreshAt,
|
||||
lastVpnRefreshAt,
|
||||
lastFipsRefreshAt,
|
||||
lastTollgateRefreshAt,
|
||||
refresh,
|
||||
refreshSystemStats,
|
||||
refreshBitcoin,
|
||||
refreshVpn,
|
||||
refreshFips,
|
||||
refreshTollgate,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user