Files
start-os/web/projects/shared/src/util/format-progress.ts
Aiden McClelland 3ec4db0225 addHealthCheck instead of additionalHealthChecks for Daemons (#2962)
* addHealthCheck on Daemons

* fix bug that prevents domains without protocols from being deleted

* fixes from testing

* version bump

* add sdk version to UI

* fix useEntrypoint

* fix dependency health check error display

* minor fixes

* beta.29

* fixes from testing

* beta.30

* set /etc/os-release (#2918)

* remove check-monitor from kiosk (#2059)

* add units for progress (#2693)

* use new progress type

* alpha.7

* fix up pwa stuff

* fix wormhole-squashfs and prune boot (#2964)

* don't exit on expected errors

* use bash

---------

Co-authored-by: Matt Hill <mattnine@protonmail.com>
2025-06-17 17:50:01 -06:00

44 lines
971 B
TypeScript

import { T } from '@start9labs/start-sdk'
export function formatProgress({ phases, overall }: T.FullProgress): {
total: number
message: string
} {
return {
total: getDecimal(overall),
message: phases
.filter(
(
p,
): p is {
name: string
progress: false | ProgressDetails
} => p.progress !== true && p.progress !== null,
)
.map(p => `<b>${p.name}</b>${getDetails(p.progress)}`)
.join(', '),
}
}
function getDecimal(progress: T.Progress): number {
if (progress === true) {
return 1
} else if (!progress || !progress.total) {
return 0
} else {
return progress.total && progress.done / progress.total
}
}
function getDetails(progress: false | ProgressDetails) {
return progress
? `: ${progress.done}/${progress.total} ${progress.units || ''}`
: ''
}
type ProgressDetails = {
done: number
total: number | null
units: T.ProgressUnits | null
}