1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-04 10:34:59 +02:00

Cleaned as much of notifications as I could find.

This commit is contained in:
kay.one 2012-01-18 21:01:47 -08:00
parent 121f3258af
commit 3cb61e4c34
16 changed files with 95 additions and 213 deletions

View File

@ -97,6 +97,8 @@
font-size: 20px; font-size: 20px;
padding: 0; padding: 0;
display: block; display: block;
line-height: 1;
padding-bottom: 10px;
text-shadow: 1px 1px #000; /* Not supported by IE :( */ text-shadow: 1px 1px #000; /* Not supported by IE :( */
} }
.gritter-image .gritter-image

View File

@ -3,7 +3,6 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Jobs; using NzbDrone.Core.Jobs;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
@ -16,7 +15,6 @@ namespace NzbDrone.Web.Controllers
{ {
public class AddSeriesController : Controller public class AddSeriesController : Controller
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
private readonly ConfigProvider _configProvider; private readonly ConfigProvider _configProvider;
private readonly QualityProvider _qualityProvider; private readonly QualityProvider _qualityProvider;
private readonly RootDirProvider _rootFolderProvider; private readonly RootDirProvider _rootFolderProvider;
@ -42,10 +40,10 @@ public AddSeriesController(RootDirProvider rootFolderProvider,
} }
[HttpPost] [HttpPost]
public JsonResult ScanNewSeries() public EmptyResult ScanNewSeries()
{ {
_jobProvider.QueueJob(typeof(ImportNewSeriesJob)); _jobProvider.QueueJob(typeof(ImportNewSeriesJob));
return new JsonResult(); return new EmptyResult();
} }
public ActionResult AddNew() public ActionResult AddNew()
@ -117,22 +115,16 @@ public JsonResult AddNewSeries(string path, string seriesName, int seriesId, int
} }
[HttpPost] [HttpPost]
[JsonErrorFilter]
public JsonResult AddExistingSeries(string path, string seriesName, int seriesId, int qualityProfileId) public JsonResult AddExistingSeries(string path, string seriesName, int seriesId, int qualityProfileId)
{ {
if (seriesId == 0 || String.IsNullOrWhiteSpace(seriesName)) if (seriesId == 0 || String.IsNullOrWhiteSpace(seriesName))
return Json(new NotificationResult() { Title = "Failed", Text = "Invalid Series Information, Series not added.", NotificationType = NotificationType.Error }); return JsonNotificationResult.Error("Add Existing series failed.", "Invalid Series information");
try _seriesProvider.AddSeries(path, seriesId, qualityProfileId);
{ ScanNewSeries();
_seriesProvider.AddSeries(path, seriesId, qualityProfileId);
ScanNewSeries();
return Json(new NotificationResult() { Title = seriesName, Text = "Was added successfully" });
}
catch (Exception ex) return JsonNotificationResult.Info(seriesName, "Was added successfully");
{
return Json(new NotificationResult() { Title = "Failed", Text = ex.Message, NotificationType = NotificationType.Error });
}
} }
[HttpPost] [HttpPost]
@ -148,19 +140,6 @@ public JsonResult QuickAddNewSeries(string seriesName, int seriesId, int quality
return AddExistingSeries(path, seriesName, seriesId, qualityProfileId); return AddExistingSeries(path, seriesName, seriesId, qualityProfileId);
} }
public JsonResult AddSeries(string path, int seriesId, int qualityProfileId)
{
//Get TVDB Series Name
//Create new folder for series
//Add the new series to the Database
_seriesProvider.AddSeries(
path.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar).Replace('`', '\''), seriesId,
qualityProfileId);
ScanNewSeries();
return new JsonResult { Data = "ok" };
}
[ChildActionOnly] [ChildActionOnly]
public ActionResult QuickAdd() public ActionResult QuickAdd()
{ {
@ -178,19 +157,15 @@ public ActionResult QuickAdd()
[HttpPost] [HttpPost]
[JsonErrorFilter("Can't add root folder")] [JsonErrorFilter]
public JsonResult SaveRootDir(string path) public JsonResult SaveRootDir(string path)
{ {
if (String.IsNullOrWhiteSpace(path)) if (String.IsNullOrWhiteSpace(path))
NotificationResult.Error("Can't add root folder", "Path can not be empty"); JsonNotificationResult.Error("Can't add root folder", "Path can not be empty");
//Don't let a user add a rootDir that is the same as their SABnzbd TV Directory
if (path.Equals(_configProvider.SabDropDirectory, StringComparison.InvariantCultureIgnoreCase))
NotificationResult.Error("Can't add root folder", "Path can not be same as sab folder.");
_rootFolderProvider.Add(new RootDir { Path = path }); _rootFolderProvider.Add(new RootDir { Path = path });
return NotificationResult.Info("Root Folder saved", "Root foler saved successfully."); return JsonNotificationResult.Info("Root Folder saved", "Root foler saved successfully.");
} }
[HttpGet] [HttpGet]
@ -217,20 +192,14 @@ public ActionResult RootDir()
return PartialView("RootDir"); return PartialView("RootDir");
} }
[JsonErrorFilter]
public JsonResult DeleteRootDir(string path) public JsonResult DeleteRootDir(string path)
{ {
try
{
var id = _rootFolderProvider.GetAll().Where(c => c.Path == path).First().Id;
_rootFolderProvider.Remove(id);
}
catch (Exception) var id = _rootFolderProvider.GetAll().Where(c => c.Path == path).First().Id;
{ _rootFolderProvider.Remove(id);
return new JsonResult { Data = "failed" };
}
return new JsonResult { Data = "ok" }; return null;
} }
} }
} }

