fix install progress by cloning

This commit is contained in:
Matt Hill
2021-09-07 08:47:30 -06:00
parent 68ff787b99
commit 2dfd5d994f
6 changed files with 17 additions and 15 deletions

View File

@@ -47,6 +47,7 @@ export class AppListPage {
}),
)
.subscribe(pkgs => {
console.log('PACKAGES LIST', pkgs)
this.loading = false
const ids = Object.keys(pkgs)
@@ -72,6 +73,8 @@ export class AppListPage {
}
// subscribe to pkg
this.pkgs[id].sub = this.patch.watch$('package-data', id).subscribe(pkg => {
console.log('SOLO PKG', id, pkg)
if (!pkg) return
let bulbClass = 'bulb-on'
let img = ''
const statusRendering = renderPkgStatus(pkg.state, pkg.installed?.status)
@@ -91,6 +94,7 @@ export class AppListPage {
break
}
this.pkgs[id].entry = pkg
this.pkgs[id].entry['install-progress'] = { ...this.pkgs[id].entry['install-progress'] }
this.pkgs[id].bulb = {
class: bulbClass,
img,

View File

@@ -6,7 +6,6 @@ import { Metric } from 'src/app/services/api/api.types'
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { ErrorToastService } from 'src/app/services/error-toast.service'
import { MainStatus } from 'src/app/services/patch-db/data-model'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
import { pauseFor } from 'src/app/util/misc.util'
@Component({
@@ -27,19 +26,11 @@ export class AppMetricsPage {
constructor (
private readonly route: ActivatedRoute,
private readonly errToast: ErrorToastService,
private readonly patch: PatchDbService,
private readonly embassyApi: ApiService,
) { }
ngOnInit () {
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
this.subs = [
this.patch.watch$('package-data', this.pkgId, 'installed', 'status', 'main')
.subscribe(main => {
this.mainStatus = main
}),
]
this.startDaemon()
}
@@ -49,7 +40,6 @@ export class AppMetricsPage {
ngOnDestroy () {
this.stopDaemon()
this.subs.forEach(sub => sub.unsubscribe())
}
async startDaemon (): Promise<void> {

View File

@@ -58,8 +58,9 @@ export class AppShowPage {
this.patch.watch$('package-data', this.pkgId)
.subscribe(pkg => {
this.pkg = pkg
this.pkg['install-progress'] = { ...this.pkg['install-progress'] }
this.rendering = renderPkgStatus(pkg.state, pkg.installed?.status)
this.mainStatus = pkg.installed?.status.main
this.mainStatus = { ...pkg.installed.status.main }
}),
// 2
this.connectionService.watchFailure$()

View File

@@ -9,7 +9,6 @@ import { ErrorToastService } from 'src/app/services/error-toast.service'
import { MarketplaceService } from '../marketplace.service'
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { PatchDbService } from 'src/app/services/patch-db/patch-db.service'
import { debounce } from 'src/app/util/misc.util'
@Component({
selector: 'marketplace-list',
@@ -51,6 +50,9 @@ export class MarketplaceListPage {
this.subs = [
this.patch.watch$('package-data').subscribe(pkgs => {
this.localPkgs = pkgs
Object.values(this.localPkgs).forEach(pkg => {
pkg['install-progress'] = { ...pkg['install-progress'] }
})
}),
]
@@ -108,7 +110,6 @@ export class MarketplaceListPage {
)
}
@debounce(1000)
private async getPkgs (doInfinite = false): Promise<void> {
try {
if (this.category === 'updates') {

View File

@@ -48,7 +48,9 @@ export class MarketplaceShowPage {
this.subs = [
this.patch.watch$('package-data', this.pkgId)
.subscribe(pkg => {
if (!pkg) return
this.localPkg = pkg
this.localPkg['install-progress'] = { ...this.localPkg['install-progress'] }
}),
]

View File

@@ -7,7 +7,11 @@ import { InstallProgress } from '../services/patch-db/data-model'
export class InstallState implements PipeTransform {
transform (loadData: InstallProgress): ProgressData {
const { downloaded, validated, unpacked, size } = loadData
console.log('LOAD DATA', loadData)
let { downloaded, validated, unpacked, size, 'download-complete': downloadComplete, 'validation-complete': validationComplete, 'unpack-complete': unpackComplete } = loadData
downloaded = downloadComplete ? size : downloaded
validated = validationComplete ? size : validated
unpacked = unpackComplete ? size : unpacked
const downloadWeight = 1
const validateWeight = .2
@@ -25,7 +29,7 @@ export class InstallState implements PipeTransform {
downloadProgress: Math.round(100 * downloaded / size),
validateProgress: Math.round(100 * validated / size),
unpackProgress: Math.round(100 * unpacked / size),
isComplete: loadData['download-complete'] && loadData['validation-complete'] && loadData['unpack-complete'],
isComplete: downloadComplete && validationComplete && unpackComplete,
}
}
}