Grégoire Delattre d94843be9f
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
Group the torrents by types in the torrent list
By the way let's show more infos about what's being downloaded.
2020-04-13 17:38:47 +02:00

50 lines
1.3 KiB
JavaScript

import React from "react";
import PropTypes from "prop-types";
import { prettySize } from "../../../utils";
export const Progress = ({ torrent }) => {
var progressStyle = torrent.status.is_finished
? "success"
: "info progress-bar-striped progress-bar-animated";
const progressBarClass = "progress-bar bg-" + progressStyle;
var percentDone = torrent.status.percent_done;
const started = percentDone !== 0;
if (started) {
percentDone = Number(percentDone).toFixed(1) + "%";
}
// Pretty sizes
const downloadedSize = prettySize(torrent.status.downloaded_size);
const totalSize = prettySize(torrent.status.total_size);
const downloadRate = prettySize(torrent.status.download_rate) + "/s";
return (
<div>
<div className="progress bg-light">
<div
className={progressBarClass}
style={{ width: percentDone }}
role="progressbar"
aria-valuenow={percentDone}
aria-valuemin="0"
aria-valuemax="100"
></div>
</div>
{started && (
<p>
{downloadedSize} / {totalSize} - {percentDone} - {downloadRate}
</p>
)}
{!started && (
<p>
<small>Not yet started</small>
</p>
)}
</div>
);
};
Progress.propTypes = {
torrent: PropTypes.object.isRequired,
};