fix install progress by cloning

This commit is contained in:
Matt Hill
2021-09-07 08:47:30 -06:00
committed by Aiden McClelland
parent 3fa84eb65f
commit 0ceb14ed2a
6 changed files with 17 additions and 15 deletions

View File

@@ -47,6 +47,7 @@ export class AppListPage {
}), }),
) )
.subscribe(pkgs => { .subscribe(pkgs => {
console.log('PACKAGES LIST', pkgs)
this.loading = false this.loading = false
const ids = Object.keys(pkgs) const ids = Object.keys(pkgs)
@@ -72,6 +73,8 @@ export class AppListPage {
} }
// subscribe to pkg // subscribe to pkg
this.pkgs[id].sub = this.patch.watch$('package-data', id).subscribe(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 bulbClass = 'bulb-on'
let img = '' let img = ''
const statusRendering = renderPkgStatus(pkg.state, pkg.installed?.status) const statusRendering = renderPkgStatus(pkg.state, pkg.installed?.status)
@@ -91,6 +94,7 @@ export class AppListPage {
break break
} }
this.pkgs[id].entry = pkg this.pkgs[id].entry = pkg
this.pkgs[id].entry['install-progress'] = { ...this.pkgs[id].entry['install-progress'] }
this.pkgs[id].bulb = { this.pkgs[id].bulb = {
class: bulbClass, class: bulbClass,
img, 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 { ApiService } from 'src/app/services/api/embassy-api.service'
import { ErrorToastService } from 'src/app/services/error-toast.service' import { ErrorToastService } from 'src/app/services/error-toast.service'
import { MainStatus } from 'src/app/services/patch-db/data-model' 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' import { pauseFor } from 'src/app/util/misc.util'
@Component({ @Component({
@@ -27,19 +26,11 @@ export class AppMetricsPage {
constructor ( constructor (
private readonly route: ActivatedRoute, private readonly route: ActivatedRoute,
private readonly errToast: ErrorToastService, private readonly errToast: ErrorToastService,
private readonly patch: PatchDbService,
private readonly embassyApi: ApiService, private readonly embassyApi: ApiService,
) { } ) { }
ngOnInit () { ngOnInit () {
this.pkgId = this.route.snapshot.paramMap.get('pkgId') 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() this.startDaemon()
} }
@@ -49,7 +40,6 @@ export class AppMetricsPage {
ngOnDestroy () { ngOnDestroy () {
this.stopDaemon() this.stopDaemon()
this.subs.forEach(sub => sub.unsubscribe())
} }
async startDaemon (): Promise<void> { async startDaemon (): Promise<void> {

View File

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

View File

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

View File

@@ -48,7 +48,9 @@ export class MarketplaceShowPage {
this.subs = [ this.subs = [
this.patch.watch$('package-data', this.pkgId) this.patch.watch$('package-data', this.pkgId)
.subscribe(pkg => { .subscribe(pkg => {
if (!pkg) return
this.localPkg = pkg 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 { export class InstallState implements PipeTransform {
transform (loadData: InstallProgress): ProgressData { 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 downloadWeight = 1
const validateWeight = .2 const validateWeight = .2
@@ -25,7 +29,7 @@ export class InstallState implements PipeTransform {
downloadProgress: Math.round(100 * downloaded / size), downloadProgress: Math.round(100 * downloaded / size),
validateProgress: Math.round(100 * validated / size), validateProgress: Math.round(100 * validated / size),
unpackProgress: Math.round(100 * unpacked / size), unpackProgress: Math.round(100 * unpacked / size),
isComplete: loadData['download-complete'] && loadData['validation-complete'] && loadData['unpack-complete'], isComplete: downloadComplete && validationComplete && unpackComplete,
} }
} }
} }