Add volume factors in UI

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

@ -37,6 +37,7 @@ import {
faBullhorn as fasBullhorn, faBullhorn as fasBullhorn,
faCalendarAlt as fasCalendarAlt, faCalendarAlt as fasCalendarAlt,
faCaretDown as fasCaretDown, faCaretDown as fasCaretDown,
faCaretUp as fasCaretUp,
faCheck as fasCheck, faCheck as fasCheck,
faCheckCircle as fasCheckCircle, faCheckCircle as fasCheckCircle,
faChevronCircleDown as fasChevronCircleDown, faChevronCircleDown as fasChevronCircleDown,
@ -136,6 +137,7 @@ export const BUG = fasBug;
export const CALENDAR = fasCalendarAlt; export const CALENDAR = fasCalendarAlt;
export const CALENDAR_O = farCalendar; export const CALENDAR_O = farCalendar;
export const CARET_DOWN = fasCaretDown; export const CARET_DOWN = fasCaretDown;
export const CARET_UP = fasCaretUp;
export const CHECK = fasCheck; export const CHECK = fasCheck;
export const CHECK_INDETERMINATE = fasMinus; export const CHECK_INDETERMINATE = fasMinus;
export const CHECK_CIRCLE = fasCheckCircle; 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 titleCase from 'Utilities/String/titleCase';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import CategoryLabel from './CategoryLabel'; import CategoryLabel from './CategoryLabel';
import DownloadVolumeFactorLabel from './DownloadVolumeFactorLabel';
import Peers from './Peers'; import Peers from './Peers';
import UploadVolumeFactorLabel from './UploadVolumeFactorLabel';
import styles from './SearchIndexRow.css'; import styles from './SearchIndexRow.css';
function getDownloadIcon(isGrabbing, isGrabbed, grabError) { function getDownloadIcon(isGrabbing, isGrabbed, grabError) {
@ -118,6 +120,8 @@ class SearchIndexRow extends Component {
grabs, grabs,
seeders, seeders,
leechers, leechers,
downloadVolumeFactor,
uploadVolumeFactor,
indexerFlags, indexerFlags,
columns, columns,
isGrabbing, isGrabbing,
@ -191,6 +195,8 @@ class SearchIndexRow extends Component {
> >
<div> <div>
{title} {title}
<DownloadVolumeFactorLabel factor={downloadVolumeFactor} />
<UploadVolumeFactorLabel factor={uploadVolumeFactor} />
</div> </div>
</Link> </Link>
</VirtualTableRowCell> </VirtualTableRowCell>
@ -375,6 +381,8 @@ SearchIndexRow.propTypes = {
grabs: PropTypes.number, grabs: PropTypes.number,
seeders: PropTypes.number, seeders: PropTypes.number,
leechers: PropTypes.number, leechers: PropTypes.number,
downloadVolumeFactor: PropTypes.number,
uploadVolumeFactor: PropTypes.number,
indexerFlags: PropTypes.arrayOf(PropTypes.string).isRequired, indexerFlags: PropTypes.arrayOf(PropTypes.string).isRequired,
columns: PropTypes.arrayOf(PropTypes.object).isRequired, columns: PropTypes.arrayOf(PropTypes.object).isRequired,
onGrabPress: PropTypes.func.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", "About": "About",
"AcceptConfirmationModal": "Accept Confirmation Modal", "AcceptConfirmationModal": "Accept Confirmation Modal",
"Actions": "Actions", "Actions": "Actions",
"ActiveIndexers": "Active Indexers",
"ActiveApps": "Active Apps", "ActiveApps": "Active Apps",
"ActiveIndexers": "Active Indexers",
"Add": "Add", "Add": "Add",
"AddApplication": "Add Application", "AddApplication": "Add Application",
"AddApplicationImplementation": "Add Application - {implementationName}", "AddApplicationImplementation": "Add Application - {implementationName}",
@ -222,6 +222,7 @@
"Folder": "Folder", "Folder": "Folder",
"ForMoreInformationOnTheIndividualDownloadClients": "For more information on the individual download clients, click on the info buttons.", "ForMoreInformationOnTheIndividualDownloadClients": "For more information on the individual download clients, click on the info buttons.",
"FoundCountReleases": "Found {itemCount} releases", "FoundCountReleases": "Found {itemCount} releases",
"Freeleech": "Freeleech",
"FullSync": "Full Sync", "FullSync": "Full Sync",
"General": "General", "General": "General",
"GeneralSettings": "General Settings", "GeneralSettings": "General Settings",
@ -336,14 +337,15 @@
"NoChanges": "No Changes", "NoChanges": "No Changes",
"NoDownloadClientsFound": "No download clients found", "NoDownloadClientsFound": "No download clients found",
"NoHistoryFound": "No history found", "NoHistoryFound": "No history found",
"NoIndexersFound": "No indexers found",
"NoIndexerHistory": "No history found for this indexer", "NoIndexerHistory": "No history found for this indexer",
"NoIndexersFound": "No indexers found",
"NoLeaveIt": "No, Leave It", "NoLeaveIt": "No, Leave It",
"NoLinks": "No Links", "NoLinks": "No Links",
"NoLogFiles": "No log files", "NoLogFiles": "No log files",
"NoSearchResultsFound": "No search results found, try performing a new search below.", "NoSearchResultsFound": "No search results found, try performing a new search below.",
"NoTagsHaveBeenAddedYet": "No tags have been added yet", "NoTagsHaveBeenAddedYet": "No tags have been added yet",
"NoUpdatesAreAvailable": "No updates are available", "NoUpdatesAreAvailable": "No updates are available",
"NoUpload": "No Upload",
"None": "None", "None": "None",
"NotSupported": "Not Supported", "NotSupported": "Not Supported",
"Notification": "Notification", "Notification": "Notification",

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

Loading…
Cancel
Save