okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
1237d9a5f
main
1import { tr } from '../lib/i18n' ; 2 3export interface InstallPart { kind ?:string ; name ?:string ; state ?:string ; done_gb ?:number ; total_gb ?:number ; files_done ?:number ; files_total ?:number } 4 5/** 6* The parts of a download, one line each: the model (with "2/4" when it comes in parts), the picture reader, the engine. A model in several 7* parts is only downloaded when every line says Done, so a person can see which part is under way instead of one bar that restarts. 8*/ 9export function DownloadParts ({ parts} :{ parts :InstallPart [] | undefined }) { 10if ( ! parts || parts . length < 2 ) return null ; 11return < ul className = "native-parts" aria-label = { tr ( "Download parts" )}> 12{ parts . map ( p => < li key = { ` ${ p . kind } - ${ p . name } ` } data-state = { p . state }> 13< span >{ tr ( p . name )}{( p . files_total ?? 0 ) > 1 ?` ${ p . files_done ?? 0 } / ${ p . files_total } ` :'' }</ span > 14< small className = "muted" >{ p . state === 'done' || p . state === 'current' ?tr ( 'Done' ) :p . state === 'waiting' || p . state === 'pending' ?tr ( 'Waiting' ) :Number . isFinite ( p . done_gb ) && Number . isFinite ( p . total_gb ) ?` ${ p . done_gb ! . toFixed ( 1 )} / ${ p . total_gb ! . toFixed ( 1 )} GB` :'' }</ small > 15</ li >)} 16</ ul >; 17}