From 88525a0b7c299162710ac831b1e91f395fba4ab2 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 23 Aug 2011 13:31:28 -0700 Subject: [PATCH] AddSeries javascript fixes. Add new series now has a drop box for rootdir. Moved add series javascript to addSeries.js. --- .../Controllers/AddSeriesController.cs | 2 +- NzbDrone.Web/NzbDrone.Web.csproj | 1 + NzbDrone.Web/Scripts/addSeries.js | 119 ++++++++++++++++++ NzbDrone.Web/Views/AddSeries/AddNew.cshtml | 35 +----- .../Views/AddSeries/ExistingSeries.cshtml | 76 +++-------- NzbDrone.Web/Views/AddSeries/Index.cshtml | 12 +- NzbDrone.Web/Views/AddSeries/RootDir.cshtml | 34 ----- 7 files changed, 152 insertions(+), 127 deletions(-) create mode 100644 NzbDrone.Web/Scripts/addSeries.js diff --git a/NzbDrone.Web/Controllers/AddSeriesController.cs b/NzbDrone.Web/Controllers/AddSeriesController.cs index 3951ead81..e7fd3607a 100644 --- a/NzbDrone.Web/Controllers/AddSeriesController.cs +++ b/NzbDrone.Web/Controllers/AddSeriesController.cs @@ -166,7 +166,7 @@ namespace NzbDrone.Web.Controllers return new JsonResult { Data = "failed" }; } - return new JsonResult { }; + return new JsonResult { Data = "ok" }; } [HttpGet] diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 53caf1316..4cc76e02d 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -267,6 +267,7 @@ + diff --git a/NzbDrone.Web/Scripts/addSeries.js b/NzbDrone.Web/Scripts/addSeries.js new file mode 100644 index 000000000..7242e3312 --- /dev/null +++ b/NzbDrone.Web/Scripts/addSeries.js @@ -0,0 +1,119 @@ +//URLs +var addSeriesUrl = '../AddSeries/AddExistingSeries'; +var addNewSeriesUrl = '../AddSeries/AddNewSeries'; +var existingSeriesUrl = '../AddSeries/ExistingSeries'; +var addNewUrl = '../AddSeries/AddNew'; + +var deleteRootDirUrl = '../AddSeries/DeleteRootDir'; +var saveRootDirUrl = '../AddSeries/SaveRootDir'; +var rootListUrl = '../AddSeries/RootList'; + + +//ExistingSeries +$(".masterQualitySelector").live('change', function () { + + var profileId = $(this).val(); + $("#existingSeries").find(".qualitySelector").each(function () { + $(this).val(profileId); + }); +}); + +$(".addExistingButton").live('click', function () { + + var root = $(this).parents(".existingSeries"); + + var title = $(this).siblings(".seriesLookup").val(); + var qualityId = $(this).siblings(".qualitySelector").val(); + + var path = root.find(".seriesPathValue Label").text(); + + $.ajax({ + type: "POST", + url: addSeriesUrl, + data: jQuery.param({ path: path, seriesName: title, qualityProfileId: qualityId }), + error: function (req, status, error) { + alert("Sorry! We could not add " + path + " at this time. " + error); + }, + success: function () { + root.hide('highlight', 'fast'); + } + }); + +}); + +function reloadExistingSeries() { + $.get(existingSeriesUrl, function (data) { + $('#existingSeries').html(data); + }); +} + +//RootDir +//$('#rootDirInput').watermark('Start typing to add new root folder...'); + +$('#rootDirs .actionButton img').live('click', function (image) { + var path = $(image.target).attr('id'); + $.post(deleteRootDirUrl, { Path: path }, function () { + refreshRoot(); + }); +}); + +$('#saveDir').live('click', saveRootDir); + +function saveRootDir() { + var path = $("#rootDirInput").val(); + if (path) { + $.post(saveRootDirUrl, { Path: path }, function () { + refreshRoot(); + $("#rootDirInput").val(''); + }); + } +} + +function refreshRoot() { + $.get(rootListUrl, function (data) { + $('#rootDirs').html(data); + }); + reloadAddNew(); + reloadExistingSeries(); +} + + +//AddNew +//$('#newSeriesPath').watermark('Path for the new series...'); +//$('#newSeriesLookup').watermark('Title of the series you want to add...'); + +$('#saveNewSeries').live('click', function () { + var seriesTitle = $("#newSeriesLookup").val(); + var qualityId = $("#qualityList").val(); + var path = $('#newSeriesPath').val(); + + $.ajax({ + type: "POST", + url: addNewSeriesUrl, + data: jQuery.param({ path: path, seriesName: seriesTitle, qualityProfileId: qualityId }), + error: function (req, status, error) { + alert("Sorry! We could not add " + path + " at this time. " + error); + }, + success: function () { + $("#newSeriesLookup").val(""); + //$('#newSeriesPath').val(""); + } + }); +}); + +function reloadAddNew() { + $.get(addNewUrl, function (data) { + $('#addNewSeries').html(data); + }); +} + + +//On load +jQuery(document).ready(function () { + //RootDir + $('#rootDirInput').watermark('Start typing to add new root folder...'); + + //AddNew + $('#newSeriesPath').watermark('Path for the new series...'); + $('#newSeriesLookup').watermark('Title of the series you want to add...'); +}); \ No newline at end of file diff --git a/NzbDrone.Web/Views/AddSeries/AddNew.cshtml b/NzbDrone.Web/Views/AddSeries/AddNew.cshtml index cdb834363..58249f5f3 100644 --- a/NzbDrone.Web/Views/AddSeries/AddNew.cshtml +++ b/NzbDrone.Web/Views/AddSeries/AddNew.cshtml @@ -5,41 +5,10 @@
- + @**@ + @Html.DropDownList("newSeriesPath", new SelectList((IList)ViewData["RootDirs"]), new { style = "width: 406px; margin-left: 0px;" }) @Html.DropDownList("qualityList", new SelectList((IList)ViewData["QualityList"], "QualityProfileId", "Name"), new { @class = "qualitySelector" })
- diff --git a/NzbDrone.Web/Views/AddSeries/ExistingSeries.cshtml b/NzbDrone.Web/Views/AddSeries/ExistingSeries.cshtml index eaa88eea6..22dd4827a 100644 --- a/NzbDrone.Web/Views/AddSeries/ExistingSeries.cshtml +++ b/NzbDrone.Web/Views/AddSeries/ExistingSeries.cshtml @@ -5,6 +5,26 @@ @{ Layout = null; } + + + @if (Model.ExistingSeries.Count == 0) {

@@ -38,59 +58,3 @@ else } - - - diff --git a/NzbDrone.Web/Views/AddSeries/Index.cshtml b/NzbDrone.Web/Views/AddSeries/Index.cshtml index 4912142ff..bd5289ebe 100644 --- a/NzbDrone.Web/Views/AddSeries/Index.cshtml +++ b/NzbDrone.Web/Views/AddSeries/Index.cshtml @@ -2,10 +2,16 @@ @section TitleContent{ Add Series } + +@section HeaderContent{ + +} + @section MainContent{ -

- Add New Series

- @{ Html.RenderAction("AddNew", "AddSeries"); } +

Add New Series

+
+ @{ Html.RenderAction("AddNew", "AddSeries"); } +

Add Series Already on Disk

diff --git a/NzbDrone.Web/Views/AddSeries/RootDir.cshtml b/NzbDrone.Web/Views/AddSeries/RootDir.cshtml index 2e566ab00..b2ebc8da6 100644 --- a/NzbDrone.Web/Views/AddSeries/RootDir.cshtml +++ b/NzbDrone.Web/Views/AddSeries/RootDir.cshtml @@ -5,37 +5,3 @@ @{Html.RenderAction("RootList");} -