From 5a8842e3dbc7b3aab9efbdfece8d2e45501083d3 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Fri, 11 Mar 2011 01:04:56 -0800 Subject: [PATCH] AddExisting clears check/hides rows once submitted. Bi-winning AddNew, currently unable to submit. Bi-polar --- NzbDrone.Core/Providers/IRootDirProvider.cs | 1 + NzbDrone.Core/Providers/RootDirProvider.cs | 5 ++ NzbDrone.Web/Controllers/SeriesController.cs | 44 ++++++++++-- .../Models/SeriesSearchResultModel.cs | 14 ++++ NzbDrone.Web/NzbDrone.Web.csproj | 2 + NzbDrone.Web/Views/Series/Add.aspx | 11 +-- NzbDrone.Web/Views/Series/AddExisting.aspx | 22 +++--- NzbDrone.Web/Views/Series/AddNew.aspx | 32 +++++++-- .../Views/Series/SeriesSearchResults.ascx | 68 +++++++++++++++++++ NzbDrone.Web/Views/Series/SubMenu.ascx | 3 +- NzbDrone.Web/Views/Settings/General.ascx | 3 + 11 files changed, 169 insertions(+), 36 deletions(-) create mode 100644 NzbDrone.Web/Models/SeriesSearchResultModel.cs create mode 100644 NzbDrone.Web/Views/Series/SeriesSearchResults.ascx diff --git a/NzbDrone.Core/Providers/IRootDirProvider.cs b/NzbDrone.Core/Providers/IRootDirProvider.cs index 13897c202..d295ba146 100644 --- a/NzbDrone.Core/Providers/IRootDirProvider.cs +++ b/NzbDrone.Core/Providers/IRootDirProvider.cs @@ -12,5 +12,6 @@ namespace NzbDrone.Core.Providers void Add(RootDir rootDir); void Remove(int rootDirId); void Update(RootDir rootDir); + RootDir GetRootDir(int rootDirId); } } diff --git a/NzbDrone.Core/Providers/RootDirProvider.cs b/NzbDrone.Core/Providers/RootDirProvider.cs index d6154e275..c1d86dbb6 100644 --- a/NzbDrone.Core/Providers/RootDirProvider.cs +++ b/NzbDrone.Core/Providers/RootDirProvider.cs @@ -38,6 +38,11 @@ namespace NzbDrone.Core.Providers _sonioRepo.Update(rootDir); } + public RootDir GetRootDir(int rootDirId) + { + return _sonioRepo.Single(rootDirId); + } + #endregion } } diff --git a/NzbDrone.Web/Controllers/SeriesController.cs b/NzbDrone.Web/Controllers/SeriesController.cs index ea6256f65..68400213c 100644 --- a/NzbDrone.Web/Controllers/SeriesController.cs +++ b/NzbDrone.Web/Controllers/SeriesController.cs @@ -27,6 +27,7 @@ namespace NzbDrone.Web.Controllers private readonly IMediaFileProvider _mediaFileProvider; private readonly IRenameProvider _renameProvider; private readonly IRootDirProvider _rootDirProvider; + private readonly ITvDbProvider _tvDbProvider; // // GET: /Series/ @@ -34,7 +35,8 @@ namespace NzbDrone.Web.Controllers public SeriesController(ISyncProvider syncProvider, ISeriesProvider seriesProvider, IEpisodeProvider episodeProvider, IRssSyncProvider rssSyncProvider, IQualityProvider qualityProvider, IMediaFileProvider mediaFileProvider, - IRenameProvider renameProvider, IRootDirProvider rootDirProvider) + IRenameProvider renameProvider, IRootDirProvider rootDirProvider, + ITvDbProvider tvDbProvider) { _seriesProvider = seriesProvider; _episodeProvider = episodeProvider; @@ -44,6 +46,7 @@ namespace NzbDrone.Web.Controllers _mediaFileProvider = mediaFileProvider; _renameProvider = renameProvider; _rootDirProvider = rootDirProvider; + _tvDbProvider = tvDbProvider; } public ActionResult Index() @@ -62,6 +65,11 @@ namespace NzbDrone.Web.Controllers return View(); } + public ActionResult AddNew() + { + return View(); + } + public ActionResult RssSync() { _rssSyncProvider.Begin(); @@ -140,7 +148,6 @@ namespace NzbDrone.Web.Controllers public ActionResult SyncSelectedSeries(List checkedRecords) { - var unmappedList = new List(); foreach (var checkedRecord in checkedRecords) @@ -156,8 +163,34 @@ namespace NzbDrone.Web.Controllers unmappedList.Add(new SeriesMappingModel{Path = path, TvDbId = tvDbId}); } - _syncProvider.BeginSyncUnmappedFolders(unmappedList); - return Content("Sync Started for Selected Series"); + if(_syncProvider.BeginSyncUnmappedFolders(unmappedList)) + return Content("Sync Started for Selected Series"); + + return Content("Sync already in progress, please wait for it to complete before retrying."); + } + + public ActionResult SearchForSeries(string seriesName) + { + var model = new List(); + + //Get Results from TvDb and convert them to something we can use. + foreach (var tvdbSearchResult in _tvDbProvider.SearchSeries(seriesName)) + { + model.Add(new SeriesSearchResultModel + { + TvDbId = tvdbSearchResult.Id, + TvDbName = tvdbSearchResult.SeriesName, + FirstAired = tvdbSearchResult.FirstAired + }); + } + + ViewData["RootDirs"] = _rootDirProvider.GetAll(); + ViewData["DirSep"] = Path.DirectorySeparatorChar; + + //model.Add(new SeriesSearchResultModel{ TvDbId = 12345, TvDbName = "30 Rock", FirstAired = DateTime.Today }); + //model.Add(new SeriesSearchResultModel { TvDbId = 65432, TvDbName = "The Office (US)", FirstAired = DateTime.Today.AddDays(-100) }); + + return PartialView("SeriesSearchResults", model); } private IEnumerable GetData(GridCommand command) @@ -221,9 +254,6 @@ namespace NzbDrone.Web.Controllers return data;*/ } - // - // GET: /Series/Details/5 - [AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _SaveAjaxEditing(string id) diff --git a/NzbDrone.Web/Models/SeriesSearchResultModel.cs b/NzbDrone.Web/Models/SeriesSearchResultModel.cs new file mode 100644 index 000000000..ec5195700 --- /dev/null +++ b/NzbDrone.Web/Models/SeriesSearchResultModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace NzbDrone.Web.Models +{ + public class SeriesSearchResultModel + { + public int TvDbId { get; set; } + public string TvDbName { get; set; } + public DateTime FirstAired { get; set; } + } +} \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 9d015b340..502fe2f66 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -99,6 +99,7 @@ + @@ -282,6 +283,7 @@ + diff --git a/NzbDrone.Web/Views/Series/Add.aspx b/NzbDrone.Web/Views/Series/Add.aspx index 3df4ce31b..97bf2b5c7 100644 --- a/NzbDrone.Web/Views/Series/Add.aspx +++ b/NzbDrone.Web/Views/Series/Add.aspx @@ -10,13 +10,8 @@ - //Add New - - - //Add Existing - - //Ask user for existing TV Root Folder... - //Get list of unmapped folders and allow the user to check off the ones they want to add... - // + <%: Html.ActionLink("Add New Series", "AddNew", "Series") %> +
+ <%: Html.ActionLink("Add Existing Series", "AddExisting", "Series") %>
\ No newline at end of file diff --git a/NzbDrone.Web/Views/Series/AddExisting.aspx b/NzbDrone.Web/Views/Series/AddExisting.aspx index 53984e81e..84ece5697 100644 --- a/NzbDrone.Web/Views/Series/AddExisting.aspx +++ b/NzbDrone.Web/Views/Series/AddExisting.aspx @@ -4,7 +4,7 @@ <%@ Import Namespace="NzbDrone.Web.Models" %> - Add Existing Series + Add Existing <% @@ -33,10 +33,6 @@ - //Get AJAX listing of unmapped directories - //When getting unmapped, also do a quick lookup on TVDB to see which series we would map this to... Don't do the mapping though... - //ITvDbProvider.GetSeries(string title); - <% Html.Telerik().Grid().Name("Unmapped_Series_Folders") .TableHtmlAttributes(new { id = "UnmappedSeriesGrid" }) @@ -85,7 +81,6 @@ else { $('#mastercheckbox').attr('checked', false); } - }); //Sync for selected series @@ -100,15 +95,14 @@ $("#result").load('<%=Url.Action("SyncSelectedSeries", "Series") %>', { checkedRecords: $checkedRecords.map(function () { return jQuery.param({ path: this.name, tvdbid: this.value }) }) - } - - //this.window.location = '<%= Url.Action("Index", "Series") %>'; + }); - ); - - - - var grid = $('#UnmappedSeriesGrid').data('tGrid'); + //Hide the series that we just tried to sync up (uncheck them too, otherwise they will be re-sync'd if we sync again) + $checkedRecords.each(function () { + var id = "#row_" + this.value; + $(this).attr("checked", false); + $(id).hide(); + }); } diff --git a/NzbDrone.Web/Views/Series/AddNew.aspx b/NzbDrone.Web/Views/Series/AddNew.aspx index 16b2eb32b..cc380409d 100644 --- a/NzbDrone.Web/Views/Series/AddNew.aspx +++ b/NzbDrone.Web/Views/Series/AddNew.aspx @@ -12,13 +12,12 @@ - //Add a new series - <%= Html.Label("Enter a Series Name") %> - <%= Html.TextBox("new_series_name", new { id="new_series_id" }) %> + <%= Html.TextBox("new_series_name", String.Empty, new { id="new_series_id" }) %> - //Browse Button?? - //Auto-Complete? +

