From df041eb300253f0ec4a50196c3c113f5381ae6f9 Mon Sep 17 00:00:00 2001 From: markus101 Date: Sun, 6 Mar 2011 23:32:36 -0800 Subject: [PATCH] Notifications UI Implemented, Added ExternalNotifications and Xbmc Providers to CentralDispatch. --- NzbDrone.Core/CentralDispatch.cs | 2 + .../Controllers/SettingsController.cs | 51 ++++++ .../Models/NotificationSettingsModel.cs | 62 +++++++ NzbDrone.Web/NzbDrone.Web.csproj | 2 + .../Views/Settings/Notifications.ascx | 165 ++++++++++++++++++ NzbDrone.Web/Views/Settings/SubMenu.ascx | 1 + 6 files changed, 283 insertions(+) create mode 100644 NzbDrone.Web/Models/NotificationSettingsModel.cs create mode 100644 NzbDrone.Web/Views/Settings/Notifications.ascx diff --git a/NzbDrone.Core/CentralDispatch.cs b/NzbDrone.Core/CentralDispatch.cs index e9c669d29..803097a05 100644 --- a/NzbDrone.Core/CentralDispatch.cs +++ b/NzbDrone.Core/CentralDispatch.cs @@ -62,6 +62,8 @@ namespace NzbDrone.Core _kernel.Bind().To(); _kernel.Bind().To(); _kernel.Bind().To(); + _kernel.Bind().To(); + _kernel.Bind().To(); _kernel.Bind().To().InSingletonScope(); _kernel.Bind().To().InSingletonScope(); _kernel.Bind().To().InSingletonScope(); diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 9fb3ecded..d8d33676c 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -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) { diff --git a/NzbDrone.Web/Models/NotificationSettingsModel.cs b/NzbDrone.Web/Models/NotificationSettingsModel.cs new file mode 100644 index 000000000..8a27fc99a --- /dev/null +++ b/NzbDrone.Web/Models/NotificationSettingsModel.cs @@ -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; } + } +} \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index fb3caf55f..1d0373733 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -91,6 +91,7 @@ + @@ -274,6 +275,7 @@ + diff --git a/NzbDrone.Web/Views/Settings/Notifications.ascx b/NzbDrone.Web/Views/Settings/Notifications.ascx new file mode 100644 index 000000000..bd6ce9c16 --- /dev/null +++ b/NzbDrone.Web/Views/Settings/Notifications.ascx @@ -0,0 +1,165 @@ +<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> + + + + <% 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.") %>--%> + +
+ Notification Settings + +
+ XBMC +
+
+
<%= Html.LabelFor(m => m.XbmcEnabled)%>
+
<%= Html.CheckBoxFor(m => m.XbmcEnabled)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcEnabled)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcNotifyOnGrab)%>
+
<%= Html.CheckBoxFor(m => m.XbmcNotifyOnGrab)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcNotifyOnGrab)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcNotifyOnDownload)%>
+
<%= Html.CheckBoxFor(m => m.XbmcNotifyOnDownload)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcNotifyOnDownload)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcNotifyOnRename)%>
+
<%= Html.CheckBoxFor(m => m.XbmcNotifyOnRename)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcNotifyOnRename)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcNotificationImage)%>
+
<%= Html.CheckBoxFor(m => m.XbmcNotificationImage)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcNotificationImage)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcDisplayTime)%>
+
<%= Html.TextBoxFor(m => m.XbmcDisplayTime)%>
+
+
<%= Html.ValidationMessageFor(m => m.XbmcDisplayTime)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcUpdateOnDownload)%>
+
<%= Html.CheckBoxFor(m => m.XbmcUpdateOnDownload)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcUpdateOnDownload)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcUpdateOnRename)%>
+
<%= Html.CheckBoxFor(m => m.XbmcUpdateOnRename)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcUpdateOnRename)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcFullUpdate)%>
+
<%= Html.CheckBoxFor(m => m.XbmcFullUpdate)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcFullUpdate)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcCleanOnDownload)%>
+
<%= Html.CheckBoxFor(m => m.XbmcCleanOnDownload)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcCleanOnDownload)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcCleanOnRename)%>
+
<%= Html.CheckBoxFor(m => m.XbmcCleanOnRename)%>
+ +
+
<%= Html.ValidationMessageFor(m => m.XbmcCleanOnRename)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcHosts)%>
+
<%= Html.TextBoxFor(m => m.XbmcHosts)%>
+
+
<%= Html.ValidationMessageFor(m => m.XbmcHosts)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcUsername)%>
+
<%= Html.TextBoxFor(m => m.XbmcUsername)%>
+
+
<%= Html.ValidationMessageFor(m => m.XbmcUsername)%>
+
+ +
+
+
<%= Html.LabelFor(m => m.XbmcPassword)%>
+
<%= Html.TextBoxFor(m => m.XbmcPassword)%>
+
+
<%= Html.ValidationMessageFor(m => m.XbmcPassword)%>
+
+
+ + + + <% } %> +
+
\ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/SubMenu.ascx b/NzbDrone.Web/Views/Settings/SubMenu.ascx index 274ee17b0..8a2dfb4c9 100644 --- a/NzbDrone.Web/Views/Settings/SubMenu.ascx +++ b/NzbDrone.Web/Views/Settings/SubMenu.ascx @@ -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(); %>