AddExisting clears check/hides rows once submitted. Bi-winning

AddNew, currently unable to submit. Bi-polar
This commit is contained in:
Mark McDowall 2011-03-11 01:04:56 -08:00
parent c3425f493f
commit 5a8842e3db
11 changed files with 169 additions and 36 deletions

View File

@ -12,5 +12,6 @@ namespace NzbDrone.Core.Providers
void Add(RootDir rootDir);
void Remove(int rootDirId);
void Update(RootDir rootDir);
RootDir GetRootDir(int rootDirId);
}
}

View File

@ -38,6 +38,11 @@ namespace NzbDrone.Core.Providers
_sonioRepo.Update(rootDir);
}
public RootDir GetRootDir(int rootDirId)
{
return _sonioRepo.Single<RootDir>(rootDirId);
}
#endregion
}
}

View File

@ -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<String> checkedRecords)
{
var unmappedList = new List<SeriesMappingModel>();
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<SeriesSearchResultModel>();
//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<Episode> 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)

View File

@ -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; }
}
}

View File

@ -99,6 +99,7 @@
<Compile Include="Models\EpisodeModel.cs" />
<Compile Include="Models\NotificationSettingsModel.cs" />
<Compile Include="Models\QualityModel.cs" />
<Compile Include="Models\SeriesSearchResultModel.cs" />
<Compile Include="Models\SettingsModels.cs" />
<Compile Include="Models\TestModel.cs" />
<Compile Include="Ninject.Web.Mvc\ControllerMissingBindingResolver.cs" />
@ -282,6 +283,7 @@
<Content Include="Views\Series\Edit.aspx" />
<Content Include="Views\Series\EpisodeDetail.ascx" />
<Content Include="Views\Series\index.aspx" />
<Content Include="Views\Series\SeriesSearchResults.ascx" />
<Content Include="Views\Series\SubMenu.ascx" />
<Content Include="Views\Series\Unmapped.aspx" />
<Content Include="Views\Series\Add.aspx" />

View File

@ -10,13 +10,8 @@
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
//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") %>
<br />
<%: Html.ActionLink("Add Existing Series", "AddExisting", "Series") %>
</asp:Content>

View File

@ -4,7 +4,7 @@
<%@ Import Namespace="NzbDrone.Web.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Add Existing Series
Add Existing
</asp:Content>
<asp:Content ID="Menu" ContentPlaceHolderID="ActionMenu" runat="server">
<%
@ -33,10 +33,6 @@
</script>
//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<AddExistingSeriesModel>().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();
});
}
</script>
</asp:Content>

View File

@ -12,13 +12,12 @@
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
//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?
<p>
<button class="t.button" onclick="searchSeries ()">Search</button>
</p>
//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
<div id="result"></div>
<script type="text/javascript" language="javascript">
function searchSeries() {
var seriesSearch = $('#new_series_id');
// if ($seriesSearch.length < 1) {
// alert("Enter a valid name to search for");
// return;
// }
//Setup a function to handle the results... Or return a partial...
$("#result").load('<%=Url.Action("SearchForSeries", "Series") %>', {
seriesName: seriesSearch.val()
}
//this.window.location = '<%= Url.Action("Index", "Series") %>';
);
}
</script>
</asp:Content>

View File

@ -0,0 +1,68 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<NzbDrone.Web.Models.SeriesSearchResultModel>>" %>
<%@ Import Namespace="NzbDrone.Core.Repository" %>
<div id="searchResults">
<fieldset>
<legend>Search Results</legend>
<% 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()) %>)
<br />
<% } %>
</fieldset>
</div>
<div id="RootDirectories" style="display:none">
<fieldset>
<legend>Root TV Folders</legend>
<% foreach (var dir in (List<RootDir>)ViewData["RootDirs"])
{ %>
<%: Html.RadioButton("selectedRootDir", dir.RootDirId, dir.Default, new { @class="dirList examplePart", name = dir.Path }) %>
<%: Html.Label(dir.Path) %>
<% if (dir.Default) { %>* <% } %>
<br />
<% } %>
</fieldset>
<div id="example"></div>
<button class="t.button" onclick="addSeries ()">Add New Series</button>
</div>
<div id="tester"></div>
<script type="text/javascript">
$(".searchRadio").live("change", function () {
var checked = $(this).attr('checked');
if (checked) {
$('#tester').text(this.value);
document.getElementById('RootDirectories').style.display = 'inline';
}
});
function addSeries() {
//Get the selected tvdbid + selected root folder
//jquery bit below doesn't want to work...
var checkedSeries = $('input:radio[name=selectedSeries]:checked').val();
//$('input:radio[name=selectedSeries]:checked').val();
$('#tester').text(checkedSeries.value);
//$('#tester').text("Hello_jhasdajsd");
}
// $(".examplePart").live("change", function() {
// var dir = $('.selectedRootDir:checked');
// var show = $('.selectedSeries:checked');
// var sep = "\\";
// var str = "Example: " + dir.name + sep + show.name;
// $('#example').text(str);
//
// });
</script>

View File

@ -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();
%>

View File

@ -30,6 +30,9 @@
<fieldset>
<legend>General</legend>
//Browse Button??
//Auto-Complete?
<div style="padding-top: 10px;">
<div style="padding-left: 7px; margin-bottom: 5px;">
<a id="addItem" style="text-decoration:none;" href="<%: Url.Action("AddRootDir", "Settings") %>">