Add volume factors in UI

ui-volume-factors
Bogdan 8 months ago
parent 98e948dbb2
commit 61750a71b0

@ -37,6 +37,7 @@ import {
faBullhorn as fasBullhorn,
faCalendarAlt as fasCalendarAlt,
faCaretDown as fasCaretDown,
faCaretUp as fasCaretUp,
faCheck as fasCheck,
faCheckCircle as fasCheckCircle,
faChevronCircleDown as fasChevronCircleDown,
@ -136,6 +137,7 @@ export const BUG = fasBug;
export const CALENDAR = fasCalendarAlt;
export const CALENDAR_O = farCalendar;
export const CARET_DOWN = fasCaretDown;
export const CARET_UP = fasCaretUp;
export const CHECK = fasCheck;
export const CHECK_INDETERMINATE = fasMinus;
export const CHECK_CIRCLE = fasCheckCircle;

@ -0,0 +1,29 @@
import React from 'react';
import Icon from 'Components/Icon';
import Label from 'Components/Label';
import { icons, kinds } from 'Helpers/Props';
import translate from 'Utilities/String/translate';
interface DownloadVolumeFactorLabelProps {
factor?: number;
}
function DownloadVolumeFactorLabel({ factor }: DownloadVolumeFactorLabelProps) {
const value = Number(factor);
if (isNaN(value) || value === 1.0) {
return null;
}
if (value === 0.0) {
return <Label kind={kinds.SUCCESS}>{translate('Freeleech')}</Label>;
}
return (
<Label kind={value > 1.0 ? kinds.DANGER : kinds.PRIMARY}>
<Icon name={icons.CARET_DOWN} /> {(value * 100).toFixed(0)}%
</Label>
);
}
export default DownloadVolumeFactorLabel;

@ -15,7 +15,9 @@ import formatBytes from 'Utilities/Number/formatBytes';
import titleCase from 'Utilities/String/titleCase';
import translate from 'Utilities/String/translate';
import CategoryLabel from './CategoryLabel';
import DownloadVolumeFactorLabel from './DownloadVolumeFactorLabel';
import Peers from './Peers';
import UploadVolumeFactorLabel from './UploadVolumeFactorLabel';
import styles from './SearchIndexRow.css';
function getDownloadIcon(isGrabbing, isGrabbed, grabError) {
@ -118,6 +120,8 @@ class SearchIndexRow extends Component {
grabs,
seeders,
leechers,
downloadVolumeFactor,
uploadVolumeFactor,
indexerFlags,
columns,
isGrabbing,
@ -191,6 +195,8 @@ class SearchIndexRow extends Component {
>
<div>
{title}
<DownloadVolumeFactorLabel factor={downloadVolumeFactor} />
<UploadVolumeFactorLabel factor={uploadVolumeFactor} />
</div>
</Link>
</VirtualTableRowCell>
@ -375,6 +381,8 @@ SearchIndexRow.propTypes = {
grabs: PropTypes.number,
seeders: PropTypes.number,
leechers: PropTypes.number,
downloadVolumeFactor: PropTypes.number,
uploadVolumeFactor: PropTypes.number,
indexerFlags: PropTypes.arrayOf(PropTypes.string).isRequired,
columns: PropTypes.arrayOf(PropTypes.object).isRequired,
onGrabPress: PropTypes.func.isRequired,

@ -0,0 +1,29 @@
import React from 'react';
import Icon from 'Components/Icon';
import Label from 'Components/Label';
import { icons, kinds } from 'Helpers/Props';
import translate from 'Utilities/String/translate';
interface UploadVolumeFactorLabelProps {
factor?: number;
}
function UploadVolumeFactorLabel({ factor }: UploadVolumeFactorLabelProps) {
const value = Number(factor);
if (isNaN(value) || value === 1.0) {
return null;
}
if (value === 0.0) {
return <Label kind={kinds.WARNING}>{translate('NoUpload')}</Label>;
}
return (
<Label kind={kinds.INFO}>
<Icon name={icons.CARET_UP} /> {(value * 100).toFixed(0)}%UL
</Label>
);
}
export default UploadVolumeFactorLabel;

@ -2,8 +2,8 @@
"About": "About",
"AcceptConfirmationModal": "Accept Confirmation Modal",
"Actions": "Actions",
"ActiveIndexers": "Active Indexers",
"ActiveApps": "Active Apps",
"ActiveIndexers": "Active Indexers",
"Add": "Add",
"AddApplication": "Add Application",
"AddApplicationImplementation": "Add Application - {implementationName}",
@ -222,6 +222,7 @@
"Folder": "Folder",
"ForMoreInformationOnTheIndividualDownloadClients": "For more information on the individual download clients, click on the info buttons.",
"FoundCountReleases": "Found {itemCount} releases",
"Freeleech": "Freeleech",
"FullSync": "Full Sync",
"General": "General",
"GeneralSettings": "General Settings",
@ -336,14 +337,15 @@
"NoChanges": "No Changes",
"NoDownloadClientsFound": "No download clients found",
"NoHistoryFound": "No history found",
"NoIndexersFound": "No indexers found",
"NoIndexerHistory": "No history found for this indexer",
"NoIndexersFound": "No indexers found",
"NoLeaveIt": "No, Leave It",
"NoLinks": "No Links",
"NoLogFiles": "No log files",
"NoSearchResultsFound": "No search results found, try performing a new search below.",
"NoTagsHaveBeenAddedYet": "No tags have been added yet",
"NoUpdatesAreAvailable": "No updates are available",
"NoUpload": "No Upload",
"None": "None",
"NotSupported": "Not Supported",
"Notification": "Notification",

@ -37,6 +37,8 @@ namespace Prowlarr.Api.V1.Search
public string InfoHash { get; set; }
public int? Seeders { get; set; }
public int? Leechers { get; set; }
public double? DownloadVolumeFactor { get; set; }
public double? UploadVolumeFactor { get; set; }
public DownloadProtocol Protocol { get; set; }
public string FileName
@ -92,6 +94,8 @@ namespace Prowlarr.Api.V1.Search
InfoHash = torrentInfo.InfoHash,
Seeders = torrentInfo.Seeders,
Leechers = (torrentInfo.Peers.HasValue && torrentInfo.Seeders.HasValue) ? (torrentInfo.Peers.Value - torrentInfo.Seeders.Value) : (int?)null,
DownloadVolumeFactor = torrentInfo.DownloadVolumeFactor,
UploadVolumeFactor = torrentInfo.UploadVolumeFactor,
Protocol = releaseInfo.DownloadProtocol,
IndexerFlags = indexerFlags
};

Loading…
Cancel
Save