mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-27 02:41:53 +00:00
sideload wip, websockets, styling, multiple todos (#2865)
* sideload wip, websockets, styling, multiple todos * sideload * misc backend updates * chore: comments * prep for license and instructions display * comment for Matt * s9pk updates and 040 sdk * fix dependency error for actions * 0.4.0-beta.1 * beta.2 --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: waterplea <alexander@inkin.ru> Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
@@ -1,22 +1,29 @@
|
||||
// @TODO get types from sdk
|
||||
type Progress = null | boolean | { done: number; total: number | null }
|
||||
type NamedProgress = { name: string; progress: Progress }
|
||||
type FullProgress = { overall: Progress; phases: Array<NamedProgress> }
|
||||
import { T } from '@start9labs/start-sdk'
|
||||
|
||||
export function formatProgress({ phases, overall }: FullProgress): {
|
||||
export function formatProgress({ phases, overall }: T.FullProgress): {
|
||||
total: number
|
||||
message: string
|
||||
} {
|
||||
return {
|
||||
total: getDecimal(overall),
|
||||
message: phases
|
||||
.filter(p => p.progress !== true && p.progress !== null)
|
||||
.map(p => `${p.name}${getPhaseBytes(p.progress)}`)
|
||||
.filter(
|
||||
(
|
||||
p,
|
||||
): p is {
|
||||
name: string
|
||||
progress: {
|
||||
done: number
|
||||
total: number | null
|
||||
}
|
||||
} => p.progress !== true && p.progress !== null,
|
||||
)
|
||||
.map(p => `<b>${p.name}</b>${getPhaseBytes(p.progress)}`)
|
||||
.join(', '),
|
||||
}
|
||||
}
|
||||
|
||||
function getDecimal(progress: Progress): number {
|
||||
function getDecimal(progress: T.Progress): number {
|
||||
if (progress === true) {
|
||||
return 1
|
||||
} else if (!progress || !progress.total) {
|
||||
@@ -26,7 +33,7 @@ function getDecimal(progress: Progress): number {
|
||||
}
|
||||
}
|
||||
|
||||
function getPhaseBytes(progress: Progress): string {
|
||||
function getPhaseBytes(progress: T.Progress): string {
|
||||
return progress === true || !progress
|
||||
? ''
|
||||
: `: (${progress.done}/${progress.total})`
|
||||
|
||||
@@ -55,3 +55,6 @@ export function toUrl(text: string | null | undefined): string {
|
||||
}
|
||||
|
||||
export type WithId<T> = T & { id: string }
|
||||
|
||||
export type OptionalProperty<T, K extends keyof T> = Omit<T, K> &
|
||||
Partial<Pick<T, K>>
|
||||
|
||||
Reference in New Issue
Block a user