mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-02 05:23:14 +00:00
Refactor AppListPage
This commit is contained in:
committed by
Aiden McClelland
parent
b546eb2504
commit
ee81ca111b
@@ -142,7 +142,7 @@ export module RR {
|
||||
export type GetPackageMetricsReq = { id: string } // package.metrics
|
||||
export type GetPackageMetricsRes = Metric
|
||||
|
||||
export type InstallPackageReq = WithExpire<{ id: string, 'version-spec'?: string }> // package.install
|
||||
export type InstallPackageReq = WithExpire<{ id: string, version?: string }> // package.install
|
||||
export type InstallPackageRes = WithRevision<null>
|
||||
|
||||
export type DryUpdatePackageReq = { id: string, version: string } // package.update.dry
|
||||
|
||||
13
ui/src/app/services/destroy.service.ts
Normal file
13
ui/src/app/services/destroy.service.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Injectable, OnDestroy } from "@angular/core";
|
||||
import { ReplaySubject } from "rxjs";
|
||||
|
||||
/**
|
||||
* Observable abstraction over ngOnDestroy to use with takeUntil
|
||||
*/
|
||||
@Injectable()
|
||||
export class DestroyService extends ReplaySubject<void> implements OnDestroy {
|
||||
ngOnDestroy() {
|
||||
this.next();
|
||||
this.complete();
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
import { Injectable } from '@angular/core'
|
||||
import { InstallProgress } from './patch-db/data-model'
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PackageLoadingService {
|
||||
constructor () { }
|
||||
|
||||
transform (loadData: InstallProgress): ProgressData {
|
||||
let { downloaded, validated, unpacked, size, 'download-complete': downloadComplete, 'validation-complete': validationComplete, 'unpack-complete': unpackComplete } = loadData
|
||||
// only permit 100% when "complete" == true
|
||||
downloaded = downloadComplete ? size : Math.max(downloaded - 1, 0)
|
||||
validated = validationComplete ? size : Math.max(validated - 1, 0)
|
||||
unpacked = unpackComplete ? size : Math.max(unpacked - 1, 0)
|
||||
|
||||
const downloadWeight = 1
|
||||
const validateWeight = .2
|
||||
const unpackWeight = .7
|
||||
|
||||
const numerator = Math.floor(
|
||||
downloadWeight * downloaded +
|
||||
validateWeight * validated +
|
||||
unpackWeight * unpacked)
|
||||
|
||||
const denominator = Math.floor(size * (downloadWeight + validateWeight + unpackWeight))
|
||||
|
||||
return {
|
||||
totalProgress: Math.floor(100 * numerator / denominator),
|
||||
downloadProgress: Math.floor(100 * downloaded / size),
|
||||
validateProgress: Math.floor(100 * validated / size),
|
||||
unpackProgress: Math.floor(100 * unpacked / size),
|
||||
isComplete: downloadComplete && validationComplete && unpackComplete,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export interface ProgressData {
|
||||
totalProgress: number
|
||||
downloadProgress: number
|
||||
validateProgress: number
|
||||
unpackProgress: number
|
||||
isComplete: boolean
|
||||
}
|
||||
Reference in New Issue
Block a user