+ +

//Search Button - Perform AJAX search for this Series on TVDB @@ -28,5 +27,28 @@ Add, ask user to choose where to save the show in (used when sorting) then add the show... Possibly ask user to choose Quality Profile +
+ +
diff --git a/NzbDrone.Web/Views/Series/SeriesSearchResults.ascx b/NzbDrone.Web/Views/Series/SeriesSearchResults.ascx new file mode 100644 index 000000000..6395ebb4e --- /dev/null +++ b/NzbDrone.Web/Views/Series/SeriesSearchResults.ascx @@ -0,0 +1,68 @@ +<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl>" %> +<%@ Import Namespace="NzbDrone.Core.Repository" %> + +
+
+ Search Results + <% foreach (var result in Model) + { %> + <%: Html.RadioButton("selectedSeries", result.TvDbId, new { @class="searchRadio examplePart", name = result.TvDbName }) %> + <%: Html.Label(result.TvDbName) %> (<%: Html.Label(result.FirstAired.ToString()) %>) +
+ <% } %> +
+
+ + + +
+ + \ No newline at end of file diff --git a/NzbDrone.Web/Views/Series/SubMenu.ascx b/NzbDrone.Web/Views/Series/SubMenu.ascx index 1fd8646df..7fbb7852e 100644 --- a/NzbDrone.Web/Views/Series/SubMenu.ascx +++ b/NzbDrone.Web/Views/Series/SubMenu.ascx @@ -4,9 +4,8 @@ <% Html.Telerik().Menu().Name("telerikGrid").Items(items => { - items.Add().Text("View Unmapped Folders").Action("Unmapped", "Series"); + items.Add().Text("Add Series").Action("Add", "Series"); items.Add().Text("Start RSS Sync").Action("RssSync", "Series"); items.Add().Text("Rename All").Action("RenameAll", "Series"); - items.Add().Text("Add Series").Action("Add", "Series"); }).Render(); %> \ No newline at end of file diff --git a/NzbDrone.Web/Views/Settings/General.ascx b/NzbDrone.Web/Views/Settings/General.ascx index bb63c61b4..d54882ce3 100644 --- a/NzbDrone.Web/Views/Settings/General.ascx +++ b/NzbDrone.Web/Views/Settings/General.ascx @@ -30,6 +30,9 @@
General + //Browse Button?? + //Auto-Complete? +