Notifications UI Implemented, Added ExternalNotifications and Xbmc Providers to CentralDispatch.

pull/4/head
markus101 14 years ago
parent 9e15b27e3a
commit df041eb300

@ -62,6 +62,8 @@ namespace NzbDrone.Core
_kernel.Bind<IHttpProvider>().To<HttpProvider>();
_kernel.Bind<IHistoryProvider>().To<HistoryProvider>();
_kernel.Bind<IQualityProvider>().To<QualityProvider>();
_kernel.Bind<IExtenalNotificationProvider>().To<ExternalNotificationProvider>();
_kernel.Bind<IXbmcProvider>().To<XbmcProvider>();
_kernel.Bind<IConfigProvider>().To<ConfigProvider>().InSingletonScope();
_kernel.Bind<ISyncProvider>().To<SyncProvider>().InSingletonScope();
_kernel.Bind<IRssProvider>().To<RssProvider>().InSingletonScope();

@ -122,6 +122,31 @@ namespace NzbDrone.Web.Controllers
return View("Index", model);
}
public ActionResult Notifications()
{
ViewData["viewName"] = "Notifications";
var model = new NotificationSettingsModel
{
XbmcEnabled = Convert.ToBoolean(_configProvider.GetValue("XbmcEnabled", false, true)),
XbmcNotifyOnGrab = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnGrab", false, true)),
XbmcNotifyOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnDownload", false, true)),
XbmcNotifyOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcNotifyOnRename", false, true)),
XbmcNotificationImage = Convert.ToBoolean(_configProvider.GetValue("XbmcNotificationImage", false, true)),
XbmcDisplayTime = Convert.ToInt32(_configProvider.GetValue("XbmcDisplayTime", 3, true)),
XbmcUpdateOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnDownload ", false, true)),
XbmcUpdateOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcUpdateOnRename", false, true)),
XbmcFullUpdate = Convert.ToBoolean(_configProvider.GetValue("XbmcFullUpdate", false, true)),
XbmcCleanOnDownload = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnDownload", false, true)),
XbmcCleanOnRename = Convert.ToBoolean(_configProvider.GetValue("XbmcCleanOnRename", false, true)),
XbmcHosts = _configProvider.GetValue("XbmcHosts", "localhost:80", true),
XbmcUsername = _configProvider.GetValue("XbmcUsername", String.Empty, true),
XbmcPassword = _configProvider.GetValue("XbmcPassword", String.Empty, true)
};
return View("Index", model);
}
public ActionResult EpisodeSorting()
{
ViewData["viewName"] = "EpisodeSorting";
@ -276,6 +301,32 @@ namespace NzbDrone.Web.Controllers
return Content(_settingsFailed);
}
[HttpPost]
public ActionResult SaveNotifications(NotificationSettingsModel data)
{
if (ModelState.IsValid)
{
_configProvider.SetValue("XbmcEnabled", data.XbmcEnabled.ToString());
_configProvider.SetValue("XbmcNotifyOnGrab", data.XbmcNotifyOnGrab.ToString());
_configProvider.SetValue("XbmcNotifyOnDownload", data.XbmcNotifyOnDownload.ToString());
_configProvider.SetValue("XbmcNotifyOnRename", data.XbmcNotifyOnRename.ToString());
_configProvider.SetValue("XbmcNotificationImage", data.XbmcNotificationImage.ToString());
_configProvider.SetValue("XbmcDisplayTime", data.XbmcDisplayTime.ToString());
_configProvider.SetValue("XbmcUpdateOnDownload", data.XbmcUpdateOnDownload.ToString());
_configProvider.SetValue("XbmcUpdateOnRename", data.XbmcUpdateOnRename.ToString());
_configProvider.SetValue("XbmcFullUpdate", data.XbmcFullUpdate.ToString());
_configProvider.SetValue("XbmcCleanOnDownload", data.XbmcCleanOnDownload.ToString());
_configProvider.SetValue("XbmcCleanOnRename", data.XbmcCleanOnRename.ToString());
_configProvider.SetValue("XbmcHosts", data.XbmcHosts);
_configProvider.SetValue("XbmcUsername", data.XbmcUsername);
_configProvider.SetValue("XbmcPassword", data.XbmcPassword);
return Content(_settingsSaved);
}
return Content(_settingsFailed);
}
[HttpPost]
public ActionResult SaveEpisodeSorting(EpisodeSortingModel data)
{

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
namespace NzbDrone.Web.Models
{
public class NotificationSettingsModel
{
[DisplayName("Enabled")]
public bool XbmcEnabled { get; set; }
[DisplayName("Notify on Grab")]
public bool XbmcNotifyOnGrab { get; set; }
[DisplayName("Notify on Download")]
public bool XbmcNotifyOnDownload { get; set; }
[DisplayName("Notify on Rename")]
public bool XbmcNotifyOnRename { get; set; }
[DisplayName("Image with Notification")]
public bool XbmcNotificationImage { get; set; }
[Required]
[Range(3, 10, ErrorMessage = "Must be between 3 and 10 seconds")]
[DisplayName("Display Time")]
public int XbmcDisplayTime { get; set; }
[DisplayName("Update on Download")]
public bool XbmcUpdateOnDownload { get; set; }
[DisplayName("Update on Rename")]
public bool XbmcUpdateOnRename { get; set; }
[DisplayName("Update on ")]
public bool XbmcFullUpdate { get; set; }
[DisplayName("Clean on Download")]
public bool XbmcCleanOnDownload { get; set; }
[DisplayName("Clean on Rename")]
public bool XbmcCleanOnRename { get; set; }
[DataType(DataType.Text)]
[DisplayName("Hosts")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string XbmcHosts { get; set; }
[DataType(DataType.Text)]
[DisplayName("Username")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string XbmcUsername { get; set; }
[DataType(DataType.Text)]
[DisplayName("Password")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string XbmcPassword { get; set; }
}
}

@ -91,6 +91,7 @@
<Compile Include="Models\IndexerSettingsModel.cs" />
<Compile Include="Models\MappingModel.cs" />
<Compile Include="Models\EpisodeModel.cs" />
<Compile Include="Models\NotificationSettingsModel.cs" />
<Compile Include="Models\QualityModel.cs" />
<Compile Include="Models\SettingsModels.cs" />
<Compile Include="Models\TestModel.cs" />
@ -274,6 +275,7 @@
<Content Include="Views\Series\EpisodeDetail.ascx" />
<Content Include="Views\Series\index.aspx" />
<Content Include="Views\Series\Unmapped.aspx" />
<Content Include="Views\Settings\Notifications.ascx" />
<Content Include="Views\Settings\Downloads.ascx" />
<Content Include="Views\Settings\EpisodeSorting.ascx" />
<Content Include="Views\Settings\General.ascx" />

@ -0,0 +1,165 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NzbDrone.Web.Models.NotificationSettingsModel>" %>
<script type="text/javascript">
$(document).ready(function () {
var options = {
target: '#result',
beforeSubmit: showRequest,
success: showResponse,
type: 'post',
resetForm: false
};
$('#form').ajaxForm(options);
$('#save_button').attr('disabled', '');
});
function showRequest(formData, jqForm, options) {
$("#result").empty().html('Saving...');
$("#form :input").attr("disabled", true);
}
function showResponse(responseText, statusText, xhr, $form) {
$("#result").empty().html(responseText);
$("#form :input").attr("disabled", false);
}
</script>
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("SaveNotifications", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
{%>
<%--<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>--%>
<fieldset>
<legend>Notification Settings</legend>
<fieldset class="sub-field">
<legend>XBMC</legend>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcEnabled)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcEnabled)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcEnabled)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcNotifyOnGrab)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcNotifyOnGrab)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcNotifyOnGrab)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcNotifyOnDownload)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcNotifyOnDownload)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcNotifyOnDownload)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcNotifyOnRename)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcNotifyOnRename)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcNotifyOnRename)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcNotificationImage)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcNotificationImage)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcNotificationImage)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcDisplayTime)%></div>
<div class="config-value"><%= Html.TextBoxFor(m => m.XbmcDisplayTime)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcDisplayTime)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcUpdateOnDownload)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcUpdateOnDownload)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcUpdateOnDownload)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcUpdateOnRename)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcUpdateOnRename)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcUpdateOnRename)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcFullUpdate)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcFullUpdate)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcFullUpdate)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcCleanOnDownload)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcCleanOnDownload)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcCleanOnDownload)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcCleanOnRename)%></div>
<div class="config-value"><%= Html.CheckBoxFor(m => m.XbmcCleanOnRename)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcCleanOnRename)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcHosts)%></div>
<div class="config-value"><%= Html.TextBoxFor(m => m.XbmcHosts)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcHosts)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcUsername)%></div>
<div class="config-value"><%= Html.TextBoxFor(m => m.XbmcUsername)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcUsername)%></div>
</div>
<div class="config-section">
<div class="config-group">
<div class="config-title"><%= Html.LabelFor(m => m.XbmcPassword)%></div>
<div class="config-value"><%= Html.TextBoxFor(m => m.XbmcPassword)%></div>
</div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.XbmcPassword)%></div>
</div>
</fieldset>
<input type="submit" id="save_button" value="Save" disabled="disabled" />
<% } %>
</fieldset>
<div id="result"></div>

@ -10,6 +10,7 @@
items.Add().Text("Downloads").Action("Downloads", "Settings");
items.Add().Text("Quality").Action("Quality", "Settings");
items.Add().Text("Episode Sorting").Action("EpisodeSorting", "Settings");
items.Add().Text("Notifications").Action("Notifications", "Settings");
}).Render();
%>

Loading…
Cancel
Save