From 1e9ae9a508f6a7a108c5b8d8be683f8bd66f8a78 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 21 Aug 2011 18:00:12 -0700 Subject: [PATCH] leftover notification code --- NzbDrone.Web/Controllers/AddSeriesController.cs | 6 +++--- NzbDrone.Web/Controllers/HistoryController.cs | 4 ++-- NzbDrone.Web/Controllers/LogController.cs | 3 ++- NzbDrone.Web/Controllers/SettingsController.cs | 8 ++++---- NzbDrone.Web/Scripts/Notification.js | 2 ++ NzbDrone.Web/Views/History/Index.cshtml | 6 +++--- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/NzbDrone.Web/Controllers/AddSeriesController.cs b/NzbDrone.Web/Controllers/AddSeriesController.cs index 61ad6a275..3951ead81 100644 --- a/NzbDrone.Web/Controllers/AddSeriesController.cs +++ b/NzbDrone.Web/Controllers/AddSeriesController.cs @@ -123,12 +123,12 @@ namespace NzbDrone.Web.Controllers _seriesProvider.AddSeries(path, series.Id, qualityProfileId); ScanNewSeries(); - return new JsonResult { Data = "ok" }; + return Json(new NotificationResult() { Title = seriesName, Text = "Was added successfully" }); } - catch (Exception) + catch (Exception ex) { - return new JsonResult { Data = "failed" }; + return Json(new NotificationResult() { Title = "Failed", Text = ex.Message, NotificationType = NotificationType.Error}); } } diff --git a/NzbDrone.Web/Controllers/HistoryController.cs b/NzbDrone.Web/Controllers/HistoryController.cs index 8145614bf..4dd2c3141 100644 --- a/NzbDrone.Web/Controllers/HistoryController.cs +++ b/NzbDrone.Web/Controllers/HistoryController.cs @@ -29,13 +29,13 @@ namespace NzbDrone.Web.Controllers public JsonResult Trim() { _historyProvider.Trim(); - return new JsonResult { Data = "ok" }; + return Json(new NotificationResult() { Title = "Trimmed History items"}); } public JsonResult Purge() { _historyProvider.Purge(); - return new JsonResult { Data = "ok" }; + return Json(new NotificationResult() { Title = "History Cleared" }); } [GridAction] diff --git a/NzbDrone.Web/Controllers/LogController.cs b/NzbDrone.Web/Controllers/LogController.cs index 8df032ecc..575916e25 100644 --- a/NzbDrone.Web/Controllers/LogController.cs +++ b/NzbDrone.Web/Controllers/LogController.cs @@ -1,5 +1,6 @@ using System.Web.Mvc; using NzbDrone.Core.Instrumentation; +using NzbDrone.Web.Models; using Telerik.Web.Mvc; namespace NzbDrone.Web.Controllers @@ -22,7 +23,7 @@ namespace NzbDrone.Web.Controllers { _logProvider.DeleteAll(); - return new JsonResult { Data = "ok" }; + return Json(new NotificationResult() { Title = "Logs Cleared" }); } [GridAction] diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index 62fb37225..ff2d4e10a 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -321,7 +321,7 @@ namespace NzbDrone.Web.Controllers [HttpPost] - public ActionResult SaveQuality(QualityModel data) + public JsonResult SaveQuality(QualityModel data) { if (ModelState.IsValid) { @@ -348,7 +348,7 @@ namespace NzbDrone.Web.Controllers //If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit if (!profile.Allowed.Contains(profile.Cutoff)) - return Content("Error Saving Settings, please fix any errors"); + return GetInvalidModelResult(); //profile.Cutoff = profile.Allowed.Last(); _qualityProvider.Update(profile); @@ -361,7 +361,7 @@ namespace NzbDrone.Web.Controllers } [HttpPost] - public ActionResult SaveNotifications(NotificationSettingsModel data) + public JsonResult SaveNotifications(NotificationSettingsModel data) { if (ModelState.IsValid) { @@ -385,7 +385,7 @@ namespace NzbDrone.Web.Controllers } [HttpPost] - public ActionResult SaveEpisodeSorting(EpisodeSortingModel data) + public JsonResult SaveEpisodeSorting(EpisodeSortingModel data) { if (ModelState.IsValid) { diff --git a/NzbDrone.Web/Scripts/Notification.js b/NzbDrone.Web/Scripts/Notification.js index 11d6cda63..a5189ef59 100644 --- a/NzbDrone.Web/Scripts/Notification.js +++ b/NzbDrone.Web/Scripts/Notification.js @@ -13,6 +13,8 @@ jqXHR.success(function (data) { //Check if the response is a message type, + + console.log(this.url); if (data.IsMessage) { if (data.NotificationType === 0) { $.gritter.add({ diff --git a/NzbDrone.Web/Views/History/Index.cshtml b/NzbDrone.Web/Views/History/Index.cshtml index a5f67248f..304100112 100644 --- a/NzbDrone.Web/Views/History/Index.cshtml +++ b/NzbDrone.Web/Views/History/Index.cshtml @@ -5,8 +5,8 @@ History } @section ActionMenu{ } @section MainContent{ @@ -44,7 +44,7 @@ History