SignalR will now update quality in UI as well (when applicable)

This commit is contained in:
Mark McDowall 2012-02-27 21:52:03 -08:00
parent c5df00cc87
commit 03a7643b75
6 changed files with 34 additions and 12 deletions

View File

@ -202,7 +202,7 @@ namespace NzbDrone.Core.Providers
_externalNotificationProvider.OnDownload(message, series); _externalNotificationProvider.OnDownload(message, series);
foreach(var episode in episodes) foreach(var episode in episodes)
_signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Ready); _signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Ready, parseResult.Quality);
} }
else else
{ {

View File

@ -67,7 +67,7 @@ namespace NzbDrone.Core.Providers
_historyProvider.Add(history); _historyProvider.Add(history);
_episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId); _episodeProvider.MarkEpisodeAsFetched(episode.EpisodeId);
_signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Downloading); _signalRProvider.UpdateEpisodeStatus(episode.EpisodeId, EpisodeStatusType.Downloading, null);
} }
_externalNotificationProvider.OnGrab(downloadTitle); _externalNotificationProvider.OnGrab(downloadTitle);

View File

@ -4,6 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using NLog; using NLog;
using NzbDrone.Core.Model; using NzbDrone.Core.Model;
using NzbDrone.Core.Repository.Quality;
using SignalR; using SignalR;
using SignalR.Hosting.AspNet; using SignalR.Hosting.AspNet;
using SignalR.Hubs; using SignalR.Hubs;
@ -15,11 +16,25 @@ namespace NzbDrone.Core.Providers
{ {
private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private static readonly Logger logger = LogManager.GetCurrentClassLogger();
public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus) public virtual void UpdateEpisodeStatus(int episodeId, EpisodeStatusType episodeStatus, Quality quality)
{ {
logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus); try
{
logger.Trace("Sending Status update to client. EpisodeId: {0}, Status: {1}", episodeId, episodeStatus);
GetClients().updatedStatus(episodeId, episodeStatus.ToString()); GetClients().updatedStatus(new
{
EpisodeId = episodeId,
EpisodeStatus = episodeStatus.ToString(),
Quality = (quality == null ? String.Empty : quality.QualityType.ToString())
});
var test = 0;
}
catch (Exception ex)
{
logger.Trace("Error");
throw;
}
} }
private dynamic GetClients() private dynamic GetClients()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 760 B

View File

@ -63,9 +63,9 @@ $(function () {
var signalRProvider = $.connection.signalRProvider; var signalRProvider = $.connection.signalRProvider;
// Declare a function on the chat hub so the server can invoke it // Declare a function on the chat hub so the server can invoke it
signalRProvider.updatedStatus = function (episodeId, episodeStatus) { signalRProvider.updatedStatus = function (data) {
var imageSrc = '../../Content/Images/' + episodeStatus + '.png'; var imageSrc = '../../Content/Images/' + data.EpisodeStatus + '.png';
var row = $('tr.episodeId_' + episodeId); var row = $('tr.episodeId_' + data.EpisodeId);
if (row.length == 0) if (row.length == 0)
return; return;
@ -75,13 +75,20 @@ $(function () {
if (statusImage.length == 0) if (statusImage.length == 0)
return; return;
statusImage.attr('alt', episodeStatus); statusImage.attr('alt', data.EpisodeStatus);
statusImage.attr('title', episodeStatus); statusImage.attr('title', data.EpisodeStatus);
statusImage.attr('src', imageSrc); statusImage.attr('src', imageSrc);
if (episodeStatus != "Missing") { if (data.EpisodeStatus != "Missing") {
statusImage.parent('td').removeClass('episodeMissing'); statusImage.parent('td').removeClass('episodeMissing');
} }
if (data.Quality != null) {
var qualityColumn = $(row).find('.episodeQuality');
if (qualityColumn)
qualityColumn.text(data.Quality);
}
}; };
// Start the connection // Start the connection

View File

@ -6,7 +6,7 @@
<td>@Model.EpisodeNumber</td> <td>@Model.EpisodeNumber</td>
<td>@Model.Title</td> <td>@Model.Title</td>
<td>@Model.AirDate</td> <td>@Model.AirDate</td>
<td>@Model.Quality</td> <td class="episodeQuality">@Model.Quality</td>
@{ @{
string cellColourClass = String.Empty; string cellColourClass = String.Empty;