mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 15:56:05 -07:00
This commit is contained in:
parent
d458dca541
commit
a5257a0fbf
4 changed files with 93 additions and 90 deletions
3
PlexRequests.UI/Content/requests.js
vendored
3
PlexRequests.UI/Content/requests.js
vendored
|
@ -637,7 +637,8 @@ function buildRequestContext(result, type) {
|
||||||
qualities: result.qualities,
|
qualities: result.qualities,
|
||||||
hasQualities: result.qualities && result.qualities.length > 0,
|
hasQualities: result.qualities && result.qualities.length > 0,
|
||||||
artist: result.artistName,
|
artist: result.artistName,
|
||||||
musicBrainzId : result.musicBrainzId
|
musicBrainzId: result.musicBrainzId,
|
||||||
|
episodes : result.episodes
|
||||||
};
|
};
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
|
|
|
@ -1,58 +1,59 @@
|
||||||
#region Copyright
|
#region Copyright
|
||||||
// /************************************************************************
|
// /************************************************************************
|
||||||
// Copyright (c) 2016 Jamie Rees
|
// Copyright (c) 2016 Jamie Rees
|
||||||
// File: RequestViewModel.cs
|
// File: RequestViewModel.cs
|
||||||
// Created By: Jamie Rees
|
// Created By: Jamie Rees
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
// a copy of this software and associated documentation files (the
|
// a copy of this software and associated documentation files (the
|
||||||
// "Software"), to deal in the Software without restriction, including
|
// "Software"), to deal in the Software without restriction, including
|
||||||
// without limitation the rights to use, copy, modify, merge, publish,
|
// without limitation the rights to use, copy, modify, merge, publish,
|
||||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
// permit persons to whom the Software is furnished to do so, subject to
|
// permit persons to whom the Software is furnished to do so, subject to
|
||||||
// the following conditions:
|
// the following conditions:
|
||||||
//
|
//
|
||||||
// The above copyright notice and this permission notice shall be
|
// The above copyright notice and this permission notice shall be
|
||||||
// included in all copies or substantial portions of the Software.
|
// included in all copies or substantial portions of the Software.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
using PlexRequests.Store;
|
using PlexRequests.Store;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace PlexRequests.UI.Models
|
namespace PlexRequests.UI.Models
|
||||||
{
|
{
|
||||||
public class RequestViewModel
|
public class RequestViewModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int ProviderId { get; set; }
|
public int ProviderId { get; set; }
|
||||||
public string ImdbId { get; set; }
|
public string ImdbId { get; set; }
|
||||||
public string Overview { get; set; }
|
public string Overview { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string PosterPath { get; set; }
|
public string PosterPath { get; set; }
|
||||||
public DateTime ReleaseDate { get; set; }
|
public DateTime ReleaseDate { get; set; }
|
||||||
public bool Released { get; set; }
|
public bool Released { get; set; }
|
||||||
public long ReleaseDateTicks { get; set; }
|
public long ReleaseDateTicks { get; set; }
|
||||||
public RequestType Type { get; set; }
|
public RequestType Type { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
public bool Approved { get; set; }
|
public bool Approved { get; set; }
|
||||||
public string[] RequestedUsers { get; set; }
|
public string[] RequestedUsers { get; set; }
|
||||||
public DateTime RequestedDate { get; set; }
|
public DateTime RequestedDate { get; set; }
|
||||||
public long RequestedDateTicks { get; set; }
|
public long RequestedDateTicks { get; set; }
|
||||||
public string ReleaseYear { get; set; }
|
public string ReleaseYear { get; set; }
|
||||||
public bool Available { get; set; }
|
public bool Available { get; set; }
|
||||||
public bool Admin { get; set; }
|
public bool Admin { get; set; }
|
||||||
public int IssueId { get; set; }
|
public int IssueId { get; set; }
|
||||||
public string TvSeriesRequestType { get; set; }
|
public string TvSeriesRequestType { get; set; }
|
||||||
public string MusicBrainzId { get; set; }
|
public string MusicBrainzId { get; set; }
|
||||||
public QualityModel[] Qualities { get; set; }
|
public QualityModel[] Qualities { get; set; }
|
||||||
public string ArtistName { get; set; }
|
public string ArtistName { get; set; }
|
||||||
}
|
public Store.EpisodesModel[] Episodes { get; set; }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -183,13 +183,13 @@ namespace PlexRequests.UI.Modules
|
||||||
|
|
||||||
private async Task<Response> GetTvShows()
|
private async Task<Response> GetTvShows()
|
||||||
{
|
{
|
||||||
var settings = PrSettings.GetSettings();
|
var settingsTask = PrSettings.GetSettingsAsync();
|
||||||
|
|
||||||
var requests = await Service.GetAllAsync();
|
var requests = await Service.GetAllAsync();
|
||||||
requests = requests.Where(x => x.Type == RequestType.TvShow);
|
requests = requests.Where(x => x.Type == RequestType.TvShow);
|
||||||
|
|
||||||
var dbTv = requests;
|
var dbTv = requests;
|
||||||
|
var settings = await settingsTask;
|
||||||
if (settings.UsersCanViewOnlyOwnRequests && !IsAdmin)
|
if (settings.UsersCanViewOnlyOwnRequests && !IsAdmin)
|
||||||
{
|
{
|
||||||
dbTv = dbTv.Where(x => x.UserHasRequested(Username)).ToList();
|
dbTv = dbTv.Where(x => x.UserHasRequested(Username)).ToList();
|
||||||
|
@ -200,21 +200,21 @@ namespace PlexRequests.UI.Modules
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var sonarrSettings = SonarrSettings.GetSettings();
|
var sonarrSettings = await SonarrSettings.GetSettingsAsync();
|
||||||
if (sonarrSettings.Enabled)
|
if (sonarrSettings.Enabled)
|
||||||
{
|
{
|
||||||
var result = Cache.GetOrSetAsync(CacheKeys.SonarrQualityProfiles, async () =>
|
var result = Cache.GetOrSetAsync(CacheKeys.SonarrQualityProfiles, async () =>
|
||||||
{
|
{
|
||||||
return await Task.Run(() => SonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri));
|
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
|
else
|
||||||
{
|
{
|
||||||
var sickRageSettings = SickRageSettings.GetSettings();
|
var sickRageSettings = await SickRageSettings.GetSettingsAsync();
|
||||||
if (sickRageSettings.Enabled)
|
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,
|
||||||
ProviderId = tv.ProviderId,
|
Status = tv.Status,
|
||||||
Type = tv.Type,
|
ImdbId = tv.ImdbId,
|
||||||
Status = tv.Status,
|
Id = tv.Id,
|
||||||
ImdbId = tv.ImdbId,
|
PosterPath = tv.PosterPath,
|
||||||
Id = tv.Id,
|
ReleaseDate = tv.ReleaseDate,
|
||||||
PosterPath = tv.PosterPath,
|
ReleaseDateTicks = tv.ReleaseDate.Ticks,
|
||||||
ReleaseDate = tv.ReleaseDate,
|
RequestedDate = tv.RequestedDate,
|
||||||
ReleaseDateTicks = tv.ReleaseDate.Ticks,
|
RequestedDateTicks = DateTimeHelper.OffsetUTCDateTime(tv.RequestedDate, DateTimeOffset).Ticks,
|
||||||
RequestedDate = tv.RequestedDate,
|
Released = DateTime.Now > tv.ReleaseDate,
|
||||||
RequestedDateTicks = DateTimeHelper.OffsetUTCDateTime(tv.RequestedDate, DateTimeOffset).Ticks,
|
Approved = tv.Available || tv.Approved,
|
||||||
Released = DateTime.Now > tv.ReleaseDate,
|
Title = tv.Title,
|
||||||
Approved = tv.Available || tv.Approved,
|
Overview = tv.Overview,
|
||||||
Title = tv.Title,
|
RequestedUsers = IsAdmin ? tv.AllUsers.ToArray() : new string[] { },
|
||||||
Overview = tv.Overview,
|
ReleaseYear = tv.ReleaseDate.Year.ToString(),
|
||||||
RequestedUsers = IsAdmin ? tv.AllUsers.ToArray() : new string[] { },
|
Available = tv.Available,
|
||||||
ReleaseYear = tv.ReleaseDate.Year.ToString(),
|
Admin = IsAdmin,
|
||||||
Available = tv.Available,
|
IssueId = tv.IssueId,
|
||||||
Admin = IsAdmin,
|
TvSeriesRequestType = tv.SeasonsRequested,
|
||||||
IssueId = tv.IssueId,
|
Qualities = qualities.ToArray(),
|
||||||
TvSeriesRequestType = tv.SeasonsRequested,
|
Episodes = tv.Episodes,
|
||||||
Qualities = qualities.ToArray()
|
|
||||||
};
|
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
return Response.AsJson(viewModel);
|
return Response.AsJson(viewModel);
|
||||||
|
|
|
@ -173,6 +173,9 @@
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
</div>
|
</div>
|
||||||
{{#if_eq type "tv"}}
|
{{#if_eq type "tv"}}
|
||||||
|
{{#each episodes}}
|
||||||
|
{{this.seasonNumber}} - {{this.episodeNumber}} @*// TODO Show the episodes requested*@
|
||||||
|
{{/each}}
|
||||||
<div>@UI.Requests_SeasonsRequested: {{seriesRequested}}</div>
|
<div>@UI.Requests_SeasonsRequested: {{seriesRequested}}</div>
|
||||||
{{/if_eq}}
|
{{/if_eq}}
|
||||||
{{#if requestedUsers}}
|
{{#if requestedUsers}}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue