receptor/src/ui/torrent_progress.js

39 lines
778 B
JavaScript

import React, { Component } from 'react';
import { Progress } from 'reactstrap';
function color(torrent) {
switch (torrent.status) {
case "leeching":
return "success";
case "seeding":
return "primary";
case "hashing":
case "magnet":
return "info";
case "idle":
case "pending":
case "paused":
return "default";
case "error":
return "error";
}
}
function inset(torrent) {
switch (torrent.status) {
case "leeching":
return `${(torrent.progress * 100).toFixed(0)}%`;
default:
return torrent.status;
}
}
export default function TorrentProgress({ torrent }) {
return (
<Progress
value={torrent.progress * 100}
color={color(torrent)}
>{inset(torrent)}</Progress>
);
}