10 feat download queue (#59)

* testing message queue

* better mq syncronisation

* major code refactoring, concern separation.

* bugfix

* code refactoring

* queuesize configurable via flags

* code refactoring

* comments

* code refactoring, updated readme
This commit is contained in:
Marco
2023-06-26 11:27:15 +02:00
committed by GitHub
parent dd753c5f26
commit 3ded768a6f
14 changed files with 283 additions and 118 deletions

View File

@@ -30,6 +30,7 @@ export function DownloadsCardView({ downloads, onStop }: Props) {
resolution={download.info.resolution ?? ''}
speed={download.progress.speed}
size={download.info.filesize_approx ?? 0}
status={download.progress.process_status}
/>
</Fragment>
</Grid>

View File

@@ -55,7 +55,11 @@ export function DownloadsListView({ downloads, onStop }: Props) {
download.progress.percentage === '-1' ? 100 :
Number(download.progress.percentage.replace('%', ''))
}
variant="determinate"
variant={
download.progress.process_status === 0
? 'indeterminate'
: 'determinate'
}
color={download.progress.percentage === '-1' ? 'success' : 'primary'}
/>
</TableCell>

View File

@@ -13,7 +13,7 @@ import {
Typography
} from '@mui/material'
import { useEffect, useState } from 'react'
import { ellipsis, formatSpeedMiB, roundMiB } from '../utils'
import { ellipsis, formatSpeedMiB, mapProcessStatus, roundMiB } from '../utils'
type Props = {
title: string
@@ -23,6 +23,7 @@ type Props = {
percentage: string
size: number
speed: number
status: number
onStop: () => void
onCopy: () => void
}
@@ -35,6 +36,7 @@ export function StackableResult({
percentage,
speed,
size,
status,
onStop,
onCopy,
}: Props) {
@@ -80,7 +82,7 @@ export function StackableResult({
}
<Stack direction="row" spacing={1} py={2}>
<Chip
label={isCompleted ? 'Completed' : 'Downloading'}
label={isCompleted ? 'Completed' : mapProcessStatus(status)}
color="primary"
size="small"
/>

View File

@@ -37,6 +37,7 @@ type DownloadProgress = {
speed: number
eta: number
percentage: string
process_status: number
}
export type RPCResult = {

View File

@@ -99,4 +99,19 @@ export const datetimeCompareFunc = (a: string, b: string) => new Date(a).getTime
export function isRPCResponse(object: any): object is RPCResponse<any> {
return 'result' in object && 'id' in object
}
export function mapProcessStatus(status: number) {
switch (status) {
case 0:
return 'Pending'
case 1:
return 'Downloading'
case 2:
return 'Completed'
case 3:
return 'Error'
default:
return 'Pending'
}
}