Fixed: Repaired Cutoff Unmet UI and added Cutoff Unmet status badge to History.

pull/3113/head
Taloth Saldono 10 years ago
parent 0870afb425
commit 64ecaf5f6e

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Api.Episodes; using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions; using NzbDrone.Api.Extensions;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.SignalR; using NzbDrone.SignalR;
@ -11,17 +12,11 @@ namespace NzbDrone.Api.Calendar
{ {
public class CalendarModule : EpisodeModuleWithSignalR public class CalendarModule : EpisodeModuleWithSignalR
{ {
private readonly IEpisodeService _episodeService; public CalendarModule(IEpisodeService episodeService,
private readonly SeriesRepository _seriesRepository; IQualityUpgradableSpecification qualityUpgradableSpecification,
IBroadcastSignalRMessage signalRBroadcaster)
public CalendarModule(IBroadcastSignalRMessage signalRBroadcaster, : base(episodeService, qualityUpgradableSpecification, signalRBroadcaster, "calendar")
IEpisodeService episodeService,
SeriesRepository seriesRepository)
: base(episodeService, signalRBroadcaster, "calendar")
{ {
_episodeService = episodeService;
_seriesRepository = seriesRepository;
GetResourceAll = GetCalendar; GetResourceAll = GetCalendar;
} }
@ -36,8 +31,7 @@ namespace NzbDrone.Api.Calendar
if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value); if (queryStart.HasValue) start = DateTime.Parse(queryStart.Value);
if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value); if (queryEnd.HasValue) end = DateTime.Parse(queryEnd.Value);
var resources = ToListResource(() => _episodeService.EpisodesBetweenDates(start, end)) var resources = ToListResource(() => _episodeService.EpisodesBetweenDates(start, end));
.LoadSubtype(e => e.SeriesId, _seriesRepository);
return resources.OrderBy(e => e.AirDateUtc).ToList(); return resources.OrderBy(e => e.AirDateUtc).ToList();
} }

