From 6f27d8c33f8edde1a99baf79c6ee07d3d0cc1450 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 3 Oct 2013 14:06:52 -0700 Subject: [PATCH] Queue should update now --- src/NzbDrone.Api/Queue/QueueResource.cs | 1 + .../Download/Clients/Nzbget/NzbgetClient.cs | 2 +- .../Download/Clients/Sabnzbd/SabQueueItem.cs | 2 +- .../Download/Clients/Sabnzbd/SabnzbdClient.cs | 6 ++- src/NzbDrone.Core/Download/QueueItem.cs | 3 +- src/NzbDrone.Core/Queue/Queue.cs | 1 + src/NzbDrone.Core/Queue/QueueService.cs | 3 +- src/UI/Cells/cells.less | 5 +++ src/UI/History/Queue/QueueLayout.js | 8 ++++ src/UI/History/Queue/QueueStatusCell.js | 39 +++++++++++++++++++ src/UI/Mixins/jquery.ajax.js | 2 +- 11 files changed, 65 insertions(+), 7 deletions(-) create mode 100644 src/UI/History/Queue/QueueStatusCell.js diff --git a/src/NzbDrone.Api/Queue/QueueResource.cs b/src/NzbDrone.Api/Queue/QueueResource.cs index 77a7c2772..429a25c44 100644 --- a/src/NzbDrone.Api/Queue/QueueResource.cs +++ b/src/NzbDrone.Api/Queue/QueueResource.cs @@ -14,5 +14,6 @@ public class QueueResource : RestResource public String Title { get; set; } public Decimal Sizeleft { get; set; } public TimeSpan Timeleft { get; set; } + public String Status { get; set; } } } diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs index ee94a2198..e7a53fde9 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/NzbgetClient.cs @@ -73,7 +73,7 @@ public virtual IEnumerable GetQueue() queueItem.Id = nzbGetQueueItem.NzbId.ToString(); queueItem.Title = nzbGetQueueItem.NzbName; queueItem.Size = nzbGetQueueItem.FileSizeMb; - queueItem.SizeLeft = nzbGetQueueItem.RemainingSizeMb; + queueItem.Sizeleft = nzbGetQueueItem.RemainingSizeMb; yield return queueItem; } diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabQueueItem.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabQueueItem.cs index b6fcdb0dd..bc233eb84 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabQueueItem.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabQueueItem.cs @@ -27,7 +27,7 @@ public class SabQueueItem public string Category { get; set; } [JsonProperty(PropertyName = "mbleft")] - public decimal SizeLeft { get; set; } + public decimal Sizeleft { get; set; } public int Percentage { get; set; } diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs index 817f3a30d..3e36e941d 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/SabnzbdClient.cs @@ -117,9 +117,11 @@ public IEnumerable GetQueue() queueItem.Id = sabQueueItem.Id; queueItem.Title = sabQueueItem.Title; queueItem.Size = sabQueueItem.Size; - queueItem.SizeLeft = sabQueueItem.Size; + queueItem.Sizeleft = sabQueueItem.Sizeleft; + queueItem.Timeleft = sabQueueItem.Timeleft; + queueItem.Status = sabQueueItem.Status; - queueItems.Add( queueItem); + queueItems.Add(queueItem); } return queueItems; diff --git a/src/NzbDrone.Core/Download/QueueItem.cs b/src/NzbDrone.Core/Download/QueueItem.cs index f9de11ff0..c63d98c1a 100644 --- a/src/NzbDrone.Core/Download/QueueItem.cs +++ b/src/NzbDrone.Core/Download/QueueItem.cs @@ -7,7 +7,8 @@ public class QueueItem public string Id { get; set; } public decimal Size { get; set; } public string Title { get; set; } - public decimal SizeLeft { get; set; } + public decimal Sizeleft { get; set; } public TimeSpan Timeleft { get; set; } + public String Status { get; set; } } } diff --git a/src/NzbDrone.Core/Queue/Queue.cs b/src/NzbDrone.Core/Queue/Queue.cs index 611aa05f4..e1ceb3ff8 100644 --- a/src/NzbDrone.Core/Queue/Queue.cs +++ b/src/NzbDrone.Core/Queue/Queue.cs @@ -13,5 +13,6 @@ public class Queue : ModelBase public String Title { get; set; } public Decimal Sizeleft { get; set; } public TimeSpan Timeleft { get; set; } + public String Status { get; set; } } } diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index 07eb767f2..e3e78c7ac 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -59,8 +59,9 @@ private List MapQueue(IEnumerable queueItems) queue.Quality = remoteEpisode.ParsedEpisodeInfo.Quality; queue.Title = queueItem.Title; queue.Size = queueItem.Size; - queue.Sizeleft = queueItem.SizeLeft; + queue.Sizeleft = queueItem.Sizeleft; queue.Timeleft = queueItem.Timeleft; + queue.Status = queueItem.Status; queued.Add(queue); } } diff --git a/src/UI/Cells/cells.less b/src/UI/Cells/cells.less index af5a71e8d..b557af740 100644 --- a/src/UI/Cells/cells.less +++ b/src/UI/Cells/cells.less @@ -96,4 +96,9 @@ td.episode-status-cell, td.quality-cell { .timeleft-cell { cursor: default; width: 80px; +} + +.queue-status-cell { + width: 20px; + text-align: center !important; } \ No newline at end of file diff --git a/src/UI/History/Queue/QueueLayout.js b/src/UI/History/Queue/QueueLayout.js index d397d4fd7..612ec0297 100644 --- a/src/UI/History/Queue/QueueLayout.js +++ b/src/UI/History/Queue/QueueLayout.js @@ -8,6 +8,7 @@ define( 'Cells/EpisodeNumberCell', 'Cells/EpisodeTitleCell', 'Cells/QualityCell', + 'History/Queue/QueueStatusCell', 'History/Queue/TimeleftCell' ], function (Marionette, Backgrid, @@ -16,6 +17,7 @@ define( EpisodeNumberCell, EpisodeTitleCell, QualityCell, + QueueStatusCell, TimeleftCell) { return Marionette.Layout.extend({ template: 'History/Queue/QueueLayoutTemplate', @@ -26,6 +28,12 @@ define( columns: [ + { + name : 'status', + label: '', + cell : QueueStatusCell, + cellValue: 'this' + }, { name : 'series', label: 'Series', diff --git a/src/UI/History/Queue/QueueStatusCell.js b/src/UI/History/Queue/QueueStatusCell.js new file mode 100644 index 000000000..67442cb09 --- /dev/null +++ b/src/UI/History/Queue/QueueStatusCell.js @@ -0,0 +1,39 @@ +'use strict'; + +define( + [ + 'Cells/NzbDroneCell' + ], function (NzbDroneCell) { + return NzbDroneCell.extend({ + + className: 'queue-status-cell', + + render: function () { + this.$el.empty(); + + if (this.cellValue) { + var status = this.cellValue.get('status').toLowerCase(); + var icon = 'icon-nd-downloading'; + var title = 'Downloading'; + + if (status === 'paused') { + icon = 'icon-pause'; + title = 'Paused'; + } + + if (status === 'queued') { + icon = 'icon-cloud'; + title = 'Queued'; + } + + var timeleft = this.cellValue.get('timeleft'); + var size = this.cellValue.get('size'); + var sizeleft = this.cellValue.get('sizeleft'); + + this.$el.html(''.format(icon, title)); + } + + return this; + } + }); + }); diff --git a/src/UI/Mixins/jquery.ajax.js b/src/UI/Mixins/jquery.ajax.js index e05a7d8fb..918d565af 100644 --- a/src/UI/Mixins/jquery.ajax.js +++ b/src/UI/Mixins/jquery.ajax.js @@ -22,7 +22,7 @@ define(function () { } if (xhr) { xhr.headers = xhr.headers || {}; - xhr.headers['Authorization'] = window.NzbDrone.ApiKey; +// xhr.headers.Authorization = window.NzbDrone.ApiKey; } return original.apply(this, arguments);