few small changes, added plex settings

pull/13/head
Jamie Rees 9 years ago
parent f2399d6407
commit b9dd08a8bc

@ -67,6 +67,7 @@
<Compile Include="ISettingsService.cs" />
<Compile Include="RequestService.cs" />
<Compile Include="SettingModels\AuthenticationSettings.cs" />
<Compile Include="SettingModels\PlexSettings.cs" />
<Compile Include="SettingModels\SonarrSettings.cs" />
<Compile Include="SettingModels\SickRageSettings.cs" />
<Compile Include="SettingModels\CouchPotatoSettings.cs" />

@ -0,0 +1,49 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: CouchPotatoSettings.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System;
using Newtonsoft.Json;
using PlexRequests.Helpers;
namespace PlexRequests.Core.SettingModels
{
public class PlexSettings : Settings
{
public string Ip { get; set; }
public int Port { get; set; }
[JsonIgnore]
public Uri FullUri
{
get
{
var formatted = Ip.ReturnUri(Port);
return formatted;
}
}
}
}

@ -60,6 +60,7 @@ namespace PlexRequests.UI
container.Register<ISettingsService<PlexRequestSettings>, SettingsServiceV2<PlexRequestSettings>>();
container.Register<ISettingsService<CouchPotatoSettings>, SettingsServiceV2<CouchPotatoSettings>>();
container.Register<ISettingsService<AuthenticationSettings>, SettingsServiceV2<AuthenticationSettings>>();
container.Register<ISettingsService<PlexSettings>, SettingsServiceV2<PlexSettings>>();
container.Register<IRepository<RequestedModel>, GenericRepository<RequestedModel>>();
base.ConfigureRequestContainer(container, context);

@ -48,13 +48,16 @@ namespace PlexRequests.UI.Modules
private ISettingsService<PlexRequestSettings> RpService { get; set; }
private ISettingsService<CouchPotatoSettings> CpService { get; set; }
private ISettingsService<AuthenticationSettings> AuthService { get; set; }
private ISettingsService<PlexSettings> PlexService { get; set; }
private static Logger Log = LogManager.GetCurrentClassLogger();
public AdminModule(ISettingsService<PlexRequestSettings> rpService, ISettingsService<CouchPotatoSettings> cpService, ISettingsService<AuthenticationSettings> auth) : base("admin")
public AdminModule(ISettingsService<PlexRequestSettings> rpService, ISettingsService<CouchPotatoSettings> cpService, ISettingsService<AuthenticationSettings> auth, ISettingsService<PlexSettings> plex) : base("admin")
{
RpService = rpService;
CpService = cpService;
AuthService = auth;
PlexService = plex;
#if !DEBUG
this.RequiresAuthentication();
#endif
@ -71,6 +74,9 @@ namespace PlexRequests.UI.Modules
Get["/couchpotato"] = _ => CouchPotato();
Post["/couchpotato"] = _ => SaveCouchPotato();
Get["/plex"] = _ => Plex();
Post["/plex"] = _ => SavePlex();
}
private Negotiator Authentication()
@ -180,5 +186,20 @@ namespace PlexRequests.UI.Modules
return Context.GetRedirect("~/admin/couchpotato");
}
private Negotiator Plex()
{
var settings = PlexService.GetSettings();
return View["Plex", settings];
}
private Response SavePlex()
{
var plexSettings = this.Bind<PlexSettings>();
PlexService.SaveSettings(plexSettings);
return Context.GetRedirect("~/admin/plex");
}
}
}

@ -249,6 +249,9 @@
<Content Include="Views\Admin\Authentication.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Views\Admin\Plex.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Web.Debug.config">
<DependentUpon>web.config</DependentUpon>
</None>

@ -0,0 +1,42 @@
@Html.Partial("/Admin/_Sidebar")
@{
int port;
if (Model.Port == 0)
{
port = 32400;
}
else
{
port = Model.Port;
}
}
<div class="col-sm-8">
<form class="form-horizontal" method="POST" id="mainForm">
<fieldset>
<legend>Plex Settings</legend>
<div class="form-group">
<label for="Ip" class="col-lg-2 control-label">Plex Hostname or IP</label>
<div class="col-lg-10">
<input type="text" class="form-control form-control-custom " id="Ip" name="Ip" placeholder="localhost" value="@Model.Ip">
</div>
</div>
<div class="form-group">
<label for="portNumber" class="col-lg-2 control-label">Port</label>
<div class="col-lg-10">
<input type="text" class="form-control form-control-custom " id="portNumber" name="Port" placeholder="Port Number" value="@port">
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>

@ -2,6 +2,7 @@
<div class="list-group table-of-contents">
<a class="list-group-item" href="/admin">Plex Request Settings</a>
<a class="list-group-item" href="/admin/authentication">Authentication</a>
<a class="list-group-item" href="/admin/plex">Plex Settings</a>
<a class="list-group-item" href="/admin/couchpotato">CouchPotato Settings</a>
<a class="list-group-item" href="/admin/sonarr">Sonarr Settings</a>
<a class="list-group-item" href="/admin/sickbeard">Sickbeard Settings</a>

@ -1,19 +1,34 @@
<form method="POST" id="loginForm">
<label>
Username</label> <input class="form-control" type="text" name="Username"/>
<br/>
@if (Model.UsePassword)
{
<label> Password </label>
<input class="form-control" name="Password" type="password"/>
}
<br/>
<input id="loginBtn" class="btn btn-success" type="submit" value="Login"/>
<h1>Login</h1>
<div class="row">
<label class="col-md-5">
Want to watch a movie or tv show but it's not currently on Plex?
Login below with your Plex.tv username and password! <span title="Your login details are only used to authenticate your Plex account."><i class="fa fa-question-circle"></i></span>
</label>
</div>
<form method="POST" id="loginForm">
<div class="col-md-2">
<label style="padding-top: 8px"> Username </label>
</div>
<div class="col-md-5">
<input class="form-control form-control-custom col-md-5" type="text" name="Username"/>
</div>
<br />
@if (Model.UsePassword)
{
<div class="col-md-2">
<label style="padding-top: 8px"> Password </label>
</div>
<div class="col-md-5">
<input class="form-control form-control-custom col-md-5" name="Password" type="password" />
</div>
}
<br />
<input id="loginBtn" class="btn btn-success" type="submit" value="Login" />
</form>
<script>
$(function() {
$(function () {
$('#loginBtn').click(function (e) {
e.preventDefault();

Loading…
Cancel
Save