diff --git a/frontend/js/components/torrents/list/progress.js b/frontend/js/components/torrents/list/progress.js
new file mode 100644
index 0000000..eb63bd4
--- /dev/null
+++ b/frontend/js/components/torrents/list/progress.js
@@ -0,0 +1,47 @@
+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 (
+
+ {started && (
+ <>
+
+
+ {downloadedSize} / {totalSize} - {percentDone} - {downloadRate}
+
+ >
+ )}
+ {!started &&
Download not yet started
}
+
+ );
+};
+Progress.propTypes = {
+ torrent: PropTypes.object.isRequired,
+};
diff --git a/frontend/js/components/torrents/list/torrent.js b/frontend/js/components/torrents/list/torrent.js
index dbe19ab..ccc3cc3 100644
--- a/frontend/js/components/torrents/list/torrent.js
+++ b/frontend/js/components/torrents/list/torrent.js
@@ -2,23 +2,14 @@ import React from "react";
import PropTypes from "prop-types";
import { useDispatch } from "react-redux";
-import { prettySize, prettyEpisodeName } from "../../../utils";
+import { prettyEpisodeName } from "../../../utils";
import { removeTorrent } from "../../../actions/torrents";
+import { Progress } from "./progress";
+
export const Torrent = ({ torrent }) => {
const dispatch = useDispatch();
- 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) + "%";
- }
-
const torrentTitle = (torrent) => {
switch (torrent.type) {
case "movie":
@@ -36,10 +27,6 @@ export const Torrent = ({ torrent }) => {
}
};
- // 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 (
@@ -49,26 +36,7 @@ export const Torrent = ({ torrent }) => {
onClick={() => dispatch(removeTorrent(torrent.status.id))}
>
-
- {started && (
-
-
-
- {downloadedSize} / {totalSize} - {percentDone} - {downloadRate}
-
-
- )}
- {!started &&
Download not yet started
}
-
+
);
};