From a6f2db9139c4a6b01d162ccf8884fc02c874b4cf Mon Sep 17 00:00:00 2001
From: jack-mil <62065280+jack-mil@users.noreply.github.com>
Date: Mon, 10 Jul 2023 23:49:00 -0400
Subject: [PATCH] New: Custom Format Score column in queue
Closes #5780
---
frontend/src/Activity/Queue/QueueRow.css | 6 ++++++
frontend/src/Activity/Queue/QueueRow.css.d.ts | 1 +
frontend/src/Activity/Queue/QueueRow.js | 14 ++++++++++++++
frontend/src/Store/Actions/queueActions.js | 13 ++++++++++++-
src/Sonarr.Api.V3/Queue/QueueResource.cs | 7 ++++++-
5 files changed, 39 insertions(+), 2 deletions(-)
diff --git a/frontend/src/Activity/Queue/QueueRow.css b/frontend/src/Activity/Queue/QueueRow.css
index ee0483f96..4a9ff08b9 100644
--- a/frontend/src/Activity/Queue/QueueRow.css
+++ b/frontend/src/Activity/Queue/QueueRow.css
@@ -16,6 +16,12 @@
width: 150px;
}
+.customFormatScore {
+ composes: cell from '~Components/Table/Cells/TableRowCell.css';
+
+ width: 55px;
+}
+
.actions {
composes: cell from '~Components/Table/Cells/TableRowCell.css';
diff --git a/frontend/src/Activity/Queue/QueueRow.css.d.ts b/frontend/src/Activity/Queue/QueueRow.css.d.ts
index be7fcd916..13d67ea3a 100644
--- a/frontend/src/Activity/Queue/QueueRow.css.d.ts
+++ b/frontend/src/Activity/Queue/QueueRow.css.d.ts
@@ -2,6 +2,7 @@
// Please do not change this file!
interface CssExports {
'actions': string;
+ 'customFormatScore': string;
'progress': string;
'protocol': string;
'quality': string;
diff --git a/frontend/src/Activity/Queue/QueueRow.js b/frontend/src/Activity/Queue/QueueRow.js
index aba9ce3ea..5334f69cf 100644
--- a/frontend/src/Activity/Queue/QueueRow.js
+++ b/frontend/src/Activity/Queue/QueueRow.js
@@ -17,6 +17,7 @@ import { icons, kinds } from 'Helpers/Props';
import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal';
import SeriesTitleLink from 'Series/SeriesTitleLink';
import formatBytes from 'Utilities/Number/formatBytes';
+import formatPreferredWordScore from 'Utilities/Number/formatPreferredWordScore';
import QueueStatusCell from './QueueStatusCell';
import RemoveQueueItemModal from './RemoveQueueItemModal';
import TimeleftCell from './TimeleftCell';
@@ -91,6 +92,7 @@ class QueueRow extends Component {
languages,
quality,
customFormats,
+ customFormatScore,
protocol,
indexer,
outputPath,
@@ -259,6 +261,17 @@ class QueueRow extends Component {
);
}
+ if (name === 'customFormatScore') {
+ return (
+
+ {formatPreferredWordScore(customFormatScore)}
+
+ );
+ }
+
if (name === 'protocol') {
return (
@@ -413,6 +426,7 @@ QueueRow.propTypes = {
languages: PropTypes.arrayOf(PropTypes.object).isRequired,
quality: PropTypes.object.isRequired,
customFormats: PropTypes.arrayOf(PropTypes.object),
+ customFormatScore: PropTypes.number.isRequired,
protocol: PropTypes.string.isRequired,
indexer: PropTypes.string,
outputPath: PropTypes.string,
diff --git a/frontend/src/Store/Actions/queueActions.js b/frontend/src/Store/Actions/queueActions.js
index aa351d152..ef0466466 100644
--- a/frontend/src/Store/Actions/queueActions.js
+++ b/frontend/src/Store/Actions/queueActions.js
@@ -1,7 +1,9 @@
import _ from 'lodash';
+import React from 'react';
import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-actions';
-import { sortDirections } from 'Helpers/Props';
+import Icon from 'Components/Icon';
+import { icons, sortDirections } from 'Helpers/Props';
import { createThunk, handleThunks } from 'Store/thunks';
import createAjaxRequest from 'Utilities/createAjaxRequest';
import serverSideCollectionHandlers from 'Utilities/serverSideCollectionHandlers';
@@ -104,6 +106,15 @@ export const defaultState = {
isSortable: false,
isVisible: true
},
+ {
+ name: 'customFormatScore',
+ columnLabel: 'Custom Format Score',
+ label: React.createElement(Icon, {
+ name: icons.SCORE,
+ title: 'Custom format score'
+ }),
+ isVisible: false
+ },
{
name: 'protocol',
label: 'Protocol',
diff --git a/src/Sonarr.Api.V3/Queue/QueueResource.cs b/src/Sonarr.Api.V3/Queue/QueueResource.cs
index dd286960f..94dbcb127 100644
--- a/src/Sonarr.Api.V3/Queue/QueueResource.cs
+++ b/src/Sonarr.Api.V3/Queue/QueueResource.cs
@@ -23,6 +23,7 @@ namespace Sonarr.Api.V3.Queue
public List Languages { get; set; }
public QualityModel Quality { get; set; }
public List CustomFormats { get; set; }
+ public int CustomFormatScore { get; set; }
public decimal Size { get; set; }
public string Title { get; set; }
public decimal Sizeleft { get; set; }
@@ -50,6 +51,9 @@ namespace Sonarr.Api.V3.Queue
return null;
}
+ var customFormats = model.RemoteEpisode?.CustomFormats;
+ var customFormatScore = model.Series.QualityProfile.Value.CalculateCustomFormatScore(customFormats);
+
return new QueueResource
{
Id = model.Id,
@@ -60,7 +64,8 @@ namespace Sonarr.Api.V3.Queue
Episode = includeEpisode && model.Episode != null ? model.Episode.ToResource() : null,
Languages = model.Languages,
Quality = model.Quality,
- CustomFormats = model.RemoteEpisode?.CustomFormats?.ToResource(false),
+ CustomFormats = customFormats?.ToResource(false),
+ CustomFormatScore = customFormatScore,
Size = model.Size,
Title = model.Title,
Sizeleft = model.Sizeleft,