pull/470/head
TidusJar 8 years ago
parent 67df79bcca
commit ce7305faf0

@ -34,6 +34,7 @@ namespace PlexRequests.Core.SettingModels
public string EmailSender { get; set; }
public string EmailUsername { get; set; }
public bool Enabled { get; set; }
public bool Authentication { get; set; }
public bool EnableUserEmailNotifications { get; set; }
public string RecipientEmail { get; set; }
}

@ -1,47 +1,45 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: SonarrValidator.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 FluentValidation;
using PlexRequests.Core.SettingModels;
namespace PlexRequests.UI.Validators
{
public class EmailNotificationSettingsValidator : AbstractValidator<EmailNotificationSettings>
{
public EmailNotificationSettingsValidator()
{
RuleFor(request => request.EmailHost).NotEmpty().WithMessage("You must specify a Host name.");
RuleFor(request => request.EmailPort).NotEmpty().WithMessage("You must specify a Port.");
RuleFor(request => request.RecipientEmail).NotEmpty().WithMessage("You must specify a Recipient.");
RuleFor(request => request.RecipientEmail).EmailAddress().WithMessage("You must specify a valid Recipient.");
RuleFor(request => request.EmailUsername).NotEmpty().WithMessage("You must specify a Username.");
RuleFor(request => request.EmailPassword).NotEmpty().WithMessage("You must specify a valid password.");
RuleFor(request => request.EmailSender).EmailAddress().WithMessage("You must specify a valid Email for the email sender.");
RuleFor(request => request.EmailSender).NotEmpty().WithMessage("You must specify a Email Sender.");
}
}
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: SonarrValidator.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 FluentValidation;
using PlexRequests.Core.SettingModels;
namespace PlexRequests.UI.Validators
{
public class EmailNotificationSettingsValidator : AbstractValidator<EmailNotificationSettings>
{
public EmailNotificationSettingsValidator()
{
RuleFor(request => request.EmailHost).NotEmpty().WithMessage("You must specify a Host name.");
RuleFor(request => request.EmailPort).NotEmpty().WithMessage("You must specify a Port.");
RuleFor(request => request.RecipientEmail).NotEmpty().WithMessage("You must specify a Recipient.");
RuleFor(request => request.RecipientEmail).EmailAddress().WithMessage("You must specify a valid Recipient.");
RuleFor(request => request.EmailSender).EmailAddress().WithMessage("You must specify a valid Email for the email sender.");
RuleFor(request => request.EmailSender).NotEmpty().WithMessage("You must specify a Email Sender.");
}
}
}

@ -18,7 +18,7 @@
<form class="form-horizontal" method="POST" id="mainForm">
<fieldset>
<legend>Email Notifications</legend>
 
<div class="form-group">
<div class="checkbox">
@ -33,21 +33,35 @@
</div>
</div>
<div class="form-group">
<div class="checkbox">
<div class="form-group">
<div class="checkbox">
@if (Model.EnableUserEmailNotifications)
{
<input type="checkbox" id="EnableUserEmailNotifications" name="EnableUserEmailNotifications" checked="checked"><label for="EnableUserEmailNotifications">Enable user email notifications</label>
}
else
{
<input type="checkbox" id="EnableUserEmailNotifications" name="EnableUserEmailNotifications"><label for="EnableUserEmailNotifications">Enable user email notifications</label>
}
@if (Model.EnableUserEmailNotifications)
{
<input type="checkbox" id="EnableUserEmailNotifications" name="EnableUserEmailNotifications" checked="checked"><label for="EnableUserEmailNotifications">Enable user email notifications</label>
}
else
{
<input type="checkbox" id="EnableUserEmailNotifications" name="EnableUserEmailNotifications"><label for="EnableUserEmailNotifications">Enable user email notifications</label>
}
</div>
</div>
<div class="form-group">
<div class="checkbox">
@if (Model.Authentication)
{
<input type="checkbox" id="Authentication" name="Authentication" checked="checked"><label for="Authentication">Enable SMTP Authentication</label>
}
else
{
<input type="checkbox" id="Authentication" name="Authentication"><label for="Authentication">Enable SMTP Authentication</label>
}
</div>
</div>
<small>Please note that if user notifications is enabled, the email will get sent with the SMTP set-up below.</small>
</div>
<small>Please note that if user notifications is enabled, the email will get sent with the SMTP set-up below.</small>
<div class="form-group">
<label for="EmailHost" class="control-label">SMTP Host name or IP</label>
<div class="">
@ -144,6 +158,15 @@
<script>
$(function () {
var auth = $('#Authentication').prop('checked');
ChangeUsernameAndPassword(auth);
$("#Authentication")
.change(function(e) {
ChangeUsernameAndPassword(auth);
});
var base = '@Html.GetBaseUrl()';
$('#save').click(function (e) {
e.preventDefault();
@ -207,6 +230,17 @@
}
});
});
function ChangeUsernameAndPassword(checked) {
var $userName = $('#EmailUsername');
var $password = $('#EmailPassword');
if (!checked) {
$userName.attr('disabled', 'disabled');
$password.attr('disabled', 'disabled');
} else {
$userName.removeAttr('disabled', 'disabled');
$password.removeAttr('disabled', 'disabled');
}
};
});

Loading…
Cancel
Save