mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
Fix/patch fe (#2444)
* clear caches on logout * fix uninstall pkg missing error
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core'
|
||||
import { Observable, combineLatest, firstValueFrom } from 'rxjs'
|
||||
import { map } from 'rxjs/operators'
|
||||
import { filter, map } from 'rxjs/operators'
|
||||
import { DataModel } from 'src/app/services/patch-db/data-model'
|
||||
import { getPackageInfo, PkgInfo } from '../../../util/get-package-info'
|
||||
import { PatchDB } from 'patch-db-client'
|
||||
@@ -17,7 +17,7 @@ export class PackageInfoPipe implements PipeTransform {
|
||||
|
||||
transform(pkgId: string): Observable<PkgInfo> {
|
||||
return combineLatest([
|
||||
this.patch.watch$('package-data', pkgId),
|
||||
this.patch.watch$('package-data', pkgId).pipe(filter(Boolean)),
|
||||
this.depErrorService.getPkgDepErrors$(pkgId),
|
||||
]).pipe(map(([pkg, depErrors]) => getPackageInfo(pkg, depErrors)))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { BehaviorSubject, Observable } from 'rxjs'
|
||||
import { Observable, Subject } from 'rxjs'
|
||||
import { Update } from 'patch-db-client'
|
||||
import { RR } from './api.types'
|
||||
import { DataModel } from 'src/app/services/patch-db/data-model'
|
||||
@@ -6,7 +6,7 @@ import { Log } from '@start9labs/shared'
|
||||
import { WebSocketSubjectConfig } from 'rxjs/webSocket'
|
||||
|
||||
export abstract class ApiService {
|
||||
readonly patchStream$ = new BehaviorSubject<Update<DataModel>[]>([])
|
||||
readonly patchStream$ = new Subject<Update<DataModel>[]>()
|
||||
|
||||
// http
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ import {
|
||||
interval,
|
||||
map,
|
||||
Observable,
|
||||
ReplaySubject,
|
||||
shareReplay,
|
||||
Subject,
|
||||
switchMap,
|
||||
tap,
|
||||
timer,
|
||||
@@ -50,8 +51,8 @@ const PROGRESS: InstallProgress = {
|
||||
|
||||
@Injectable()
|
||||
export class MockApiService extends ApiService {
|
||||
readonly mockWsSource$ = new ReplaySubject<Update<DataModel>>()
|
||||
private readonly revertTime = 2000
|
||||
readonly mockWsSource$ = new Subject<Update<DataModel>>()
|
||||
private readonly revertTime = 1800
|
||||
sequence = 0
|
||||
|
||||
constructor(
|
||||
@@ -149,7 +150,6 @@ export class MockApiService extends ApiService {
|
||||
async echo(params: RR.EchoReq, url?: string): Promise<RR.EchoRes> {
|
||||
if (url) {
|
||||
const num = Math.floor(Math.random() * 10) + 1
|
||||
console.warn(num)
|
||||
if (num > 8) return params.message
|
||||
throw new Error()
|
||||
}
|
||||
@@ -158,7 +158,9 @@ export class MockApiService extends ApiService {
|
||||
}
|
||||
|
||||
openPatchWebsocket$(): Observable<Update<DataModel>> {
|
||||
return this.mockWsSource$
|
||||
return this.mockWsSource$.pipe(
|
||||
shareReplay({ bufferSize: 1, refCount: true }),
|
||||
)
|
||||
}
|
||||
|
||||
openLogsWebsocket$(config: WebSocketSubjectConfig<Log>): Observable<Log> {
|
||||
|
||||
@@ -2,7 +2,6 @@ import {
|
||||
DataModel,
|
||||
DockerIoFormat,
|
||||
HealthResult,
|
||||
Manifest,
|
||||
PackageMainStatus,
|
||||
PackageState,
|
||||
} from 'src/app/services/patch-db/data-model'
|
||||
|
||||
@@ -1,14 +1,6 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { Emver } from '@start9labs/shared'
|
||||
import {
|
||||
distinctUntilChanged,
|
||||
filter,
|
||||
map,
|
||||
pairwise,
|
||||
shareReplay,
|
||||
startWith,
|
||||
tap,
|
||||
} from 'rxjs/operators'
|
||||
import { distinctUntilChanged, map, shareReplay } from 'rxjs/operators'
|
||||
import { PatchDB } from 'patch-db-client'
|
||||
import {
|
||||
DataModel,
|
||||
@@ -43,7 +35,7 @@ export class DepErrorService {
|
||||
),
|
||||
),
|
||||
distinctUntilChanged(deepEqual),
|
||||
shareReplay(1),
|
||||
shareReplay({ bufferSize: 1, refCount: true }),
|
||||
)
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -77,7 +77,7 @@ export class MarketplaceService implements AbstractMarketplaceService {
|
||||
map(({ 'selected-url': url, 'known-hosts': hosts }) =>
|
||||
toStoreIdentity(url, hosts[url]),
|
||||
),
|
||||
shareReplay(1),
|
||||
shareReplay({ bufferSize: 1, refCount: true }),
|
||||
)
|
||||
|
||||
private readonly marketplace$ = this.knownHosts$.pipe(
|
||||
@@ -105,7 +105,7 @@ export class MarketplaceService implements AbstractMarketplaceService {
|
||||
},
|
||||
{},
|
||||
),
|
||||
shareReplay(1),
|
||||
shareReplay({ bufferSize: 1, refCount: true }),
|
||||
)
|
||||
|
||||
private readonly filteredMarketplace$ = combineLatest([
|
||||
|
||||
@@ -13,13 +13,9 @@ import { LocalStorageBootstrap } from './patch-db/local-storage-bootstrap'
|
||||
export class PatchMonitorService extends Observable<any> {
|
||||
// @TODO not happy with Observable<void>
|
||||
private readonly stream$ = this.authService.isVerified$.pipe(
|
||||
tap(verified => {
|
||||
if (verified) {
|
||||
this.patch.start(this.bootstrapper)
|
||||
} else {
|
||||
this.patch.stop()
|
||||
}
|
||||
}),
|
||||
tap(verified =>
|
||||
verified ? this.patch.start(this.bootstrapper) : this.patch.stop(),
|
||||
),
|
||||
)
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -18,11 +18,7 @@ import { combineLatest, from, timer } from 'rxjs'
|
||||
export class TimeService {
|
||||
private readonly startTimeMs$ = this.patch
|
||||
.watch$('server-info', 'system-start-time')
|
||||
.pipe(
|
||||
take(1),
|
||||
map(startTime => new Date(startTime).valueOf()),
|
||||
shareReplay(),
|
||||
)
|
||||
.pipe(map(startTime => new Date(startTime).valueOf()))
|
||||
|
||||
readonly systemTime$ = from(this.apiService.getSystemTime({})).pipe(
|
||||
switchMap(utcStr => {
|
||||
|
||||
Reference in New Issue
Block a user