added settings page for #8

pull/13/head
tidusjar 9 years ago
parent 5153afd3f1
commit 334a6f3d8e

@ -71,6 +71,7 @@ namespace PlexRequests.UI
container.Register<ISettingsService<AuthenticationSettings>, SettingsServiceV2<AuthenticationSettings>>();
container.Register<ISettingsService<PlexSettings>, SettingsServiceV2<PlexSettings>>();
container.Register<ISettingsService<SonarrSettings>, SettingsServiceV2<SonarrSettings>>();
container.Register<ISettingsService<EmailNotificationSettings>, SettingsServiceV2<EmailNotificationSettings>>();
container.Register<IRepository<RequestedModel>, GenericRepository<RequestedModel>>();
container.Register<IRequestService, RequestService>();

@ -51,6 +51,7 @@ namespace PlexRequests.UI.Modules
private ISettingsService<AuthenticationSettings> AuthService { get; set; }
private ISettingsService<PlexSettings> PlexService { get; set; }
private ISettingsService<SonarrSettings> SonarrService { get; set; }
private ISettingsService<EmailNotificationSettings> EmailService { get; set; }
private ISonarrApi SonarrApi { get; set; }
private static Logger Log = LogManager.GetCurrentClassLogger();
@ -59,7 +60,8 @@ namespace PlexRequests.UI.Modules
ISettingsService<AuthenticationSettings> auth
, ISettingsService<PlexSettings> plex,
ISettingsService<SonarrSettings> sonarr,
ISonarrApi sonarrApi) : base("admin")
ISonarrApi sonarrApi,
ISettingsService<EmailNotificationSettings> email) : base("admin")
{
RpService = rpService;
CpService = cpService;
@ -67,10 +69,11 @@ namespace PlexRequests.UI.Modules
PlexService = plex;
SonarrService = sonarr;
SonarrApi = sonarrApi;
EmailService = email;
//#if !DEBUG
#if !DEBUG
this.RequiresAuthentication();
//#endif
#endif
Get["/"] = _ => Admin();
Get["/authentication"] = _ => Authentication();
@ -92,6 +95,9 @@ namespace PlexRequests.UI.Modules
Post["/sonarr"] = _ => SaveSonarr();
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
Get["/emailnotification"] = _ => EmailNotifications();
Post["/emailnotification"] = _ => SaveEmailNotifications();
}
private Negotiator Authentication()
@ -239,5 +245,21 @@ namespace PlexRequests.UI.Modules
return Response.AsJson(profiles);
}
private Negotiator EmailNotifications()
{
var settings = EmailService.GetSettings();
return View["EmailNotifications",settings];
}
private Response SaveEmailNotifications()
{
var settings = this.Bind<EmailNotificationSettings>();
Log.Trace(settings.DumpJson());
var result = EmailService.SaveSettings(settings);
Log.Info("Saved email settings, result: {0}", result);
return Context.GetRedirect("~/admin/emailnotification");
}
}
}

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

@ -26,6 +26,9 @@
#endregion
using System;
using FluentScheduler;
using NLog;
using Owin;
using PlexRequests.UI.Jobs;
using TaskFactory = FluentScheduler.TaskFactory;
@ -34,6 +37,8 @@ namespace PlexRequests.UI
{
public class Startup
{
private static Logger Log = LogManager.GetCurrentClassLogger();
public void Configuration(IAppBuilder app)
{
try
@ -44,7 +49,7 @@ namespace PlexRequests.UI
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
Log.Fatal(exception);
throw;
}

@ -0,0 +1,92 @@
@Html.Partial("_Sidebar")
@{
int port;
if (Model.EmailPort == 0)
{
port = 25;
}
else
{
port = Model.EmailPort;
}
}
<div class="col-sm-8 col-sm-push-1">
<form class="form-horizontal" method="POST" id="mainForm">
<fieldset>
<legend>Email Notifications</legend>
<div class="form-group">
<div class="checkbox">
<label>
@if (Model.Enabled)
{
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><text>Enabled</text>
}
else
{
<input type="checkbox" id="Enabled" name="Enabled"><text>Enabled</text>
}
</label>
</div>
</div>
<div class="form-group">
<label for="EmailHost" class="control-label">SMTP Hostname or IP</label>
<div class="">
<input type="text" class="form-control form-control-custom " id="EmailHost" name="EmailHost" placeholder="localhost" value="@Model.EmailHost">
</div>
</div>
<div class="form-group">
<label for="EmailPort" class="control-label">SMTP Port</label>
<div class="">
<input type="text" class="form-control form-control-custom " id="EmailPort" name="EmailPort" placeholder="Port Number" value="@port">
</div>
</div>
<div class="form-group">
<label for="RecipientEmail" class="control-label">Email Recipient</label>
<div>
<input type="text" class="form-control form-control-custom " id="RecipientEmail" name="RecipientEmail" value="@Model.RecipientEmail">
</div>
</div>
<div class="form-group">
<div class="checkbox">
<label>
@if (Model.EmailAuthentication)
{
<input type="checkbox" id="EmailAuthentication" name="EmailAuthentication" checked="checked"><text>Authenticate</text>
}
else
{
<input type="checkbox" id="EmailAuthentication" name="EmailAuthentication"><text>Authenticate</text>
}
</label>
</div>
</div>
<div class="form-group">
<label for="EmailUsername" class="control-label">Username</label>
<div>
<input type="text" class="form-control form-control-custom " id="EmailUsername" name="EmailUsername" value="@Model.EmailUsername">
</div>
</div>
<div class="form-group">
<label for="EmailPassword" class="control-label">Password</label>
<div>
<input type="password" class="form-control form-control-custom " id="EmailPassword" name="EmailPassword" value="@Model.EmailPassword">
</div>
</div>
<div class="form-group">
<div>
<button type="submit" class="btn btn-primary-outline">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>

@ -43,8 +43,16 @@
else
{
<a class="list-group-item" href="/admin/sonarr">Sonarr Settings</a>
}
@*<a class="list-group-item" href="/admin/sickbeard">Sickbeard Settings</a>*@
@if (Context.Request.Path == "/admin/emailnotification")
{
<a class="list-group-item active" href="/admin/emailnotification">Email Notifications</a>
}
else
{
<a class="list-group-item" href="/admin/emailnotification">Email Notifications</a>
}
</div>
</div>
Loading…
Cancel
Save