mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 15:56:05 -07:00
Moved Newsletter Settings to its own page
This commit is contained in:
parent
c1ea2ecc65
commit
626decacb1
9 changed files with 152 additions and 22 deletions
|
@ -89,6 +89,7 @@
|
|||
<Compile Include="SettingModels\ExternalSettings.cs" />
|
||||
<Compile Include="SettingModels\HeadphonesSettings.cs" />
|
||||
<Compile Include="SettingModels\LandingPageSettings.cs" />
|
||||
<Compile Include="SettingModels\NewsletterSettings.cs" />
|
||||
<Compile Include="SettingModels\NotificationSettings.cs" />
|
||||
<Compile Include="SettingModels\NotificationSettingsV2.cs" />
|
||||
<Compile Include="SettingModels\RequestSettings.cs" />
|
||||
|
|
38
PlexRequests.Core/SettingModels/NewsletterSettings.cs
Normal file
38
PlexRequests.Core/SettingModels/NewsletterSettings.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2016 Jamie Rees
|
||||
// File: NewsletterSettings.cs
|
||||
// Created By: Jim MacKenzie
|
||||
//
|
||||
// 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.Collections.Generic;
|
||||
using PlexRequests.Core.Models;
|
||||
using PlexRequests.Core.Notification;
|
||||
|
||||
namespace PlexRequests.Core.SettingModels
|
||||
{
|
||||
public class NewletterSettings : Settings
|
||||
{
|
||||
public bool SendRecentlyAddedEmail { get; set; }
|
||||
}
|
||||
}
|
|
@ -58,7 +58,6 @@ namespace PlexRequests.Core.SettingModels
|
|||
public bool Wizard { get; set; }
|
||||
public bool DisableTvRequestsByEpisode { get; set; }
|
||||
public bool DisableTvRequestsBySeason { get; set; }
|
||||
public bool SendRecentlyAddedEmail { get; set; }
|
||||
|
||||
public string CustomDonationUrl { get; set; }
|
||||
public bool EnableCustomDonationUrl { get; set; }
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace PlexRequests.Services.Jobs
|
|||
public class RecentlyAdded : IJob, IRecentlyAdded
|
||||
{
|
||||
public RecentlyAdded(IPlexApi api, ISettingsService<PlexSettings> plexSettings, ISettingsService<EmailNotificationSettings> email,
|
||||
ISettingsService<ScheduledJobsSettings> scheduledService, IJobRecord rec, ISettingsService<PlexRequestSettings> plexRequest)
|
||||
ISettingsService<ScheduledJobsSettings> scheduledService, IJobRecord rec, ISettingsService<NewletterSettings> plexRequest)
|
||||
{
|
||||
JobRecord = rec;
|
||||
Api = api;
|
||||
|
@ -63,7 +63,7 @@ namespace PlexRequests.Services.Jobs
|
|||
private readonly TheMovieDbApi _movieApi = new TheMovieDbApi();
|
||||
private ISettingsService<PlexSettings> PlexSettings { get; }
|
||||
private ISettingsService<EmailNotificationSettings> EmailSettings { get; }
|
||||
private ISettingsService<PlexRequestSettings> PlexRequestSettings { get; }
|
||||
private ISettingsService<NewletterSettings> PlexRequestSettings { get; }
|
||||
private ISettingsService<ScheduledJobsSettings> ScheduledJobsSettings { get; }
|
||||
private IJobRecord JobRecord { get; }
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@ namespace PlexRequests.UI.Modules
|
|||
private ISettingsService<PushbulletNotificationSettings> PushbulletService { get; }
|
||||
private ISettingsService<PushoverNotificationSettings> PushoverService { get; }
|
||||
private ISettingsService<HeadphonesSettings> HeadphonesService { get; }
|
||||
private ISettingsService<NewletterSettings> NewsLetterService { get; }
|
||||
private ISettingsService<LogSettings> LogService { get; }
|
||||
private IPlexApi PlexApi { get; }
|
||||
private ISonarrApi SonarrApi { get; }
|
||||
|
@ -112,6 +113,7 @@ namespace PlexRequests.UI.Modules
|
|||
PushbulletApi pbApi,
|
||||
ICouchPotatoApi cpApi,
|
||||
ISettingsService<PushoverNotificationSettings> pushoverSettings,
|
||||
ISettingsService<NewletterSettings> newsletter,
|
||||
IPushoverApi pushoverApi,
|
||||
IRepository<LogEntity> logsRepo,
|
||||
INotificationService notify,
|
||||
|
@ -139,6 +141,7 @@ namespace PlexRequests.UI.Modules
|
|||
PushoverApi = pushoverApi;
|
||||
NotificationService = notify;
|
||||
HeadphonesService = headphones;
|
||||
NewsLetterService = newsletter;
|
||||
LogService = logs;
|
||||
Cache = cache;
|
||||
SlackSettings = slackSettings;
|
||||
|
@ -200,6 +203,9 @@ namespace PlexRequests.UI.Modules
|
|||
Get["/headphones"] = _ => Headphones();
|
||||
Post["/headphones"] = _ => SaveHeadphones();
|
||||
|
||||
Get["/newsletter"] = _ => Newsletter();
|
||||
Post["/newsletter"] = _ => SaveNewsletter();
|
||||
|
||||
Post["/createapikey"] = x => CreateApiKey();
|
||||
|
||||
Post["/autoupdate"] = x => AutoUpdate();
|
||||
|
@ -814,6 +820,33 @@ namespace PlexRequests.UI.Modules
|
|||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
|
||||
private Negotiator Newsletter()
|
||||
{
|
||||
var settings = NewsLetterService.GetSettings();
|
||||
return View["NewsletterSettings", settings];
|
||||
}
|
||||
|
||||
private Response SaveNewsletter()
|
||||
{
|
||||
var settings = this.Bind<NewletterSettings>();
|
||||
|
||||
var valid = this.Validate(settings);
|
||||
if (!valid.IsValid)
|
||||
{
|
||||
var error = valid.SendJsonError();
|
||||
Log.Info("Error validating Headphones settings, message: {0}", error.Message);
|
||||
return Response.AsJson(error);
|
||||
}
|
||||
settings.SendRecentlyAddedEmail = settings.SendRecentlyAddedEmail;
|
||||
var result = NewsLetterService.SaveSettings(settings);
|
||||
|
||||
Log.Info("Saved headphones settings, result: {0}", result);
|
||||
return Response.AsJson(result
|
||||
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Newsletter!" }
|
||||
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
|
||||
}
|
||||
|
||||
|
||||
private Response CreateApiKey()
|
||||
{
|
||||
this.RequiresClaims(UserClaims.Admin);
|
||||
|
|
|
@ -711,6 +711,7 @@
|
|||
<Content Include="Views\Admin\NotificationSettings.cshtml">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="Views\Admin\NewsletterSettings.cshtml" />
|
||||
<None Include="Web.Debug.config">
|
||||
<DependentUpon>web.config</DependentUpon>
|
||||
</None>
|
||||
|
|
76
PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml
Normal file
76
PlexRequests.UI/Views/Admin/NewsletterSettings.cshtml
Normal file
|
@ -0,0 +1,76 @@
|
|||
@using System.Linq
|
||||
@using PlexRequests.Core.Models
|
||||
@using PlexRequests.UI.Helpers
|
||||
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<PlexRequests.Core.SettingModels.NewletterSettings>
|
||||
@Html.Partial("_Sidebar")
|
||||
|
||||
<div class="col-sm-8 col-sm-push-1">
|
||||
<form class="form-horizontal" method="POST" id="mainForm">
|
||||
<fieldset>
|
||||
<legend>Newsletter Settings</legend>
|
||||
|
||||
<!-- Email Nofication Section -->
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
|
||||
<small>Note: This will require you to setup your email notifications</small>
|
||||
@if (Model.SendRecentlyAddedEmail)
|
||||
{
|
||||
<input type="checkbox" id="SendRecentlyAddedEmail" name="SendRecentlyAddedEmail" checked="checked"><label for="SendRecentlyAddedEmail">Send out a weekly email of recently added content to all your Plex 'Friends'</label>
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="checkbox" id="SendRecentlyAddedEmail" name="SendRecentlyAddedEmail"><label for="SendRecentlyAddedEmail">Send out a weekly email of recently added content to all your Plex 'Friends'</label>
|
||||
}
|
||||
|
||||
</div>
|
||||
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin</button>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<br />
|
||||
<div class="form-group">
|
||||
<div>
|
||||
<button type="submit" id="save" class="btn btn-primary-outline">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Email Nofication Section -->
|
||||
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
|
||||
|
||||
var base = '@Html.GetBaseUrl()';
|
||||
$('#save').click(function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $form = $("#mainForm");
|
||||
var data = $form.serialize();
|
||||
|
||||
$.ajax({
|
||||
type: $form.prop("method"),
|
||||
data: data,
|
||||
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>
|
|
@ -76,25 +76,6 @@
|
|||
</div>
|
||||
<br/>
|
||||
<br/>
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
|
||||
<small>Note: This will require you to setup your email notifications</small>
|
||||
@if (Model.SendRecentlyAddedEmail)
|
||||
{
|
||||
<input type="checkbox" id="SendRecentlyAddedEmail" name="SendRecentlyAddedEmail" checked="checked"><label for="SendRecentlyAddedEmail">Send out a weekly email of recently added content to all your Plex 'Friends'</label>
|
||||
}
|
||||
else
|
||||
{
|
||||
<input type="checkbox" id="SendRecentlyAddedEmail" name="SendRecentlyAddedEmail"><label for="SendRecentlyAddedEmail">Send out a weekly email of recently added content to all your Plex 'Friends'</label>
|
||||
}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin</button>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="checkbox">
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
@Html.GetSidebarUrl(Context, "/admin/sonarr", "Sonarr")
|
||||
@Html.GetSidebarUrl(Context, "/admin/sickrage", "SickRage")
|
||||
@Html.GetSidebarUrl(Context, "/admin/headphones", "Headphones (Beta)")
|
||||
@Html.GetSidebarUrl(Context, "/admin/newsletter", "Newsletter Settings")
|
||||
@Html.GetSidebarUrl(Context, "/admin/emailnotification", "Email Notifications")
|
||||
@Html.GetSidebarUrl(Context, "/admin/pushbulletnotification", "Pushbullet Notifications")
|
||||
@Html.GetSidebarUrl(Context, "/admin/pushovernotification", "Pushover Notifications")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue