- {{ localDep ? (localDep | manifest).title : pkg.installed.status['dependency-errors'][dep.key]?.title }}
+ {{ patch.data['package-data'][dep.key] ? (patch.data['package-data'][dep.key] | manifest).title : pkg.installed.status['dependency-errors'][dep.key]?.title }}
{{ manifest.dependencies[dep.key].version | displayEmver }}
{{ pkg.installed.status['dependency-errors'][dep.key] ? pkg.installed.status['dependency-errors'][dep.key].type : 'satisfied' }}
@@ -91,11 +90,11 @@
-
+
+
diff --git a/ui/src/app/pages/apps-routes/app-show/app-show.page.ts b/ui/src/app/pages/apps-routes/app-show/app-show.page.ts
index b906e333b..b899ba5b7 100644
--- a/ui/src/app/pages/apps-routes/app-show/app-show.page.ts
+++ b/ui/src/app/pages/apps-routes/app-show/app-show.page.ts
@@ -48,11 +48,10 @@ export class AppShowPage {
async ngOnInit () {
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
+ this.pkg = this.patch.data['package-data'][this.pkgId]
+ // @TODO re-fetch manifest if package state changes.
+ this.manifest = getManifest(this.pkg)
this.subs = [
- this.patch.watch$('package-data', this.pkgId).subscribe(pkg => {
- this.pkg = pkg
- this.manifest = getManifest(this.pkg)
- }),
this.patch.connected$().subscribe(c => this.connected = c),
]
this.setButtons()
@@ -62,7 +61,7 @@ export class AppShowPage {
this.content.scrollToPoint(undefined, 1)
}
- async ngOnDestroy () {
+ ngOnDestroy () {
this.subs.forEach(sub => sub.unsubscribe())
}
diff --git a/ui/src/app/pipes/display-bulb.pipe.ts b/ui/src/app/pipes/display-bulb.pipe.ts
index 003245bc1..3d99d99ac 100644
--- a/ui/src/app/pipes/display-bulb.pipe.ts
+++ b/ui/src/app/pipes/display-bulb.pipe.ts
@@ -1,5 +1,6 @@
import { Pipe, PipeTransform } from '@angular/core'
-import { PackageDataEntry } from '../services/patch-db/data-model'
+import { PackageState, Status } from '../services/patch-db/data-model'
+import { PatchDbModel } from '../services/patch-db/patch-db.service'
import { renderPkgStatus } from '../services/pkg-status-rendering.service'
@Pipe({
@@ -7,9 +8,14 @@ import { renderPkgStatus } from '../services/pkg-status-rendering.service'
})
export class DisplayBulbPipe implements PipeTransform {
- transform (pkg: PackageDataEntry, bulb: DisplayBulb, connected: boolean): boolean {
+ constructor (
+ private readonly patch: PatchDbModel,
+ ) { }
+
+ transform (pkgId: string, bulb: DisplayBulb, connected: boolean): boolean {
+ const pkg = this.patch.data['package-data'][pkgId]
if (!connected) return bulb === 'off'
- const { color } = renderPkgStatus(pkg)
+ const { color } = renderPkgStatus(pkg.state, pkg.installed.status)
switch (color) {
case 'danger': return bulb === 'red'
case 'success': return bulb === 'green'
diff --git a/ui/src/app/pipes/status.pipe.ts b/ui/src/app/pipes/status.pipe.ts
index 85ba8b365..0a7826dbf 100644
--- a/ui/src/app/pipes/status.pipe.ts
+++ b/ui/src/app/pipes/status.pipe.ts
@@ -1,12 +1,19 @@
import { Pipe, PipeTransform } from '@angular/core'
-import { PackageDataEntry } from '../services/patch-db/data-model'
+import { PatchDbModel } from '../services/patch-db/patch-db.service'
import { FEStatus, renderPkgStatus } from '../services/pkg-status-rendering.service'
@Pipe({
name: 'status',
})
export class StatusPipe implements PipeTransform {
- transform (pkg: PackageDataEntry): FEStatus {
- return renderPkgStatus(pkg).feStatus
+
+ constructor (
+ private readonly patch: PatchDbModel,
+ ) { }
+
+ transform (pkgId: string): FEStatus {
+ console.log(pkgId)
+ const pkg = this.patch.data['package-data'][pkgId]
+ return renderPkgStatus(pkg.state, pkg.installed.status).feStatus
}
}
\ No newline at end of file
diff --git a/ui/src/app/services/api/mock-api.service.ts b/ui/src/app/services/api/mock-api.service.ts
index 9da2b921b..d7f452c3d 100644
--- a/ui/src/app/services/api/mock-api.service.ts
+++ b/ui/src/app/services/api/mock-api.service.ts
@@ -9,7 +9,6 @@ import { parsePropertiesPermissive } from 'src/app/util/properties.util'
import { Mock } from './mock-app-fixures'
import { HttpService } from '../http.service'
import markdown from 'raw-loader!src/assets/markdown/md-sample.md'
-import { map } from 'rxjs/operators'
@Injectable()
export class MockApiService extends ApiService {
@@ -22,10 +21,9 @@ export class MockApiService extends ApiService {
// every time a patch is returned from the mock, we override its sequence to be 1 more than the last sequence in the patch-db as provided by `o`.
watch$ (store: Store
): Observable> {
- store.watchCache$().pipe(map(cache => cache.sequence)).subscribe(seq => {
+ store.sequence$.subscribe(seq => {
console.log('INCOMING: ', seq)
if (this.sequence < seq) {
- console.log('hererereree')
this.sequence = seq
}
})
diff --git a/ui/src/app/services/patch-db/local-storage-bootstrap.ts b/ui/src/app/services/patch-db/local-storage-bootstrap.ts
index 5cddf1a86..c28a45cc2 100644
--- a/ui/src/app/services/patch-db/local-storage-bootstrap.ts
+++ b/ui/src/app/services/patch-db/local-storage-bootstrap.ts
@@ -15,7 +15,7 @@ export class LocalStorageBootstrap implements Bootstrapper {
async init (): Promise> {
const cache: DBCache = await this.storage.get(LocalStorageBootstrap.CONTENT_KEY)
- return cache || { sequence: 0, data: { } }
+ return cache || { sequence: 0, data: { } as DataModel }
}
async update (cache: DBCache): Promise {
diff --git a/ui/src/app/services/patch-db/patch-db.service.ts b/ui/src/app/services/patch-db/patch-db.service.ts
index ca66e8dd6..d6f8e4426 100644
--- a/ui/src/app/services/patch-db/patch-db.service.ts
+++ b/ui/src/app/services/patch-db/patch-db.service.ts
@@ -18,6 +18,7 @@ export enum ConnectionStatus {
})
export class PatchDbModel {
connectionStatus$ = new BehaviorSubject(ConnectionStatus.Initializing)
+ data: DataModel
private patchDb: PatchDB
private patchSub: Subscription
@@ -29,6 +30,7 @@ export class PatchDbModel {
async init (): Promise {
const cache = await this.bootstrapper.init()
this.patchDb = new PatchDB(this.sources, cache)
+ this.data = this.patchDb.store.cache.data
}
start (): void {
@@ -75,7 +77,7 @@ export class PatchDbModel {
return this.connectionStatus$.asObservable()
}
- watch$: Store ['watch$'] = (...args: (string | number)[]): Observable => {
+ watch$: Store['watch$'] = (...args: (string | number)[]): Observable => {
// console.log('WATCHING')
return this.patchDb.store.watch$(...(args as [])).pipe(
tap(cache => console.log('CHANGE IN STORE', cache)),
diff --git a/ui/src/app/services/pkg-status-rendering.service.ts b/ui/src/app/services/pkg-status-rendering.service.ts
index fbcf06422..4fba04e29 100644
--- a/ui/src/app/services/pkg-status-rendering.service.ts
+++ b/ui/src/app/services/pkg-status-rendering.service.ts
@@ -1,11 +1,11 @@
-import { HealthCheckResultLoading, MainStatusRunning, PackageDataEntry, PackageMainStatus, PackageState, Status } from './patch-db/data-model'
+import { HealthCheckResultLoading, MainStatusRunning, PackageMainStatus, PackageState, Status } from './patch-db/data-model'
-export function renderPkgStatus (pkg: PackageDataEntry): PkgStatusRendering {
- switch (pkg.state) {
+export function renderPkgStatus (state: PackageState, status: Status): PkgStatusRendering {
+ switch (state) {
case PackageState.Installing: return { display: 'Installing', color: 'primary', showDots: true, feStatus: FEStatus.Installing }
case PackageState.Updating: return { display: 'Updating', color: 'primary', showDots: true, feStatus: FEStatus.Updating }
case PackageState.Removing: return { display: 'Removing', color: 'warning', showDots: true, feStatus: FEStatus.Removing }
- case PackageState.Installed: return handleInstalledState(pkg.installed.status)
+ case PackageState.Installed: return handleInstalledState(status)
}
}