New: Custom Format Score column in queue

Closes #5780
This commit is contained in:
jack-mil 2023-07-10 23:49:00 -04:00 committed by GitHub
parent 96b7aa6585
commit a6f2db9139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 39 additions and 2 deletions

View File

@ -16,6 +16,12 @@
width: 150px; width: 150px;
} }
.customFormatScore {
composes: cell from '~Components/Table/Cells/TableRowCell.css';
width: 55px;
}
.actions { .actions {
composes: cell from '~Components/Table/Cells/TableRowCell.css'; composes: cell from '~Components/Table/Cells/TableRowCell.css';

View File

@ -2,6 +2,7 @@
// Please do not change this file! // Please do not change this file!
interface CssExports { interface CssExports {
'actions': string; 'actions': string;
'customFormatScore': string;
'progress': string; 'progress': string;
'protocol': string; 'protocol': string;
'quality': string; 'quality': string;

View File

@ -17,6 +17,7 @@ import { icons, kinds } from 'Helpers/Props';
import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal'; import InteractiveImportModal from 'InteractiveImport/InteractiveImportModal';
import SeriesTitleLink from 'Series/SeriesTitleLink'; import SeriesTitleLink from 'Series/SeriesTitleLink';
import formatBytes from 'Utilities/Number/formatBytes'; import formatBytes from 'Utilities/Number/formatBytes';
import formatPreferredWordScore from 'Utilities/Number/formatPreferredWordScore';
import QueueStatusCell from './QueueStatusCell'; import QueueStatusCell from './QueueStatusCell';
import RemoveQueueItemModal from './RemoveQueueItemModal'; import RemoveQueueItemModal from './RemoveQueueItemModal';
import TimeleftCell from './TimeleftCell'; import TimeleftCell from './TimeleftCell';
@ -91,6 +92,7 @@ class QueueRow extends Component {
languages, languages,
quality, quality,
customFormats, customFormats,
customFormatScore,
protocol, protocol,
indexer, indexer,
outputPath, outputPath,
@ -259,6 +261,17 @@ class QueueRow extends Component {
); );
} }
if (name === 'customFormatScore') {
return (
<TableRowCell
key={name}
className={styles.customFormatScore}
>
{formatPreferredWordScore(customFormatScore)}
</TableRowCell>
);
}
if (name === 'protocol') { if (name === 'protocol') {
return ( return (
<TableRowCell key={name}> <TableRowCell key={name}>
@ -413,6 +426,7 @@ QueueRow.propTypes = {
languages: PropTypes.arrayOf(PropTypes.object).isRequired, languages: PropTypes.arrayOf(PropTypes.object).isRequired,
quality: PropTypes.object.isRequired, quality: PropTypes.object.isRequired,
customFormats: PropTypes.arrayOf(PropTypes.object), customFormats: PropTypes.arrayOf(PropTypes.object),
customFormatScore: PropTypes.number.isRequired,
protocol: PropTypes.string.isRequired, protocol: PropTypes.string.isRequired,
indexer: PropTypes.string, indexer: PropTypes.string,
outputPath: PropTypes.string, outputPath: PropTypes.string,

View File

@ -1,7 +1,9 @@
import _ from 'lodash'; import _ from 'lodash';
import React from 'react';
import { createAction } from 'redux-actions'; import { createAction } from 'redux-actions';
import { batchActions } from 'redux-batched-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 { createThunk, handleThunks } from 'Store/thunks';
import createAjaxRequest from 'Utilities/createAjaxRequest'; import createAjaxRequest from 'Utilities/createAjaxRequest';
import serverSideCollectionHandlers from 'Utilities/serverSideCollectionHandlers'; import serverSideCollectionHandlers from 'Utilities/serverSideCollectionHandlers';
@ -104,6 +106,15 @@ export const defaultState = {
isSortable: false, isSortable: false,
isVisible: true isVisible: true
}, },
{
name: 'customFormatScore',
columnLabel: 'Custom Format Score',
label: React.createElement(Icon, {
name: icons.SCORE,
title: 'Custom format score'
}),
isVisible: false
},
{ {
name: 'protocol', name: 'protocol',
label: 'Protocol', label: 'Protocol',

View File

@ -23,6 +23,7 @@ namespace Sonarr.Api.V3.Queue
public List<Language> Languages { get; set; } public List<Language> Languages { get; set; }
public QualityModel Quality { get; set; } public QualityModel Quality { get; set; }
public List<CustomFormatResource> CustomFormats { get; set; } public List<CustomFormatResource> CustomFormats { get; set; }
public int CustomFormatScore { get; set; }
public decimal Size { get; set; } public decimal Size { get; set; }
public string Title { get; set; } public string Title { get; set; }
public decimal Sizeleft { get; set; } public decimal Sizeleft { get; set; }
@ -50,6 +51,9 @@ namespace Sonarr.Api.V3.Queue
return null; return null;
} }
var customFormats = model.RemoteEpisode?.CustomFormats;
var customFormatScore = model.Series.QualityProfile.Value.CalculateCustomFormatScore(customFormats);
return new QueueResource return new QueueResource
{ {
Id = model.Id, Id = model.Id,
@ -60,7 +64,8 @@ namespace Sonarr.Api.V3.Queue
Episode = includeEpisode && model.Episode != null ? model.Episode.ToResource() : null, Episode = includeEpisode && model.Episode != null ? model.Episode.ToResource() : null,
Languages = model.Languages, Languages = model.Languages,
Quality = model.Quality, Quality = model.Quality,
CustomFormats = model.RemoteEpisode?.CustomFormats?.ToResource(false), CustomFormats = customFormats?.ToResource(false),
CustomFormatScore = customFormatScore,
Size = model.Size, Size = model.Size,
Title = model.Title, Title = model.Title,
Sizeleft = model.Sizeleft, Sizeleft = model.Sizeleft,