From e64161166204b8088777640daefb5dd3849463ed Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 31 Jan 2015 00:24:09 -0800 Subject: [PATCH] New: Show download protocol in Queue --- src/NzbDrone.Api/Indexers/ReleaseModule.cs | 3 +-- src/NzbDrone.Api/Indexers/ReleaseResource.cs | 1 - src/NzbDrone.Api/Queue/QueueResource.cs | 2 ++ src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs | 1 + src/NzbDrone.Core/Download/DownloadClientProvider.cs | 9 ++++++++- .../Download/Pending/PendingReleaseService.cs | 3 ++- src/NzbDrone.Core/Queue/Queue.cs | 2 ++ src/NzbDrone.Core/Queue/QueueService.cs | 3 ++- src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs | 2 +- src/UI/Activity/Queue/QueueActionsCell.js | 6 ++++++ src/UI/Activity/Queue/QueueLayout.js | 7 +++++++ src/UI/Activity/Queue/QueueLayoutTemplate.hbs | 4 ++-- src/UI/Activity/activity.less | 9 ++++++++- 13 files changed, 42 insertions(+), 10 deletions(-) diff --git a/src/NzbDrone.Api/Indexers/ReleaseModule.cs b/src/NzbDrone.Api/Indexers/ReleaseModule.cs index e151cfc7f..469ac4d6e 100644 --- a/src/NzbDrone.Api/Indexers/ReleaseModule.cs +++ b/src/NzbDrone.Api/Indexers/ReleaseModule.cs @@ -141,8 +141,7 @@ namespace NzbDrone.Api.Indexers release.QualityWeight += release.Quality.Revision.Real * 10; release.QualityWeight += release.Quality.Revision.Version; - - + var torrentRelease = downloadDecision.RemoteEpisode.Release as TorrentInfo; if (torrentRelease != null) diff --git a/src/NzbDrone.Api/Indexers/ReleaseResource.cs b/src/NzbDrone.Api/Indexers/ReleaseResource.cs index f6490f188..6ead9eb8d 100644 --- a/src/NzbDrone.Api/Indexers/ReleaseResource.cs +++ b/src/NzbDrone.Api/Indexers/ReleaseResource.cs @@ -39,7 +39,6 @@ namespace NzbDrone.Api.Indexers public String DownloadUrl { get; set; } public String InfoUrl { get; set; } public Boolean DownloadAllowed { get; set; } - public DownloadProtocol DownloadProtocol { get; set; } public Int32 ReleaseWeight { get; set; } diff --git a/src/NzbDrone.Api/Queue/QueueResource.cs b/src/NzbDrone.Api/Queue/QueueResource.cs index 7719b2860..257108170 100644 --- a/src/NzbDrone.Api/Queue/QueueResource.cs +++ b/src/NzbDrone.Api/Queue/QueueResource.cs @@ -5,6 +5,7 @@ using NzbDrone.Core.Qualities; using NzbDrone.Api.Series; using NzbDrone.Api.Episodes; using NzbDrone.Core.Download.TrackedDownloads; +using NzbDrone.Core.Indexers; namespace NzbDrone.Api.Queue { @@ -22,5 +23,6 @@ namespace NzbDrone.Api.Queue public String TrackedDownloadStatus { get; set; } public List StatusMessages { get; set; } public String DownloadId { get; set; } + public DownloadProtocol Protocol { get; set; } } } diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs index 462206c3f..d69cf8446 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/Sabnzbd.cs @@ -7,6 +7,7 @@ using NzbDrone.Common.Disk; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; using NzbDrone.Core.Configuration; +using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Validation; using NzbDrone.Core.RemotePathMappings; diff --git a/src/NzbDrone.Core/Download/DownloadClientProvider.cs b/src/NzbDrone.Core/Download/DownloadClientProvider.cs index e0c12eace..8e0b3b475 100644 --- a/src/NzbDrone.Core/Download/DownloadClientProvider.cs +++ b/src/NzbDrone.Core/Download/DownloadClientProvider.cs @@ -27,11 +27,18 @@ namespace NzbDrone.Core.Download public IEnumerable GetDownloadClients() { - return _downloadClientFactory.GetAvailableProviders(); + return _downloadClientFactory.GetAvailableProviders();//.Select(MapDownloadClient); } + public IDownloadClient Get(int id) { return _downloadClientFactory.GetAvailableProviders().Single(d => d.Definition.Id == id); } + + public IDownloadClient MapDownloadClient(IDownloadClient downloadClient) + { + downloadClient.Definition = _downloadClientFactory.GetProviderCharacteristics(downloadClient, (DownloadClientDefinition)downloadClient.Definition); + return downloadClient; + } } } diff --git a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs index 8108b1c98..e3c42ea57 100644 --- a/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs +++ b/src/NzbDrone.Core/Download/Pending/PendingReleaseService.cs @@ -112,7 +112,8 @@ namespace NzbDrone.Core.Download.Pending RemoteEpisode = pendingRelease.RemoteEpisode, Timeleft = ect.Subtract(DateTime.UtcNow), EstimatedCompletionTime = ect, - Status = "Pending" + Status = "Pending", + Protocol = pendingRelease.RemoteEpisode.Release.DownloadProtocol }; queued.Add(queue); } diff --git a/src/NzbDrone.Core/Queue/Queue.cs b/src/NzbDrone.Core/Queue/Queue.cs index 3e833f6a3..d39b22fb3 100644 --- a/src/NzbDrone.Core/Queue/Queue.cs +++ b/src/NzbDrone.Core/Queue/Queue.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using NzbDrone.Core.Datastore; using NzbDrone.Core.Download.TrackedDownloads; +using NzbDrone.Core.Indexers; using NzbDrone.Core.Parser.Model; using NzbDrone.Core.Qualities; using NzbDrone.Core.Tv; @@ -23,5 +24,6 @@ namespace NzbDrone.Core.Queue public List StatusMessages { get; set; } public String DownloadId { get; set; } public RemoteEpisode RemoteEpisode { get; set; } + public DownloadProtocol Protocol { get; set; } } } diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index 0a4a0bb65..a9b621cc6 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -59,7 +59,8 @@ namespace NzbDrone.Core.Queue TrackedDownloadStatus = trackedDownload.Status.ToString(), StatusMessages = trackedDownload.StatusMessages.ToList(), RemoteEpisode = trackedDownload.RemoteEpisode, - DownloadId = trackedDownload.DownloadItem.DownloadId + DownloadId = trackedDownload.DownloadItem.DownloadId, + Protocol = trackedDownload.Protocol }; if (queue.Timeleft.HasValue) diff --git a/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs b/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs index 656d1347f..db45e747a 100644 --- a/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs +++ b/src/NzbDrone.Core/ThingiProvider/ProviderFactory.cs @@ -111,7 +111,7 @@ namespace NzbDrone.Core.ThingiProvider { var type = GetImplementation(definition); var instance = (TProvider)_container.Resolve(type); - instance.Definition = definition; + instance.Definition = GetProviderCharacteristics(instance, definition); return instance; } diff --git a/src/UI/Activity/Queue/QueueActionsCell.js b/src/UI/Activity/Queue/QueueActionsCell.js index 9c0dede97..613006c85 100644 --- a/src/UI/Activity/Queue/QueueActionsCell.js +++ b/src/UI/Activity/Queue/QueueActionsCell.js @@ -16,6 +16,10 @@ define( 'click .x-grab' : '_grab' }, + ui: { + 'import' : '.x-import' + }, + render: function () { this.$el.empty(); @@ -69,6 +73,8 @@ define( data: JSON.stringify(this.model.toJSON()) }); + $(this.ui.import).spinForPromise(promise); + promise.success(function () { //find models that have the same series id and episode ids and remove them self.model.trigger('destroy', self.model); diff --git a/src/UI/Activity/Queue/QueueLayout.js b/src/UI/Activity/Queue/QueueLayout.js index cbcfc6ba4..4d6348287 100644 --- a/src/UI/Activity/Queue/QueueLayout.js +++ b/src/UI/Activity/Queue/QueueLayout.js @@ -12,6 +12,7 @@ define( 'Activity/Queue/QueueActionsCell', 'Activity/Queue/TimeleftCell', 'Activity/Queue/ProgressCell', + 'Release/ProtocolCell', 'Shared/Grid/Pager' ], function (Marionette, Backgrid, @@ -24,6 +25,7 @@ define( QueueActionsCell, TimeleftCell, ProgressCell, + ProtocolCell, GridPager) { return Marionette.Layout.extend({ template: 'Activity/Queue/QueueLayoutTemplate', @@ -65,6 +67,11 @@ define( cell : QualityCell, sortable : false }, + { + name : 'protocol', + label : 'Protocol', + cell : ProtocolCell + }, { name : 'timeleft', label : 'Timeleft', diff --git a/src/UI/Activity/Queue/QueueLayoutTemplate.hbs b/src/UI/Activity/Queue/QueueLayoutTemplate.hbs index 8b8fd8599..32b89d775 100644 --- a/src/UI/Activity/Queue/QueueLayoutTemplate.hbs +++ b/src/UI/Activity/Queue/QueueLayoutTemplate.hbs @@ -1,6 +1,6 @@ -
+
-
+
diff --git a/src/UI/Activity/activity.less b/src/UI/Activity/activity.less index 5ed1cd2ee..5bd498bff 100644 --- a/src/UI/Activity/activity.less +++ b/src/UI/Activity/activity.less @@ -1,4 +1,11 @@ .queue-status-cell .popover { - max-width: 800px; + max-width : 800px; +} + +.queue { + .protocol-cell { + text-align : center; + width : 80px; + } }