From a5257a0fbfe4c1df320413ac71881b1968390024 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 27 Jul 2016 16:56:19 +0100 Subject: [PATCH] #254 --- PlexRequests.UI/Content/requests.js | 3 +- PlexRequests.UI/Models/RequestViewModel.cs | 117 ++++++++++---------- PlexRequests.UI/Modules/RequestsModule.cs | 60 +++++----- PlexRequests.UI/Views/Requests/Index.cshtml | 3 + 4 files changed, 93 insertions(+), 90 deletions(-) diff --git a/PlexRequests.UI/Content/requests.js b/PlexRequests.UI/Content/requests.js index a65bc3425..dad1c9c8f 100644 --- a/PlexRequests.UI/Content/requests.js +++ b/PlexRequests.UI/Content/requests.js @@ -637,7 +637,8 @@ function buildRequestContext(result, type) { qualities: result.qualities, hasQualities: result.qualities && result.qualities.length > 0, artist: result.artistName, - musicBrainzId : result.musicBrainzId + musicBrainzId: result.musicBrainzId, + episodes : result.episodes }; return context; diff --git a/PlexRequests.UI/Models/RequestViewModel.cs b/PlexRequests.UI/Models/RequestViewModel.cs index 0b434d3c5..f4855106c 100644 --- a/PlexRequests.UI/Models/RequestViewModel.cs +++ b/PlexRequests.UI/Models/RequestViewModel.cs @@ -1,58 +1,59 @@ -#region Copyright -// /************************************************************************ -// Copyright (c) 2016 Jamie Rees -// File: RequestViewModel.cs -// Created By: Jamie Rees -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// ************************************************************************/ -#endregion -using PlexRequests.Store; -using System; - -namespace PlexRequests.UI.Models -{ - public class RequestViewModel - { - public int Id { get; set; } - public int ProviderId { get; set; } - public string ImdbId { get; set; } - public string Overview { get; set; } - public string Title { get; set; } - public string PosterPath { get; set; } - public DateTime ReleaseDate { get; set; } - public bool Released { get; set; } - public long ReleaseDateTicks { get; set; } - public RequestType Type { get; set; } - public string Status { get; set; } - public bool Approved { get; set; } - public string[] RequestedUsers { get; set; } - public DateTime RequestedDate { get; set; } - public long RequestedDateTicks { get; set; } - public string ReleaseYear { get; set; } - public bool Available { get; set; } - public bool Admin { get; set; } - public int IssueId { get; set; } - public string TvSeriesRequestType { get; set; } - public string MusicBrainzId { get; set; } - public QualityModel[] Qualities { get; set; } - public string ArtistName { get; set; } - } -} +#region Copyright +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: RequestViewModel.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion +using PlexRequests.Store; +using System; + +namespace PlexRequests.UI.Models +{ + public class RequestViewModel + { + public int Id { get; set; } + public int ProviderId { get; set; } + public string ImdbId { get; set; } + public string Overview { get; set; } + public string Title { get; set; } + public string PosterPath { get; set; } + public DateTime ReleaseDate { get; set; } + public bool Released { get; set; } + public long ReleaseDateTicks { get; set; } + public RequestType Type { get; set; } + public string Status { get; set; } + public bool Approved { get; set; } + public string[] RequestedUsers { get; set; } + public DateTime RequestedDate { get; set; } + public long RequestedDateTicks { get; set; } + public string ReleaseYear { get; set; } + public bool Available { get; set; } + public bool Admin { get; set; } + public int IssueId { get; set; } + public string TvSeriesRequestType { get; set; } + public string MusicBrainzId { get; set; } + public QualityModel[] Qualities { get; set; } + public string ArtistName { get; set; } + public Store.EpisodesModel[] Episodes { get; set; } + } +} diff --git a/PlexRequests.UI/Modules/RequestsModule.cs b/PlexRequests.UI/Modules/RequestsModule.cs index 392243ffe..b69c7d67d 100644 --- a/PlexRequests.UI/Modules/RequestsModule.cs +++ b/PlexRequests.UI/Modules/RequestsModule.cs @@ -183,13 +183,13 @@ namespace PlexRequests.UI.Modules private async Task GetTvShows() { - var settings = PrSettings.GetSettings(); + var settingsTask = PrSettings.GetSettingsAsync(); var requests = await Service.GetAllAsync(); requests = requests.Where(x => x.Type == RequestType.TvShow); var dbTv = requests; - + var settings = await settingsTask; if (settings.UsersCanViewOnlyOwnRequests && !IsAdmin) { dbTv = dbTv.Where(x => x.UserHasRequested(Username)).ToList(); @@ -200,21 +200,21 @@ namespace PlexRequests.UI.Modules { try { - var sonarrSettings = SonarrSettings.GetSettings(); + var sonarrSettings = await SonarrSettings.GetSettingsAsync(); if (sonarrSettings.Enabled) { var result = Cache.GetOrSetAsync(CacheKeys.SonarrQualityProfiles, async () => { return await Task.Run(() => SonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri)); }); - qualities = result.Result.Select(x => new QualityModel() { Id = x.id.ToString(), Name = x.name }).ToList(); + qualities = result.Result.Select(x => new QualityModel { Id = x.id.ToString(), Name = x.name }).ToList(); } else { - var sickRageSettings = SickRageSettings.GetSettings(); + var sickRageSettings = await SickRageSettings.GetSettingsAsync(); if (sickRageSettings.Enabled) { - qualities = sickRageSettings.Qualities.Select(x => new QualityModel() { Id = x.Key, Name = x.Value }).ToList(); + qualities = sickRageSettings.Qualities.Select(x => new QualityModel { Id = x.Key, Name = x.Value }).ToList(); } } } @@ -225,32 +225,30 @@ namespace PlexRequests.UI.Modules } - var viewModel = dbTv.Select(tv => + var viewModel = dbTv.Select(tv => new RequestViewModel { - return new RequestViewModel - { - ProviderId = tv.ProviderId, - Type = tv.Type, - Status = tv.Status, - ImdbId = tv.ImdbId, - Id = tv.Id, - PosterPath = tv.PosterPath, - ReleaseDate = tv.ReleaseDate, - ReleaseDateTicks = tv.ReleaseDate.Ticks, - RequestedDate = tv.RequestedDate, - RequestedDateTicks = DateTimeHelper.OffsetUTCDateTime(tv.RequestedDate, DateTimeOffset).Ticks, - Released = DateTime.Now > tv.ReleaseDate, - Approved = tv.Available || tv.Approved, - Title = tv.Title, - Overview = tv.Overview, - RequestedUsers = IsAdmin ? tv.AllUsers.ToArray() : new string[] { }, - ReleaseYear = tv.ReleaseDate.Year.ToString(), - Available = tv.Available, - Admin = IsAdmin, - IssueId = tv.IssueId, - TvSeriesRequestType = tv.SeasonsRequested, - Qualities = qualities.ToArray() - }; + ProviderId = tv.ProviderId, + Type = tv.Type, + Status = tv.Status, + ImdbId = tv.ImdbId, + Id = tv.Id, + PosterPath = tv.PosterPath, + ReleaseDate = tv.ReleaseDate, + ReleaseDateTicks = tv.ReleaseDate.Ticks, + RequestedDate = tv.RequestedDate, + RequestedDateTicks = DateTimeHelper.OffsetUTCDateTime(tv.RequestedDate, DateTimeOffset).Ticks, + Released = DateTime.Now > tv.ReleaseDate, + Approved = tv.Available || tv.Approved, + Title = tv.Title, + Overview = tv.Overview, + RequestedUsers = IsAdmin ? tv.AllUsers.ToArray() : new string[] { }, + ReleaseYear = tv.ReleaseDate.Year.ToString(), + Available = tv.Available, + Admin = IsAdmin, + IssueId = tv.IssueId, + TvSeriesRequestType = tv.SeasonsRequested, + Qualities = qualities.ToArray(), + Episodes = tv.Episodes, }).ToList(); return Response.AsJson(viewModel); diff --git a/PlexRequests.UI/Views/Requests/Index.cshtml b/PlexRequests.UI/Views/Requests/Index.cshtml index d603ea105..898e58781 100644 --- a/PlexRequests.UI/Views/Requests/Index.cshtml +++ b/PlexRequests.UI/Views/Requests/Index.cshtml @@ -173,6 +173,9 @@ {{/if_eq}} {{#if_eq type "tv"}} + {{#each episodes}} + {{this.seasonNumber}} - {{this.episodeNumber}} @*// TODO Show the episodes requested*@ + {{/each}}
@UI.Requests_SeasonsRequested: {{seriesRequested}}
{{/if_eq}} {{#if requestedUsers}}