mirror of https://github.com/Ombi-app/Ombi
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
248 lines
9.9 KiB
248 lines
9.9 KiB
8 years ago
|
@using System.Linq
|
||
8 years ago
|
@using Ombi.UI.Helpers
|
||
|
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Ombi.Core.SettingModels.EmailNotificationSettings>
|
||
8 years ago
|
@Html.Partial("Shared/Partial/_Sidebar")
|
||
8 years ago
|
@{
|
||
|
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">
|
||
8 years ago
|
|
||
|
@if (Model.Enabled)
|
||
|
{
|
||
|
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label>
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
<input type="checkbox" id="Enabled" name="Enabled"><label for="Enabled">Enabled</label>
|
||
|
}
|
||
|
|
||
8 years ago
|
</div>
|
||
|
</div>
|
||
8 years ago
|
|
||
|
<div class="form-group">
|
||
|
<div class="checkbox">
|
||
8 years ago
|
|
||
8 years ago
|
@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>
|
||
8 years ago
|
</div>
|
||
8 years ago
|
|
||
8 years ago
|
<div class="form-group">
|
||
|
<label for="EmailHost" class="control-label">SMTP Host name 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="EmailSender" class="control-label">Email Sender</label>
|
||
|
<div>
|
||
|
<input type="text" class="form-control form-control-custom " id="EmailSender" name="EmailSender" value="@Model.EmailSender">
|
||
|
</div>
|
||
|
</div>
|
||
8 years ago
|
|
||
|
<small>The sender is who the email will be sent from, this can be for any email including user notification emails (if that is enabled).</small>
|
||
8 years ago
|
<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>
|
||
8 years ago
|
<small>The recipient email is used for emails going to the administrator.</small>
|
||
8 years ago
|
|
||
|
|
||
|
|
||
|
<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>
|
||
|
|
||
8 years ago
|
@* <!--Accordion Item-->
|
||
|
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
|
||
|
@for (var i = 0; i < Model.Message.Count; i++)
|
||
|
{
|
||
|
<div class="panel panel-default">
|
||
|
<div class="panel-heading" role="tab" id="@(i)headingOne">
|
||
|
<h4 class="panel-title">
|
||
|
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#@(i)collapseOne" aria-controls="@(i)collapseOne">
|
||
|
@Model.Message[i].NotificationType.ToString()
|
||
|
</a>
|
||
|
</h4>
|
||
8 years ago
|
</div>
|
||
8 years ago
|
<div id="@(i)collapseOne" class="panel-collapse collapse in" role="tabpanel" aria-labelledby="@(i)headingOne">
|
||
|
<div class="panel-body">
|
||
|
<div class="form-group">
|
||
|
<label for="@(Model.Message[i])" class="control-label"> @Model.Message[i].NotificationType.ToString() Subject</label>
|
||
|
<div>
|
||
|
<input type="text" class="form-control form-control-custom " id="@(Model.Message[i].Subject)" name="Message[@(i)].Subject" value="@(Model.Message[i].Subject)">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-group">
|
||
|
<label for="@(Model.Message[i].Body)" class="control-label">@Model.Message[i].NotificationType.ToString() Body</label>
|
||
|
<div>
|
||
|
<input type="text" class="form-control form-control-custom " id="@(Model.Message[i].Body)" name="Message[@(i)].Body" value="@(Model.Message[i].Body)">
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
8 years ago
|
</div>
|
||
|
</div>
|
||
8 years ago
|
}
|
||
|
</div>*@
|
||
8 years ago
|
|
||
8 years ago
|
<div class="form-group">
|
||
|
<div>
|
||
|
<button id="testEmail" type="submit" class="btn btn-primary-outline">Test <div id="spinner"></div></button>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="form-group">
|
||
|
<div>
|
||
|
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</fieldset>
|
||
8 years ago
|
|
||
8 years ago
|
</form>
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
$(function () {
|
||
|
|
||
8 years ago
|
var auth = $('#Authentication').prop('checked');
|
||
|
changeUsernameAndPassword(auth);
|
||
8 years ago
|
|
||
|
|
||
8 years ago
|
$("#Authentication")
|
||
|
.change(function () {
|
||
|
auth = $('#Authentication').prop('checked');
|
||
|
changeUsernameAndPassword(auth);
|
||
|
});
|
||
8 years ago
|
|
||
8 years ago
|
var base = '@Html.GetBaseUrl()';
|
||
|
$('#save').click(function (e) {
|
||
|
e.preventDefault();
|
||
|
var port = $('#EmailPort').val();
|
||
|
if (isNaN(port)) {
|
||
|
generateNotify("You must specify a valid Port.", "warning");
|
||
|
return;
|
||
|
}
|
||
8 years ago
|
|
||
8 years ago
|
var $form = $("#mainForm");
|
||
8 years ago
|
var data = $form.serialize();
|
||
|
|
||
8 years ago
|
$.ajax({
|
||
|
type: $form.prop("method"),
|
||
8 years ago
|
data: data,
|
||
8 years ago
|
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");
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
8 years ago
|
$('#testEmail').click(function (e) {
|
||
|
$('#spinner').attr("class", "fa fa-spinner fa-spin");
|
||
8 years ago
|
|
||
|
var url = createBaseUrl(base, '/admin/testemailnotification');
|
||
|
e.preventDefault();
|
||
|
var port = $('#EmailPort').val();
|
||
|
if (isNaN(port)) {
|
||
|
generateNotify("You must specify a valid Port.", "warning");
|
||
|
return;
|
||
|
}
|
||
|
var $form = $("#mainForm");
|
||
|
$.ajax({
|
||
|
type: $form.prop("method"),
|
||
|
data: $form.serialize(),
|
||
|
url: url,
|
||
|
dataType: "json",
|
||
|
success: function (response) {
|
||
|
if (response.result === true) {
|
||
8 years ago
|
$('#spinner').attr("class", "fa fa-check");
|
||
8 years ago
|
generateNotify(response.message, "success");
|
||
|
} else {
|
||
8 years ago
|
$('#spinner').attr("class", "fa fa-times");
|
||
8 years ago
|
generateNotify(response.message, "warning");
|
||
|
}
|
||
|
},
|
||
|
error: function (e) {
|
||
|
console.log(e);
|
||
8 years ago
|
$('#spinner').attr("class", "fa fa-times");
|
||
8 years ago
|
generateNotify("Something went wrong!", "danger");
|
||
|
}
|
||
|
});
|
||
|
});
|
||
8 years ago
|
function changeUsernameAndPassword(checked) {
|
||
|
var $userName = $('#EmailUsername');
|
||
|
var $password = $('#EmailPassword');
|
||
|
if (!checked) {
|
||
|
disableElement($userName);
|
||
|
disableElement($password);
|
||
|
} else {
|
||
|
enableElement($userName);
|
||
|
enableElement($password);
|
||
|
}
|
||
|
};
|
||
|
|
||
|
function disableElement(element) {
|
||
|
element.attr('disabled', 'disabled');
|
||
|
element.removeClass('form-control-custom');
|
||
|
element.addClass('form-control-custom-disabled');
|
||
|
}
|
||
|
|
||
|
function enableElement(element) {
|
||
|
element.removeAttr('disabled', 'disabled');
|
||
|
element.addClass('form-control-custom');
|
||
|
element.removeClass('form-control-custom-disabled');
|
||
|
}
|
||
8 years ago
|
|
||
|
|
||
|
});
|
||
9 years ago
|
</script>
|