Merge branch 'wanted' into develop
This commit is contained in:
commit
860db98294
|
@ -160,6 +160,14 @@ namespace Marr.Data
|
||||||
get { return _children; }
|
get { return _children; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds an Child in the graph for LazyLoaded property.
|
||||||
|
/// </summary>
|
||||||
|
public void AddLazyRelationship(Relationship childRelationship)
|
||||||
|
{
|
||||||
|
_children.Add(new EntityGraph(childRelationship.RelationshipInfo.EntityType.GetGenericArguments()[0], this, childRelationship));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds an entity to the appropriate place in the object graph.
|
/// Adds an entity to the appropriate place in the object graph.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -182,7 +190,10 @@ namespace Marr.Data
|
||||||
}
|
}
|
||||||
else // RelationTypes.One
|
else // RelationTypes.One
|
||||||
{
|
{
|
||||||
_relationship.Setter(_parent._entity, entityInstance);
|
if (_relationship.IsLazyLoaded)
|
||||||
|
_relationship.Setter(_parent._entity, Activator.CreateInstance(_relationship.MemberType, entityInstance));
|
||||||
|
else
|
||||||
|
_relationship.Setter(_parent._entity, entityInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityReference entityRef = new EntityReference(entityInstance);
|
EntityReference entityRef = new EntityReference(entityInstance);
|
||||||
|
|
|
@ -551,6 +551,23 @@ namespace Marr.Data.QGen
|
||||||
return Join(joinType, rightMember, filterExpression);
|
return Join(joinType, rightMember, filterExpression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, Expression<Func<TLeft, LazyLoaded<TRight>>> rightEntity, Expression<Func<TLeft, TRight, bool>> filterExpression)
|
||||||
|
{
|
||||||
|
_isJoin = true;
|
||||||
|
MemberInfo rightMember = (rightEntity.Body as MemberExpression).Member;
|
||||||
|
|
||||||
|
foreach (var item in EntGraph)
|
||||||
|
{
|
||||||
|
if (item.EntityType == typeof(TLeft))
|
||||||
|
{
|
||||||
|
var relationship = item.Relationships.Single(v => v.Member == rightMember);
|
||||||
|
item.AddLazyRelationship(relationship);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Join(joinType, rightMember, filterExpression);
|
||||||
|
}
|
||||||
|
|
||||||
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, MemberInfo rightMember, Expression<Func<TLeft, TRight, bool>> filterExpression)
|
public virtual QueryBuilder<T> Join<TLeft, TRight>(JoinType joinType, MemberInfo rightMember, Expression<Func<TLeft, TRight, bool>> filterExpression)
|
||||||
{
|
{
|
||||||
_isJoin = true;
|
_isJoin = true;
|
||||||
|
|
|
@ -150,7 +150,9 @@
|
||||||
<Compile Include="Mapping\MappingValidation.cs" />
|
<Compile Include="Mapping\MappingValidation.cs" />
|
||||||
<Compile Include="Mapping\ResourceMappingException.cs" />
|
<Compile Include="Mapping\ResourceMappingException.cs" />
|
||||||
<Compile Include="Mapping\ValueInjectorExtensions.cs" />
|
<Compile Include="Mapping\ValueInjectorExtensions.cs" />
|
||||||
<Compile Include="Missing\MissingModule.cs" />
|
<Compile Include="Wanted\CutoffModule.cs" />
|
||||||
|
<Compile Include="Wanted\LegacyMissingModule.cs" />
|
||||||
|
<Compile Include="Wanted\MissingModule.cs" />
|
||||||
<Compile Include="Config\NamingSampleResource.cs" />
|
<Compile Include="Config\NamingSampleResource.cs" />
|
||||||
<Compile Include="NzbDroneRestModuleWithSignalR.cs" />
|
<Compile Include="NzbDroneRestModuleWithSignalR.cs" />
|
||||||
<Compile Include="Qualities\QualityProfileValidation.cs" />
|
<Compile Include="Qualities\QualityProfileValidation.cs" />
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
using System.Linq;
|
||||||
|
using NzbDrone.Api.Episodes;
|
||||||
|
using NzbDrone.Api.Extensions;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
|
namespace NzbDrone.Api.Wanted
|
||||||
|
{
|
||||||
|
public class CutoffModule : NzbDroneRestModule<EpisodeResource>
|
||||||
|
{
|
||||||
|
private readonly IEpisodeCutoffService _episodeCutoffService;
|
||||||
|
private readonly SeriesRepository _seriesRepository;
|
||||||
|
|
||||||
|
public CutoffModule(IEpisodeCutoffService episodeCutoffService, SeriesRepository seriesRepository)
|
||||||
|
:base("wanted/cutoff")
|
||||||
|
{
|
||||||
|
_episodeCutoffService = episodeCutoffService;
|
||||||
|
_seriesRepository = seriesRepository;
|
||||||
|
GetResourcePaged = GetCutoffUnmetEpisodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PagingResource<EpisodeResource> GetCutoffUnmetEpisodes(PagingResource<EpisodeResource> pagingResource)
|
||||||
|
{
|
||||||
|
var pagingSpec = new PagingSpec<Episode>
|
||||||
|
{
|
||||||
|
Page = pagingResource.Page,
|
||||||
|
PageSize = pagingResource.PageSize,
|
||||||
|
SortKey = pagingResource.SortKey,
|
||||||
|
SortDirection = pagingResource.SortDirection
|
||||||
|
};
|
||||||
|
|
||||||
|
if (pagingResource.FilterKey == "monitored" && pagingResource.FilterValue == "false")
|
||||||
|
{
|
||||||
|
pagingSpec.FilterExpression = v => v.Monitored == false || v.Series.Monitored == false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pagingSpec.FilterExpression = v => v.Monitored == true && v.Series.Monitored == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PagingResource<EpisodeResource> resource = ApplyToPage(_episodeCutoffService.EpisodesWhereCutoffUnmet, pagingSpec);
|
||||||
|
|
||||||
|
resource.Records = resource.Records.LoadSubtype(e => e.SeriesId, _seriesRepository).ToList();
|
||||||
|
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using Nancy;
|
||||||
|
|
||||||
|
namespace NzbDrone.Api.Wanted
|
||||||
|
{
|
||||||
|
class LegacyMissingModule : NzbDroneApiModule
|
||||||
|
{
|
||||||
|
public LegacyMissingModule() : base("missing")
|
||||||
|
{
|
||||||
|
Get["/"] = x =>
|
||||||
|
{
|
||||||
|
string queryString = ConvertQueryParams(Request.Query);
|
||||||
|
var url = String.Format("/api/wanted/missing?{0}", queryString);
|
||||||
|
|
||||||
|
return Response.AsRedirect(url);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ConvertQueryParams(DynamicDictionary query)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (var key in query)
|
||||||
|
{
|
||||||
|
var value = query[key];
|
||||||
|
|
||||||
|
sb.AppendFormat("&{0}={1}", key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.ToString().Trim('&');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,7 @@ using NzbDrone.Api.Extensions;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Tv;
|
using NzbDrone.Core.Tv;
|
||||||
|
|
||||||
namespace NzbDrone.Api.Missing
|
namespace NzbDrone.Api.Wanted
|
||||||
{
|
{
|
||||||
public class MissingModule : NzbDroneRestModule<EpisodeResource>
|
public class MissingModule : NzbDroneRestModule<EpisodeResource>
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace NzbDrone.Api.Missing
|
||||||
private readonly SeriesRepository _seriesRepository;
|
private readonly SeriesRepository _seriesRepository;
|
||||||
|
|
||||||
public MissingModule(IEpisodeService episodeService, SeriesRepository seriesRepository)
|
public MissingModule(IEpisodeService episodeService, SeriesRepository seriesRepository)
|
||||||
:base("missing")
|
:base("wanted/missing")
|
||||||
{
|
{
|
||||||
_episodeService = episodeService;
|
_episodeService = episodeService;
|
||||||
_seriesRepository = seriesRepository;
|
_seriesRepository = seriesRepository;
|
||||||
|
@ -29,7 +29,17 @@ namespace NzbDrone.Api.Missing
|
||||||
SortDirection = pagingResource.SortDirection
|
SortDirection = pagingResource.SortDirection
|
||||||
};
|
};
|
||||||
|
|
||||||
var resource = ApplyToPage(_episodeService.EpisodesWithoutFiles, pagingSpec);
|
if (pagingResource.FilterKey == "monitored" && pagingResource.FilterValue == "false")
|
||||||
|
{
|
||||||
|
pagingSpec.FilterExpression = v => v.Monitored == false || v.Series.Monitored == false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pagingSpec.FilterExpression = v => v.Monitored == true && v.Series.Monitored == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PagingResource<EpisodeResource> resource = ApplyToPage(v => _episodeService.EpisodesWithoutFiles(v), pagingSpec);
|
||||||
|
|
||||||
resource.Records = resource.Records.LoadSubtype(e => e.SeriesId, _seriesRepository).ToList();
|
resource.Records = resource.Records.LoadSubtype(e => e.SeriesId, _seriesRepository).ToList();
|
||||||
|
|
||||||
return resource;
|
return resource;
|
|
@ -45,12 +45,12 @@ namespace NzbDrone.Automation.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void missing_page()
|
public void wanted_page()
|
||||||
{
|
{
|
||||||
page.MissingNavIcon.Click();
|
page.WantedNavIcon.Click();
|
||||||
page.WaitForNoSpinner();
|
page.WaitForNoSpinner();
|
||||||
|
|
||||||
page.FindByClass("iv-missing-missinglayout").Should().NotBeNull();
|
page.FindByClass("iv-wanted-missing-missinglayout").Should().NotBeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -72,11 +72,11 @@ namespace NzbDrone.Automation.Test.PageModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWebElement MissingNavIcon
|
public IWebElement WantedNavIcon
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Find(By.LinkText("Missing"));
|
return Find(By.LinkText("Wanted"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.Datastore
|
||||||
|
{
|
||||||
|
|
||||||
|
[TestFixture]
|
||||||
|
public class MarrDataLazyLoadingFixture : DbTest
|
||||||
|
{
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
var qualityProfile = new NzbDrone.Core.Qualities.QualityProfile
|
||||||
|
{
|
||||||
|
Name = "Test",
|
||||||
|
Cutoff = Quality.WEBDL720p,
|
||||||
|
Items = NzbDrone.Core.Test.Qualities.QualityFixture.GetDefaultQualities()
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
qualityProfile = Db.Insert(qualityProfile);
|
||||||
|
|
||||||
|
var series = Builder<Series>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(v => v.QualityProfileId = qualityProfile.Id)
|
||||||
|
.BuildListOfNew();
|
||||||
|
|
||||||
|
Db.InsertMany(series);
|
||||||
|
|
||||||
|
var episodeFiles = Builder<EpisodeFile>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(v => v.SeriesId = series[0].Id)
|
||||||
|
.BuildListOfNew();
|
||||||
|
|
||||||
|
Db.InsertMany(episodeFiles);
|
||||||
|
|
||||||
|
var episodes = Builder<Episode>.CreateListOfSize(10)
|
||||||
|
.All()
|
||||||
|
.With(v => v.Monitored = true)
|
||||||
|
.With(v => v.EpisodeFileId = episodeFiles[0].Id)
|
||||||
|
.With(v => v.SeriesId = series[0].Id)
|
||||||
|
.BuildListOfNew();
|
||||||
|
|
||||||
|
Db.InsertMany(episodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_lazy_load_qualityprofile_if_not_joined()
|
||||||
|
{
|
||||||
|
var db = Mocker.Resolve<IDatabase>();
|
||||||
|
var DataMapper = db.GetDataMapper();
|
||||||
|
|
||||||
|
var episodes = DataMapper.Query<Episode>()
|
||||||
|
.Join<Episode, Series>(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var episode in episodes)
|
||||||
|
{
|
||||||
|
Assert.IsNotNull(episode.Series);
|
||||||
|
Assert.IsFalse(episode.Series.QualityProfile.IsLoaded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_explicit_load_episodefile_if_joined()
|
||||||
|
{
|
||||||
|
var db = Mocker.Resolve<IDatabase>();
|
||||||
|
var DataMapper = db.GetDataMapper();
|
||||||
|
|
||||||
|
var episodes = DataMapper.Query<Episode>()
|
||||||
|
.Join<Episode, EpisodeFile>(Marr.Data.QGen.JoinType.Inner, v => v.EpisodeFile, (l, r) => l.EpisodeFileId == r.Id)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var episode in episodes)
|
||||||
|
{
|
||||||
|
Assert.IsNull(episode.Series);
|
||||||
|
Assert.IsTrue(episode.EpisodeFile.IsLoaded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_explicit_load_qualityprofile_if_joined()
|
||||||
|
{
|
||||||
|
var db = Mocker.Resolve<IDatabase>();
|
||||||
|
var DataMapper = db.GetDataMapper();
|
||||||
|
|
||||||
|
var episodes = DataMapper.Query<Episode>()
|
||||||
|
.Join<Episode, Series>(Marr.Data.QGen.JoinType.Inner, v => v.Series, (l, r) => l.SeriesId == r.Id)
|
||||||
|
.Join<Series, QualityProfile>(Marr.Data.QGen.JoinType.Inner, v => v.QualityProfile, (l, r) => l.QualityProfileId == r.Id)
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var episode in episodes)
|
||||||
|
{
|
||||||
|
Assert.IsNotNull(episode.Series);
|
||||||
|
Assert.IsTrue(episode.Series.QualityProfile.IsLoaded);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -104,6 +104,7 @@
|
||||||
<Compile Include="Blacklisting\BlacklistRepositoryFixture.cs" />
|
<Compile Include="Blacklisting\BlacklistRepositoryFixture.cs" />
|
||||||
<Compile Include="DataAugmentationFixture\Scene\SceneMappingProxyFixture.cs" />
|
<Compile Include="DataAugmentationFixture\Scene\SceneMappingProxyFixture.cs" />
|
||||||
<Compile Include="DataAugmentationFixture\Scene\SceneMappingServiceFixture.cs" />
|
<Compile Include="DataAugmentationFixture\Scene\SceneMappingServiceFixture.cs" />
|
||||||
|
<Compile Include="Datastore\MarrDataLazyLoadingFixture.cs" />
|
||||||
<Compile Include="Datastore\BasicRepositoryFixture.cs" />
|
<Compile Include="Datastore\BasicRepositoryFixture.cs" />
|
||||||
<Compile Include="Datastore\Converters\ProviderSettingConverterFixture.cs" />
|
<Compile Include="Datastore\Converters\ProviderSettingConverterFixture.cs" />
|
||||||
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
|
<Compile Include="Datastore\DatabaseRelationshipFixture.cs" />
|
||||||
|
@ -211,6 +212,7 @@
|
||||||
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodesFixture.cs" />
|
<Compile Include="Housekeeping\Housekeepers\CleanupOrphanedEpisodesFixture.cs" />
|
||||||
<Compile Include="ThingiProviderTests\NullConfigFixture.cs" />
|
<Compile Include="ThingiProviderTests\NullConfigFixture.cs" />
|
||||||
<Compile Include="ThingiProvider\ProviderBaseFixture.cs" />
|
<Compile Include="ThingiProvider\ProviderBaseFixture.cs" />
|
||||||
|
<Compile Include="TvTests\EpisodeRepositoryTests\EpisodesWhereCutoffUnmetFixture.cs" />
|
||||||
<Compile Include="TvTests\RefreshEpisodeServiceFixture.cs" />
|
<Compile Include="TvTests\RefreshEpisodeServiceFixture.cs" />
|
||||||
<Compile Include="TvTests\EpisodeProviderTests\HandleEpisodeFileDeletedFixture.cs" />
|
<Compile Include="TvTests\EpisodeProviderTests\HandleEpisodeFileDeletedFixture.cs" />
|
||||||
<Compile Include="TvTests\EpisodeRepositoryTests\FindEpisodeFixture.cs" />
|
<Compile Include="TvTests\EpisodeRepositoryTests\FindEpisodeFixture.cs" />
|
||||||
|
|
|
@ -0,0 +1,167 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using FizzWare.NBuilder;
|
||||||
|
using FluentAssertions;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
using NzbDrone.Core.Tv;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class EpisodesWhereCutoffUnmetFixture : DbTest<EpisodeRepository, Episode>
|
||||||
|
{
|
||||||
|
private Series _monitoredSeries;
|
||||||
|
private Series _unmonitoredSeries;
|
||||||
|
private PagingSpec<Episode> _pagingSpec;
|
||||||
|
private List<QualitiesBelowCutoff> _qualitiesBelowCutoff;
|
||||||
|
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
var qualityProfile = new QualityProfile
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Cutoff = Quality.WEBDL480p,
|
||||||
|
Items = new List<QualityProfileItem>
|
||||||
|
{
|
||||||
|
new QualityProfileItem { Allowed = true, Quality = Quality.SDTV },
|
||||||
|
new QualityProfileItem { Allowed = true, Quality = Quality.WEBDL480p },
|
||||||
|
new QualityProfileItem { Allowed = true, Quality = Quality.RAWHD }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_monitoredSeries = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.TvRageId = RandomNumber)
|
||||||
|
.With(s => s.Runtime = 30)
|
||||||
|
.With(s => s.Monitored = true)
|
||||||
|
.With(s => s.TitleSlug = "Title3")
|
||||||
|
.With(s => s.Id = qualityProfile.Id)
|
||||||
|
.BuildNew();
|
||||||
|
|
||||||
|
_unmonitoredSeries = Builder<Series>.CreateNew()
|
||||||
|
.With(s => s.TvdbId = RandomNumber)
|
||||||
|
.With(s => s.Runtime = 30)
|
||||||
|
.With(s => s.Monitored = false)
|
||||||
|
.With(s => s.TitleSlug = "Title2")
|
||||||
|
.With(s => s.Id = qualityProfile.Id)
|
||||||
|
.BuildNew();
|
||||||
|
|
||||||
|
_monitoredSeries.Id = Db.Insert(_monitoredSeries).Id;
|
||||||
|
_unmonitoredSeries.Id = Db.Insert(_unmonitoredSeries).Id;
|
||||||
|
|
||||||
|
_pagingSpec = new PagingSpec<Episode>
|
||||||
|
{
|
||||||
|
Page = 1,
|
||||||
|
PageSize = 10,
|
||||||
|
SortKey = "AirDate",
|
||||||
|
SortDirection = SortDirection.Ascending
|
||||||
|
};
|
||||||
|
|
||||||
|
_qualitiesBelowCutoff = new List<QualitiesBelowCutoff>
|
||||||
|
{
|
||||||
|
new QualitiesBelowCutoff(qualityProfile.Id, new[] {Quality.SDTV.Id})
|
||||||
|
};
|
||||||
|
|
||||||
|
var qualityMet = new EpisodeFile { Path = "a", Quality = new QualityModel { Quality = Quality.WEBDL480p } };
|
||||||
|
var qualityUnmet = new EpisodeFile { Path = "b", Quality = new QualityModel { Quality = Quality.SDTV } };
|
||||||
|
var qualityRawHD = new EpisodeFile { Path = "c", Quality = new QualityModel { Quality = Quality.RAWHD } };
|
||||||
|
|
||||||
|
MediaFileRepository fileRepository = Mocker.Resolve<MediaFileRepository>();
|
||||||
|
|
||||||
|
qualityMet = fileRepository.Insert(qualityMet);
|
||||||
|
qualityUnmet = fileRepository.Insert(qualityUnmet);
|
||||||
|
qualityRawHD = fileRepository.Insert(qualityRawHD);
|
||||||
|
|
||||||
|
var monitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(4)
|
||||||
|
.All()
|
||||||
|
.With(e => e.Id = 0)
|
||||||
|
.With(e => e.SeriesId = _monitoredSeries.Id)
|
||||||
|
.With(e => e.AirDateUtc = DateTime.Now.AddDays(-5))
|
||||||
|
.With(e => e.Monitored = true)
|
||||||
|
.With(e => e.EpisodeFileId = qualityUnmet.Id)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(e => e.Monitored = false)
|
||||||
|
.With(e => e.EpisodeFileId = qualityMet.Id)
|
||||||
|
.TheNext(1)
|
||||||
|
.With(e => e.EpisodeFileId = qualityRawHD.Id)
|
||||||
|
.TheLast(1)
|
||||||
|
.With(e => e.SeasonNumber = 0)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
var unmonitoredSeriesEpisodes = Builder<Episode>.CreateListOfSize(3)
|
||||||
|
.All()
|
||||||
|
.With(e => e.Id = 0)
|
||||||
|
.With(e => e.SeriesId = _unmonitoredSeries.Id)
|
||||||
|
.With(e => e.AirDateUtc = DateTime.Now.AddDays(-5))
|
||||||
|
.With(e => e.Monitored = true)
|
||||||
|
.With(e => e.EpisodeFileId = qualityUnmet.Id)
|
||||||
|
.TheFirst(1)
|
||||||
|
.With(e => e.Monitored = false)
|
||||||
|
.With(e => e.EpisodeFileId = qualityMet.Id)
|
||||||
|
.TheLast(1)
|
||||||
|
.With(e => e.SeasonNumber = 0)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
var unairedEpisodes = Builder<Episode>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.Id = 0)
|
||||||
|
.With(e => e.SeriesId = _monitoredSeries.Id)
|
||||||
|
.With(e => e.AirDateUtc = DateTime.Now.AddDays(5))
|
||||||
|
.With(e => e.Monitored = true)
|
||||||
|
.With(e => e.EpisodeFileId = qualityUnmet.Id)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
Db.InsertMany(monitoredSeriesEpisodes);
|
||||||
|
Db.InsertMany(unmonitoredSeriesEpisodes);
|
||||||
|
Db.InsertMany(unairedEpisodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenMonitoredFilterExpression()
|
||||||
|
{
|
||||||
|
_pagingSpec.FilterExpression = e => e.Monitored == true && e.Series.Monitored == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenUnmonitoredFilterExpression()
|
||||||
|
{
|
||||||
|
_pagingSpec.FilterExpression = e => e.Monitored == false || e.Series.Monitored == false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_include_episodes_where_cutoff_has_not_be_met()
|
||||||
|
{
|
||||||
|
GivenMonitoredFilterExpression();
|
||||||
|
|
||||||
|
var spec = Subject.EpisodesWhereCutoffUnmet(_pagingSpec, _qualitiesBelowCutoff, false);
|
||||||
|
|
||||||
|
spec.Records.Should().HaveCount(1);
|
||||||
|
spec.Records.Should().OnlyContain(e => e.EpisodeFile.Value.Quality.Quality == Quality.SDTV);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_only_contain_monitored_episodes()
|
||||||
|
{
|
||||||
|
GivenMonitoredFilterExpression();
|
||||||
|
|
||||||
|
var spec = Subject.EpisodesWhereCutoffUnmet(_pagingSpec, _qualitiesBelowCutoff, false);
|
||||||
|
|
||||||
|
spec.Records.Should().HaveCount(1);
|
||||||
|
spec.Records.Should().OnlyContain(e => e.Monitored);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_only_contain_episode_with_monitored_series()
|
||||||
|
{
|
||||||
|
GivenMonitoredFilterExpression();
|
||||||
|
|
||||||
|
var spec = Subject.EpisodesWhereCutoffUnmet(_pagingSpec, _qualitiesBelowCutoff, false);
|
||||||
|
|
||||||
|
spec.Records.Should().HaveCount(1);
|
||||||
|
spec.Records.Should().OnlyContain(e => e.Series.Monitored);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -72,13 +72,36 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
|
var unairedEpisodes = Builder<Episode>.CreateListOfSize(1)
|
||||||
|
.All()
|
||||||
|
.With(e => e.Id = 0)
|
||||||
|
.With(e => e.SeriesId = _monitoredSeries.Id)
|
||||||
|
.With(e => e.EpisodeFileId = 0)
|
||||||
|
.With(e => e.AirDateUtc = DateTime.Now.AddDays(5))
|
||||||
|
.With(e => e.Monitored = true)
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
|
||||||
Db.InsertMany(monitoredSeriesEpisodes);
|
Db.InsertMany(monitoredSeriesEpisodes);
|
||||||
Db.InsertMany(unmonitoredSeriesEpisodes);
|
Db.InsertMany(unmonitoredSeriesEpisodes);
|
||||||
|
Db.InsertMany(unairedEpisodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenMonitoredFilterExpression()
|
||||||
|
{
|
||||||
|
_pagingSpec.FilterExpression = e => e.Monitored == true && e.Series.Monitored == true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GivenUnmonitoredFilterExpression()
|
||||||
|
{
|
||||||
|
_pagingSpec.FilterExpression = e => e.Monitored == false || e.Series.Monitored == false;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_get_monitored_episodes()
|
public void should_get_monitored_episodes()
|
||||||
{
|
{
|
||||||
|
GivenMonitoredFilterExpression();
|
||||||
|
|
||||||
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
||||||
|
|
||||||
episodes.Records.Should().HaveCount(1);
|
episodes.Records.Should().HaveCount(1);
|
||||||
|
@ -96,6 +119,8 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_include_unmonitored_episodes()
|
public void should_not_include_unmonitored_episodes()
|
||||||
{
|
{
|
||||||
|
GivenMonitoredFilterExpression();
|
||||||
|
|
||||||
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
||||||
|
|
||||||
episodes.Records.Should().NotContain(e => e.Monitored == false);
|
episodes.Records.Should().NotContain(e => e.Monitored == false);
|
||||||
|
@ -104,17 +129,19 @@ namespace NzbDrone.Core.Test.TvTests.EpisodeRepositoryTests
|
||||||
[Test]
|
[Test]
|
||||||
public void should_not_contain_unmonitored_series()
|
public void should_not_contain_unmonitored_series()
|
||||||
{
|
{
|
||||||
|
GivenMonitoredFilterExpression();
|
||||||
|
|
||||||
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
||||||
|
|
||||||
episodes.Records.Should().NotContain(e => e.SeriesId == _unmonitoredSeries.Id);
|
episodes.Records.Should().NotContain(e => e.SeriesId == _unmonitoredSeries.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void should_have_count_of_one()
|
public void should_not_return_unaired()
|
||||||
{
|
{
|
||||||
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
var episodes = Subject.EpisodesWithoutFiles(_pagingSpec, false);
|
||||||
|
|
||||||
episodes.TotalRecords.Should().Be(1);
|
episodes.TotalRecords.Should().Be(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -512,6 +512,7 @@
|
||||||
<Compile Include="Parser\Parser.cs" />
|
<Compile Include="Parser\Parser.cs" />
|
||||||
<Compile Include="Parser\ParsingService.cs" />
|
<Compile Include="Parser\ParsingService.cs" />
|
||||||
<Compile Include="Parser\QualityParser.cs" />
|
<Compile Include="Parser\QualityParser.cs" />
|
||||||
|
<Compile Include="Qualities\QualitiesBelowCutoff.cs" />
|
||||||
<Compile Include="Qualities\QualityModelComparer.cs" />
|
<Compile Include="Qualities\QualityModelComparer.cs" />
|
||||||
<Compile Include="Qualities\QualityProfileItem.cs" />
|
<Compile Include="Qualities\QualityProfileItem.cs" />
|
||||||
<Compile Include="Rest\JsonNetSerializer.cs" />
|
<Compile Include="Rest\JsonNetSerializer.cs" />
|
||||||
|
@ -536,6 +537,7 @@
|
||||||
<Compile Include="ThingiProvider\ProviderRepository.cs" />
|
<Compile Include="ThingiProvider\ProviderRepository.cs" />
|
||||||
<Compile Include="ThingiProvider\ProviderFactory.cs" />
|
<Compile Include="ThingiProvider\ProviderFactory.cs" />
|
||||||
<Compile Include="Tv\Actor.cs" />
|
<Compile Include="Tv\Actor.cs" />
|
||||||
|
<Compile Include="Tv\EpisodeCutoffService.cs" />
|
||||||
<Compile Include="Tv\EpisodeService.cs" />
|
<Compile Include="Tv\EpisodeService.cs" />
|
||||||
<Compile Include="Tv\Events\SeriesEditedEvent.cs" />
|
<Compile Include="Tv\Events\SeriesEditedEvent.cs" />
|
||||||
<Compile Include="Tv\Events\SeriesRefreshStartingEvent.cs" />
|
<Compile Include="Tv\Events\SeriesRefreshStartingEvent.cs" />
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Qualities
|
||||||
|
{
|
||||||
|
public class QualitiesBelowCutoff
|
||||||
|
{
|
||||||
|
public Int32 ProfileId { get; set; }
|
||||||
|
public IEnumerable<Int32> QualityIds { get; set; }
|
||||||
|
|
||||||
|
public QualitiesBelowCutoff(int profileId, IEnumerable<int> qualityIds)
|
||||||
|
{
|
||||||
|
ProfileId = profileId;
|
||||||
|
QualityIds = qualityIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NLog;
|
||||||
|
using NzbDrone.Core.Datastore;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Tv
|
||||||
|
{
|
||||||
|
public interface IEpisodeCutoffService
|
||||||
|
{
|
||||||
|
PagingSpec<Episode> EpisodesWhereCutoffUnmet(PagingSpec<Episode> pagingSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class EpisodeCutoffService : IEpisodeCutoffService
|
||||||
|
{
|
||||||
|
private readonly IEpisodeRepository _episodeRepository;
|
||||||
|
private readonly IQualityProfileService _qualityProfileService;
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
public EpisodeCutoffService(IEpisodeRepository episodeRepository, IQualityProfileService qualityProfileService, Logger logger)
|
||||||
|
{
|
||||||
|
_episodeRepository = episodeRepository;
|
||||||
|
_qualityProfileService = qualityProfileService;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagingSpec<Episode> EpisodesWhereCutoffUnmet(PagingSpec<Episode> pagingSpec)
|
||||||
|
{
|
||||||
|
var qualitiesBelowCutoff = new List<QualitiesBelowCutoff>();
|
||||||
|
var qualityProfiles = _qualityProfileService.All();
|
||||||
|
|
||||||
|
//Get all items less than the cutoff
|
||||||
|
foreach (var qualityProfile in qualityProfiles)
|
||||||
|
{
|
||||||
|
var cutoffIndex = qualityProfile.Items.FindIndex(v => v.Quality == qualityProfile.Cutoff);
|
||||||
|
var belowCutoff = qualityProfile.Items.Take(cutoffIndex).ToList();
|
||||||
|
|
||||||
|
if (belowCutoff.Any())
|
||||||
|
{
|
||||||
|
qualitiesBelowCutoff.Add(new QualitiesBelowCutoff(qualityProfile.Id, belowCutoff.Select(i => i.Quality.Id)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _episodeRepository.EpisodesWhereCutoffUnmet(pagingSpec, qualitiesBelowCutoff, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,7 +4,8 @@ using System.Linq;
|
||||||
using Marr.Data.QGen;
|
using Marr.Data.QGen;
|
||||||
using NzbDrone.Core.Datastore;
|
using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
|
using NzbDrone.Core.MediaFiles;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Tv
|
namespace NzbDrone.Core.Tv
|
||||||
{
|
{
|
||||||
|
@ -18,6 +19,7 @@ namespace NzbDrone.Core.Tv
|
||||||
List<Episode> GetEpisodes(int seriesId, int seasonNumber);
|
List<Episode> GetEpisodes(int seriesId, int seasonNumber);
|
||||||
List<Episode> GetEpisodeByFileId(int fileId);
|
List<Episode> GetEpisodeByFileId(int fileId);
|
||||||
PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec, bool includeSpecials);
|
PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec, bool includeSpecials);
|
||||||
|
PagingSpec<Episode> EpisodesWhereCutoffUnmet(PagingSpec<Episode> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff, bool includeSpecials);
|
||||||
Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
Episode FindEpisodeBySceneNumbering(int seriesId, int seasonNumber, int episodeNumber);
|
||||||
List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate);
|
List<Episode> EpisodesBetweenDates(DateTime startDate, DateTime endDate);
|
||||||
void SetMonitoredFlat(Episode episode, bool monitored);
|
void SetMonitoredFlat(Episode episode, bool monitored);
|
||||||
|
@ -91,8 +93,24 @@ namespace NzbDrone.Core.Tv
|
||||||
startingSeasonNumber = 0;
|
startingSeasonNumber = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pagingSpec.Records = GetEpisodesWithoutFilesQuery(pagingSpec, currentTime, startingSeasonNumber).ToList();
|
pagingSpec.TotalRecords = GetMissingEpisodesQuery(pagingSpec, currentTime, startingSeasonNumber).GetRowCount();
|
||||||
pagingSpec.TotalRecords = GetEpisodesWithoutFilesQuery(pagingSpec, currentTime, startingSeasonNumber).GetRowCount();
|
pagingSpec.Records = GetMissingEpisodesQuery(pagingSpec, currentTime, startingSeasonNumber).ToList();
|
||||||
|
|
||||||
|
return pagingSpec;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PagingSpec<Episode> EpisodesWhereCutoffUnmet(PagingSpec<Episode> pagingSpec, List<QualitiesBelowCutoff> qualitiesBelowCutoff, bool includeSpecials)
|
||||||
|
{
|
||||||
|
var currentTime = DateTime.UtcNow;
|
||||||
|
var startingSeasonNumber = 1;
|
||||||
|
|
||||||
|
if (includeSpecials)
|
||||||
|
{
|
||||||
|
startingSeasonNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pagingSpec.TotalRecords = EpisodesWhereCutoffUnmetQuery(pagingSpec, currentTime, qualitiesBelowCutoff, startingSeasonNumber).GetRowCount();
|
||||||
|
pagingSpec.Records = EpisodesWhereCutoffUnmetQuery(pagingSpec, currentTime, qualitiesBelowCutoff, startingSeasonNumber).ToList();
|
||||||
|
|
||||||
return pagingSpec;
|
return pagingSpec;
|
||||||
}
|
}
|
||||||
|
@ -142,17 +160,45 @@ namespace NzbDrone.Core.Tv
|
||||||
SetFields(new Episode { Id = episodeId, EpisodeFileId = fileId }, episode => episode.EpisodeFileId);
|
SetFields(new Episode { Id = episodeId, EpisodeFileId = fileId }, episode => episode.EpisodeFileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SortBuilder<Episode> GetEpisodesWithoutFilesQuery(PagingSpec<Episode> pagingSpec, DateTime currentTime, int startingSeasonNumber)
|
private SortBuilder<Episode> GetMissingEpisodesQuery(PagingSpec<Episode> pagingSpec, DateTime currentTime, int startingSeasonNumber)
|
||||||
{
|
{
|
||||||
return Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
|
return Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
|
||||||
.Where(e => e.EpisodeFileId == 0)
|
.Where(pagingSpec.FilterExpression)
|
||||||
.AndWhere(e => e.SeasonNumber >= startingSeasonNumber)
|
.AndWhere(e => e.EpisodeFileId == 0)
|
||||||
.AndWhere(e => e.AirDateUtc <= currentTime)
|
.AndWhere(e => e.SeasonNumber >= startingSeasonNumber)
|
||||||
.AndWhere(e => e.Monitored)
|
.AndWhere(e => e.AirDateUtc <= currentTime)
|
||||||
.AndWhere(e => e.Series.Monitored)
|
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||||
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
.Skip(pagingSpec.PagingOffset())
|
||||||
.Skip(pagingSpec.PagingOffset())
|
.Take(pagingSpec.PageSize);
|
||||||
.Take(pagingSpec.PageSize);
|
}
|
||||||
|
|
||||||
|
private SortBuilder<Episode> EpisodesWhereCutoffUnmetQuery(PagingSpec<Episode> pagingSpec, DateTime currentTime, List<QualitiesBelowCutoff> qualitiesBelowCutoff, int startingSeasonNumber)
|
||||||
|
{
|
||||||
|
return Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
|
||||||
|
.Join<Episode, EpisodeFile>(JoinType.Left, e => e.EpisodeFile, (e, s) => e.EpisodeFileId == s.Id)
|
||||||
|
.Where(pagingSpec.FilterExpression)
|
||||||
|
.AndWhere(e => e.EpisodeFileId != 0)
|
||||||
|
.AndWhere(e => e.SeasonNumber >= startingSeasonNumber)
|
||||||
|
.AndWhere(e => e.AirDateUtc <= currentTime)
|
||||||
|
.AndWhere(BuildQualityCutoffWhereClause(qualitiesBelowCutoff))
|
||||||
|
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||||
|
.Skip(pagingSpec.PagingOffset())
|
||||||
|
.Take(pagingSpec.PageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string BuildQualityCutoffWhereClause(List<QualitiesBelowCutoff> qualitiesBelowCutoff)
|
||||||
|
{
|
||||||
|
var clauses = new List<String>();
|
||||||
|
|
||||||
|
foreach (var profile in qualitiesBelowCutoff)
|
||||||
|
{
|
||||||
|
foreach (var belowCutoff in profile.QualityIds)
|
||||||
|
{
|
||||||
|
clauses.Add(String.Format("([t1].[QualityProfileId] = {0} AND [t2].[Quality] LIKE '%_quality_: {1},%')", profile.ProfileId, belowCutoff));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return String.Format("({0})", String.Join(" OR ", clauses));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ using NzbDrone.Core.Datastore;
|
||||||
using NzbDrone.Core.MediaFiles.Events;
|
using NzbDrone.Core.MediaFiles.Events;
|
||||||
using NzbDrone.Core.Messaging.Events;
|
using NzbDrone.Core.Messaging.Events;
|
||||||
using NzbDrone.Core.Tv.Events;
|
using NzbDrone.Core.Tv.Events;
|
||||||
|
using NzbDrone.Core.Qualities;
|
||||||
|
|
||||||
namespace NzbDrone.Core.Tv
|
namespace NzbDrone.Core.Tv
|
||||||
{
|
{
|
||||||
|
@ -40,12 +41,14 @@ namespace NzbDrone.Core.Tv
|
||||||
{
|
{
|
||||||
|
|
||||||
private readonly IEpisodeRepository _episodeRepository;
|
private readonly IEpisodeRepository _episodeRepository;
|
||||||
|
private readonly IQualityProfileRepository _qualityProfileRepository;
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
public EpisodeService(IEpisodeRepository episodeRepository, IConfigService configService, Logger logger)
|
public EpisodeService(IEpisodeRepository episodeRepository, IQualityProfileRepository qualityProfileRepository, IConfigService configService, Logger logger)
|
||||||
{
|
{
|
||||||
_episodeRepository = episodeRepository;
|
_episodeRepository = episodeRepository;
|
||||||
|
_qualityProfileRepository = qualityProfileRepository;
|
||||||
_configService = configService;
|
_configService = configService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<mapping url="http://localhost:8989/Upcoming" local-file="$PROJECT_DIR$/Upcoming" />
|
<mapping url="http://localhost:8989/Upcoming" local-file="$PROJECT_DIR$/Upcoming" />
|
||||||
<mapping url="http://localhost:8989/app.js" local-file="$PROJECT_DIR$/app.js" />
|
<mapping url="http://localhost:8989/app.js" local-file="$PROJECT_DIR$/app.js" />
|
||||||
<mapping url="http://localhost:8989/Mixins" local-file="$PROJECT_DIR$/Mixins" />
|
<mapping url="http://localhost:8989/Mixins" local-file="$PROJECT_DIR$/Mixins" />
|
||||||
<mapping url="http://localhost:8989/Missing" local-file="$PROJECT_DIR$/Missing" />
|
<mapping url="http://localhost:8989/Wanted" local-file="$PROJECT_DIR$/Wanted" />
|
||||||
<mapping url="http://localhost:8989/Quality" local-file="$PROJECT_DIR$/Quality" />
|
<mapping url="http://localhost:8989/Quality" local-file="$PROJECT_DIR$/Quality" />
|
||||||
<mapping url="http://localhost:8989/Config.js" local-file="$PROJECT_DIR$/Config.js" />
|
<mapping url="http://localhost:8989/Config.js" local-file="$PROJECT_DIR$/Config.js" />
|
||||||
<mapping url="http://localhost:8989/Shared" local-file="$PROJECT_DIR$/Shared" />
|
<mapping url="http://localhost:8989/Shared" local-file="$PROJECT_DIR$/Shared" />
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<mapping url="http://localhost:8989/Upcoming" local-file="$PROJECT_DIR$/Upcoming" />
|
<mapping url="http://localhost:8989/Upcoming" local-file="$PROJECT_DIR$/Upcoming" />
|
||||||
<mapping url="http://localhost:8989/app.js" local-file="$PROJECT_DIR$/app.js" />
|
<mapping url="http://localhost:8989/app.js" local-file="$PROJECT_DIR$/app.js" />
|
||||||
<mapping url="http://localhost:8989/Mixins" local-file="$PROJECT_DIR$/Mixins" />
|
<mapping url="http://localhost:8989/Mixins" local-file="$PROJECT_DIR$/Mixins" />
|
||||||
<mapping url="http://localhost:8989/Missing" local-file="$PROJECT_DIR$/Missing" />
|
<mapping url="http://localhost:8989/Wanted" local-file="$PROJECT_DIR$/Wanted" />
|
||||||
<mapping url="http://localhost:8989/Config.js" local-file="$PROJECT_DIR$/Config.js" />
|
<mapping url="http://localhost:8989/Config.js" local-file="$PROJECT_DIR$/Config.js" />
|
||||||
<mapping url="http://localhost:8989/Quality" local-file="$PROJECT_DIR$/Quality" />
|
<mapping url="http://localhost:8989/Quality" local-file="$PROJECT_DIR$/Quality" />
|
||||||
<mapping url="http://localhost:8989/AddSeries" local-file="$PROJECT_DIR$/AddSeries" />
|
<mapping url="http://localhost:8989/AddSeries" local-file="$PROJECT_DIR$/AddSeries" />
|
||||||
|
|
|
@ -3,11 +3,12 @@
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
'reqres',
|
'reqres',
|
||||||
|
'backbone',
|
||||||
'Cells/NzbDroneCell',
|
'Cells/NzbDroneCell',
|
||||||
'History/Queue/QueueCollection',
|
'History/Queue/QueueCollection',
|
||||||
'moment',
|
'moment',
|
||||||
'Shared/FormatHelpers'
|
'Shared/FormatHelpers'
|
||||||
], function (reqres, NzbDroneCell, QueueCollection, Moment, FormatHelpers) {
|
], function (reqres, Backbone, NzbDroneCell, QueueCollection, Moment, FormatHelpers) {
|
||||||
return NzbDroneCell.extend({
|
return NzbDroneCell.extend({
|
||||||
|
|
||||||
className: 'episode-status-cell',
|
className: 'episode-status-cell',
|
||||||
|
@ -31,8 +32,16 @@ define(
|
||||||
var hasAired = Moment(this.model.get('airDateUtc')).isBefore(Moment());
|
var hasAired = Moment(this.model.get('airDateUtc')).isBefore(Moment());
|
||||||
var hasFile = this.model.get('hasFile');
|
var hasFile = this.model.get('hasFile');
|
||||||
|
|
||||||
if (hasFile && reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
|
if (hasFile) {
|
||||||
var episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
|
var episodeFile;
|
||||||
|
|
||||||
|
if (reqres.hasHandler(reqres.Requests.GetEpisodeFileById)) {
|
||||||
|
episodeFile = reqres.request(reqres.Requests.GetEpisodeFileById, this.model.get('episodeFileId'));
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
episodeFile = new Backbone.Model(this.model.get('episodeFile'));
|
||||||
|
}
|
||||||
|
|
||||||
this.listenTo(episodeFile, 'change', this._refresh);
|
this.listenTo(episodeFile, 'change', this._refresh);
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ define(
|
||||||
'History/HistoryLayout',
|
'History/HistoryLayout',
|
||||||
'Settings/SettingsLayout',
|
'Settings/SettingsLayout',
|
||||||
'AddSeries/AddSeriesLayout',
|
'AddSeries/AddSeriesLayout',
|
||||||
'Missing/MissingLayout',
|
'Wanted/WantedLayout',
|
||||||
'Calendar/CalendarLayout',
|
'Calendar/CalendarLayout',
|
||||||
'Release/ReleaseLayout',
|
'Release/ReleaseLayout',
|
||||||
'System/SystemLayout',
|
'System/SystemLayout',
|
||||||
|
@ -20,7 +20,7 @@ define(
|
||||||
HistoryLayout,
|
HistoryLayout,
|
||||||
SettingsLayout,
|
SettingsLayout,
|
||||||
AddSeriesLayout,
|
AddSeriesLayout,
|
||||||
MissingLayout,
|
WantedLayout,
|
||||||
CalendarLayout,
|
CalendarLayout,
|
||||||
ReleaseLayout,
|
ReleaseLayout,
|
||||||
SystemLayout,
|
SystemLayout,
|
||||||
|
@ -44,10 +44,10 @@ define(
|
||||||
this.showMainRegion(new SettingsLayout({ action: action }));
|
this.showMainRegion(new SettingsLayout({ action: action }));
|
||||||
},
|
},
|
||||||
|
|
||||||
missing: function () {
|
wanted: function (action) {
|
||||||
this.setTitle('Missing');
|
this.setTitle('Wanted');
|
||||||
|
|
||||||
this.showMainRegion(new MissingLayout());
|
this.showMainRegion(new WantedLayout({ action: action }));
|
||||||
},
|
},
|
||||||
|
|
||||||
history: function (action) {
|
history: function (action) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ define(
|
||||||
};
|
};
|
||||||
|
|
||||||
this.prototype.setFilterMode = function(mode, options) {
|
this.prototype.setFilterMode = function(mode, options) {
|
||||||
this.setFilter(this.filterModes[mode], options);
|
return this.setFilter(this.filterModes[mode], options);
|
||||||
};
|
};
|
||||||
|
|
||||||
var originalMakeFullCollection = this.prototype._makeFullCollection;
|
var originalMakeFullCollection = this.prototype._makeFullCollection;
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{UrlBase}}/missing">
|
<a href="{{UrlBase}}/wanted">
|
||||||
<i class="icon-warning-sign"></i>
|
<i class="icon-warning-sign"></i>
|
||||||
<br>
|
<br>
|
||||||
Missing
|
Wanted
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|
|
@ -14,7 +14,8 @@ define(
|
||||||
'calendar' : 'calendar',
|
'calendar' : 'calendar',
|
||||||
'settings' : 'settings',
|
'settings' : 'settings',
|
||||||
'settings/:action(/:query)' : 'settings',
|
'settings/:action(/:query)' : 'settings',
|
||||||
'missing' : 'missing',
|
'wanted' : 'wanted',
|
||||||
|
'wanted/:action' : 'wanted',
|
||||||
'history' : 'history',
|
'history' : 'history',
|
||||||
'history/:action' : 'history',
|
'history/:action' : 'history',
|
||||||
'rss' : 'rss',
|
'rss' : 'rss',
|
||||||
|
|
|
@ -16,13 +16,18 @@ define(
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
this.menu = options.menu;
|
this.menu = options.menu;
|
||||||
|
|
||||||
if (this.menu.storeState) {
|
this.setActive();
|
||||||
this.setActive();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
setActive: function () {
|
setActive: function () {
|
||||||
var storedKey = Config.getValue(this.menu.menuKey, this.menu.defaultAction);
|
var storedKey = this.menu.defaultAction;
|
||||||
|
|
||||||
|
if (this.menu.storeState) {
|
||||||
|
storedKey = Config.getValue(this.menu.menuKey, storedKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!storedKey)
|
||||||
|
return;
|
||||||
|
|
||||||
this.collection.each(function (model) {
|
this.collection.each(function (model) {
|
||||||
if (model.get('key').toLocaleLowerCase() === storedKey.toLowerCase()) {
|
if (model.get('key').toLocaleLowerCase() === storedKey.toLowerCase()) {
|
||||||
|
|
|
@ -1,19 +1,21 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
define(
|
define(
|
||||||
[
|
[
|
||||||
|
'underscore',
|
||||||
'Series/EpisodeModel',
|
'Series/EpisodeModel',
|
||||||
'backbone.pageable',
|
'backbone.pageable',
|
||||||
|
'Mixins/AsFilteredCollection',
|
||||||
'Mixins/AsPersistedStateCollection'
|
'Mixins/AsPersistedStateCollection'
|
||||||
], function (EpisodeModel, PagableCollection, AsPersistedStateCollection) {
|
], function (_, EpisodeModel, PagableCollection, AsFilteredCollection, AsPersistedStateCollection) {
|
||||||
var collection = PagableCollection.extend({
|
var collection = PagableCollection.extend({
|
||||||
url : window.NzbDrone.ApiRoot + '/missing',
|
url : window.NzbDrone.ApiRoot + '/wanted/cutoff',
|
||||||
model: EpisodeModel,
|
model: EpisodeModel,
|
||||||
tableName: 'missing',
|
tableName: 'wanted.cutoff',
|
||||||
|
|
||||||
state: {
|
state: {
|
||||||
pageSize: 15,
|
pageSize : 15,
|
||||||
sortKey : 'airDateUtc',
|
sortKey : 'airDateUtc',
|
||||||
order : 1
|
order : 1
|
||||||
},
|
},
|
||||||
|
|
||||||
queryParams: {
|
queryParams: {
|
||||||
|
@ -28,6 +30,12 @@ define(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Filter Modes
|
||||||
|
filterModes: {
|
||||||
|
'monitored' : ['monitored', 'true'],
|
||||||
|
'unmonitored' : ['monitored', 'false'],
|
||||||
|
},
|
||||||
|
|
||||||
parseState: function (resp) {
|
parseState: function (resp) {
|
||||||
return {totalRecords: resp.totalRecords};
|
return {totalRecords: resp.totalRecords};
|
||||||
},
|
},
|
||||||
|
@ -41,5 +49,6 @@ define(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
collection = AsFilteredCollection.call(collection);
|
||||||
return AsPersistedStateCollection.call(collection);
|
return AsPersistedStateCollection.call(collection);
|
||||||
});
|
});
|
|
@ -0,0 +1,206 @@
|
||||||
|
'use strict';
|
||||||
|
define(
|
||||||
|
[
|
||||||
|
'underscore',
|
||||||
|
'marionette',
|
||||||
|
'backgrid',
|
||||||
|
'Wanted/Cutoff/CutoffUnmetCollection',
|
||||||
|
'Cells/SeriesTitleCell',
|
||||||
|
'Cells/EpisodeNumberCell',
|
||||||
|
'Cells/EpisodeTitleCell',
|
||||||
|
'Cells/RelativeDateCell',
|
||||||
|
'Cells/EpisodeStatusCell',
|
||||||
|
'Shared/Grid/Pager',
|
||||||
|
'Shared/Toolbar/ToolbarLayout',
|
||||||
|
'Shared/LoadingView',
|
||||||
|
'Shared/Messenger',
|
||||||
|
'Commands/CommandController',
|
||||||
|
'backgrid.selectall'
|
||||||
|
], function (_,
|
||||||
|
Marionette,
|
||||||
|
Backgrid,
|
||||||
|
CutoffUnmetCollection,
|
||||||
|
SeriesTitleCell,
|
||||||
|
EpisodeNumberCell,
|
||||||
|
EpisodeTitleCell,
|
||||||
|
RelativeDateCell,
|
||||||
|
EpisodeStatusCell,
|
||||||
|
GridPager,
|
||||||
|
ToolbarLayout,
|
||||||
|
LoadingView,
|
||||||
|
Messenger,
|
||||||
|
CommandController) {
|
||||||
|
return Marionette.Layout.extend({
|
||||||
|
template: 'Wanted/Cutoff/CutoffUnmetLayoutTemplate',
|
||||||
|
|
||||||
|
regions: {
|
||||||
|
missing: '#x-missing',
|
||||||
|
toolbar: '#x-toolbar',
|
||||||
|
pager : '#x-pager'
|
||||||
|
},
|
||||||
|
|
||||||
|
ui: {
|
||||||
|
searchSelectedButton: '.btn i.icon-search'
|
||||||
|
},
|
||||||
|
|
||||||
|
columns:
|
||||||
|
[
|
||||||
|
{
|
||||||
|
name : '',
|
||||||
|
cell : 'select-row',
|
||||||
|
headerCell: 'select-all',
|
||||||
|
sortable : false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'series',
|
||||||
|
label : 'Series Title',
|
||||||
|
sortable : false,
|
||||||
|
cell : SeriesTitleCell
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'this',
|
||||||
|
label : 'Episode',
|
||||||
|
sortable : false,
|
||||||
|
cell : EpisodeNumberCell
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'this',
|
||||||
|
label : 'Episode Title',
|
||||||
|
sortable : false,
|
||||||
|
cell : EpisodeTitleCell,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'airDateUtc',
|
||||||
|
label : 'Air Date',
|
||||||
|
cell : RelativeDateCell
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'status',
|
||||||
|
label : 'Status',
|
||||||
|
cell : EpisodeStatusCell,
|
||||||
|
sortable: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
this.collection = new CutoffUnmetCollection();
|
||||||
|
|
||||||
|
this.listenTo(this.collection, 'sync', this._showTable);
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow: function () {
|
||||||
|
this.missing.show(new LoadingView());
|
||||||
|
this._showToolbar();
|
||||||
|
this.collection.fetch();
|
||||||
|
},
|
||||||
|
|
||||||
|
_showTable: function () {
|
||||||
|
this.missingGrid = new Backgrid.Grid({
|
||||||
|
columns : this.columns,
|
||||||
|
collection: this.collection,
|
||||||
|
className : 'table table-hover'
|
||||||
|
});
|
||||||
|
|
||||||
|
this.missing.show(this.missingGrid);
|
||||||
|
|
||||||
|
this.pager.show(new GridPager({
|
||||||
|
columns : this.columns,
|
||||||
|
collection: this.collection
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
_showToolbar: function () {
|
||||||
|
var leftSideButtons = {
|
||||||
|
type : 'default',
|
||||||
|
storeState: false,
|
||||||
|
items :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
title: 'Search Selected',
|
||||||
|
icon : 'icon-search',
|
||||||
|
callback: this._searchSelected,
|
||||||
|
ownerContext: this
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Season Pass',
|
||||||
|
icon : 'icon-bookmark',
|
||||||
|
route: 'seasonpass'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
var filterOptions = {
|
||||||
|
type : 'radio',
|
||||||
|
storeState : false,
|
||||||
|
menuKey : 'wanted.filterMode',
|
||||||
|
defaultAction : 'monitored',
|
||||||
|
items :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key : 'monitored',
|
||||||
|
title : '',
|
||||||
|
tooltip : 'Monitored Only',
|
||||||
|
icon : 'icon-nd-monitored',
|
||||||
|
callback : this._setFilter
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key : 'unmonitored',
|
||||||
|
title : '',
|
||||||
|
tooltip : 'Unmonitored Only',
|
||||||
|
icon : 'icon-nd-unmonitored',
|
||||||
|
callback : this._setFilter
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
this.toolbar.show(new ToolbarLayout({
|
||||||
|
left :
|
||||||
|
[
|
||||||
|
leftSideButtons
|
||||||
|
],
|
||||||
|
right :
|
||||||
|
[
|
||||||
|
filterOptions
|
||||||
|
],
|
||||||
|
context: this
|
||||||
|
}));
|
||||||
|
|
||||||
|
CommandController.bindToCommand({
|
||||||
|
element: this.$('.x-toolbar-left-1 .btn i.icon-search'),
|
||||||
|
command: {
|
||||||
|
name: 'episodeSearch'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
_setFilter: function(buttonContext) {
|
||||||
|
var mode = buttonContext.model.get('key');
|
||||||
|
|
||||||
|
this.collection.state.currentPage = 1;
|
||||||
|
var promise = this.collection.setFilterMode(mode);
|
||||||
|
|
||||||
|
if (buttonContext)
|
||||||
|
buttonContext.ui.icon.spinForPromise(promise);
|
||||||
|
},
|
||||||
|
|
||||||
|
_searchSelected: function () {
|
||||||
|
var selected = this.missingGrid.getSelectedModels();
|
||||||
|
|
||||||
|
if (selected.length === 0) {
|
||||||
|
Messenger.show({
|
||||||
|
type: 'error',
|
||||||
|
message: 'No episodes selected'
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ids = _.pluck(selected, 'id');
|
||||||
|
|
||||||
|
CommandController.Execute('episodeSearch', {
|
||||||
|
name : 'episodeSearch',
|
||||||
|
episodeIds: ids
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,54 @@
|
||||||
|
'use strict';
|
||||||
|
define(
|
||||||
|
[
|
||||||
|
'underscore',
|
||||||
|
'Series/EpisodeModel',
|
||||||
|
'backbone.pageable',
|
||||||
|
'Mixins/AsFilteredCollection',
|
||||||
|
'Mixins/AsPersistedStateCollection'
|
||||||
|
], function (_, EpisodeModel, PagableCollection, AsFilteredCollection, AsPersistedStateCollection) {
|
||||||
|
var collection = PagableCollection.extend({
|
||||||
|
url : window.NzbDrone.ApiRoot + '/wanted/missing',
|
||||||
|
model: EpisodeModel,
|
||||||
|
tableName: 'wanted.missing',
|
||||||
|
|
||||||
|
state: {
|
||||||
|
pageSize : 15,
|
||||||
|
sortKey : 'airDateUtc',
|
||||||
|
order : 1
|
||||||
|
},
|
||||||
|
|
||||||
|
queryParams: {
|
||||||
|
totalPages : null,
|
||||||
|
totalRecords: null,
|
||||||
|
pageSize : 'pageSize',
|
||||||
|
sortKey : 'sortKey',
|
||||||
|
order : 'sortDir',
|
||||||
|
directions : {
|
||||||
|
'-1': 'asc',
|
||||||
|
'1' : 'desc'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Filter Modes
|
||||||
|
filterModes: {
|
||||||
|
'monitored' : ['monitored', 'true'],
|
||||||
|
'unmonitored' : ['monitored', 'false'],
|
||||||
|
},
|
||||||
|
|
||||||
|
parseState: function (resp) {
|
||||||
|
return {totalRecords: resp.totalRecords};
|
||||||
|
},
|
||||||
|
|
||||||
|
parseRecords: function (resp) {
|
||||||
|
if (resp) {
|
||||||
|
return resp.records;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
collection = AsFilteredCollection.call(collection);
|
||||||
|
return AsPersistedStateCollection.call(collection);
|
||||||
|
});
|
|
@ -4,11 +4,12 @@ define(
|
||||||
'underscore',
|
'underscore',
|
||||||
'marionette',
|
'marionette',
|
||||||
'backgrid',
|
'backgrid',
|
||||||
'Missing/MissingCollection',
|
'Wanted/Missing/MissingCollection',
|
||||||
'Cells/SeriesTitleCell',
|
'Cells/SeriesTitleCell',
|
||||||
'Cells/EpisodeNumberCell',
|
'Cells/EpisodeNumberCell',
|
||||||
'Cells/EpisodeTitleCell',
|
'Cells/EpisodeTitleCell',
|
||||||
'Cells/RelativeDateCell',
|
'Cells/RelativeDateCell',
|
||||||
|
'Cells/EpisodeStatusCell',
|
||||||
'Shared/Grid/Pager',
|
'Shared/Grid/Pager',
|
||||||
'Shared/Toolbar/ToolbarLayout',
|
'Shared/Toolbar/ToolbarLayout',
|
||||||
'Shared/LoadingView',
|
'Shared/LoadingView',
|
||||||
|
@ -23,13 +24,14 @@ define(
|
||||||
EpisodeNumberCell,
|
EpisodeNumberCell,
|
||||||
EpisodeTitleCell,
|
EpisodeTitleCell,
|
||||||
RelativeDateCell,
|
RelativeDateCell,
|
||||||
|
EpisodeStatusCell,
|
||||||
GridPager,
|
GridPager,
|
||||||
ToolbarLayout,
|
ToolbarLayout,
|
||||||
LoadingView,
|
LoadingView,
|
||||||
Messenger,
|
Messenger,
|
||||||
CommandController) {
|
CommandController) {
|
||||||
return Marionette.Layout.extend({
|
return Marionette.Layout.extend({
|
||||||
template: 'Missing/MissingLayoutTemplate',
|
template: 'Wanted/Missing/MissingLayoutTemplate',
|
||||||
|
|
||||||
regions: {
|
regions: {
|
||||||
missing: '#x-missing',
|
missing: '#x-missing',
|
||||||
|
@ -52,25 +54,31 @@ define(
|
||||||
{
|
{
|
||||||
name : 'series',
|
name : 'series',
|
||||||
label : 'Series Title',
|
label : 'Series Title',
|
||||||
sortable: false,
|
sortable : false,
|
||||||
cell : SeriesTitleCell
|
cell : SeriesTitleCell
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'this',
|
name : 'this',
|
||||||
label : 'Episode',
|
label : 'Episode',
|
||||||
sortable: false,
|
sortable : false,
|
||||||
cell : EpisodeNumberCell
|
cell : EpisodeNumberCell
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'this',
|
name : 'this',
|
||||||
label : 'Episode Title',
|
label : 'Episode Title',
|
||||||
sortable: false,
|
sortable : false,
|
||||||
cell : EpisodeTitleCell
|
cell : EpisodeTitleCell,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name : 'airDateUtc',
|
name : 'airDateUtc',
|
||||||
label: 'Air Date',
|
label : 'Air Date',
|
||||||
cell : RelativeDateCell
|
cell : RelativeDateCell
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name : 'status',
|
||||||
|
label : 'Status',
|
||||||
|
cell : EpisodeStatusCell,
|
||||||
|
sortable: false
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -82,8 +90,8 @@ define(
|
||||||
|
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
this.missing.show(new LoadingView());
|
this.missing.show(new LoadingView());
|
||||||
this.collection.fetch();
|
|
||||||
this._showToolbar();
|
this._showToolbar();
|
||||||
|
this.collection.fetch();
|
||||||
},
|
},
|
||||||
|
|
||||||
_showTable: function () {
|
_showTable: function () {
|
||||||
|
@ -121,11 +129,39 @@ define(
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var filterOptions = {
|
||||||
|
type : 'radio',
|
||||||
|
storeState : false,
|
||||||
|
menuKey : 'wanted.filterMode',
|
||||||
|
defaultAction : 'monitored',
|
||||||
|
items :
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key : 'monitored',
|
||||||
|
title : '',
|
||||||
|
tooltip : 'Monitored Only',
|
||||||
|
icon : 'icon-nd-monitored',
|
||||||
|
callback : this._setFilter
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key : 'unmonitored',
|
||||||
|
title : '',
|
||||||
|
tooltip : 'Unmonitored Only',
|
||||||
|
icon : 'icon-nd-unmonitored',
|
||||||
|
callback : this._setFilter
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
this.toolbar.show(new ToolbarLayout({
|
this.toolbar.show(new ToolbarLayout({
|
||||||
left :
|
left :
|
||||||
[
|
[
|
||||||
leftSideButtons
|
leftSideButtons
|
||||||
],
|
],
|
||||||
|
right :
|
||||||
|
[
|
||||||
|
filterOptions
|
||||||
|
],
|
||||||
context: this
|
context: this
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -137,6 +173,16 @@ define(
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setFilter: function(buttonContext) {
|
||||||
|
var mode = buttonContext.model.get('key');
|
||||||
|
|
||||||
|
this.collection.state.currentPage = 1;
|
||||||
|
var promise = this.collection.setFilterMode(mode);
|
||||||
|
|
||||||
|
if (buttonContext)
|
||||||
|
buttonContext.ui.icon.spinForPromise(promise);
|
||||||
|
},
|
||||||
|
|
||||||
_searchSelected: function () {
|
_searchSelected: function () {
|
||||||
var selected = this.missingGrid.getSelectedModels();
|
var selected = this.missingGrid.getSelectedModels();
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<div id="x-toolbar"/>
|
||||||
|
<div class="row">
|
||||||
|
<div class="span12">
|
||||||
|
<div id="x-missing"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="span12">
|
||||||
|
<div id="x-pager"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,69 @@
|
||||||
|
'use strict';
|
||||||
|
define(
|
||||||
|
[
|
||||||
|
'marionette',
|
||||||
|
'backbone',
|
||||||
|
'backgrid',
|
||||||
|
'Wanted/Missing/MissingLayout',
|
||||||
|
'Wanted/Cutoff/CutoffUnmetLayout'
|
||||||
|
], function (Marionette, Backbone, Backgrid, MissingLayout, CutoffUnmetLayout) {
|
||||||
|
return Marionette.Layout.extend({
|
||||||
|
template: 'Wanted/WantedLayoutTemplate',
|
||||||
|
|
||||||
|
regions: {
|
||||||
|
content : '#content'
|
||||||
|
//missing : '#missing',
|
||||||
|
//cutoff : '#cutoff'
|
||||||
|
},
|
||||||
|
|
||||||
|
ui: {
|
||||||
|
missingTab : '.x-missing-tab',
|
||||||
|
cutoffTab : '.x-cutoff-tab'
|
||||||
|
},
|
||||||
|
|
||||||
|
events: {
|
||||||
|
'click .x-missing-tab' : '_showMissing',
|
||||||
|
'click .x-cutoff-tab' : '_showCutoffUnmet'
|
||||||
|
},
|
||||||
|
|
||||||
|
initialize: function (options) {
|
||||||
|
if (options.action) {
|
||||||
|
this.action = options.action.toLowerCase();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
onShow: function () {
|
||||||
|
switch (this.action) {
|
||||||
|
case 'cutoff':
|
||||||
|
this._showCutoffUnmet();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this._showMissing();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_navigate: function (route) {
|
||||||
|
Backbone.history.navigate(route);
|
||||||
|
},
|
||||||
|
|
||||||
|
_showMissing: function (e) {
|
||||||
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.content.show(new MissingLayout());
|
||||||
|
this.ui.missingTab.tab('show');
|
||||||
|
this._navigate('/wanted/missing');
|
||||||
|
},
|
||||||
|
|
||||||
|
_showCutoffUnmet: function (e) {
|
||||||
|
if (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.content.show(new CutoffUnmetLayout());
|
||||||
|
this.ui.cutoffTab.tab('show');
|
||||||
|
this._navigate('/wanted/cutoff');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,10 @@
|
||||||
|
<ul class="nav nav-tabs">
|
||||||
|
<li><a href="#missing" class="x-missing-tab no-router">Missing</a></li>
|
||||||
|
<li><a href="#cutoff" class="x-cutoff-tab no-router">Cutoff Unmet</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="content"></div>
|
||||||
|
<!--<div class="tab-content">
|
||||||
|
<div class="tab-pane" id="missing"></div>
|
||||||
|
<div class="tab-pane" id="cutoff"></div>
|
||||||
|
</div>-->
|
Loading…
Reference in New Issue