frontend fixes for alpha.2 (#2919)

* rmeove icon from toggles

* fix: comments

* fix: more comments

* always show public domains even if interface private, only show delete on domains

* fix: even more comments

* fix: last comments

* feat: empty state for dashboard

* rework welcome, dlete update-toast, minor

* translation improvements

---------

Co-authored-by: waterplea <alexander@inkin.ru>
This commit is contained in:
Matt Hill
2025-05-09 10:29:17 -06:00
committed by GitHub
parent a3252f9671
commit 8c977c51ca
45 changed files with 585 additions and 497 deletions

View File

@@ -89,9 +89,7 @@ export class ActionService {
this.dialog
.openAlert(
`${this.i18n.transform('Action can only be executed when service is')} ${statusesStr}` as i18nKey,
{
label: 'Forbidden',
},
{ label: 'Forbidden' },
)
.pipe(filter(Boolean))
.subscribe()

View File

@@ -1,4 +1,4 @@
import { Injectable } from '@angular/core'
import { inject, Injectable } from '@angular/core'
import { PatchDB } from 'patch-db-client'
import {
BehaviorSubject,
@@ -17,11 +17,14 @@ import { RR } from './api/api.types'
providedIn: 'root',
})
export class OSService {
private readonly api = inject(ApiService)
private readonly patch = inject<PatchDB<DataModel>>(PatchDB)
osUpdate?: RR.CheckOsUpdateRes
updateAvailable$ = new BehaviorSubject<boolean>(false)
readonly updateAvailable$ = new BehaviorSubject<boolean>(false)
readonly updating$ = this.patch.watch$('serverInfo', 'statusInfo').pipe(
map(status => !!status.updateProgress || status.updated),
map(status => status.updateProgress ?? status.updated),
distinctUntilChanged(),
)
@@ -35,21 +38,12 @@ export class OSService {
readonly updatingOrBackingUp$ = combineLatest([
this.updating$,
this.backingUp$,
]).pipe(map(([updating, backingUp]) => updating || backingUp))
]).pipe(map(([updating, backingUp]) => !!updating || backingUp))
readonly showUpdate$ = combineLatest([
this.updateAvailable$,
this.updating$,
]).pipe(
map(([available, updating]) => {
return available && !updating
}),
)
constructor(
private readonly api: ApiService,
private readonly patch: PatchDB<DataModel>,
) {}
]).pipe(map(([available, updating]) => available && !updating))
async loadOS(): Promise<void> {
const { version, id } = await getServerInfo(this.patch)
@@ -59,9 +53,11 @@ export class OSService {
registry: startosRegistry,
serverId: id,
})
const [latestVersion, _] = Object.entries(this.osUpdate).at(-1)!
const updateAvailable =
Version.parse(latestVersion).compare(Version.parse(version)) === 'greater'
this.updateAvailable$.next(updateAvailable)
const [latest, _] = Object.entries(this.osUpdate).at(-1)!
this.updateAvailable$.next(
Version.parse(latest).compare(Version.parse(version)) === 'greater',
)
}
}

View File

@@ -1,7 +1,8 @@
import { inject, Injectable } from '@angular/core'
import { CanActivateFn, IsActiveMatchOptions, Router } from '@angular/router'
import { DialogService } from '@start9labs/shared'
import { DialogService, i18nPipe } from '@start9labs/shared'
import { TUI_TRUE_HANDLER } from '@taiga-ui/cdk'
import { TuiAlertService } from '@taiga-ui/core'
import {
BehaviorSubject,
combineLatest,
@@ -41,7 +42,8 @@ const OPTIONS: IsActiveMatchOptions = {
providedIn: 'root',
})
export class StateService extends Observable<RR.ServerState | null> {
private readonly dialog = inject(DialogService)
private readonly alerts = inject(TuiAlertService)
private readonly i18n = inject(i18nPipe)
private readonly api = inject(ApiService)
private readonly router = inject(Router)
private readonly network$ = inject(NetworkService)
@@ -91,10 +93,10 @@ export class StateService extends Observable<RR.ServerState | null> {
.pipe(
exhaustMap(() =>
concat(
this.dialog
.openAlert('Trying to reach server', {
label: 'State unknown',
autoClose: 0,
this.alerts
.open(this.i18n.transform('Trying to reach server'), {
label: this.i18n.transform('State unknown'),
closeable: false,
appearance: 'negative',
})
.pipe(
@@ -104,8 +106,8 @@ export class StateService extends Observable<RR.ServerState | null> {
),
),
),
this.dialog.openAlert('Connection restored', {
label: 'Server connected',
this.alerts.open(this.i18n.transform('Connection restored'), {
label: this.i18n.transform('Server connected'),
appearance: 'positive',
}),
),