@ -10,17 +10,15 @@ namespace NzbDrone.Api.Episodes
{ {
public class EpisodeModule : EpisodeModuleWithSignalR public class EpisodeModule : EpisodeModuleWithSignalR
{ {
private readonly ISeriesService _seriesService; protected readonly ISeriesService _seriesService;
private readonly IEpisodeService _episodeService;
private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
public EpisodeModule(IBroadcastSignalRMessage signalRBroadcaster, ISeriesService seriesService, IEpisodeService episodeService, public EpisodeModule(ISeriesService seriesService,
IQualityUpgradableSpecification qualityUpgradableSpecification) IEpisodeService episodeService,
: base(episodeService, signalRBroadcaster) IQualityUpgradableSpecification qualityUpgradableSpecification,
IBroadcastSignalRMessage signalRBroadcaster)
: base(episodeService, qualityUpgradableSpecification, signalRBroadcaster)
{ {
_seriesService = seriesService; _seriesService = seriesService;
_episodeService = episodeService;
_qualityUpgradableSpecification = qualityUpgradableSpecification;
GetResourceAll = GetEpisodes; GetResourceAll = GetEpisodes;
UpdateResource = SetMonitored; UpdateResource = SetMonitored;
@ -37,17 +35,7 @@ namespace NzbDrone.Api.Episodes
var series = _seriesService.GetSeries(seriesId.Value); var series = _seriesService.GetSeries(seriesId.Value);
var resources = new List<EpisodeResource>(); var resources = ToListResource(_episodeService.GetEpisodeBySeries(seriesId.Value));
foreach (var episode in _episodeService.GetEpisodeBySeries(seriesId.Value))
{
var resource = episode.InjectTo<EpisodeResource>();
if (episode.EpisodeFile.IsLoaded)
{
resource.EpisodeFile.QualityCutoffNotMet = _qualityUpgradableSpecification.CutoffNotMet(series.Profile.Value, episode.EpisodeFile.Value.Quality);
}
resources.Add(resource);
}
return resources; return resources;
} }

@ -1,5 +1,9 @@
using NzbDrone.Api.Mapping; using System;
using System.IO;
using NzbDrone.Api.EpisodeFiles;
using NzbDrone.Api.Mapping;
using NzbDrone.Core.Datastore.Events; using NzbDrone.Core.Datastore.Events;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.MediaFiles.Events; using NzbDrone.Core.MediaFiles.Events;
using NzbDrone.Core.Messaging.Events; using NzbDrone.Core.Messaging.Events;
@ -12,20 +16,28 @@ namespace NzbDrone.Api.Episodes
IHandle<EpisodeGrabbedEvent>, IHandle<EpisodeGrabbedEvent>,
IHandle<EpisodeDownloadedEvent> IHandle<EpisodeDownloadedEvent>
{ {
private readonly IEpisodeService _episodeService; protected readonly IEpisodeService _episodeService;
protected readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
protected EpisodeModuleWithSignalR(IEpisodeService episodeService, IBroadcastSignalRMessage signalRBroadcaster) protected EpisodeModuleWithSignalR(IEpisodeService episodeService,
IQualityUpgradableSpecification qualityUpgradableSpecification,
IBroadcastSignalRMessage signalRBroadcaster)
: base(signalRBroadcaster) : base(signalRBroadcaster)
{ {
_episodeService = episodeService; _episodeService = episodeService;
_qualityUpgradableSpecification = qualityUpgradableSpecification;
GetResourceById = GetEpisode; GetResourceById = GetEpisode;
} }
protected EpisodeModuleWithSignalR(IEpisodeService episodeService, IBroadcastSignalRMessage signalRBroadcaster, string resource) protected EpisodeModuleWithSignalR(IEpisodeService episodeService,
IQualityUpgradableSpecification qualityUpgradableSpecification,
IBroadcastSignalRMessage signalRBroadcaster,
String resource)
: base(signalRBroadcaster, resource) : base(signalRBroadcaster, resource)
{ {
_episodeService = episodeService; _episodeService = episodeService;
_qualityUpgradableSpecification = qualityUpgradableSpecification;
GetResourceById = GetEpisode; GetResourceById = GetEpisode;
} }
@ -34,7 +46,25 @@ namespace NzbDrone.Api.Episodes
{ {
var episode = _episodeService.GetEpisode(id); var episode = _episodeService.GetEpisode(id);
episode.EpisodeFile.LazyLoad(); episode.EpisodeFile.LazyLoad();
return episode.InjectTo<EpisodeResource>(); return ToResource(episode);
}
protected override EpisodeResource ToResource<TModel>(TModel model)
{
var resource = base.ToResource(model);
var episode = model as Episode;
if (episode != null)
{
if (episode.EpisodeFile.IsLoaded && episode.EpisodeFile.Value != null)
{
resource.EpisodeFile = episode.EpisodeFile.Value.InjectTo<EpisodeFileResource>();
resource.EpisodeFile.Path = Path.Combine(episode.Series.Path, episode.EpisodeFile.Value.RelativePath);
resource.EpisodeFile.QualityCutoffNotMet = _qualityUpgradableSpecification.CutoffNotMet(episode.Series.Profile.Value, episode.EpisodeFile.Value.Quality);
}
}
return resource;
} }
public void Handle(EpisodeGrabbedEvent message) public void Handle(EpisodeGrabbedEvent message)

@ -2,6 +2,7 @@
using Nancy; using Nancy;
using NzbDrone.Api.Extensions; using NzbDrone.Api.Extensions;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Download; using NzbDrone.Core.Download;
using NzbDrone.Core.History; using NzbDrone.Core.History;
@ -10,17 +11,35 @@ namespace NzbDrone.Api.History
public class HistoryModule : NzbDroneRestModule<HistoryResource> public class HistoryModule : NzbDroneRestModule<HistoryResource>
{ {
private readonly IHistoryService _historyService; private readonly IHistoryService _historyService;
private readonly IQualityUpgradableSpecification _qualityUpgradableSpecification;
private readonly IDownloadTrackingService _downloadTrackingService; private readonly IDownloadTrackingService _downloadTrackingService;
public HistoryModule(IHistoryService historyService, IDownloadTrackingService downloadTrackingService) public HistoryModule(IHistoryService historyService,
IQualityUpgradableSpecification qualityUpgradableSpecification,
IDownloadTrackingService downloadTrackingService)
{ {
_historyService = historyService; _historyService = historyService;
_qualityUpgradableSpecification = qualityUpgradableSpecification;
_downloadTrackingService = downloadTrackingService; _downloadTrackingService = downloadTrackingService;
GetResourcePaged = GetHistory; GetResourcePaged = GetHistory;
Post["/failed"] = x => MarkAsFailed(); Post["/failed"] = x => MarkAsFailed();
} }
protected override HistoryResource ToResource<TModel>(TModel model)
{
var resource = base.ToResource<TModel>(model);
var history = model as NzbDrone.Core.History.History;
if (history != null && history.Series != null)
{
resource.QualityCutoffNotMet = _qualityUpgradableSpecification.CutoffNotMet(history.Series.Profile.Value, history.Quality);
}
return resource;
}
private PagingResource<HistoryResource> GetHistory(PagingResource<HistoryResource> pagingResource) private PagingResource<HistoryResource> GetHistory(PagingResource<HistoryResource> pagingResource)
{ {
var episodeId = Request.Query.EpisodeId; var episodeId = Request.Query.EpisodeId;

@ -15,6 +15,7 @@ namespace NzbDrone.Api.History
public int SeriesId { get; set; } public int SeriesId { get; set; }
public string SourceTitle { get; set; } public string SourceTitle { get; set; }
public QualityModel Quality { get; set; } public QualityModel Quality { get; set; }
public Boolean QualityCutoffNotMet { get; set; }
public DateTime Date { get; set; } public DateTime Date { get; set; }
public string Indexer { get; set; } public string Indexer { get; set; }
public string NzbInfoUrl { get; set; } public string NzbInfoUrl { get; set; }

@ -1,4 +1,5 @@
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.REST; using NzbDrone.Api.REST;
using NzbDrone.Api.Validation; using NzbDrone.Api.Validation;
@ -34,7 +35,17 @@ namespace NzbDrone.Api
protected List<TResource> ToListResource<TModel>(Func<IEnumerable<TModel>> function) where TModel : class protected List<TResource> ToListResource<TModel>(Func<IEnumerable<TModel>> function) where TModel : class
{ {
var modelList = function(); var modelList = function();
return modelList.InjectTo<List<TResource>>(); return ToListResource(modelList);
}
protected virtual List<TResource> ToListResource<TModel>(IEnumerable<TModel> modelList) where TModel : class
{
return modelList.Select(ToResource).ToList();
}
protected virtual TResource ToResource<TModel>(TModel model) where TModel : class
{
return model.InjectTo<TResource>();
} }
protected PagingResource<TResource> ApplyToPage<TModel>(Func<PagingSpec<TModel>, PagingSpec<TModel>> function, PagingSpec<TModel> pagingSpec) where TModel : ModelBase, new() protected PagingResource<TResource> ApplyToPage<TModel>(Func<PagingSpec<TModel>, PagingSpec<TModel>> function, PagingSpec<TModel> pagingSpec) where TModel : ModelBase, new()
@ -48,7 +59,7 @@ namespace NzbDrone.Api
SortDirection = pagingSpec.SortDirection, SortDirection = pagingSpec.SortDirection,
SortKey = pagingSpec.SortKey, SortKey = pagingSpec.SortKey,
TotalRecords = pagingSpec.TotalRecords, TotalRecords = pagingSpec.TotalRecords,
Records = pagingSpec.Records.InjectTo<List<TResource>>() Records = ToListResource(pagingSpec.Records)
}; };
} }
} }

@ -2,6 +2,7 @@
using NzbDrone.Api.Episodes; using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions; using NzbDrone.Api.Extensions;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.SignalR; using NzbDrone.SignalR;
@ -10,13 +11,14 @@ namespace NzbDrone.Api.Wanted
public class CutoffModule : EpisodeModuleWithSignalR public class CutoffModule : EpisodeModuleWithSignalR
{ {
private readonly IEpisodeCutoffService _episodeCutoffService; private readonly IEpisodeCutoffService _episodeCutoffService;
private readonly ISeriesRepository _seriesRepository;
public CutoffModule(IEpisodeService episodeService, IEpisodeCutoffService episodeCutoffService, ISeriesRepository seriesRepository, IBroadcastSignalRMessage signalRBroadcaster) public CutoffModule(IEpisodeCutoffService episodeCutoffService,
: base(episodeService, signalRBroadcaster, "wanted/cutoff") IEpisodeService episodeService,
IQualityUpgradableSpecification qualityUpgradableSpecification,
IBroadcastSignalRMessage signalRBroadcaster)
: base(episodeService, qualityUpgradableSpecification, signalRBroadcaster, "wanted/cutoff")
{ {
_episodeCutoffService = episodeCutoffService; _episodeCutoffService = episodeCutoffService;
_seriesRepository = seriesRepository;
GetResourcePaged = GetCutoffUnmetEpisodes; GetResourcePaged = GetCutoffUnmetEpisodes;
} }
@ -41,8 +43,6 @@ namespace NzbDrone.Api.Wanted
PagingResource<EpisodeResource> resource = ApplyToPage(_episodeCutoffService.EpisodesWhereCutoffUnmet, pagingSpec); PagingResource<EpisodeResource> resource = ApplyToPage(_episodeCutoffService.EpisodesWhereCutoffUnmet, pagingSpec);
resource.Records = resource.Records.LoadSubtype(e => e.SeriesId, _seriesRepository).ToList();
return resource; return resource;
} }
} }

@ -3,6 +3,7 @@ using System.Linq;
using NzbDrone.Api.Episodes; using NzbDrone.Api.Episodes;
using NzbDrone.Api.Extensions; using NzbDrone.Api.Extensions;
using NzbDrone.Core.Datastore; using NzbDrone.Core.Datastore;
using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using NzbDrone.SignalR; using NzbDrone.SignalR;
@ -11,14 +12,11 @@ namespace NzbDrone.Api.Wanted
{ {
public class MissingModule : EpisodeModuleWithSignalR public class MissingModule : EpisodeModuleWithSignalR
{ {
private readonly IEpisodeService _episodeService; public MissingModule(IEpisodeService episodeService,
private readonly ISeriesRepository _seriesRepository; IQualityUpgradableSpecification qualityUpgradableSpecification,
IBroadcastSignalRMessage signalRBroadcaster)
public MissingModule(IEpisodeService episodeService, ISeriesRepository seriesRepository, IBroadcastSignalRMessage signalRBroadcaster) : base(episodeService, qualityUpgradableSpecification, signalRBroadcaster, "wanted/missing")
: base(episodeService, signalRBroadcaster, "wanted/missing")
{ {
_episodeService = episodeService;
_seriesRepository = seriesRepository;
GetResourcePaged = GetMissingEpisodes; GetResourcePaged = GetMissingEpisodes;
} }
@ -43,8 +41,6 @@ namespace NzbDrone.Api.Wanted
PagingResource<EpisodeResource> resource = ApplyToPage(v => _episodeService.EpisodesWithoutFiles(v), pagingSpec); PagingResource<EpisodeResource> resource = ApplyToPage(v => _episodeService.EpisodesWithoutFiles(v), pagingSpec);
resource.Records = resource.Records.LoadSubtype(e => e.SeriesId, _seriesRepository).ToList();
return resource; return resource;
} }
} }

@ -1,5 +1,5 @@
{{#if proper}} {{#if proper}}
<span class="badge badge-info" title="PROPER">{{quality.name}}</span> <span class="badge badge-info" title="PROPER">{{quality.name}}</span>
{{else}} {{else}}
<span class="badge badge-inverse">{{quality.name}}</span> <span class="badge">{{quality.name}}</span>
{{/if}} {{/if}}

@ -78,7 +78,7 @@
} }
} }
td.episode-status-cell, td.quality-cell { td.episode-status-cell, td.quality-cell, td.history-quality-cell {
text-align: center; text-align: center;
width: 80px; width: 80px;

@ -0,0 +1,31 @@
'use strict';
define(
[
'Cells/NzbDroneCell'
], function (NzbDroneCell) {
return NzbDroneCell.extend({
className: 'history-quality-cell',
render: function () {
var title = '';
var quality = this.model.get('quality');
if (quality.proper) {
title = 'PROPER';
}
if (this.model.get('qualityCutoffNotMet')) {
this.$el.html('<span class="badge badge-inverse" title="{0}">{1}</span>'.format(title, quality.quality.name));
}
else {
this.$el.html('<span class="badge" title="{0}">{1}</span>'.format(title, quality.quality.name));
}
return this;
}
});
});

@ -8,7 +8,7 @@ define(
'Cells/SeriesTitleCell', 'Cells/SeriesTitleCell',
'Cells/EpisodeNumberCell', 'Cells/EpisodeNumberCell',
'Cells/EpisodeTitleCell', 'Cells/EpisodeTitleCell',
'Cells/QualityCell', 'History/Table/HistoryQualityCell',
'Cells/RelativeDateCell', 'Cells/RelativeDateCell',
'History/Table/HistoryDetailsCell', 'History/Table/HistoryDetailsCell',
'Shared/Grid/Pager', 'Shared/Grid/Pager',
@ -21,7 +21,7 @@ define(
SeriesTitleCell, SeriesTitleCell,
EpisodeNumberCell, EpisodeNumberCell,
EpisodeTitleCell, EpisodeTitleCell,
QualityCell, HistoryQualityCell,
RelativeDateCell, RelativeDateCell,
HistoryDetailsCell, HistoryDetailsCell,
GridPager, GridPager,
@ -62,9 +62,9 @@ define(
sortable : false sortable : false
}, },
{ {
name : 'quality', name : 'this',
label : 'Quality', label : 'Quality',
cell : QualityCell, cell : HistoryQualityCell,
sortable : false sortable : false
}, },
{ {

Loading…
Cancel
Save