mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 21:33:15 -07:00
Work on the requests page mostly done.
This commit is contained in:
parent
70362b908f
commit
98d143c9b2
17 changed files with 297 additions and 78 deletions
|
@ -1,4 +1,6 @@
|
|||
using Nancy;
|
||||
using Nancy.Extensions;
|
||||
using Nancy.Responses;
|
||||
|
||||
namespace RequestPlex.UI.Modules
|
||||
{
|
||||
|
@ -6,8 +8,8 @@ namespace RequestPlex.UI.Modules
|
|||
{
|
||||
public IndexModule()
|
||||
{
|
||||
Get["/"] = parameters => View["Index"];
|
||||
Get["/Index"] = parameters => View["Index"];
|
||||
Get["/"] = parameters => Context.GetRedirect("~/search");
|
||||
Get["/Index"] = parameters => Context.GetRedirect("~/search");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,28 +1,43 @@
|
|||
using Nancy;
|
||||
using System.Linq;
|
||||
|
||||
using Nancy;
|
||||
using Nancy.Responses.Negotiation;
|
||||
|
||||
using RequestPlex.Api;
|
||||
using RequestPlex.Core;
|
||||
using RequestPlex.Core.SettingModels;
|
||||
using RequestPlex.Store;
|
||||
|
||||
namespace RequestPlex.UI.Modules
|
||||
{
|
||||
public class RequestsModule : NancyModule
|
||||
{
|
||||
public RequestsModule(ISettingsService<RequestPlexSettings> s)
|
||||
private IRepository<RequestedModel> Service { get; set; }
|
||||
public RequestsModule(IRepository<RequestedModel> service)
|
||||
{
|
||||
Get["requests/"] = _ => "Hello!";
|
||||
Get["requests/test"] = _ =>
|
||||
{
|
||||
var se = new RequestPlexSettings
|
||||
{
|
||||
PlexAuthToken = "abc",
|
||||
Port = 2344,
|
||||
UserAuthentication = false
|
||||
};
|
||||
s.SaveSettings(se);
|
||||
var a = s.GetSettings();
|
||||
return "Hi!";
|
||||
};
|
||||
Service = service;
|
||||
|
||||
Get["requests/"] = _ => LoadRequests();
|
||||
Get["requests/movies"] = _ => GetMovies();
|
||||
Get["requests/tvshows"] = _ => GetTvShows();
|
||||
}
|
||||
|
||||
|
||||
private Negotiator LoadRequests()
|
||||
{
|
||||
return View["Requests/Index"];
|
||||
}
|
||||
|
||||
private Response GetMovies()
|
||||
{
|
||||
var dbMovies = Service.GetAll().Where(x => x.Type == RequestType.Movie);
|
||||
return Response.AsJson(dbMovies);
|
||||
}
|
||||
|
||||
private Response GetTvShows()
|
||||
{
|
||||
var dbTv = Service.GetAll().Where(x => x.Type == RequestType.TvShow);
|
||||
return Response.AsJson(dbTv);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,10 +86,17 @@ namespace RequestPlex.UI.Modules
|
|||
{
|
||||
return Response.AsJson(new { Result = false, Message = "Movie has already been requested!" });
|
||||
}
|
||||
|
||||
s.AddRequest(movieId, RequestType.Movie);
|
||||
return Response.AsJson(new { Result = true });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Requests the tv show.
|
||||
/// </summary>
|
||||
/// <param name="showId">The show identifier.</param>
|
||||
/// <param name="latest">if set to <c>true</c> [latest].</param>
|
||||
/// <returns></returns>
|
||||
private Response RequestTvShow(int showId, bool latest)
|
||||
{
|
||||
// Latest send to Sonarr and no need to store in DB
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue