mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 20:14:49 +00:00
use hostname from patchDB as default server name (#1758)
* replace offline toast with global indicator * use hostname from patchDB as default server name * add alert to marketplace delete and reword logout alert
This commit is contained in:
30
frontend/projects/ui/src/app/services/server-name.service.ts
Normal file
30
frontend/projects/ui/src/app/services/server-name.service.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { PatchDbService } from './patch-db/patch-db.service'
|
||||
import { combineLatest, filter, map, Observable } from 'rxjs'
|
||||
|
||||
export interface ServerNameInfo {
|
||||
current: string
|
||||
default: string
|
||||
}
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class ServerNameService {
|
||||
private readonly chosenName$ = this.patch.watch$('ui', 'name')
|
||||
private readonly hostname$ = this.patch
|
||||
.watch$('server-info', 'hostname')
|
||||
.pipe(filter(Boolean))
|
||||
|
||||
readonly name$: Observable<ServerNameInfo> = combineLatest([
|
||||
this.chosenName$,
|
||||
this.hostname$,
|
||||
]).pipe(
|
||||
map(([chosen, hostname]) => {
|
||||
return {
|
||||
current: chosen || hostname,
|
||||
default: hostname,
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
constructor(private readonly patch: PatchDbService) {}
|
||||
}
|
||||
Reference in New Issue
Block a user