mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
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:
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user