mirror of https://github.com/Ombi-app/Ombi
parent
ffe6bc41ac
commit
57ec940d5a
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,230 +1,227 @@
|
|||||||
#region Copyright
|
#region Copyright
|
||||||
// /************************************************************************
|
// /************************************************************************
|
||||||
// Copyright (c) 2016 Jamie Rees
|
// Copyright (c) 2016 Jamie Rees
|
||||||
// File: ApplicationTesterModule.cs
|
// File: ApplicationTesterModule.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 System;
|
using System;
|
||||||
|
|
||||||
using Nancy;
|
using Nancy;
|
||||||
using Nancy.ModelBinding;
|
using Nancy.ModelBinding;
|
||||||
using Nancy.Security;
|
using Nancy.Security;
|
||||||
using Nancy.Validation;
|
using Nancy.Validation;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
|
||||||
using PlexRequests.Api.Interfaces;
|
using PlexRequests.Api.Interfaces;
|
||||||
using PlexRequests.Core;
|
using PlexRequests.Core;
|
||||||
using PlexRequests.Core.SettingModels;
|
using PlexRequests.Core.SettingModels;
|
||||||
using PlexRequests.UI.Helpers;
|
using PlexRequests.UI.Helpers;
|
||||||
using PlexRequests.UI.Models;
|
using PlexRequests.UI.Models;
|
||||||
|
|
||||||
namespace PlexRequests.UI.Modules
|
namespace PlexRequests.UI.Modules
|
||||||
{
|
{
|
||||||
public class ApplicationTesterModule : BaseAuthModule
|
public class ApplicationTesterModule : BaseAuthModule
|
||||||
{
|
{
|
||||||
|
|
||||||
public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi,
|
public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi,
|
||||||
ISettingsService<AuthenticationSettings> authSettings, ISickRageApi srApi, IHeadphonesApi hpApi, ISettingsService<PlexRequestSettings> pr) : base("test", pr)
|
ISickRageApi srApi, IHeadphonesApi hpApi, ISettingsService<PlexRequestSettings> pr) : base("test", pr)
|
||||||
{
|
{
|
||||||
this.RequiresAuthentication();
|
this.RequiresAuthentication();
|
||||||
|
|
||||||
CpApi = cpApi;
|
CpApi = cpApi;
|
||||||
SonarrApi = sonarrApi;
|
SonarrApi = sonarrApi;
|
||||||
PlexApi = plexApi;
|
PlexApi = plexApi;
|
||||||
AuthSettings = authSettings;
|
SickRageApi = srApi;
|
||||||
SickRageApi = srApi;
|
HeadphonesApi = hpApi;
|
||||||
HeadphonesApi = hpApi;
|
|
||||||
|
Post["/cp"] = _ => CouchPotatoTest();
|
||||||
Post["/cp"] = _ => CouchPotatoTest();
|
Post["/sonarr"] = _ => SonarrTest();
|
||||||
Post["/sonarr"] = _ => SonarrTest();
|
Post["/plex"] = _ => PlexTest();
|
||||||
Post["/plex"] = _ => PlexTest();
|
Post["/sickrage"] = _ => SickRageTest();
|
||||||
Post["/sickrage"] = _ => SickRageTest();
|
Post["/headphones"] = _ => HeadphonesTest();
|
||||||
Post["/headphones"] = _ => HeadphonesTest();
|
|
||||||
|
}
|
||||||
}
|
|
||||||
|
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
|
private ISonarrApi SonarrApi { get; }
|
||||||
private ISonarrApi SonarrApi { get; }
|
private ICouchPotatoApi CpApi { get; }
|
||||||
private ICouchPotatoApi CpApi { get; }
|
private IPlexApi PlexApi { get; }
|
||||||
private IPlexApi PlexApi { get; }
|
private ISickRageApi SickRageApi { get; }
|
||||||
private ISickRageApi SickRageApi { get; }
|
private IHeadphonesApi HeadphonesApi { get; }
|
||||||
private IHeadphonesApi HeadphonesApi { get; }
|
|
||||||
private ISettingsService<AuthenticationSettings> AuthSettings { get; }
|
private Response CouchPotatoTest()
|
||||||
|
{
|
||||||
private Response CouchPotatoTest()
|
var couchPotatoSettings = this.Bind<CouchPotatoSettings>();
|
||||||
{
|
var valid = this.Validate(couchPotatoSettings);
|
||||||
var couchPotatoSettings = this.Bind<CouchPotatoSettings>();
|
if (!valid.IsValid)
|
||||||
var valid = this.Validate(couchPotatoSettings);
|
{
|
||||||
if (!valid.IsValid)
|
return Response.AsJson(valid.SendJsonError());
|
||||||
{
|
}
|
||||||
return Response.AsJson(valid.SendJsonError());
|
try
|
||||||
}
|
{
|
||||||
try
|
var status = CpApi.GetStatus(couchPotatoSettings.FullUri, couchPotatoSettings.ApiKey);
|
||||||
{
|
return status.success
|
||||||
var status = CpApi.GetStatus(couchPotatoSettings.FullUri, couchPotatoSettings.ApiKey);
|
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to CouchPotato successfully!" })
|
||||||
return status.success
|
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to CouchPotato, please check your settings." });
|
||||||
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to CouchPotato successfully!" })
|
|
||||||
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to CouchPotato, please check your settings." });
|
}
|
||||||
|
catch (Exception e) // Exceptions are expected if we cannot connect so we will just log and swallow them.
|
||||||
}
|
{
|
||||||
catch (Exception e) // Exceptions are expected if we cannot connect so we will just log and swallow them.
|
Log.Warn("Exception thrown when attempting to get CP's status: ");
|
||||||
{
|
Log.Warn(e);
|
||||||
Log.Warn("Exception thrown when attempting to get CP's status: ");
|
var message = $"Could not connect to CouchPotato, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
||||||
Log.Warn(e);
|
if (e.InnerException != null)
|
||||||
var message = $"Could not connect to CouchPotato, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
{
|
||||||
if (e.InnerException != null)
|
message = $"Could not connect to CouchPotato, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
||||||
{
|
}
|
||||||
message = $"Could not connect to CouchPotato, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
|
||||||
}
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
|
}
|
||||||
}
|
|
||||||
}
|
private Response SonarrTest()
|
||||||
|
{
|
||||||
private Response SonarrTest()
|
var sonarrSettings = this.Bind<SonarrSettings>();
|
||||||
{
|
var valid = this.Validate(sonarrSettings);
|
||||||
var sonarrSettings = this.Bind<SonarrSettings>();
|
if (!valid.IsValid)
|
||||||
var valid = this.Validate(sonarrSettings);
|
{
|
||||||
if (!valid.IsValid)
|
return Response.AsJson(valid.SendJsonError());
|
||||||
{
|
}
|
||||||
return Response.AsJson(valid.SendJsonError());
|
try
|
||||||
}
|
{
|
||||||
try
|
var status = SonarrApi.SystemStatus(sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
||||||
{
|
return status?.version != null
|
||||||
var status = SonarrApi.SystemStatus(sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to Sonarr successfully!" })
|
||||||
return status?.version != null
|
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Sonarr, please check your settings." });
|
||||||
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to Sonarr successfully!" })
|
|
||||||
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Sonarr, please check your settings." });
|
}
|
||||||
|
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
|
||||||
}
|
{
|
||||||
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
|
Log.Warn("Exception thrown when attempting to get Sonarr's status: ");
|
||||||
{
|
Log.Warn(e);
|
||||||
Log.Warn("Exception thrown when attempting to get Sonarr's status: ");
|
var message = $"Could not connect to Sonarr, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
||||||
Log.Warn(e);
|
if (e.InnerException != null)
|
||||||
var message = $"Could not connect to Sonarr, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
{
|
||||||
if (e.InnerException != null)
|
message = $"Could not connect to Sonarr, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
||||||
{
|
}
|
||||||
message = $"Could not connect to Sonarr, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
|
||||||
}
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
|
}
|
||||||
}
|
|
||||||
}
|
private Response PlexTest()
|
||||||
|
{
|
||||||
private Response PlexTest()
|
var plexSettings = this.Bind<PlexSettings>();
|
||||||
{
|
var valid = this.Validate(plexSettings);
|
||||||
var plexSettings = this.Bind<PlexSettings>();
|
if (!valid.IsValid)
|
||||||
var valid = this.Validate(plexSettings);
|
{
|
||||||
if (!valid.IsValid)
|
return Response.AsJson(valid.SendJsonError());
|
||||||
{
|
}
|
||||||
return Response.AsJson(valid.SendJsonError());
|
if (plexSettings?.PlexAuthToken == null)
|
||||||
}
|
{
|
||||||
var settings = AuthSettings.GetSettings();
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Plex is not setup yet, you need to update your Authentication settings" });
|
||||||
if (settings?.PlexAuthToken == null)
|
}
|
||||||
{
|
try
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Plex is not setup yet, you need to update your Authentication settings" });
|
{
|
||||||
}
|
var status = PlexApi.GetStatus(plexSettings.PlexAuthToken, plexSettings.FullUri);
|
||||||
try
|
return status != null
|
||||||
{
|
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to Plex successfully!" })
|
||||||
var status = PlexApi.GetStatus(settings.PlexAuthToken, plexSettings.FullUri);
|
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Plex, please check your settings." });
|
||||||
return status != null
|
|
||||||
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to Plex successfully!" })
|
}
|
||||||
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Plex, please check your settings." });
|
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
|
||||||
|
{
|
||||||
}
|
Log.Warn("Exception thrown when attempting to get Plex's status: ");
|
||||||
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
|
Log.Warn(e);
|
||||||
{
|
var message = $"Could not connect to Plex, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
||||||
Log.Warn("Exception thrown when attempting to get Plex's status: ");
|
if (e.InnerException != null)
|
||||||
Log.Warn(e);
|
{
|
||||||
var message = $"Could not connect to Plex, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
message = $"Could not connect to Plex, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
||||||
if (e.InnerException != null)
|
}
|
||||||
{
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
|
||||||
message = $"Could not connect to Plex, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
}
|
||||||
}
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
|
|
||||||
}
|
private Response SickRageTest()
|
||||||
}
|
{
|
||||||
|
var sickRageSettings = this.Bind<SickRageSettings>();
|
||||||
private Response SickRageTest()
|
var valid = this.Validate(sickRageSettings);
|
||||||
{
|
if (!valid.IsValid)
|
||||||
var sickRageSettings = this.Bind<SickRageSettings>();
|
{
|
||||||
var valid = this.Validate(sickRageSettings);
|
return Response.AsJson(valid.SendJsonError());
|
||||||
if (!valid.IsValid)
|
}
|
||||||
{
|
try
|
||||||
return Response.AsJson(valid.SendJsonError());
|
{
|
||||||
}
|
var status = SickRageApi.Ping(sickRageSettings.ApiKey, sickRageSettings.FullUri);
|
||||||
try
|
return status?.result == "success"
|
||||||
{
|
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to SickRage successfully!" })
|
||||||
var status = SickRageApi.Ping(sickRageSettings.ApiKey, sickRageSettings.FullUri);
|
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to SickRage, please check your settings." });
|
||||||
return status?.result == "success"
|
|
||||||
? Response.AsJson(new JsonResponseModel { Result = true, Message = "Connected to SickRage successfully!" })
|
}
|
||||||
: Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to SickRage, please check your settings." });
|
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
|
||||||
|
{
|
||||||
}
|
Log.Warn("Exception thrown when attempting to get SickRage's status: ");
|
||||||
catch (Exception e) // Exceptions are expected, if we cannot connect so we will just log and swallow them.
|
Log.Warn(e);
|
||||||
{
|
var message = $"Could not connect to SickRage, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
||||||
Log.Warn("Exception thrown when attempting to get SickRage's status: ");
|
if (e.InnerException != null)
|
||||||
Log.Warn(e);
|
{
|
||||||
var message = $"Could not connect to SickRage, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
message = $"Could not connect to SickRage, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
||||||
if (e.InnerException != null)
|
}
|
||||||
{
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
|
||||||
message = $"Could not connect to SickRage, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
}
|
||||||
}
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = message });
|
|
||||||
}
|
private Response HeadphonesTest()
|
||||||
}
|
{
|
||||||
|
var settings = this.Bind<HeadphonesSettings>();
|
||||||
private Response HeadphonesTest()
|
var valid = this.Validate(settings);
|
||||||
{
|
if (!valid.IsValid)
|
||||||
var settings = this.Bind<HeadphonesSettings>();
|
{
|
||||||
var valid = this.Validate(settings);
|
return Response.AsJson(valid.SendJsonError());
|
||||||
if (!valid.IsValid)
|
}
|
||||||
{
|
try
|
||||||
return Response.AsJson(valid.SendJsonError());
|
{
|
||||||
}
|
var result = HeadphonesApi.GetVersion(settings.ApiKey, settings.FullUri);
|
||||||
try
|
if (!string.IsNullOrEmpty(result.latest_version))
|
||||||
{
|
{
|
||||||
var result = HeadphonesApi.GetVersion(settings.ApiKey, settings.FullUri);
|
return
|
||||||
if (!string.IsNullOrEmpty(result.latest_version))
|
Response.AsJson(new JsonResponseModel
|
||||||
{
|
{
|
||||||
return
|
Result = true,
|
||||||
Response.AsJson(new JsonResponseModel
|
Message = "Connected to Headphones successfully!"
|
||||||
{
|
});
|
||||||
Result = true,
|
}
|
||||||
Message = "Connected to Headphones successfully!"
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Headphones, please check your settings." });
|
||||||
});
|
}
|
||||||
}
|
catch (Exception e)
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = "Could not connect to Headphones, please check your settings." });
|
{
|
||||||
}
|
Log.Warn("Exception thrown when attempting to get Headphones's status: ");
|
||||||
catch (Exception e)
|
Log.Warn(e);
|
||||||
{
|
var message = $"Could not connect to Headphones, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
||||||
Log.Warn("Exception thrown when attempting to get Headphones's status: ");
|
if (e.InnerException != null)
|
||||||
Log.Warn(e);
|
{
|
||||||
var message = $"Could not connect to Headphones, please check your settings. <strong>Exception Message:</strong> {e.Message}";
|
message = $"Could not connect to Headphones, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
||||||
if (e.InnerException != null)
|
}
|
||||||
{
|
return Response.AsJson(new JsonResponseModel { Result = false, Message = message }); ;
|
||||||
message = $"Could not connect to Headphones, please check your settings. <strong>Exception Message:</strong> {e.InnerException.Message}";
|
}
|
||||||
}
|
}
|
||||||
return Response.AsJson(new JsonResponseModel { Result = false, Message = message }); ;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,184 +1,139 @@
|
|||||||
@using PlexRequests.UI.Helpers
|
@using PlexRequests.UI.Helpers
|
||||||
@Html.Partial("_Sidebar")
|
@Html.Partial("_Sidebar")
|
||||||
|
|
||||||
@{
|
@{
|
||||||
var baseUrl = Html.GetBaseUrl();
|
var baseUrl = Html.GetBaseUrl();
|
||||||
var formAction = "/admin/authentication";
|
var formAction = "/admin/authentication";
|
||||||
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
|
if (!string.IsNullOrEmpty(baseUrl.ToHtmlString()))
|
||||||
{
|
{
|
||||||
formAction = "/" + baseUrl.ToHtmlString() + formAction;
|
formAction = "/" + baseUrl.ToHtmlString() + formAction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<div class="col-sm-8 col-sm-push-1">
|
<div class="col-sm-8 col-sm-push-1">
|
||||||
<form class="form-horizontal" method="POST" action="@formAction" id="mainForm">
|
<form class="form-horizontal" method="POST" action="@formAction" id="mainForm">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Authentication Settings</legend>
|
<legend>Authentication Settings</legend>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
|
||||||
@if (Model.UserAuthentication)
|
@if (Model.UserAuthentication)
|
||||||
{
|
{
|
||||||
<input type="checkbox" id="userAuth" name="UserAuthentication" checked="checked">
|
<input type="checkbox" id="userAuth" name="UserAuthentication" checked="checked">
|
||||||
<label for="userAuth">Enable User Authentication</label>
|
<label for="userAuth">Enable User Authentication</label>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<input type="checkbox" id="userAuth" name="UserAuthentication">
|
<input type="checkbox" id="userAuth" name="UserAuthentication">
|
||||||
<label for="userAuth">Enable User Authentication</label>
|
<label for="userAuth">Enable User Authentication</label>
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
|
||||||
@if (Model.UsePassword)
|
@if (Model.UsePassword)
|
||||||
{
|
{
|
||||||
<input type="checkbox" id="UsePassword" name="UsePassword" checked="checked">
|
<input type="checkbox" id="UsePassword" name="UsePassword" checked="checked">
|
||||||
<label for="UsePassword">Require users to login with their passwords</label>
|
<label for="UsePassword">Require users to login with their passwords</label>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<input type="checkbox" id="UsePassword" name="UsePassword">
|
<input type="checkbox" id="UsePassword" name="UsePassword">
|
||||||
<label for="UsePassword">Require users to login with their passwords</label>
|
<label for="UsePassword">Require users to login with their passwords</label>
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="authToken" class="control-label">Plex Authorization Token</label>
|
<br />
|
||||||
<div class="">
|
<br />
|
||||||
<input type="text" class="form-control-custom form-control" id="authToken" name="PlexAuthToken" placeholder="Plex Auth Token" value="@Model.PlexAuthToken">
|
<p class="form-group">Current users that are allowed to authenticate: </p>
|
||||||
</div>
|
|
||||||
</div>
|
<div class="form-group">
|
||||||
|
<select id="users" multiple="" class="form-control-custom" style="height: 180px;"></select>
|
||||||
<div class="form-group">
|
</div>
|
||||||
<label for="username" class="control-label">Username and Password</label>
|
<div class="form-group">
|
||||||
<div>
|
|
||||||
<input type="text" class="form-control form-control-custom" id="username" name="Username" placeholder="username">
|
<div>
|
||||||
</div>
|
<button id="refreshUsers" class="btn btn-primary-outline">Refresh Users</button>
|
||||||
<br/>
|
</div>
|
||||||
<div>
|
</div>
|
||||||
<input type="password" class="form-control form-control-custom" id="password" name="Password" placeholder="Password">
|
|
||||||
</div>
|
<p class="form-group">A comma separated list of users that you do not want to login.</p>
|
||||||
</div>
|
<div class="form-group">
|
||||||
<div class="form-group">
|
<label for="deniedUsers" class="control-label">Denied Users</label>
|
||||||
<div class="">
|
<div >
|
||||||
<button id="requestToken" class="btn btn-primary-outline">Request Token <i class="fa fa-key"></i></button>
|
<input type="text" class="form-control-custom form-control " id="DeniedUsers" name="DeniedUsers" placeholder="e.g. John, Bobby" value="@Model.DeniedUsers">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<br/>
|
||||||
|
<div>
|
||||||
<br />
|
</div>
|
||||||
<br />
|
<div class="form-group">
|
||||||
<p class="form-group">Current users that are allowed to authenticate: </p>
|
<div>
|
||||||
|
<button type="submit" class="btn btn-primary-outline">Submit</button>
|
||||||
<div class="form-group">
|
</div>
|
||||||
<select id="users" multiple="" class="form-control-custom" style="height: 180px;"></select>
|
</div>
|
||||||
</div>
|
</fieldset>
|
||||||
<div class="form-group">
|
</form>
|
||||||
|
</div>
|
||||||
<div>
|
|
||||||
<button id="refreshUsers" class="btn btn-primary-outline">Refresh Users</button>
|
|
||||||
</div>
|
<script>
|
||||||
</div>
|
$(function () {
|
||||||
|
|
||||||
<p class="form-group">A comma separated list of users that you do not want to login.</p>
|
var base = '@Html.GetBaseUrl()';
|
||||||
<div class="form-group">
|
|
||||||
<label for="deniedUsers" class="control-label">Denied Users</label>
|
if ($('#PlexAuthToken')) {
|
||||||
<div >
|
loadUserList();
|
||||||
<input type="text" class="form-control-custom form-control " id="DeniedUsers" name="DeniedUsers" placeholder="e.g. John, Bobby" value="@Model.DeniedUsers">
|
}
|
||||||
</div>
|
|
||||||
</div>
|
$('#refreshUsers').click(function (e) {
|
||||||
<br/>
|
e.preventDefault();
|
||||||
<div>
|
loadUserList();
|
||||||
</div>
|
});
|
||||||
<div class="form-group">
|
|
||||||
<div>
|
|
||||||
<button type="submit" class="btn btn-primary-outline">Submit</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</fieldset>
|
function loadUserList() {
|
||||||
</form>
|
$('#users').html("");
|
||||||
</div>
|
var url = "getusers";
|
||||||
|
$.ajax({
|
||||||
|
type: "Get",
|
||||||
<script>
|
url: url,
|
||||||
$(function () {
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
var base = '@Html.GetBaseUrl()';
|
|
||||||
|
$('#users').html("");
|
||||||
if ($('#PlexAuthToken')) {
|
if(!response.result){
|
||||||
loadUserList();
|
generateNotify(response.message,"danger");
|
||||||
}
|
$('#users').append("<option>Error!</option>");
|
||||||
|
return;
|
||||||
$('#refreshUsers').click(function (e) {
|
}
|
||||||
e.preventDefault();
|
if (response.users.length > 0) {
|
||||||
loadUserList();
|
$(response.users).each(function () {
|
||||||
});
|
$('#users').append("<option>" + this + "</option>");
|
||||||
|
});
|
||||||
$('#requestToken').click(function (e) {
|
} else {
|
||||||
e.preventDefault();
|
$('#users').append("<option>No Users, Please refresh!</option>");
|
||||||
var $form = $("#mainForm");
|
}
|
||||||
$.ajax({
|
},
|
||||||
type: $form.prop("method"),
|
error: function (e) {
|
||||||
url: "requestauth",
|
console.log(e);
|
||||||
data: $form.serialize(),
|
generateNotify("Something went wrong!", "danger");
|
||||||
dataType: "json",
|
$('#users').html("");
|
||||||
success: function (response) {
|
$('#users').append("<option>Error!</option>");
|
||||||
console.log(response);
|
}
|
||||||
if (response.result === true) {
|
});
|
||||||
generateNotify("Success!", "success");
|
|
||||||
$('#authToken').val(response.authToken);
|
}
|
||||||
} else {
|
|
||||||
generateNotify(response.message, "warning");
|
|
||||||
}
|
});
|
||||||
},
|
|
||||||
error: function (e) {
|
|
||||||
console.log(e);
|
|
||||||
generateNotify("Something went wrong!", "danger");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function loadUserList() {
|
|
||||||
$('#users').html("");
|
|
||||||
var url = "getusers";
|
|
||||||
$.ajax({
|
|
||||||
type: "Get",
|
|
||||||
url: url,
|
|
||||||
dataType: "json",
|
|
||||||
success: function (response) {
|
|
||||||
|
|
||||||
$('#users').html("");
|
|
||||||
if(!response.result){
|
|
||||||
generateNotify(response.message,"danger");
|
|
||||||
$('#users').append("<option>Error!</option>");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (response.users.length > 0) {
|
|
||||||
$(response.users).each(function () {
|
|
||||||
$('#users').append("<option>" + this + "</option>");
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$('#users').append("<option>No Users, Please refresh!</option>");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
error: function (e) {
|
|
||||||
console.log(e);
|
|
||||||
generateNotify("Something went wrong!", "danger");
|
|
||||||
$('#users').html("");
|
|
||||||
$('#users').append("<option>Error!</option>");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
@ -1,153 +1,201 @@
|
|||||||
@using PlexRequests.UI.Helpers
|
@using PlexRequests.UI.Helpers
|
||||||
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<PlexRequests.Core.SettingModels.PlexSettings>
|
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<PlexRequests.Core.SettingModels.PlexSettings>
|
||||||
@Html.Partial("_Sidebar")
|
@Html.Partial("_Sidebar")
|
||||||
@{
|
@{
|
||||||
int port;
|
int port;
|
||||||
if (Model.Port == 0)
|
if (Model.Port == 0)
|
||||||
{
|
{
|
||||||
port = 32400;
|
port = 32400;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
port = Model.Port;
|
port = Model.Port;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
<div class="col-sm-8 col-sm-push-1">
|
<div class="col-sm-8 col-sm-push-1">
|
||||||
<form class="form-horizontal" method="POST" id="mainForm">
|
<form class="form-horizontal" method="POST" id="mainForm">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Plex Settings</legend>
|
<legend>Plex Settings</legend>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="Ip" class="control-label">Plex Hostname or IP</label>
|
<label for="Ip" class="control-label">Plex Hostname or IP</label>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip">
|
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="portNumber" class="control-label">Port</label>
|
<label for="portNumber" class="control-label">Port</label>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
|
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
|
||||||
@if (Model.Ssl)
|
@if (Model.Ssl)
|
||||||
{
|
{
|
||||||
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><label for="Ssl">SSL</label>
|
<input type="checkbox" id="Ssl" name="Ssl" checked="checked"><label for="Ssl">SSL</label>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<input type="checkbox" id="Ssl" name="Ssl"><label for="Ssl">SSL</label>
|
<input type="checkbox" id="Ssl" name="Ssl"><label for="Ssl">SSL</label>
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="checkbox">
|
<div class="checkbox">
|
||||||
|
|
||||||
@if (Model.AdvancedSearch)
|
@if (Model.AdvancedSearch)
|
||||||
{
|
{
|
||||||
<input type="checkbox" id="AdvancedSearch" name="AdvancedSearch" checked="checked"><label for="AdvancedSearch">Use Advanced Search</label>
|
<input type="checkbox" id="AdvancedSearch" name="AdvancedSearch" checked="checked"><label for="AdvancedSearch">Use Advanced Search</label>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<input type="checkbox" id="AdvancedSearch" name="AdvancedSearch"><label for="AdvancedSearch">Use Advanced Search</label>
|
<input type="checkbox" id="AdvancedSearch" name="AdvancedSearch"><label for="AdvancedSearch">Use Advanced Search</label>
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<small>If enabled we will be able to have a 100% accurate match, but we will be querying Plex for every single item in your library. So if you have a big library then this could take some time.</small>
|
<small>If enabled we will be able to have a 100% accurate match, but we will be querying Plex for every single item in your library. So if you have a big library then this could take some time.</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="SubDir" class="control-label">Plex SubDirectory</label>
|
<label for="SubDir" class="control-label">Plex SubDirectory</label>
|
||||||
<div>
|
<div>
|
||||||
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
|
<input type="text" class="form-control form-control-custom " id="SubDir" name="SubDir" value="@Model.SubDir">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
|
||||||
<div>
|
<div class="form-group">
|
||||||
<button id="testPlex" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button>
|
<label for="authToken" class="control-label">Plex Authorization Token</label>
|
||||||
</div>
|
<div class="">
|
||||||
</div>
|
<input type="text" class="form-control-custom form-control" id="authToken" name="PlexAuthToken" placeholder="Plex Auth Token" value="@Model.PlexAuthToken">
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
</div>
|
||||||
<div>
|
|
||||||
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
|
<div class="form-group">
|
||||||
</div>
|
<label for="username" class="control-label">Username and Password</label>
|
||||||
</div>
|
<div>
|
||||||
</fieldset>
|
<input type="text" class="form-control form-control-custom" id="username" name="Username" placeholder="username">
|
||||||
</form>
|
</div>
|
||||||
</div>
|
<br />
|
||||||
|
<div>
|
||||||
|
<input type="password" class="form-control form-control-custom" id="password" name="Password" placeholder="Password">
|
||||||
<script>
|
</div>
|
||||||
$(function () {
|
</div>
|
||||||
var base = '@Html.GetBaseUrl()';
|
<div class="form-group">
|
||||||
|
<div class="">
|
||||||
$('#testPlex').click(function (e) {
|
<button id="requestToken" class="btn btn-primary-outline">Request Token <i class="fa fa-key"></i></button>
|
||||||
e.preventDefault();
|
</div>
|
||||||
var url = createBaseUrl(base, '/test/plex');
|
</div>
|
||||||
var $form = $("#mainForm");
|
|
||||||
|
<div class="form-group">
|
||||||
$('#spinner').attr("class", "fa fa-spinner fa-spin");
|
<div>
|
||||||
$.ajax({
|
<button id="testPlex" type="submit" class="btn btn-primary-outline">Test Connectivity <div id="spinner"></div></button>
|
||||||
type: $form.prop("method"),
|
</div>
|
||||||
url: url,
|
</div>
|
||||||
data: $form.serialize(),
|
|
||||||
dataType: "json",
|
<div class="form-group">
|
||||||
success: function (response) {
|
<div>
|
||||||
$('#spinner').attr("class", "");
|
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
|
||||||
console.log(response);
|
</div>
|
||||||
if (response.result === true) {
|
</div>
|
||||||
generateNotify(response.message, "success");
|
</fieldset>
|
||||||
|
</form>
|
||||||
$('#spinner').attr("class", "fa fa-check");
|
</div>
|
||||||
$('#authToken').val(response.authToken);
|
|
||||||
} else {
|
|
||||||
generateNotify(response.message, "warning");
|
<script>
|
||||||
$('#spinner').attr("class", "fa fa-times");
|
$(function () {
|
||||||
}
|
var base = '@Html.GetBaseUrl()';
|
||||||
},
|
|
||||||
error: function (e) {
|
$('#testPlex').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
$('#spinner').attr("class", "fa fa-times");
|
var url = createBaseUrl(base, '/test/plex');
|
||||||
console.log(e);
|
var $form = $("#mainForm");
|
||||||
generateNotify("Something went wrong!", "danger");
|
|
||||||
}
|
$('#spinner').attr("class", "fa fa-spinner fa-spin");
|
||||||
});
|
$.ajax({
|
||||||
});
|
type: $form.prop("method"),
|
||||||
|
url: url,
|
||||||
$('#save').click(function (e) {
|
data: $form.serialize(),
|
||||||
e.preventDefault();
|
dataType: "json",
|
||||||
var port = $('#portNumber').val();
|
success: function (response) {
|
||||||
if (isNaN(port)) {
|
$('#spinner').attr("class", "");
|
||||||
generateNotify("You must specify a Port.", "warning");
|
console.log(response);
|
||||||
return;
|
if (response.result === true) {
|
||||||
}
|
generateNotify(response.message, "success");
|
||||||
|
|
||||||
var $form = $("#mainForm");
|
$('#spinner').attr("class", "fa fa-check");
|
||||||
$.ajax({
|
$('#authToken').val(response.authToken);
|
||||||
type: $form.prop("method"),
|
} else {
|
||||||
data: $form.serialize(),
|
generateNotify(response.message, "warning");
|
||||||
url: $form.prop("action"),
|
$('#spinner').attr("class", "fa fa-times");
|
||||||
dataType: "json",
|
}
|
||||||
success: function (response) {
|
},
|
||||||
if (response.result === true) {
|
error: function (e) {
|
||||||
generateNotify(response.message, "success");
|
|
||||||
} else {
|
$('#spinner').attr("class", "fa fa-times");
|
||||||
generateNotify(response.message, "warning");
|
console.log(e);
|
||||||
}
|
generateNotify("Something went wrong!", "danger");
|
||||||
},
|
}
|
||||||
error: function (e) {
|
});
|
||||||
console.log(e);
|
});
|
||||||
generateNotify("Something went wrong!", "danger");
|
|
||||||
}
|
$('#requestToken').click(function (e) {
|
||||||
});
|
e.preventDefault();
|
||||||
});
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
});
|
type: $form.prop("method"),
|
||||||
|
url: "requestauth",
|
||||||
|
data: $form.serialize(),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
console.log(response);
|
||||||
|
if (response.result === true) {
|
||||||
|
generateNotify("Success!", "success");
|
||||||
|
$('#authToken').val(response.authToken);
|
||||||
|
} else {
|
||||||
|
generateNotify(response.message, "warning");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#save').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var port = $('#portNumber').val();
|
||||||
|
if (isNaN(port)) {
|
||||||
|
generateNotify("You must specify a Port.", "warning");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var $form = $("#mainForm");
|
||||||
|
$.ajax({
|
||||||
|
type: $form.prop("method"),
|
||||||
|
data: $form.serialize(),
|
||||||
|
url: $form.prop("action"),
|
||||||
|
dataType: "json",
|
||||||
|
success: function (response) {
|
||||||
|
if (response.result === true) {
|
||||||
|
generateNotify(response.message, "success");
|
||||||
|
} else {
|
||||||
|
generateNotify(response.message, "warning");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (e) {
|
||||||
|
console.log(e);
|
||||||
|
generateNotify("Something went wrong!", "danger");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
</script>
|
</script>
|
Loading…
Reference in new issue