mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
added settings page for #8
This commit is contained in:
parent
5153afd3f1
commit
334a6f3d8e
6 changed files with 136 additions and 5 deletions
|
@ -71,6 +71,7 @@ namespace PlexRequests.UI
|
||||||
container.Register<ISettingsService<AuthenticationSettings>, SettingsServiceV2<AuthenticationSettings>>();
|
container.Register<ISettingsService<AuthenticationSettings>, SettingsServiceV2<AuthenticationSettings>>();
|
||||||
container.Register<ISettingsService<PlexSettings>, SettingsServiceV2<PlexSettings>>();
|
container.Register<ISettingsService<PlexSettings>, SettingsServiceV2<PlexSettings>>();
|
||||||
container.Register<ISettingsService<SonarrSettings>, SettingsServiceV2<SonarrSettings>>();
|
container.Register<ISettingsService<SonarrSettings>, SettingsServiceV2<SonarrSettings>>();
|
||||||
|
container.Register<ISettingsService<EmailNotificationSettings>, SettingsServiceV2<EmailNotificationSettings>>();
|
||||||
container.Register<IRepository<RequestedModel>, GenericRepository<RequestedModel>>();
|
container.Register<IRepository<RequestedModel>, GenericRepository<RequestedModel>>();
|
||||||
container.Register<IRequestService, RequestService>();
|
container.Register<IRequestService, RequestService>();
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ namespace PlexRequests.UI.Modules
|
||||||
private ISettingsService<AuthenticationSettings> AuthService { get; set; }
|
private ISettingsService<AuthenticationSettings> AuthService { get; set; }
|
||||||
private ISettingsService<PlexSettings> PlexService { get; set; }
|
private ISettingsService<PlexSettings> PlexService { get; set; }
|
||||||
private ISettingsService<SonarrSettings> SonarrService { get; set; }
|
private ISettingsService<SonarrSettings> SonarrService { get; set; }
|
||||||
|
private ISettingsService<EmailNotificationSettings> EmailService { get; set; }
|
||||||
private ISonarrApi SonarrApi { get; set; }
|
private ISonarrApi SonarrApi { get; set; }
|
||||||
|
|
||||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
|
@ -59,7 +60,8 @@ namespace PlexRequests.UI.Modules
|
||||||
ISettingsService<AuthenticationSettings> auth
|
ISettingsService<AuthenticationSettings> auth
|
||||||
, ISettingsService<PlexSettings> plex,
|
, ISettingsService<PlexSettings> plex,
|
||||||
ISettingsService<SonarrSettings> sonarr,
|
ISettingsService<SonarrSettings> sonarr,
|
||||||
ISonarrApi sonarrApi) : base("admin")
|
ISonarrApi sonarrApi,
|
||||||
|
ISettingsService<EmailNotificationSettings> email) : base("admin")
|
||||||
{
|
{
|
||||||
RpService = rpService;
|
RpService = rpService;
|
||||||
CpService = cpService;
|
CpService = cpService;
|
||||||
|
@ -67,10 +69,11 @@ namespace PlexRequests.UI.Modules
|
||||||
PlexService = plex;
|
PlexService = plex;
|
||||||
SonarrService = sonarr;
|
SonarrService = sonarr;
|
||||||
SonarrApi = sonarrApi;
|
SonarrApi = sonarrApi;
|
||||||
|
EmailService = email;
|
||||||
|
|
||||||
//#if !DEBUG
|
#if !DEBUG
|
||||||
this.RequiresAuthentication();
|
this.RequiresAuthentication();
|
||||||
//#endif
|
#endif
|
||||||
Get["/"] = _ => Admin();
|
Get["/"] = _ => Admin();
|
||||||
|
|
||||||
Get["/authentication"] = _ => Authentication();
|
Get["/authentication"] = _ => Authentication();
|
||||||
|
@ -92,6 +95,9 @@ namespace PlexRequests.UI.Modules
|
||||||
Post["/sonarr"] = _ => SaveSonarr();
|
Post["/sonarr"] = _ => SaveSonarr();
|
||||||
|
|
||||||
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
|
Post["/sonarrprofiles"] = _ => GetSonarrQualityProfiles();
|
||||||
|
|
||||||
|
Get["/emailnotification"] = _ => EmailNotifications();
|
||||||
|
Post["/emailnotification"] = _ => SaveEmailNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Negotiator Authentication()
|
private Negotiator Authentication()
|
||||||
|
@ -239,5 +245,21 @@ namespace PlexRequests.UI.Modules
|
||||||
return Response.AsJson(profiles);
|
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">
|
<Content Include="Views\Admin\Sonarr.cshtml">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Views\Admin\EmailNotifications.cshtml">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<None Include="Web.Debug.config">
|
<None Include="Web.Debug.config">
|
||||||
<DependentUpon>web.config</DependentUpon>
|
<DependentUpon>web.config</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
#endregion
|
#endregion
|
||||||
using System;
|
using System;
|
||||||
using FluentScheduler;
|
using FluentScheduler;
|
||||||
|
|
||||||
|
using NLog;
|
||||||
|
|
||||||
using Owin;
|
using Owin;
|
||||||
using PlexRequests.UI.Jobs;
|
using PlexRequests.UI.Jobs;
|
||||||
using TaskFactory = FluentScheduler.TaskFactory;
|
using TaskFactory = FluentScheduler.TaskFactory;
|
||||||
|
@ -34,6 +37,8 @@ namespace PlexRequests.UI
|
||||||
{
|
{
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||||
public void Configuration(IAppBuilder app)
|
public void Configuration(IAppBuilder app)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -44,7 +49,7 @@ namespace PlexRequests.UI
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
Console.WriteLine(exception.Message);
|
Log.Fatal(exception);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
92
PlexRequests.UI/Views/Admin/EmailNotifications.cshtml
Normal file
92
PlexRequests.UI/Views/Admin/EmailNotifications.cshtml
Normal file
|
@ -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
|
else
|
||||||
{
|
{
|
||||||
<a class="list-group-item" href="/admin/sonarr">Sonarr Settings</a>
|
<a class="list-group-item" href="/admin/sonarr">Sonarr Settings</a>
|
||||||
|
|
||||||
}
|
}
|
||||||
@*<a class="list-group-item" href="/admin/sickbeard">Sickbeard 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>
|
||||||
</div>
|
</div>
|
Loading…
Add table
Add a link
Reference in a new issue