Reworked the custom notifications... again. Need to figure out how to find the view to the model

This commit is contained in:
tidusjar 2016-07-08 17:29:14 +01:00
commit a19e81d1f8
6 changed files with 112 additions and 35 deletions

View file

@ -1,4 +1,7 @@
@using PlexRequests.UI.Helpers
@using System.Linq
@using PlexRequests.Core.Models
@using PlexRequests.UI.Helpers
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<PlexRequests.Core.SettingModels.EmailNotificationSettings>
@Html.Partial("_Sidebar")
@{
int port;
@ -18,30 +21,30 @@
<div class="form-group">
<div class="checkbox">
@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>
}
@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>
}
</div>
</div>
<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>
<small>Please note that if user notifications is enabled, the email will get sent with the SMTP set-up below.</small>
@ -90,6 +93,38 @@
</div>
</div>
<!--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>
</div>
<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>
</div>
</div>
}
</div>
<div class="form-group">
<div>
<button id="testEmail" type="submit" class="btn btn-primary-outline">Test <div id="spinner"></div></button>
@ -102,6 +137,7 @@
</div>
</div>
</fieldset>
</form>
</div>
@ -116,10 +152,13 @@
generateNotify("You must specify a valid Port.", "warning");
return;
}
var $form = $("#mainForm");
var data = $form.serialize();
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
data: data,
url: $form.prop("action"),
dataType: "json",
success: function (response) {