upload: show speed #104
Massimo Melina committed
Dec 1, 2023 at 19:32 UTC
cc4e5055be13cac4a2b6d4b1c51d24ff521a91a3
1 file changed
+3
-3
frontend/src/upload.ts
+3
-3
@@ -3,7 +3,7 @@
3
import { createElement as h, DragEvent, Fragment, useMemo, CSSProperties } from 'react'
4
import { Checkbox, Flex, FlexV, iconBtn } from './components'
5
import { basename, closeDialog, formatBytes, formatPerc, hIcon, isMobile, newDialog, prefix, selectFiles, working,
6
- HTTP_CONFLICT, HTTP_PAYLOAD_TOO_LARGE
6
+ HTTP_CONFLICT, HTTP_PAYLOAD_TOO_LARGE, formatSpeed
7
} from './misc'
8
import _ from 'lodash'
9
import { proxy, ref, subscribe, useSnapshot } from 'valtio'
@@ -100,7 +100,7 @@ export function showUpload() {
100
}
101
102
function Content(){
103
- const { qs, paused, eta, skipExisting, adding } = useSnapshot(uploadState) as Readonly<typeof uploadState>
103
+ const { qs, paused, eta, speed, skipExisting, adding } = useSnapshot(uploadState) as Readonly<typeof uploadState>
104
const { props } = useSnapState()
105
const etaStr = useMemo(() => !eta ? '' : formatTime(eta*1000, 0, 2), [eta])
106
const inQ = _.sumBy(qs, q => q.entries.length) - (uploadState.uploading ? 1 : 0)
@@ -148,7 +148,7 @@ export function showUpload() {
148
h(UploadStatus, { margin: '.5em 0' }),
149
qs.length > 0 && h('div', {},
150
h(Flex, { justifyContent: 'center', borderTop: '1px dashed', padding: '.5em' },
151
- [queueStr, etaStr].filter(Boolean).join(', '),
151
+ [queueStr, etaStr, speed && formatSpeed(speed)].filter(Boolean).join(', '),
152
inQ > 0 && iconBtn('delete', ()=> {
153
uploadState.qs = []
154
abortCurrentUpload()