From 6e56682c11888a446c779d75462b0776d2ff95bd Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 18 Mar 2026 16:52:47 -0600 Subject: [PATCH] better wifi ux --- .../system/routes/wifi/wifi.component.ts | 63 +++++++++++++++++-- 1 file changed, 58 insertions(+), 5 deletions(-) diff --git a/web/projects/ui/src/app/routes/portal/routes/system/routes/wifi/wifi.component.ts b/web/projects/ui/src/app/routes/portal/routes/system/routes/wifi/wifi.component.ts index 0c4ba2174..24b6075eb 100644 --- a/web/projects/ui/src/app/routes/portal/routes/system/routes/wifi/wifi.component.ts +++ b/web/projects/ui/src/app/routes/portal/routes/system/routes/wifi/wifi.component.ts @@ -3,6 +3,7 @@ import { ChangeDetectorRef, Component, inject, + signal, } from '@angular/core' import { toSignal } from '@angular/core/rxjs-interop' import { FormsModule } from '@angular/forms' @@ -15,10 +16,26 @@ import { pauseFor, } from '@start9labs/shared' import { TuiButton, TuiLoader, TuiNotificationService } from '@taiga-ui/core' -import { TuiNotificationMiddleService, TuiSwitch } from '@taiga-ui/kit' +import { + TuiButtonLoading, + TuiNotificationMiddleService, + TuiSwitch, +} from '@taiga-ui/kit' import { TuiCardLarge } from '@taiga-ui/layout' import { PatchDB } from 'patch-db-client' -import { catchError, defer, map, merge, Observable, of, Subject } from 'rxjs' +import { + catchError, + defer, + finalize, + first, + map, + merge, + Observable, + of, + Subject, + switchMap, + tap, +} from 'rxjs' import { FormComponent, FormContext, @@ -55,10 +72,23 @@ import { wifiSpec } from './wifi.const' @if (status()?.interface) { + @if (status()?.enabled) { + + } () + private readonly refresh$ = new Subject() private readonly formDialog = inject(FormDialogService) private readonly cdr = inject(ChangeDetectorRef) private readonly patch = inject>(PatchDB) private readonly i18n = inject(i18nPipe) - readonly status = toSignal(this.patch.watch$('serverInfo', 'network', 'wifi')) - readonly wifi = toSignal(merge(this.getWifi$(), this.update$)) + private readonly status$ = this.patch.watch$('serverInfo', 'network', 'wifi') + readonly status = toSignal(this.status$) + readonly wifi = toSignal( + merge( + this.status$.pipe( + first(s => !!s?.interface), + switchMap(() => this.getWifi$()), + ), + this.refresh$.pipe( + tap(() => this.refreshing.set(true)), + switchMap(() => + this.getWifi$().pipe(finalize(() => this.refreshing.set(false))), + ), + ), + this.update$, + ), + ) + + readonly refreshing = signal(false) + + refresh() { + this.refresh$.next() + } async onToggle(enable: boolean) { const loader = this.loader