From 61750a71b0f9d9b213687b68c559f9a97b2c51d6 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 9 Sep 2023 14:17:31 +0300 Subject: [PATCH] Add volume factors in UI --- frontend/src/Helpers/Props/icons.js | 2 ++ .../Table/DownloadVolumeFactorLabel.tsx | 29 +++++++++++++++++++ frontend/src/Search/Table/SearchIndexRow.js | 8 +++++ .../Search/Table/UploadVolumeFactorLabel.tsx | 29 +++++++++++++++++++ src/NzbDrone.Core/Localization/Core/en.json | 6 ++-- src/Prowlarr.Api.V1/Search/ReleaseResource.cs | 4 +++ 6 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 frontend/src/Search/Table/DownloadVolumeFactorLabel.tsx create mode 100644 frontend/src/Search/Table/UploadVolumeFactorLabel.tsx diff --git a/frontend/src/Helpers/Props/icons.js b/frontend/src/Helpers/Props/icons.js index 834452242..ea8c2fd0f 100644 --- a/frontend/src/Helpers/Props/icons.js +++ b/frontend/src/Helpers/Props/icons.js @@ -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; diff --git a/frontend/src/Search/Table/DownloadVolumeFactorLabel.tsx b/frontend/src/Search/Table/DownloadVolumeFactorLabel.tsx new file mode 100644 index 000000000..48da3349f --- /dev/null +++ b/frontend/src/Search/Table/DownloadVolumeFactorLabel.tsx @@ -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 ; + } + + return ( + + ); +} + +export default DownloadVolumeFactorLabel; diff --git a/frontend/src/Search/Table/SearchIndexRow.js b/frontend/src/Search/Table/SearchIndexRow.js index 67c267696..20191a74e 100644 --- a/frontend/src/Search/Table/SearchIndexRow.js +++ b/frontend/src/Search/Table/SearchIndexRow.js @@ -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 { >
{title} + +
@@ -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, diff --git a/frontend/src/Search/Table/UploadVolumeFactorLabel.tsx b/frontend/src/Search/Table/UploadVolumeFactorLabel.tsx new file mode 100644 index 000000000..cc7a13c6f --- /dev/null +++ b/frontend/src/Search/Table/UploadVolumeFactorLabel.tsx @@ -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 ; + } + + return ( + + ); +} + +export default UploadVolumeFactorLabel; diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json index 309613c7d..f4e4b99e5 100644 --- a/src/NzbDrone.Core/Localization/Core/en.json +++ b/src/NzbDrone.Core/Localization/Core/en.json @@ -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", diff --git a/src/Prowlarr.Api.V1/Search/ReleaseResource.cs b/src/Prowlarr.Api.V1/Search/ReleaseResource.cs index 49364f445..8b06c7883 100644 --- a/src/Prowlarr.Api.V1/Search/ReleaseResource.cs +++ b/src/Prowlarr.Api.V1/Search/ReleaseResource.cs @@ -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 };