small bit of work on #266

pull/470/head
tidusjar 9 years ago
parent a5257a0fbf
commit cd135d824c

@ -443,7 +443,8 @@ $(function () {
requested: result.requested,
approved: result.approved,
available: result.available,
episodes : result.episodes
episodes: result.episodes,
tvFullyAvailable: result.tvFullyAvailable
};
return context;
}

@ -50,5 +50,6 @@ namespace PlexRequests.UI.Models
public string ImdbId { get; set; }
public int SiteRating { get; set; }
public Store.EpisodesModel[] Episodes { get; set; }
public bool TvFullyAvailable { get; set; }
}
}

@ -40,7 +40,6 @@ using PlexRequests.Api.Models.Music;
using PlexRequests.Core;
using PlexRequests.Core.SettingModels;
using PlexRequests.Helpers;
using PlexRequests.Helpers.Exceptions;
using PlexRequests.Services.Interfaces;
using PlexRequests.Services.Notification;
using PlexRequests.Store;
@ -49,10 +48,9 @@ using PlexRequests.UI.Models;
using System.Threading.Tasks;
using Nancy.Extensions;
using Nancy.ModelBinding;
using Nancy.Responses;
using Newtonsoft.Json;
using PlexRequests.Api.Models.Sonarr;
using PlexRequests.Api.Models.Tv;
using PlexRequests.Core.Models;
using PlexRequests.Helpers.Analytics;
@ -289,6 +287,7 @@ namespace PlexRequests.UI.Modules
{
Analytics.TrackEventAsync(Category.Search, Action.TvShow, searchTerm, Username, CookieHelper.GetAnalyticClientId(Cookies));
var plexSettings = await PlexService.GetSettingsAsync();
var providerId = string.Empty;
var apiTv = new List<TvMazeSearch>();
await Task.Factory.StartNew(() => new TvMazeApi().Search(searchTerm)).ContinueWith((t) =>
@ -313,10 +312,12 @@ namespace PlexRequests.UI.Modules
var viewTv = new List<SearchTvShowViewModel>();
foreach (var t in apiTv)
{
var tvInfoTask = Task.Run(() => TvApi.EpisodeLookup(t.show.id));
var banner = t.show.image?.medium;
if (!string.IsNullOrEmpty(banner))
{
banner = banner.Replace("http", "https");
banner = banner.Replace("http", "https"); // Always use the Https banners
}
var viewT = new SearchTvShowViewModel
@ -334,9 +335,7 @@ namespace PlexRequests.UI.Modules
SeriesName = t.show.name,
Status = t.show.status
};
var providerId = string.Empty;
if (plexSettings.AdvancedSearch)
{
@ -349,7 +348,7 @@ namespace PlexRequests.UI.Modules
}
else if (t.show?.externals?.thetvdb != null)
{
int tvdbid = (int)t.show.externals.thetvdb;
var tvdbid = (int)t.show.externals.thetvdb;
if (dbTv.ContainsKey(tvdbid))
{
@ -365,7 +364,15 @@ namespace PlexRequests.UI.Modules
viewT.Requested = true;
}
}
var tvInfo = await tvInfoTask;
// Check if we have every episode in all seasons
var epModel = tvInfo.Select(tvIn => new Store.EpisodesModel { SeasonNumber = tvIn.season, EpisodeNumber = tvIn.number }).ToList();
var diff = viewT.Episodes.Except(epModel);
if (diff.Any())
{
viewT.TvFullyAvailable = true;
}
viewTv.Add(viewT);
}

@ -184,19 +184,23 @@
{{/if_eq}}
{{/if_eq}}
{{#if_eq type "tv"}}
<div class="dropdown">
<button id="{{id}}" class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-plus"></i> @UI.Search_Request
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a id="{{id}}" season-select="0" class="dropdownTv " href="#">@UI.Search_AllSeasons</a></li>
<li><a id="{{id}}" season-select="1" class="dropdownTv" href="#">@UI.Search_FirstSeason</a></li>
<li><a id="{{id}}" season-select="2" class="dropdownTv" href="#">@UI.Search_LatestSeason</a></li>
<li><a id="SeasonSelect" data-identifier="{{id}}" data-toggle="modal" data-target="#seasonsModal" href="#">@UI.Search_SelectSeason...</a></li>
<li><a id="EpisodeSelect" data-identifier="{{id}}" data-toggle="modal" data-target="#episodesModal" href="#">@UI.Search_SelectEpisode...</a></li>
</ul>
</div>
{{#if_eq tvFullyAvailable true}}
<button style="text-align: right" class="btn btn-success-outline disabled" disabled><i class="fa fa-check"></i> @UI.Search_Available</button>
{{else}}
<div class="dropdown">
<button id="{{id}}" class="btn btn-primary-outline dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<i class="fa fa-plus"></i> @UI.Search_Request
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a id="{{id}}" season-select="0" class="dropdownTv " href="#">@UI.Search_AllSeasons</a></li>
<li><a id="{{id}}" season-select="1" class="dropdownTv" href="#">@UI.Search_FirstSeason</a></li>
<li><a id="{{id}}" season-select="2" class="dropdownTv" href="#">@UI.Search_LatestSeason</a></li>
<li><a id="SeasonSelect" data-identifier="{{id}}" data-toggle="modal" data-target="#seasonsModal" href="#">@UI.Search_SelectSeason...</a></li>
<li><a id="EpisodeSelect" data-identifier="{{id}}" data-toggle="modal" data-target="#episodesModal" href="#">@UI.Search_SelectEpisode...</a></li>
</ul>
</div>
{{/if_eq}}
{{/if_eq}}

Loading…
Cancel
Save