JDownloader Widget - Add Total Queue and Remaining In Queue (#1612)

undefined
This commit is contained in:
Karl0ss 2023-06-16 07:40:10 +01:00 committed by GitHub
parent af00e44550
commit 8df11acbe8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 14 deletions

View File

@ -655,8 +655,9 @@
"updates": "Updates"
},
"jdownloader": {
"downloadCount": "Queue Count",
"downloadQueueSize": "Queue Size",
"downloadSpeed": "Download Speed"
"downloadCount": "Queue",
"downloadBytesRemaining": "Remaining",
"downloadTotalBytes": "Size",
"downloadSpeed": "Speed"
}
}

View File

@ -21,7 +21,8 @@ export default function Component({ service }) {
return (
<Container service={service}>
<Block label="jdownloader.downloadCount" />
<Block label="jdownloader.downloadQueueSize" />
<Block label="jdownloader.downloadTotalBytes" />
<Block label="jdownloader.downloadBytesRemaining" />
<Block label="jdownloader.downloadSpeed" />
</Container>
);
@ -30,7 +31,8 @@ export default function Component({ service }) {
return (
<Container service={service}>
<Block label="jdownloader.downloadCount" value={t("common.number", { value: jdownloaderData.downloadCount })} />
<Block label="jdownloader.downloadQueueSize" value={t("common.bytes", { value: jdownloaderData.totalBytes })} />
<Block label="jdownloader.downloadTotalBytes" value={t("common.bytes", { value: jdownloaderData.totalBytes })} />
<Block label="jdownloader.downloadBytesRemaining" value={t("common.bytes", { value: jdownloaderData.bytesRemaining })} />
<Block label="jdownloader.downloadSpeed" value={t("common.byterate", { value: jdownloaderData.totalSpeed })} />
</Container>
);

View File

@ -171,17 +171,22 @@ export default async function jdownloaderProxyHandler(req, res) {
}
)
let bytesRemaining = 0;
let totalBytes = 0;
let totalSpeed = 0;
packageStatus.forEach(file => {
totalBytes += file.bytesTotal;
if (file.finished !== true) {
bytesRemaining += file.bytesTotal;
if (file.speed) {
totalSpeed += file.speed;
}
}
});
const data = {
downloadCount: packageStatus.length,
bytesRemaining,
totalBytes,
totalSpeed
};