|
|
|
@ -28,6 +28,7 @@ using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using Nancy;
|
|
|
|
|
using Nancy.Linker;
|
|
|
|
|
using Nancy.Responses.Negotiation;
|
|
|
|
|
|
|
|
|
|
using PlexRequests.Api.Interfaces;
|
|
|
|
@ -40,26 +41,23 @@ namespace PlexRequests.UI.Modules
|
|
|
|
|
public class LandingPageModule : BaseModule
|
|
|
|
|
{
|
|
|
|
|
public LandingPageModule(ISettingsService<PlexRequestSettings> settingsService, ISettingsService<LandingPageSettings> landing,
|
|
|
|
|
ISettingsService<PlexSettings> ps, IPlexApi pApi, ISettingsService<AuthenticationSettings> auth) : base("landing", settingsService)
|
|
|
|
|
ISettingsService<PlexSettings> ps, IPlexApi pApi, ISettingsService<AuthenticationSettings> auth, IResourceLinker linker) : base("landing", settingsService)
|
|
|
|
|
{
|
|
|
|
|
LandingSettings = landing;
|
|
|
|
|
PlexSettings = ps;
|
|
|
|
|
PlexApi = pApi;
|
|
|
|
|
AuthSettings = auth;
|
|
|
|
|
Linker = linker;
|
|
|
|
|
|
|
|
|
|
Get["/", true] = async (x, ct) => await Index();
|
|
|
|
|
Get["/status", true] = async (x, ct) => await CheckStatus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ISettingsService<LandingPageSettings> LandingSettings { get; }
|
|
|
|
|
private ISettingsService<PlexSettings> PlexSettings { get; }
|
|
|
|
|
private ISettingsService<AuthenticationSettings> AuthSettings { get; }
|
|
|
|
|
private IPlexApi PlexApi { get; }
|
|
|
|
|
|
|
|
|
|
private async Task<Negotiator> Index()
|
|
|
|
|
Get["LandingPageIndex","/", true] = async (x, ct) =>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var s = await LandingSettings.GetSettingsAsync();
|
|
|
|
|
if (!s.BeforeLogin && string.IsNullOrEmpty(Username)) //We are signed in
|
|
|
|
|
{
|
|
|
|
|
var url = Linker.BuildAbsoluteUri(Context, "SearchIndex").ToString();
|
|
|
|
|
return Response.AsRedirect(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var model = new LandingPageViewModel
|
|
|
|
|
{
|
|
|
|
|
Enabled = s.Enabled,
|
|
|
|
@ -71,10 +69,18 @@ namespace PlexRequests.UI.Modules
|
|
|
|
|
NoticeStart = s.NoticeStart,
|
|
|
|
|
ContinueUrl = s.BeforeLogin ? $"userlogin" : $"search"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return View["Landing/Index", model];
|
|
|
|
|
};
|
|
|
|
|
Get["/status", true] = async (x, ct) => await CheckStatus();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ISettingsService<LandingPageSettings> LandingSettings { get; }
|
|
|
|
|
private ISettingsService<PlexSettings> PlexSettings { get; }
|
|
|
|
|
private ISettingsService<AuthenticationSettings> AuthSettings { get; }
|
|
|
|
|
private IPlexApi PlexApi { get; }
|
|
|
|
|
private IResourceLinker Linker { get; }
|
|
|
|
|
|
|
|
|
|
private async Task<Response> CheckStatus()
|
|
|
|
|
{
|
|
|
|
|
var auth = await AuthSettings.GetSettingsAsync();
|
|
|
|
|