View File

@ -1,12 +1,7 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
using NLog;
using NzbDrone.Core.Jobs; using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Twitter;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Web.Filters;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
@ -18,8 +13,6 @@ public class CommandController : Controller
private readonly SmtpProvider _smtpProvider; private readonly SmtpProvider _smtpProvider;
private readonly TwitterProvider _twitterProvider; private readonly TwitterProvider _twitterProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public CommandController(JobProvider jobProvider, SabProvider sabProvider, public CommandController(JobProvider jobProvider, SabProvider sabProvider,
SmtpProvider smtpProvider, TwitterProvider twitterProvider) SmtpProvider smtpProvider, TwitterProvider twitterProvider)
{ {
@ -32,54 +25,41 @@ public CommandController(JobProvider jobProvider, SabProvider sabProvider,
public JsonResult RssSync() public JsonResult RssSync()
{ {
_jobProvider.QueueJob(typeof(RssSyncJob)); _jobProvider.QueueJob(typeof(RssSyncJob));
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return JsonNotificationResult.Info("Queued");
} }
public JsonResult BacklogSearch() public JsonResult BacklogSearch()
{ {
_jobProvider.QueueJob(typeof(BacklogSearchJob)); _jobProvider.QueueJob(typeof(BacklogSearchJob));
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return JsonNotificationResult.Info("Queued");
} }
public JsonResult ScanDisk(int seriesId) public JsonResult ScanDisk(int seriesId)
{ {
//Syncs the episodes on disk for the specified series
_jobProvider.QueueJob(typeof(DiskScanJob), seriesId); _jobProvider.QueueJob(typeof(DiskScanJob), seriesId);
return JsonNotificationResult.Info("Queued");
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
} }
public JsonResult UpdateInfo(int seriesId) public JsonResult UpdateInfo(int seriesId)
{ {
//Syncs the episodes on disk for the specified series
_jobProvider.QueueJob(typeof(UpdateInfoJob), seriesId); _jobProvider.QueueJob(typeof(UpdateInfoJob), seriesId);
return JsonNotificationResult.Info("Queued");
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
} }
[HttpPost] [HttpPost]
[JsonErrorFilter]
public JsonResult GetSabnzbdCategories(string host, int port, string apiKey, string username, string password) public JsonResult GetSabnzbdCategories(string host, int port, string apiKey, string username, string password)
{ {
try return new JsonResult { Data = _sabProvider.GetCategories(host, port, apiKey, username, password) };
{
return new JsonResult {Data = _sabProvider.GetCategories(host, port, apiKey, username, password)};
}
catch (Exception ex)
{
Logger.Warn("Unable to get Categories from SABnzbd");
Logger.DebugException(ex.Message, ex);
return Json(new NotificationResult { Title = "Failed", Text = "Unable to get SABnzbd Categories", NotificationType = NotificationType.Error });
}
} }
[HttpPost] [HttpPost]
public JsonResult SendTestEmail(string server, int port, bool ssl, string username, string password, string fromAddress, string toAddresses) public JsonResult SendTestEmail(string server, int port, bool ssl, string username, string password, string fromAddress, string toAddresses)
{ {
if (_smtpProvider.SendTestEmail(server, port, ssl, username, password, fromAddress, toAddresses)) if (_smtpProvider.SendTestEmail(server, port, ssl, username, password, fromAddress, toAddresses))
return Json(new NotificationResult { Title = "Successfully sent test email." }); JsonNotificationResult.Info("Successfull", "Test email sent.");
return Json(new NotificationResult { Title = "Failed", Text = "Unable to send Email, please check your settings", NotificationType = NotificationType.Error }); return JsonNotificationResult.Opps("Couldn't send Email, please check your settings");
} }
public JsonResult GetTwitterAuthorization() public JsonResult GetTwitterAuthorization()
@ -87,7 +67,7 @@ public JsonResult GetTwitterAuthorization()
var result = _twitterProvider.GetAuthorization(); var result = _twitterProvider.GetAuthorization();
if (result == null) if (result == null)
return Json(new NotificationResult { Title = "Failed", Text = "Unable to get Twitter Authorization", NotificationType = NotificationType.Error }, JsonRequestBehavior.AllowGet); JsonNotificationResult.Opps("Couldn't get Twitter Authorization");
return new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return new JsonResult { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
} }
@ -97,9 +77,10 @@ public JsonResult VerifyTwitterAuthorization(string token, string verifier)
var result = _twitterProvider.GetAndSaveAccessToken(token, verifier); var result = _twitterProvider.GetAndSaveAccessToken(token, verifier);
if (!result) if (!result)
return Json(new NotificationResult { Title = "Failed", Text = "Unable to verify Twitter Authorization", NotificationType = NotificationType.Error }, JsonRequestBehavior.AllowGet); JsonNotificationResult.Opps("Couldn't verify Twitter Authorization");
return JsonNotificationResult.Info("Good News!", "Successfully verified Twitter Authorization.");
return Json(new NotificationResult { Title = "Successfully verified Twitter Authorization." }, JsonRequestBehavior.AllowGet);
} }
} }
} }

