mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 07:46:05 -07:00
fixed #413
This commit is contained in:
parent
d8111bcedb
commit
5bda83bfdf
4 changed files with 34 additions and 22 deletions
|
@ -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();
|
||||
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);
|
||||
}
|
||||
|
||||
private ISettingsService<LandingPageSettings> LandingSettings { get; }
|
||||
private ISettingsService<PlexSettings> PlexSettings { get; }
|
||||
private ISettingsService<AuthenticationSettings> AuthSettings { get; }
|
||||
private IPlexApi PlexApi { get; }
|
||||
|
||||
private async Task<Negotiator> Index()
|
||||
{
|
||||
|
||||
var s = await LandingSettings.GetSettingsAsync();
|
||||
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();
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace PlexRequests.UI.Modules
|
|||
RequestLimitRepo = rl;
|
||||
|
||||
|
||||
Get["/", true] = async (x, ct) => await RequestLoad();
|
||||
Get["SearchIndex","/", true] = async (x, ct) => await RequestLoad();
|
||||
|
||||
Get["movie/{searchTerm}", true] = async (x, ct) => await SearchMovie((string)x.searchTerm);
|
||||
Get["tv/{searchTerm}", true] = async (x, ct) => await SearchTvShow((string)x.searchTerm);
|
||||
|
@ -151,6 +151,7 @@ namespace PlexRequests.UI.Modules
|
|||
|
||||
private async Task<Negotiator> RequestLoad()
|
||||
{
|
||||
|
||||
var settings = await PrService.GetSettingsAsync();
|
||||
|
||||
return View["Search/Index", settings];
|
||||
|
|
|
@ -65,6 +65,10 @@
|
|||
<HintPath>..\packages\Nancy.Bootstrappers.Ninject.1.4.1\lib\net40\Nancy.Bootstrappers.Ninject.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Linker, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Nancy.Linker.0.3.1\lib\net40-Client\Nancy.Linker.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Nancy.Metadata.Modules, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Nancy.Metadata.Modules.1.4.1\lib\net40\Nancy.Metadata.Modules.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net45" />
|
||||
<package id="Nancy.Bootstrappers.Ninject" version="1.4.1" targetFramework="net45" />
|
||||
<package id="Nancy.Hosting.Self" version="1.4.1" targetFramework="net45" />
|
||||
<package id="Nancy.Linker" version="0.3.1" targetFramework="net45" />
|
||||
<package id="Nancy.Metadata.Modules" version="1.4.1" targetFramework="net45" />
|
||||
<package id="Nancy.Owin" version="1.4.1" targetFramework="net45" />
|
||||
<package id="Nancy.Swagger" version="0.1.0-alpha3" targetFramework="net45" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue