From cb0f7792f2f7f4b238e903b9e130f7992e3754e2 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sat, 24 May 2014 12:50:34 +0200 Subject: [PATCH] Queue UI no longer shows unknown ETAs as 0:00:00. --- src/NzbDrone.Api/Queue/QueueResource.cs | 2 +- .../Download/DownloadClientItem.cs | 4 ++-- src/NzbDrone.Core/Queue/Queue.cs | 2 +- src/NzbDrone.Core/Queue/QueueService.cs | 5 ++++- src/UI/Cells/cells.less | 1 + src/UI/History/Queue/TimeleftCell.js | 17 +++++++++++------ 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/NzbDrone.Api/Queue/QueueResource.cs b/src/NzbDrone.Api/Queue/QueueResource.cs index 0adfe1e79..5d8cc2642 100644 --- a/src/NzbDrone.Api/Queue/QueueResource.cs +++ b/src/NzbDrone.Api/Queue/QueueResource.cs @@ -13,7 +13,7 @@ namespace NzbDrone.Api.Queue public Decimal Size { get; set; } public String Title { get; set; } public Decimal Sizeleft { get; set; } - public TimeSpan Timeleft { get; set; } + public TimeSpan? Timeleft { get; set; } public String Status { get; set; } } } diff --git a/src/NzbDrone.Core/Download/DownloadClientItem.cs b/src/NzbDrone.Core/Download/DownloadClientItem.cs index 6cc2dbb2f..8b9365c9c 100644 --- a/src/NzbDrone.Core/Download/DownloadClientItem.cs +++ b/src/NzbDrone.Core/Download/DownloadClientItem.cs @@ -15,8 +15,8 @@ namespace NzbDrone.Core.Download public Int64 TotalSize { get; set; } public Int64 RemainingSize { get; set; } - public TimeSpan DownloadTime { get; set; } - public TimeSpan RemainingTime { get; set; } + public TimeSpan? DownloadTime { get; set; } + public TimeSpan? RemainingTime { get; set; } public String OutputPath { get; set; } public String Message { get; set; } diff --git a/src/NzbDrone.Core/Queue/Queue.cs b/src/NzbDrone.Core/Queue/Queue.cs index a1b2ff7f3..c8cde78d4 100644 --- a/src/NzbDrone.Core/Queue/Queue.cs +++ b/src/NzbDrone.Core/Queue/Queue.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Queue public Decimal Size { get; set; } public String Title { get; set; } public Decimal Sizeleft { get; set; } - public TimeSpan Timeleft { get; set; } + public TimeSpan? Timeleft { get; set; } public String Status { get; set; } public RemoteEpisode RemoteEpisode { get; set; } } diff --git a/src/NzbDrone.Core/Queue/QueueService.cs b/src/NzbDrone.Core/Queue/QueueService.cs index 018c9f01f..ead4f083c 100644 --- a/src/NzbDrone.Core/Queue/QueueService.cs +++ b/src/NzbDrone.Core/Queue/QueueService.cs @@ -24,7 +24,10 @@ namespace NzbDrone.Core.Queue public List GetQueue() { - var queueItems = _downloadTrackingService.GetQueuedDownloads().Select(v => v.DownloadItem).ToList(); + var queueItems = _downloadTrackingService.GetQueuedDownloads() + .Select(v => v.DownloadItem) + .OrderBy(v => v.RemainingTime) + .ToList(); return MapQueue(queueItems); } diff --git a/src/UI/Cells/cells.less b/src/UI/Cells/cells.less index 4105f32a1..42442e6af 100644 --- a/src/UI/Cells/cells.less +++ b/src/UI/Cells/cells.less @@ -137,6 +137,7 @@ td.episode-status-cell, td.quality-cell { .timeleft-cell { cursor : default; width : 80px; + text-align: center; } .queue-status-cell { diff --git a/src/UI/History/Queue/TimeleftCell.js b/src/UI/History/Queue/TimeleftCell.js index 9ead67f63..813014001 100644 --- a/src/UI/History/Queue/TimeleftCell.js +++ b/src/UI/History/Queue/TimeleftCell.js @@ -2,8 +2,9 @@ define( [ - 'Cells/NzbDroneCell' - ], function (NzbDroneCell) { + 'Cells/NzbDroneCell', + 'filesize' + ], function (NzbDroneCell, fileSize) { return NzbDroneCell.extend({ className: 'timeleft-cell', @@ -14,11 +15,15 @@ define( if (this.cellValue) { var timeleft = this.cellValue.get('timeleft'); - var size = this.cellValue.get('size'); - var sizeleft = this.cellValue.get('sizeleft'); + var totalSize = fileSize(this.cellValue.get('size'), 1, false); + var remainingSize = fileSize(this.cellValue.get('sizeleft'), 1, false); - this.$el.html(timeleft); - this.$el.attr('title', '{0} MB / {1} MB'.format(sizeleft, size)); + if (timeleft === undefined) { + this.$el.html("-"); + } else { + this.$el.html(timeleft); + } + this.$el.attr('title', '{0} / {1}'.format(remainingSize, totalSize)); } return this;