Rework PackageDataEntry for new strategy (#2573)

* rework PackageDataEntry for new strategy

* fix type error

* fix issues with manifest fetching

* mock installs working
This commit is contained in:
Matt Hill
2024-03-19 08:38:04 -06:00
committed by GitHub
parent c8be701f0e
commit cc38dab76f
64 changed files with 1759 additions and 2068 deletions

View File

@@ -1,24 +1,32 @@
import { Pipe, PipeTransform } from '@angular/core'
import { InstallProgress } from 'src/app/services/patch-db/data-model'
import { packageLoadingProgress } from 'src/app/util/package-loading-progress'
import { Progress } from 'src/app/services/patch-db/data-model'
@Pipe({
name: 'installProgress',
name: 'installingProgressString',
})
export class InstallProgressPipe implements PipeTransform {
transform(installProgress?: InstallProgress): number {
return packageLoadingProgress(installProgress)?.totalProgress || 0
export class InstallingProgressDisplayPipe implements PipeTransform {
transform(progress: Progress): string {
if (progress === true) return 'finalizing'
if (progress === false || !progress.total) return 'unknown %'
const percentage = Math.round((100 * progress.done) / progress.total)
return percentage < 99 ? String(percentage) + '%' : 'finalizing'
}
}
@Pipe({
name: 'installProgressDisplay',
name: 'installingProgress',
})
export class InstallProgressDisplayPipe implements PipeTransform {
transform(installProgress?: InstallProgress): string {
const totalProgress =
packageLoadingProgress(installProgress)?.totalProgress || 0
return totalProgress < 99 ? totalProgress + '%' : 'finalizing'
export class InstallingProgressPipe implements PipeTransform {
transform(progress: Progress): number | null {
if (progress === true) return 1
if (progress === false || !progress.total) return null
return Number((progress.done / progress.total).toFixed(2))
}
}
function getProgress(progress: Progress): number | null {
if (progress === true) return 1
if (progress === false || !progress.total) return null
return Number((progress.done / progress.total).toFixed(2))
}