From bd27beecdfac42f20f6c0a98f243b9874ad31910 Mon Sep 17 00:00:00 2001 From: Drew Ansbacher Date: Mon, 20 Sep 2021 21:18:55 -0600 Subject: [PATCH] no tsc errs --- ui/src/app/pages/apps-routes/app-list/app-list.page.ts | 8 ++++---- ui/src/app/services/pkg-status-rendering.service.ts | 5 +++-- ui/src/app/util/misc.util.ts | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts index 45803a141..868b05d01 100644 --- a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts +++ b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts @@ -4,7 +4,7 @@ import { ConnectionFailure, ConnectionService } from 'src/app/services/connectio import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { PackageDataEntry, PackageState } from 'src/app/services/patch-db/data-model' import { Subscription } from 'rxjs' -import { PkgStatusRendering, renderPkgStatus } from 'src/app/services/pkg-status-rendering.service' +import { PrimaryRendering, renderPkgStatus, StatusRendering } from 'src/app/services/pkg-status-rendering.service' import { filter } from 'rxjs/operators' import { isEmptyObject } from 'src/app/util/misc.util' import { PackageLoadingService, ProgressData } from 'src/app/services/package-loading.service' @@ -23,7 +23,7 @@ export class AppListPage { class: string img: string } - statusRendering: PkgStatusRendering | null + statusRendering: StatusRendering | null sub: Subscription | null installProgress: ProgressData }} = { } @@ -70,7 +70,7 @@ export class AppListPage { class: 'bulb-off', img: 'assets/img/off-bulb.png', }, - statusRendering: renderPkgStatus(pkgs[id].state, pkgs[id].installed?.status), + statusRendering: PrimaryRendering[renderPkgStatus(pkgs[id]).primary], sub: null, installProgress: !isEmptyObject(pkgs[id]['install-progress']) ? this.installPackageService.transform(pkgs[id]['install-progress']) : undefined, } @@ -79,7 +79,7 @@ export class AppListPage { if (!pkg) return let bulbClass = 'bulb-on' let img = '' - const statusRendering = renderPkgStatus(pkg.state, pkg.installed?.status) + const statusRendering = PrimaryRendering[renderPkgStatus(pkg).primary] switch (statusRendering.color) { case 'danger': img = 'assets/img/danger-bulb.png' diff --git a/ui/src/app/services/pkg-status-rendering.service.ts b/ui/src/app/services/pkg-status-rendering.service.ts index 4408985b2..81ffac2ec 100644 --- a/ui/src/app/services/pkg-status-rendering.service.ts +++ b/ui/src/app/services/pkg-status-rendering.service.ts @@ -11,17 +11,18 @@ export function renderPkgStatus (pkg: PackageDataEntry): { let health: HealthStatus | null = null if (pkg.state === PackageState.Installed) { - primary = PrimaryStatus[pkg.installed.status.main.status] + primary = pkg.installed.status.main.status as string as PrimaryStatus dependency = getDependencyStatus(pkg.installed) health = getHealthStatus(pkg.installed.status) } else { - primary = PrimaryStatus[pkg.state] + primary = pkg.state as string as PrimaryStatus } return { primary, dependency, health } } function getDependencyStatus (pkg: InstalledPackageDataEntry): DependencyStatus { + console.log('pkg', pkg) if (isEmptyObject(pkg['current-dependencies'])) return null const pkgIds = Object.keys(pkg.status['dependency-errors']) diff --git a/ui/src/app/util/misc.util.ts b/ui/src/app/util/misc.util.ts index fcb466867..ca1576f32 100644 --- a/ui/src/app/util/misc.util.ts +++ b/ui/src/app/util/misc.util.ts @@ -86,6 +86,7 @@ export function isObject (val: any): boolean { } export function isEmptyObject (obj: object): boolean { + if (obj === undefined) return true return !Object.keys(obj).length }