diff --git a/NzbDrone.Web/Content/Images/VideoFolder.png b/NzbDrone.Web/Content/Images/VideoFolder.png new file mode 100644 index 000000000..566c41eb7 Binary files /dev/null and b/NzbDrone.Web/Content/Images/VideoFolder.png differ diff --git a/NzbDrone.Web/Content/style.css b/NzbDrone.Web/Content/style.css index a4aee9077..278830506 100644 --- a/NzbDrone.Web/Content/style.css +++ b/NzbDrone.Web/Content/style.css @@ -334,4 +334,4 @@ button, input[type="button"], input[type="submit"], input[type="reset"] -khtml-opacity: 0.8; opacity: 0.8; line-height: 90% - } \ No newline at end of file + } \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/AddSeriesController.cs b/NzbDrone.Web/Controllers/AddSeriesController.cs index e2ad88b50..2573c1812 100644 --- a/NzbDrone.Web/Controllers/AddSeriesController.cs +++ b/NzbDrone.Web/Controllers/AddSeriesController.cs @@ -3,16 +3,19 @@ using System.Collections.Generic; using System.IO; using System.Web.Mvc; using System.Linq; +using NLog; using NzbDrone.Core.Helpers; using NzbDrone.Core.Providers; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Jobs; +using NzbDrone.Core.Repository; using NzbDrone.Web.Models; namespace NzbDrone.Web.Controllers { public class AddSeriesController : Controller { + private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); private readonly ConfigProvider _configProvider; private readonly QualityProvider _qualityProvider; private readonly RootDirProvider _rootFolderProvider; @@ -70,6 +73,8 @@ namespace NzbDrone.Web.Controllers public ActionResult Add() { + ViewData["RootDirs"] = _rootFolderProvider.GetAll(); + var unmappedList = new List(); var profiles = _qualityProvider.GetAllProfiles(); @@ -109,15 +114,25 @@ namespace NzbDrone.Web.Controllers [HttpPost] public JsonResult AddNewSeries(string rootPath, string seriesName, int seriesId, int qualityProfileId) { - var path = rootPath.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar).Replace('`', '\'') + - Path.DirectorySeparatorChar + EpisodeRenameHelper.CleanFilename(seriesName); + try + { + var path = + rootPath.Replace('|', Path.DirectorySeparatorChar).Replace('^', Path.VolumeSeparatorChar).Replace( + '`', '\'') + + Path.DirectorySeparatorChar + EpisodeRenameHelper.CleanFilename(seriesName); - //Create the folder for the new series and then Add it - _diskProvider.CreateDirectory(path); + //Create the folder for the new series and then Add it + _diskProvider.CreateDirectory(path); - _seriesProvider.AddSeries(path, seriesId, qualityProfileId); - ScanNewSeries(); - return new JsonResult { Data = "ok" }; + _seriesProvider.AddSeries(path, seriesId, qualityProfileId); + ScanNewSeries(); + return new JsonResult {Data = "ok"}; + } + + catch(Exception ex) + { + return new JsonResult { Data = "failed" }; + } } public JsonResult AddSeries(string path, int seriesId, int qualityProfileId) @@ -157,5 +172,80 @@ namespace NzbDrone.Web.Controllers return new SelectList(dataVal, "Id", "SeriesName", selectId); } + + [HttpPost] + public JsonResult SaveRootDir(int id, string path) + { + try + { + _rootFolderProvider.Update(new RootDir { Id = id, Path = path }); + } + catch (Exception ex) + { + Logger.Debug("Failed to save Root Dir"); + Logger.DebugException(ex.Message, ex); + + return new JsonResult { Data = "failed" }; + } + + return new JsonResult { Data = "ok" }; + } + + public ViewResult AddRootDir() + { + var rootDir = new RootDir { Path = String.Empty }; + + var id = _rootFolderProvider.Add(rootDir); + rootDir.Id = id; + + ViewData["RootDirId"] = id; + + return View("RootDir", rootDir); + } + + public ActionResult GetRootDirView(RootDir rootDir) + { + ViewData["RootDirId"] = rootDir.Id; + + return PartialView("RootDir", rootDir); + } + + public JsonResult DeleteRootDir(int rootDirId) + { + try + { + _rootFolderProvider.Remove(rootDirId); + } + + catch (Exception) + { + return new JsonResult { Data = "failed" }; + } + + return new JsonResult { Data = "ok" }; + } + + public JsonResult JsonAutoCompletePath(string term) + { + var windowsSep = term.LastIndexOf('\\'); + + if (windowsSep > -1) + { + var start = term.Substring(windowsSep + 1); + var dirs = _diskProvider.GetDirectories(term.Substring(0, windowsSep + 1)).Where(d => new DirectoryInfo(d).Name.ToLower().StartsWith(start.ToLower())).Take(10); + return Json(dirs.ToArray(), JsonRequestBehavior.AllowGet); + } + + var index = term.LastIndexOf('/'); + + if (index > -1) + { + var start = term.Substring(index + 1); + var dirs = _diskProvider.GetDirectories(term.Substring(0, index + 1)).Where(d => new DirectoryInfo(d).Name.ToLower().StartsWith(start.ToLower())).Take(10); + return Json(dirs.ToArray(), JsonRequestBehavior.AllowGet); + } + + return Json(new JsonResult(), JsonRequestBehavior.AllowGet); + } } } \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/SettingsController.cs b/NzbDrone.Web/Controllers/SettingsController.cs index b88d81708..1a00d24d9 100644 --- a/NzbDrone.Web/Controllers/SettingsController.cs +++ b/NzbDrone.Web/Controllers/SettingsController.cs @@ -62,21 +62,11 @@ namespace NzbDrone.Web.Controllers ViewData["viewName"] = viewName; else - return RedirectToAction("General"); + return RedirectToAction("Indexers"); return View("Index"); } - public ActionResult General() - { - ViewData["viewName"] = "General"; - - return View("Index", new SettingsModel - { - Directories = _rootDirProvider.GetAll() - }); - } - public ActionResult Indexers() { ViewData["viewName"] = "Indexers"; @@ -236,40 +226,6 @@ namespace NzbDrone.Web.Controllers return PartialView("QualityProfileItem", profile); } - public ViewResult AddRootDir() - { - var rootDir = new RootDir { Path = String.Empty }; - - var id = _rootDirProvider.Add(rootDir); - rootDir.Id = id; - - ViewData["RootDirId"] = id; - - return View("RootDir", rootDir); - } - - public ActionResult GetRootDirView(RootDir rootDir) - { - ViewData["RootDirId"] = rootDir.Id; - - return PartialView("RootDir", rootDir); - } - - public JsonResult DeleteRootDir(int rootDirId) - { - try - { - _rootDirProvider.Remove(rootDirId); - } - - catch (Exception) - { - return new JsonResult { Data = "failed" }; - } - - return new JsonResult { Data = "ok" }; - } - public ActionResult SubMenu() { return PartialView(); @@ -317,29 +273,6 @@ namespace NzbDrone.Web.Controllers } } - public JsonResult JsonAutoCompletePath(string term) - { - var windowsSep = term.LastIndexOf('\\'); - - if (windowsSep > -1) - { - var start = term.Substring(windowsSep + 1); - var dirs = _diskProvider.GetDirectories(term.Substring(0, windowsSep + 1)).Where(d => new DirectoryInfo(d).Name.ToLower().StartsWith(start.ToLower())).Take(10); - return Json(dirs.ToArray(), JsonRequestBehavior.AllowGet); - } - - var index = term.LastIndexOf('/'); - - if (index > -1) - { - var start = term.Substring(index + 1); - var dirs = _diskProvider.GetDirectories(term.Substring(0, index + 1)).Where(d => new DirectoryInfo(d).Name.ToLower().StartsWith(start.ToLower())).Take(10); - return Json(dirs.ToArray(), JsonRequestBehavior.AllowGet); - } - - return Json(new JsonResult(), JsonRequestBehavior.AllowGet); - } - [HttpPost] public ActionResult SaveGeneral(SettingsModel data) { diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index a75cebce3..130169841 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -696,10 +696,9 @@ - - + diff --git a/NzbDrone.Web/Views/AddSeries/Add.cshtml b/NzbDrone.Web/Views/AddSeries/Add.cshtml index 87933d52a..8c104f3df 100644 --- a/NzbDrone.Web/Views/AddSeries/Add.cshtml +++ b/NzbDrone.Web/Views/AddSeries/Add.cshtml @@ -1,7 +1,18 @@ @model IEnumerable +@using NzbDrone.Core.Repository + + @section TitleContent{ Add Series } @@ -21,17 +32,47 @@ .LoadContentFrom("AddNew", "AddSeries") .Render(); } - - @if (Model.Count() == 0) + + @{ Html.Telerik().PanelBar() + .Name("RootDirPanel") + .HtmlAttributes(new { style = "margin: 0px;" }) + .ExpandMode(PanelBarExpandMode.Multiple) + .Items(panelItem => { - @Html.DisplayText("No Series to Add"); + panelItem.Add() + .Text("Root Directories") + .ImageUrl("~/Content/Images/VideoFolder.png") + .Content(@ +
+ + +
+ @foreach (var root in ViewData["RootDirs"] as List) + { + Html.RenderAction("GetRootDirView", root); + } +
+
+
); + }).Render(); } +
+ @Html.Telerik().DropDownList().Name("masterDropbox").BindTo((SelectList) ViewData["qualities"]).HtmlAttributes( new {style = "width: 100px; margin-left:5px;"}).ClientEvents(events => events.OnChange("masterChanged")) + @if (Model.Count() == 0) + { + @Html.DisplayText("No Series to Add"); + } + @foreach (var path in Model) { Html.RenderAction("RenderPartial", "AddSeries", new {path}); @@ -39,7 +80,6 @@ } \ No newline at end of file diff --git a/NzbDrone.Web/Views/AddSeries/AddNew.cshtml b/NzbDrone.Web/Views/AddSeries/AddNew.cshtml index b7f37b191..2a86e3913 100644 --- a/NzbDrone.Web/Views/AddSeries/AddNew.cshtml +++ b/NzbDrone.Web/Views/AddSeries/AddNew.cshtml @@ -53,14 +53,18 @@ url: addNewSeriesUrl, data: jQuery.param({ rootPath: rootPath, seriesName: seriesName, seriesId: id, qualityProfileId: quality }), error: function (req, status, error) { - alert("Sorry! We could not add " + path + " at this time. " + error); + alert("Sorry! We could not add " + seriesName + " at this time. " + error); }, - success: function (){ + success: function (data, textStatus, jqXHR){ //Clear the search box $("#seriesList_new").data("tComboBox").text(''); - //Close the Window! - closeAddNewSeries(); + //Through up an alert if we failed to add the series + if (data != 'ok') + alert("Sorry! We could not add " + seriesName + ", does it already exist?"); + + else + closeAddNewSeries(); //Close the Window! } }); } diff --git a/NzbDrone.Web/Views/AddSeries/AddSeriesItem.cshtml b/NzbDrone.Web/Views/AddSeries/AddSeriesItem.cshtml index 63f728966..32f84c960 100644 --- a/NzbDrone.Web/Views/AddSeries/AddSeriesItem.cshtml +++ b/NzbDrone.Web/Views/AddSeries/AddSeriesItem.cshtml @@ -5,39 +5,16 @@ @ViewData["path"].ToString()
@{Html.Telerik().ComboBox() - .Name("seriesList_" + ViewData["guid"].ToString()) + .Name("seriesList_" + ViewData["guid"]) .BindTo(Model) .DataBinding(binding => binding.Ajax().Select("_textLookUp", "AddSeries").Delay(400)) .Filterable(f => f.FilterMode(AutoCompleteFilterMode.Contains)) .HighlightFirstMatch(true) .HtmlAttributes(new { style = "width: 300px;" }) .Render();} - @Html.Telerik().DropDownList().Name("qualityList_" + ViewData["guid"].ToString()).BindTo((SelectList)ViewData["quality"]).HtmlAttributes(new { style = "width: 100px", @class = "qualityDropbox" }) + @Html.Telerik().DropDownList().Name("qualityList_" + ViewData["guid"]).BindTo((SelectList)ViewData["quality"]).HtmlAttributes(new { style = "width: 100px", @class = "qualityDropbox" })
- - + \ No newline at end of file diff --git a/NzbDrone.Web/Views/AddSeries/RootDir.cshtml b/NzbDrone.Web/Views/AddSeries/RootDir.cshtml new file mode 100644 index 000000000..465e73562 --- /dev/null +++ b/NzbDrone.Web/Views/AddSeries/RootDir.cshtml @@ -0,0 +1,16 @@ +@model NzbDrone.Core.Repository.RootDir + +@{ + Layout = null; +} + +
+
+ @Html.TextBoxFor(m => m.Path, new { @class = "root_dir_text", id = "path_" + Model.Id }) + + Delete + + + @Html.HiddenFor(x => x.Id, new { id = "id_" + Model.Id }) +
+
\ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/General.cshtml b/NzbDrone.Web/Views/Settings/General.cshtml deleted file mode 100644 index e24e8b1d9..000000000 --- a/NzbDrone.Web/Views/Settings/General.cshtml +++ /dev/null @@ -1,88 +0,0 @@ -@model NzbDrone.Web.Models.SettingsModel - - - -@using (Html.BeginForm("SaveGeneral", "Settings", FormMethod.Post, new {id = "form", name = "form"})) -{ -@Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again."); -
- General - -
- - -
- @foreach (var item in Model.Directories) - { - Html.RenderAction("GetRootDirView", item); - } -
-
- - -
-} -
- - \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/Indexers.cshtml b/NzbDrone.Web/Views/Settings/Indexers.cshtml index 865fef4a6..cc47e0cf3 100644 --- a/NzbDrone.Web/Views/Settings/Indexers.cshtml +++ b/NzbDrone.Web/Views/Settings/Indexers.cshtml @@ -63,140 +63,139 @@ .HtmlAttributes(new { style = "width: 300px; margin: 10px;" }) .ExpandMode(PanelBarExpandMode.Single) .SelectedIndex(0) - .Items(item => + .Items(indexerItem => { - item.Add() + indexerItem.Add() .Text("NZBs.org") .ImageUrl("~/Content/Images/Indexers/NzbsOrg.png") - .Content( - "
" + + .Content(@ +
+
+
+ Enabled +
+
+ @Html.CheckBoxFor(m => m.NzbsOrgEnabled, new { @class = "indexer_checkbox" }) +
+
- "
" + - "
" + - "Enabled" + - "
" + - "
" + - Html.CheckBoxFor(m => m.NzbsOrgEnabled, new { @class = "indexer_checkbox" }) + - "
" + - "
" + - - "
" + - "
" + - Html.LabelFor(m => m.NzbsOrgUId) + - "
" + - "
" + - Html.TextBoxFor(m => m.NzbsOrgUId) + - "
" + - "
" + - "
" + - "
" + - Html.LabelFor(m => m.NzbsOrgHash) + - "
" + - "
" + - Html.TextBoxFor(m => m.NzbsOrgHash) + - "
" + - "
" + - "
" - ); - item.Add() +
+
+ @Html.LabelFor(m => m.NzbsOrgUId) +
+
+ @Html.TextBoxFor(m => m.NzbsOrgUId) +
+
+
+
+ @Html.LabelFor(m => m.NzbsOrgHash) +
+
+ @Html.TextBoxFor(m => m.NzbsOrgHash) +
+
+
+ ); + indexerItem.Add() .Text("NZB Matrix") .ImageUrl("~/Content/Images/Indexers/NzbMatrix.png") - .Content( - "
" + + .Content(@ +
- "
" + - "
" + - "Enabled" + - "
" + - "
" + - Html.CheckBoxFor(m => m.NzbMatrixEnabled, new { @class = "indexer_checkbox" }) + - "
" + - "
" + +
+
+ Enabled +
+
+ @Html.CheckBoxFor(m => m.NzbMatrixEnabled, new { @class = "indexer_checkbox" }) +
+
- "
" + - "
" + - Html.LabelFor(m => m.NzbMatrixUsername) + - "
" + - "
" + - Html.TextBoxFor(m => m.NzbMatrixUsername) + - "
" + - "
" + - "
" + - "
" + - Html.LabelFor(m => m.NzbMatrixApiKey) + - "
" + - "
" + - Html.TextBoxFor(m => m.NzbMatrixApiKey) + - "
" + - "
" + - "
" - ); - item.Add() +
+
+ @Html.LabelFor(m => m.NzbMatrixUsername) +
+
+ @Html.TextBoxFor(m => m.NzbMatrixUsername) +
+
+
+
+ @Html.LabelFor(m => m.NzbMatrixApiKey) +
+
+ @Html.TextBoxFor(m => m.NzbMatrixApiKey) +
+
+
+ ); + indexerItem.Add() .Text("NZBsRus") .ImageUrl("~/Content/Images/Indexers/NzbsRus.png") - .Content( - "
" + + .Content(@ +
- "
" + - "
" + - "Enabled" + - "
" + - "
" + - Html.CheckBoxFor(m => m.NzbsRUsEnabled, new { @class = "indexer_checkbox" }) + - "
" + - "
" + +
+
+ Enabled +
+
+ @Html.CheckBoxFor(m => m.NzbsRUsEnabled, new { @class = "indexer_checkbox" }) +
+
- "
" + - "
" + - Html.LabelFor(m => m.NzbsrusUId) + - "
" + - "
" + - Html.TextBoxFor(m => m.NzbsrusUId) + - "
" + - "
" + - "
" + - "
" + - Html.LabelFor(m => m.NzbsrusHash) + - "
" + - "
" + - Html.TextBoxFor(m => m.NzbsrusHash) + - "
" + - "
" + - "
" - ); - item.Add() +
+
+ @Html.LabelFor(m => m.NzbsrusUId) +
+
+ @Html.TextBoxFor(m => m.NzbsrusUId) +
+
+
+
+ @Html.LabelFor(m => m.NzbsrusHash) +
+
+ @Html.TextBoxFor(m => m.NzbsrusHash) +
+
+
+ ); + indexerItem.Add() .Text("Newzbin") .ImageUrl("~/Content/Images/Indexers/Newzbin.png") - .Content( - "
" + + .Content(@ +
- "
" + - "
" + - "Enabled" + - "
" + - "
" + - Html.CheckBoxFor(m => m.NewzbinEnabled, new { @class = "indexer_checkbox" }) + - "
" + - "
" + +
+
+ Enabled +
+
+ @Html.CheckBoxFor(m => m.NewzbinEnabled, new { @class = "indexer_checkbox" }) +
+
- "
" + - "
" + - Html.LabelFor(m => m.NewzbinUsername) + - "
" + - "
" + - Html.TextBoxFor(m => m.NewzbinUsername) + - "
" + - "
" + - "
" + - "
" + - Html.LabelFor(m => m.NewzbinPassword) + - "
" + - "
" + - Html.TextBoxFor(m => m.NewzbinPassword) + - "
" + - "
" + - "
" - ); +
+
+ @Html.LabelFor(m => m.NewzbinUsername) +
+
+ @Html.TextBoxFor(m => m.NewzbinUsername) +
+
+
+
+ @Html.LabelFor(m => m.NewzbinPassword) +
+
+ @Html.TextBoxFor(m => m.NewzbinPassword) +
+
+
+ ); }).Render(); } diff --git a/NzbDrone.Web/Views/Settings/RootDir.cshtml b/NzbDrone.Web/Views/Settings/RootDir.cshtml deleted file mode 100644 index 65df3ab13..000000000 --- a/NzbDrone.Web/Views/Settings/RootDir.cshtml +++ /dev/null @@ -1,35 +0,0 @@ -@model NzbDrone.Core.Repository.RootDir -@using NzbDrone.Web.Helpers; - -@{ - Layout = null; -} - - - -@using (Html.BeginCollectionItem("Directories")) -{ - var idClean = ViewData.TemplateInfo.HtmlFieldPrefix.Replace('[', '_').Replace(']', '_'); - - -
-
-
- @Html.TextBoxFor(m => m.Path, new { @class = "root_dir_text" }) - - Delete -
-
- @Html.ValidationMessageFor(m => m.Path) -
-
- @Html.TextBoxFor(x => x.Id, new { @style = "display:none" }) -
-
-
-} \ No newline at end of file