View File

@ -15,7 +15,7 @@ public DirectoryController(DiskProvider diskProvider)
} }
[HttpPost] [HttpPost]
public ActionResult _autoCompletePath(string text, int? filterMode) public JsonResult _autoCompletePath(string text, int? filterMode)
{ {
var data = GetDirectories(text); var data = GetDirectories(text);

View File

@ -1,10 +1,5 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.IO;
using System.Web.Mvc;
using NzbDrone.Core.Jobs; using NzbDrone.Core.Jobs;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
@ -15,7 +10,6 @@ public class EpisodeController : Controller
public EpisodeController(JobProvider jobProvider) public EpisodeController(JobProvider jobProvider)
{ {
_jobProvider = jobProvider; _jobProvider = jobProvider;
} }
@ -23,44 +17,38 @@ public EpisodeController(JobProvider jobProvider)
public JsonResult Search(int episodeId) public JsonResult Search(int episodeId)
{ {
_jobProvider.QueueJob(typeof(EpisodeSearchJob), episodeId); _jobProvider.QueueJob(typeof(EpisodeSearchJob), episodeId);
return new JsonResult { Data = "ok" }; return JsonNotificationResult.Info("Queued");
} }
[HttpPost] [HttpPost]
public JsonResult SearchSeason(int seriesId, int seasonNumber) public JsonResult SearchSeason(int seriesId, int seasonNumber)
{ {
_jobProvider.QueueJob(typeof(SeasonSearchJob), seriesId, seasonNumber); _jobProvider.QueueJob(typeof(SeasonSearchJob), seriesId, seasonNumber);
return new JsonResult { Data = "ok" }; return JsonNotificationResult.Info("Queued");
} }
public JsonResult BacklogSeries(int seriesId) public JsonResult BacklogSeries(int seriesId)
{ {
//Syncs the episodes on disk for the specified series
_jobProvider.QueueJob(typeof(SeriesSearchJob), seriesId); _jobProvider.QueueJob(typeof(SeriesSearchJob), seriesId);
return JsonNotificationResult.Info("Queued");
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
} }
public JsonResult Rename(int episodeFileId) public JsonResult Rename(int episodeFileId)
{ {
_jobProvider.QueueJob(typeof(RenameEpisodeJob), episodeFileId); _jobProvider.QueueJob(typeof(RenameEpisodeJob), episodeFileId);
return JsonNotificationResult.Info("Queued");
return new JsonResult { Data = "ok" };
} }
public JsonResult RenameSeason(int seriesId, int seasonNumber) public JsonResult RenameSeason(int seriesId, int seasonNumber)
{ {
_jobProvider.QueueJob(typeof(RenameSeasonJob), seriesId, seasonNumber); _jobProvider.QueueJob(typeof(RenameSeasonJob), seriesId, seasonNumber);
return JsonNotificationResult.Info("Queued");
return new JsonResult { Data = "ok" };
} }
public JsonResult RenameEpisodes(int seriesId) public JsonResult RenameEpisodes(int seriesId)
{ {
//Syncs the episodes on disk for the specified series
_jobProvider.QueueJob(typeof(RenameSeriesJob), seriesId); _jobProvider.QueueJob(typeof(RenameSeriesJob), seriesId);
return JsonNotificationResult.Info("Queued");
return new JsonResult { Data = "ok", JsonRequestBehavior = JsonRequestBehavior.AllowGet };
} }
} }
} }

