diff --git a/frontend/src/Settings/ImportLists/ImportListExclusions/ImportListExclusions.tsx b/frontend/src/Settings/ImportLists/ImportListExclusions/ImportListExclusions.tsx index dc5545e59..5cd14f4e1 100644 --- a/frontend/src/Settings/ImportLists/ImportListExclusions/ImportListExclusions.tsx +++ b/frontend/src/Settings/ImportLists/ImportListExclusions/ImportListExclusions.tsx @@ -42,7 +42,7 @@ import styles from './ImportListExclusions.css'; const COLUMNS: Column[] = [ { - name: 'tmdbid', + name: 'tmdbId', label: () => translate('TMDBId'), isVisible: true, isSortable: true, diff --git a/frontend/src/Store/Actions/systemActions.js b/frontend/src/Store/Actions/systemActions.js index 92360b589..75d2595cf 100644 --- a/frontend/src/Store/Actions/systemActions.js +++ b/frontend/src/Store/Actions/systemActions.js @@ -110,7 +110,6 @@ export const defaultState = { { name: 'actions', columnLabel: () => translate('Actions'), - isSortable: true, isVisible: true, isModifiable: false } diff --git a/src/Radarr.Api.V3/Blocklist/BlocklistController.cs b/src/Radarr.Api.V3/Blocklist/BlocklistController.cs index 58f6f2834..e070902cb 100644 --- a/src/Radarr.Api.V3/Blocklist/BlocklistController.cs +++ b/src/Radarr.Api.V3/Blocklist/BlocklistController.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; @@ -29,7 +30,18 @@ namespace Radarr.Api.V3.Blocklist public PagingResource GetBlocklist([FromQuery] PagingRequestResource paging, [FromQuery] int[] movieIds = null, [FromQuery] DownloadProtocol[] protocols = null) { var pagingResource = new PagingResource(paging); - var pagingSpec = pagingResource.MapToPagingSpec("date", SortDirection.Descending); + var pagingSpec = pagingResource.MapToPagingSpec( + "date", + SortDirection.Descending, + new HashSet(StringComparer.OrdinalIgnoreCase) + { + "movieMetadata.sortTitle", + "sourceTitle", + "languages", + "quality", + "date", + "indexer" + }); if (movieIds?.Any() == true) { diff --git a/src/Radarr.Api.V3/History/HistoryController.cs b/src/Radarr.Api.V3/History/HistoryController.cs index 81b945e47..0f6d98aea 100644 --- a/src/Radarr.Api.V3/History/HistoryController.cs +++ b/src/Radarr.Api.V3/History/HistoryController.cs @@ -64,7 +64,16 @@ namespace Radarr.Api.V3.History public PagingResource GetHistory([FromQuery] PagingRequestResource paging, bool includeMovie, [FromQuery(Name = "eventType")] int[] eventTypes, string downloadId, [FromQuery] int[] movieIds = null, [FromQuery] int[] languages = null, [FromQuery] int[] quality = null) { var pagingResource = new PagingResource(paging); - var pagingSpec = pagingResource.MapToPagingSpec("date", SortDirection.Descending); + var pagingSpec = pagingResource.MapToPagingSpec( + "date", + SortDirection.Descending, + new HashSet(StringComparer.OrdinalIgnoreCase) + { + "movieMetadata.sortTitle", + "languages", + "quality", + "date" + }); if (eventTypes != null && eventTypes.Any()) { diff --git a/src/Radarr.Api.V3/ImportLists/ImportListExclusionController.cs b/src/Radarr.Api.V3/ImportLists/ImportListExclusionController.cs index f1ca38b6e..9a7e8725a 100644 --- a/src/Radarr.Api.V3/ImportLists/ImportListExclusionController.cs +++ b/src/Radarr.Api.V3/ImportLists/ImportListExclusionController.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using FluentValidation; using Microsoft.AspNetCore.Mvc; +using NzbDrone.Core.Datastore; using NzbDrone.Core.ImportLists.ImportExclusions; using Radarr.Http; using Radarr.Http.Extensions; @@ -47,7 +48,16 @@ namespace Radarr.Api.V3.ImportLists public PagingResource GetImportListExclusionsPaged([FromQuery] PagingRequestResource paging) { var pagingResource = new PagingResource(paging); - var pageSpec = pagingResource.MapToPagingSpec(); + var pageSpec = pagingResource.MapToPagingSpec( + "id", + SortDirection.Descending, + new HashSet(StringComparer.OrdinalIgnoreCase) + { + "id", + "tmdbId", + "movieTitle", + "movieYear" + }); return pageSpec.ApplyToPage(_importListExclusionService.Paged, ImportListExclusionResourceMapper.ToResource); } diff --git a/src/Radarr.Api.V3/Wanted/CutoffController.cs b/src/Radarr.Api.V3/Wanted/CutoffController.cs index 271ad2003..3d02de570 100644 --- a/src/Radarr.Api.V3/Wanted/CutoffController.cs +++ b/src/Radarr.Api.V3/Wanted/CutoffController.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using NzbDrone.Core.Configuration; using NzbDrone.Core.CustomFormats; @@ -45,13 +46,18 @@ namespace Radarr.Api.V3.Wanted public PagingResource GetCutoffUnmetMovies([FromQuery] PagingRequestResource paging, bool monitored = true) { var pagingResource = new PagingResource(paging); - var pagingSpec = new PagingSpec - { - Page = pagingResource.Page, - PageSize = pagingResource.PageSize, - SortKey = pagingResource.SortKey, - SortDirection = pagingResource.SortDirection - }; + var pagingSpec = pagingResource.MapToPagingSpec( + "movieMetadata.sortTitle", + SortDirection.Ascending, + new HashSet(StringComparer.OrdinalIgnoreCase) + { + "movieMetadata.sortTitle", + "movieMetadata.year", + "movieMetadata.inCinemas", + "movieMetadata.digitalRelease", + "movieMetadata.physicalRelease", + "movies.lastSearchTime" + }); pagingSpec.FilterExpressions.Add(v => v.Monitored == monitored); diff --git a/src/Radarr.Api.V3/Wanted/MissingController.cs b/src/Radarr.Api.V3/Wanted/MissingController.cs index e0376f07e..dd0172485 100644 --- a/src/Radarr.Api.V3/Wanted/MissingController.cs +++ b/src/Radarr.Api.V3/Wanted/MissingController.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using Microsoft.AspNetCore.Mvc; using NzbDrone.Core.Configuration; using NzbDrone.Core.CustomFormats; @@ -41,13 +42,18 @@ namespace Radarr.Api.V3.Wanted public PagingResource GetMissingMovies([FromQuery] PagingRequestResource paging, bool monitored = true) { var pagingResource = new PagingResource(paging); - var pagingSpec = new PagingSpec - { - Page = pagingResource.Page, - PageSize = pagingResource.PageSize, - SortKey = pagingResource.SortKey, - SortDirection = pagingResource.SortDirection - }; + var pagingSpec = pagingResource.MapToPagingSpec( + "movieMetadata.sortTitle", + SortDirection.Ascending, + new HashSet(StringComparer.OrdinalIgnoreCase) + { + "movieMetadata.sortTitle", + "movieMetadata.year", + "movieMetadata.inCinemas", + "movieMetadata.digitalRelease", + "movieMetadata.physicalRelease", + "movies.lastSearchTime" + }); pagingSpec.FilterExpressions.Add(v => v.Monitored == monitored); diff --git a/src/Radarr.Http/PagingResource.cs b/src/Radarr.Http/PagingResource.cs index 61b5ef478..72d097364 100644 --- a/src/Radarr.Http/PagingResource.cs +++ b/src/Radarr.Http/PagingResource.cs @@ -38,7 +38,11 @@ namespace Radarr.Http public static class PagingResourceMapper { - public static PagingSpec MapToPagingSpec(this PagingResource pagingResource, string defaultSortKey = "Id", SortDirection defaultSortDirection = SortDirection.Ascending) + public static PagingSpec MapToPagingSpec( + this PagingResource pagingResource, + string defaultSortKey = "Id", + SortDirection defaultSortDirection = SortDirection.Ascending, + HashSet allowedSortKeys = null) { var pagingSpec = new PagingSpec { @@ -57,6 +61,13 @@ namespace Radarr.Http } } + if (pagingResource.SortKey != null && + allowedSortKeys is { Count: > 0 } && + !allowedSortKeys.Contains(pagingResource.SortKey)) + { + pagingSpec.SortKey = defaultSortKey; + } + return pagingSpec; } }