Enhancement: downloading torrents list for deluge (#4436)

pull/4439/head
Mindfreak9100 4 days ago committed by GitHub
parent 6b2a3da7ee
commit 59ed5ed114
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -14,4 +14,5 @@ widget:
type: deluge
url: http://deluge.host.or.ip
password: password # webui password
enableLeechProgress: true # optional, defaults to false
```

@ -402,6 +402,9 @@ export function cleanServiceGroups(groups) {
mappings,
display,
// deluge, qbittorrent
enableLeechProgress,
// diskstation
volume,
@ -479,9 +482,6 @@ export function cleanServiceGroups(groups) {
// proxmox
node,
// qbittorrent
enableLeechProgress,
// speedtest
bitratePrecision,
@ -572,6 +572,9 @@ export function cleanServiceGroups(groups) {
if (allowScrolling) widget.allowScrolling = allowScrolling;
if (refreshInterval) widget.refreshInterval = refreshInterval;
}
if (["deluge", "qbittorrent"].includes(type)) {
if (enableLeechProgress !== undefined) widget.enableLeechProgress = JSON.parse(enableLeechProgress);
}
if (["opnsense", "pfsense"].includes(type)) {
if (wan) widget.wan = wan;
}
@ -674,9 +677,6 @@ export function cleanServiceGroups(groups) {
if (type === "spoolman") {
if (spoolIds !== undefined) widget.spoolIds = spoolIds;
}
if (type === "qbittorrent") {
if (enableLeechProgress !== undefined) widget.enableLeechProgress = JSON.parse(enableLeechProgress);
}
return widget;
});
return cleanedService;

@ -1,5 +1,7 @@
import { useTranslation } from "next-i18next";
import QueueEntry from "../../components/widgets/queue/queueEntry";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
import useWidgetAPI from "utils/proxy/use-widget-api";
@ -32,21 +34,38 @@ export default function Component({ service }) {
let rateDl = 0;
let rateUl = 0;
let completed = 0;
const leechTorrents = [];
for (let i = 0; i < keys.length; i += 1) {
const torrent = torrents[keys[i]];
rateDl += torrent.download_payload_rate;
rateUl += torrent.upload_payload_rate;
completed += torrent.total_remaining === 0 ? 1 : 0;
if (torrent.state === "Downloading") {
leechTorrents.push(torrent);
}
}
const leech = keys.length - completed || 0;
return (
<Container service={service}>
<Block label="deluge.leech" value={t("common.number", { value: leech })} />
<Block label="deluge.download" value={t("common.byterate", { value: rateDl })} />
<Block label="deluge.seed" value={t("common.number", { value: completed })} />
<Block label="deluge.upload" value={t("common.byterate", { value: rateUl })} />
</Container>
<>
<Container service={service}>
<Block label="deluge.leech" value={t("common.number", { value: leech })} />
<Block label="deluge.download" value={t("common.byterate", { value: rateDl })} />
<Block label="deluge.seed" value={t("common.number", { value: completed })} />
<Block label="deluge.upload" value={t("common.byterate", { value: rateUl })} />
</Container>
{widget?.enableLeechProgress &&
leechTorrents.map((queueEntry) => (
<QueueEntry
progress={queueEntry.progress}
timeLeft={t("common.duration", { value: queueEntry.eta })}
title={queueEntry.name}
activity={queueEntry.state}
key={`${queueEntry.name}-${queueEntry.total_remaining}`}
/>
))}
</>
);
}

@ -17,6 +17,7 @@ const dataParams = [
"download_payload_rate",
"upload_payload_rate",
"total_remaining",
"eta",
],
{},
];

Loading…
Cancel
Save