View File

@ -1,15 +1,9 @@
using System; using System.Web.Mvc;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
{ {
public class HealthController : Controller public class HealthController : Controller
{ {
//
// GET: /Health/
[HttpGet] [HttpGet]
public JsonResult Index() public JsonResult Index()
{ {

View File

@ -1,9 +1,6 @@
using System; using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Core.Jobs; using NzbDrone.Core.Jobs;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
using Telerik.Web.Mvc; using Telerik.Web.Mvc;
@ -21,9 +18,6 @@ public HistoryController(HistoryProvider historyProvider, JobProvider jobProvide
_jobProvider = jobProvider; _jobProvider = jobProvider;
} }
//
// GET: /History/
public ActionResult Index() public ActionResult Index()
{ {
return View(); return View();
@ -32,13 +26,13 @@ public ActionResult Index()
public JsonResult Trim() public JsonResult Trim()
{ {
_historyProvider.Trim(); _historyProvider.Trim();
return Json(new NotificationResult() { Title = "Trimmed History items"}); return JsonNotificationResult.Info("Trimmed History");
} }
public JsonResult Purge() public JsonResult Purge()
{ {
_historyProvider.Purge(); _historyProvider.Purge();
return Json(new NotificationResult() { Title = "History Cleared" }); return JsonNotificationResult.Info("History Cleared");
} }
[HttpPost] [HttpPost]
@ -47,7 +41,7 @@ public JsonResult Delete(int historyId)
//Delete the existing item from history //Delete the existing item from history
_historyProvider.Delete(historyId); _historyProvider.Delete(historyId);
return Json(new NotificationResult() { Title = "History Item Deleted" }); return JsonNotificationResult.Info("History Item Deleted");
} }
[HttpPost] [HttpPost]
@ -59,7 +53,7 @@ public JsonResult Redownload(int historyId, int episodeId)
//Queue a job to download the replacement episode //Queue a job to download the replacement episode
_jobProvider.QueueJob(typeof(EpisodeSearchJob), episodeId); _jobProvider.QueueJob(typeof(EpisodeSearchJob), episodeId);
return Json(new NotificationResult() { Title = "Episode Redownload Started" }); return JsonNotificationResult.Info("Episode Redownload Started");
} }
[GridAction] [GridAction]

View File

@ -23,7 +23,7 @@ public JsonResult Clear()
{ {
_logProvider.DeleteAll(); _logProvider.DeleteAll();
return Json(new NotificationResult() { Title = "Logs Cleared" }); return JsonNotificationResult.Info("Logs Cleared");
} }
[GridAction] [GridAction]

View File

@ -112,19 +112,17 @@ public JsonResult LocalSearch(string term)
} }
[HttpPost] [HttpPost]
public JsonResult SaveSeasonIgnore(int seriesId, int seasonNumber, bool ignored) public EmptyResult SaveSeasonIgnore(int seriesId, int seasonNumber, bool ignored)
{ {
_episodeProvider.SetSeasonIgnore(seriesId, seasonNumber, ignored); _episodeProvider.SetSeasonIgnore(seriesId, seasonNumber, ignored);
return new EmptyResult();
return new JsonResult { Data = "ok" };
} }
[HttpPost] [HttpPost]
public JsonResult SaveEpisodeIgnore(int episodeId, bool ignored) public EmptyResult SaveEpisodeIgnore(int episodeId, bool ignored)
{ {
_episodeProvider.SetEpisodeIgnore(episodeId, ignored); _episodeProvider.SetEpisodeIgnore(episodeId, ignored);
return new EmptyResult();
return new JsonResult { Data = "ok" };
} }
public ActionResult Details(int seriesId) public ActionResult Details(int seriesId)

View File

@ -1,20 +1,18 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Common.Model; using NzbDrone.Common.Model;
using NzbDrone.Core.Helpers; using NzbDrone.Core.Helpers;
using NzbDrone.Core.Model;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Providers.ExternalNotification; using NzbDrone.Core.Providers.ExternalNotification;
using NzbDrone.Core.Providers.Indexer; using NzbDrone.Core.Providers.Indexer;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Filters;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
@ -58,7 +56,7 @@ public JsonResult TestResults(string q)
results.Add(new TvDbSearchResultModel { Id = 1, Title = "30 Rock", FirstAired = DateTime.Today.ToShortDateString() }); results.Add(new TvDbSearchResultModel { Id = 1, Title = "30 Rock", FirstAired = DateTime.Today.ToShortDateString() });
results.Add(new TvDbSearchResultModel { Id = 2, Title = "The Office", FirstAired = DateTime.Today.AddDays(-1).ToShortDateString() }); results.Add(new TvDbSearchResultModel { Id = 2, Title = "The Office", FirstAired = DateTime.Today.AddDays(-1).ToShortDateString() });
return Json(results, JsonRequestBehavior.AllowGet ); return Json(results, JsonRequestBehavior.AllowGet);
} }
public ActionResult Index() public ActionResult Index()
@ -260,22 +258,15 @@ public PartialViewResult GetQualityProfileView(QualityProfile profile)
return PartialView("QualityProfileItem", model); return PartialView("QualityProfileItem", model);
} }
[JsonErrorFilter]
public JsonResult DeleteQualityProfile(int profileId) public JsonResult DeleteQualityProfile(int profileId)
{ {
try if (_seriesProvider.GetAllSeries().Where(s => s.QualityProfileId == profileId).Count() != 0)
{ return JsonNotificationResult.Opps("Profile is still in use.");
if (_seriesProvider.GetAllSeries().Where(s => s.QualityProfileId == profileId).Count() != 0)
return new JsonResult { Data = "Unable to delete Profile, it is still in use." };
_qualityProvider.Delete(profileId); _qualityProvider.Delete(profileId);
}
catch (Exception) return new JsonResult();
{
return new JsonResult { Data = "failed" };
}
return new JsonResult { Data = "ok" };
} }
public PartialViewResult AddNewznabProvider() public PartialViewResult AddNewznabProvider()
@ -301,19 +292,11 @@ public ActionResult GetNewznabProviderView(NewznabDefinition provider)
return PartialView("NewznabProvider", provider); return PartialView("NewznabProvider", provider);
} }
public JsonResult DeleteNewznabProvider(int providerId) [JsonErrorFilter]
public EmptyResult DeleteNewznabProvider(int providerId)
{ {
try _newznabProvider.Delete(providerId);
{ return new EmptyResult();
_newznabProvider.Delete(providerId);
}
catch (Exception)
{
return new JsonResult { Data = "failed" };
}
return new JsonResult { Data = "ok" };
} }
public QualityModel GetUpdatedProfileList() public QualityModel GetUpdatedProfileList()
@ -324,7 +307,7 @@ public QualityModel GetUpdatedProfileList()
var selectList = new SelectList(profiles, "QualityProfileId", "Name"); var selectList = new SelectList(profiles, "QualityProfileId", "Name");
return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, QualityProfileSelectList = selectList }; return new QualityModel { DefaultQualityProfileId = defaultQualityQualityProfileId, QualityProfileSelectList = selectList };
} }
public JsonResult AutoConfigureSab() public JsonResult AutoConfigureSab()
{ {
@ -334,19 +317,13 @@ public JsonResult AutoConfigureSab()
if (info != null) if (info != null)
return Json(info, JsonRequestBehavior.AllowGet); return Json(info, JsonRequestBehavior.AllowGet);
return Json(new NotificationResult
{
Title = "Auto-Configure Failed",
Text = "Please enter your SAB Settings Manually",
NotificationType = NotificationType.Error
}, JsonRequestBehavior.AllowGet);
} }
catch (Exception) catch (Exception)
{ {
return new JsonResult { Data = "failed" };
} }
return JsonNotificationResult.Error("Auto-Configure Failed", "Please enter your SAB Settings Manually");
} }
[HttpPost] [HttpPost]
@ -400,11 +377,6 @@ public JsonResult SaveSabnzbd(SabnzbdSettingsModel data)
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
//Check to see if the TV Directory matches any RootDirs (Ignoring Case), if it does, return an error to the user
//This prevents a user from finding a way to delete their entire TV Library
var rootDirs = _rootDirProvider.GetAll();
if (rootDirs.Any(r => r.Path.Equals(data.SabDropDirectory, StringComparison.InvariantCultureIgnoreCase)))
Json(new NotificationResult { Title = "Failed", Text = "Invalid TV Directory", NotificationType = NotificationType.Error });
_configProvider.SabHost = data.SabHost; _configProvider.SabHost = data.SabHost;
_configProvider.SabPort = data.SabPort; _configProvider.SabPort = data.SabPort;
@ -419,8 +391,7 @@ public JsonResult SaveSabnzbd(SabnzbdSettingsModel data)
return GetSuccessResult(); return GetSuccessResult();
} }
return return JsonNotificationResult.Opps("Invalid Data");
Json(new NotificationResult() { Title = "Failed", Text = "Invalid request data.", NotificationType = NotificationType.Error });
} }
[HttpPost] [HttpPost]
@ -442,7 +413,7 @@ public JsonResult SaveQuality(QualityModel data)
profile.QualityProfileId = profileModel.QualityProfileId; profile.QualityProfileId = profileModel.QualityProfileId;
profile.Name = profileModel.Name; profile.Name = profileModel.Name;
profile.Cutoff = profileModel.Cutoff; profile.Cutoff = profileModel.Cutoff;
profile.Allowed = new List<QualityTypes>(); profile.Allowed = new List<QualityTypes>();
if (profileModel.Sdtv) if (profileModel.Sdtv)
@ -506,7 +477,7 @@ public JsonResult SaveNotifications(NotificationSettingsModel data)
_configProvider.XbmcPassword = data.XbmcPassword; _configProvider.XbmcPassword = data.XbmcPassword;
//SMTP //SMTP
var smtpSettings = _externalNotificationProvider.GetSettings(typeof (Smtp)); var smtpSettings = _externalNotificationProvider.GetSettings(typeof(Smtp));
smtpSettings.Enable = data.SmtpEnabled; smtpSettings.Enable = data.SmtpEnabled;
_externalNotificationProvider.SaveSettings(smtpSettings); _externalNotificationProvider.SaveSettings(smtpSettings);
@ -605,18 +576,18 @@ public JsonResult SaveMisc(MiscSettingsModel data)
private JsonResult GetSuccessResult() private JsonResult GetSuccessResult()
{ {
return Json(new NotificationResult() { Title = "Settings Saved" }); return JsonNotificationResult.Info("Settings Saved");
} }
private JsonResult GetInvalidModelResult() private JsonResult GetInvalidModelResult()
{ {
return Json(new NotificationResult() { Title = "Unable to save setting", Text = "Invalid post data", NotificationType = NotificationType.Error }); return JsonNotificationResult.Opps("Invalid post data");
} }
private SelectList GetProwlPrioritySelectList() private SelectList GetProwlPrioritySelectList()
{ {
var list = new List<ProwlPrioritySelectListModel>(); var list = new List<ProwlPrioritySelectListModel>();
list.Add(new ProwlPrioritySelectListModel{ Name = "Very Low", Value = -2 }); list.Add(new ProwlPrioritySelectListModel { Name = "Very Low", Value = -2 });
list.Add(new ProwlPrioritySelectListModel { Name = "Moderate", Value = -1 }); list.Add(new ProwlPrioritySelectListModel { Name = "Moderate", Value = -1 });
list.Add(new ProwlPrioritySelectListModel { Name = "Normal", Value = 0 }); list.Add(new ProwlPrioritySelectListModel { Name = "Normal", Value = 0 });
list.Add(new ProwlPrioritySelectListModel { Name = "High", Value = 1 }); list.Add(new ProwlPrioritySelectListModel { Name = "High", Value = 1 });

View File

@ -1,19 +0,0 @@
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Mvc;
namespace NzbDrone.Web.Controllers
{
public class StreamController : Controller
{
//
// GET: /Stream/
public ActionResult Index()
{
return File(@"Z:\Clone High\Season 1\S01E02 - Episode Two- Election Blu-Galoo.avi", "video/divx");
//return File(@"Z:\30 Rock\Season 5\S05E04 - Live Show (East Coast Taping) - HD TV.mkv", "video/divx");
}
}
}

View File

@ -30,11 +30,12 @@ public SystemController(JobProvider jobProvider, IndexerProvider indexerProvider
public ActionResult Jobs() public ActionResult Jobs()
{ {
ViewData["Queue"] = _jobProvider.Queue.Select(c => new JobQueueItemModel { ViewData["Queue"] = _jobProvider.Queue.Select(c => new JobQueueItemModel
Name = c.JobType.Name, {
TargetId = c.TargetId, Name = c.JobType.Name,
SecondaryTargetId = c.SecondaryTargetId TargetId = c.TargetId,
}); SecondaryTargetId = c.SecondaryTargetId
});
var jobs = _jobProvider.All(); var jobs = _jobProvider.All();
@ -139,9 +140,9 @@ public JsonResult RenamePendingProcessing(string path)
public JsonResult RunJob(string typeName) public JsonResult RunJob(string typeName)
{ {
if (!_jobProvider.QueueJob(typeName)) if (!_jobProvider.QueueJob(typeName))
return Json(new NotificationResult { Title = "Failed to Start Job", Text = "Invalid job name", NotificationType = NotificationType.Error }); return JsonNotificationResult.Opps("Invalid Job Name");
return Json(new NotificationResult { Title = "Job Queued" }); return JsonNotificationResult.Info("Job Queued");
} }
} }
} }

View File

@ -39,7 +39,7 @@ public ActionResult StartUpdate()
{ {
_jobProvider.QueueJob(typeof(AppUpdateJob), 0, 0); _jobProvider.QueueJob(typeof(AppUpdateJob), 0, 0);
return Json(new NotificationResult { Title = "Update will begin shortly", NotificationType = NotificationType.Info, Text = "NzbDrone will restart automatically." }); return JsonNotificationResult.Info("Update will begin shortly", "NzbDrone will restart automatically.");
} }
public ActionResult ViewLog( string filepath) public ActionResult ViewLog( string filepath)

View File

@ -6,16 +6,9 @@ namespace NzbDrone.Web.Filters
{ {
public class JsonErrorFilter : FilterAttribute, IExceptionFilter public class JsonErrorFilter : FilterAttribute, IExceptionFilter
{ {
private readonly string _errorTitle;
public JsonErrorFilter(string errorTitle)
{
_errorTitle = errorTitle;
}
public void OnException(ExceptionContext filterContext) public void OnException(ExceptionContext filterContext)
{ {
filterContext.Result = NotificationResult.Error(_errorTitle, filterContext.Exception.Message); filterContext.Result = JsonNotificationResult.Opps(filterContext.Exception.Message);
filterContext.ExceptionHandled = true; filterContext.ExceptionHandled = true;
} }

View File

@ -2,9 +2,9 @@
namespace NzbDrone.Web.Models namespace NzbDrone.Web.Models
{ {
public class NotificationResult public class JsonNotificationResult
{ {
public NotificationResult() private JsonNotificationResult()
{ {
Text = string.Empty; Text = string.Empty;
} }
@ -16,7 +16,12 @@ public NotificationResult()
public static JsonResult Info(string title, string text) public static JsonResult Info(string title, string text)
{ {
return GetJsonResult(NotificationType.Error, title, text); return GetJsonResult(NotificationType.Info, title, text);
}
public static JsonResult Info(string title)
{
return GetJsonResult(NotificationType.Info, title, string.Empty);
} }
public static JsonResult Error(string title, string text) public static JsonResult Error(string title, string text)
@ -24,11 +29,17 @@ public static JsonResult Error(string title, string text)
return GetJsonResult(NotificationType.Error, title, text); return GetJsonResult(NotificationType.Error, title, text);
} }
public static JsonResult Opps(string text)
{
return GetJsonResult(NotificationType.Error, "Opps!", text);
}
public static JsonResult GetJsonResult(NotificationType notificationType, string title, string text) public static JsonResult GetJsonResult(NotificationType notificationType, string title, string text)
{ {
return new JsonResult return new JsonResult
{ {
Data = new NotificationResult { NotificationType = notificationType, Title = title, Text = text }, Data = new JsonNotificationResult { NotificationType = notificationType, Title = title, Text = text },
ContentType = null, ContentType = null,
ContentEncoding = null, ContentEncoding = null,
JsonRequestBehavior = JsonRequestBehavior.AllowGet JsonRequestBehavior = JsonRequestBehavior.AllowGet

View File

@ -213,7 +213,6 @@
<Compile Include="Controllers\SeriesController.cs" /> <Compile Include="Controllers\SeriesController.cs" />
<Compile Include="Controllers\SettingsController.cs" /> <Compile Include="Controllers\SettingsController.cs" />
<Compile Include="Controllers\SharedController.cs" /> <Compile Include="Controllers\SharedController.cs" />
<Compile Include="Controllers\StreamController.cs" />
<Compile Include="Controllers\SystemController.cs" /> <Compile Include="Controllers\SystemController.cs" />
<Compile Include="Controllers\UpcomingController.cs" /> <Compile Include="Controllers\UpcomingController.cs" />
<Compile Include="Controllers\UpdateController.cs" /> <Compile Include="Controllers\UpdateController.cs" />
@ -232,7 +231,7 @@
<Compile Include="Models\FooterModel.cs" /> <Compile Include="Models\FooterModel.cs" />
<Compile Include="Models\ExistingSeriesModel.cs" /> <Compile Include="Models\ExistingSeriesModel.cs" />
<Compile Include="Models\JobQueueItemModel.cs" /> <Compile Include="Models\JobQueueItemModel.cs" />
<Compile Include="Models\NotificationResult.cs" /> <Compile Include="Models\JsonNotificationResult.cs" />
<Compile Include="Models\PendingProcessingModel.cs" /> <Compile Include="Models\PendingProcessingModel.cs" />
<Compile Include="Models\ProwlPrioritySelectListModel.cs" /> <Compile Include="Models\ProwlPrioritySelectListModel.cs" />
<Compile Include="Models\SabnzbdSettingsModel.cs" /> <Compile Include="Models\SabnzbdSettingsModel.cs" />