fixed ajax call for add existing

pull/7/merge
kay.one 14 years ago
parent f7a5e0d8f8
commit 4000387419

@ -187,28 +187,16 @@ namespace NzbDrone.Web.Controllers
return View(new GridModel(unmappedList));
}
public ActionResult SyncSelectedSeries(List<String> checkedRecords)
public ActionResult SyncSelectedSeries(string path, int tvdbId, int qualityProfileId)
{
var unmappedList = new List<SeriesMappingModel>();
foreach (var checkedRecord in checkedRecords)
{
NameValueCollection nvc = HttpUtility.ParseQueryString(checkedRecord);
var path = HttpUtility.UrlDecode(nvc["path"]);
var tvDbId = Convert.ToInt32(HttpUtility.UrlDecode(nvc["tvdbid"]));
var qualityProfileId = Convert.ToInt32(HttpUtility.UrlDecode(nvc["qualityProfileId"]));
//If the TvDbId for this show is 0 then skip it... User made a mistake... They will have to manually map it
if (tvDbId < 1) continue;
unmappedList.Add(new SeriesMappingModel { Path = path, TvDbId = tvDbId, QualityProfileId = qualityProfileId });
}
if (tvdbId < 1) throw new ArgumentException("Invalid tvdb id", "tvdbId");
if (_syncProvider.BeginSyncUnmappedFolders(unmappedList))
return Content("Sync Started for Selected Series");
unmappedList.Add(new SeriesMappingModel { Path = path, TvDbId = tvdbId, QualityProfileId = qualityProfileId });
return Content("Sync already in progress, please wait for it to complete before retrying.");
return Content("Ok");
}
public ActionResult AddNewSeries(string dir, int seriesId, string seriesName, int qualityProfileId)

@ -2,7 +2,6 @@
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<%@ Import Namespace="NzbDrone.Web.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Add Existing Series
</asp:Content>
@ -12,7 +11,6 @@
%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
$(document).ready(function () {
$('#mastercheckbox').attr("checked", "checked");
@ -37,10 +35,8 @@
};
</script>
<%= Html.Label("Quality Profile")%>
<%: Html.DropDownList("qualityProfileId", (SelectList)ViewData["QualitySelectList"], ViewData["QualityProfileId"])%>
<div id="unmappedGrid" style="display: none">
<%
Html.Telerik().Grid<AddExistingSeriesModel>().Name("Unmapped_Series_Folders")
@ -64,15 +60,13 @@
.Footer(false)
.Render();
%>
<p>
<button class="t.button" onclick="syncSelected ()">Sync Selected Series</button>
<button class="t.button" onclick="syncSelected ()">
Sync Selected Series</button>
</p>
</div>
<div id="result"></div>
<div id="result">
</div>
<script type="text/javascript" language="javascript">
// MasterCheckBox functionality
@ -110,17 +104,30 @@
var qualityProfileId = $("#qualityProfileId").val();
$checkedRecords.each(function () {
$.ajax(
{
type: "POST",
url: "/Series/SyncSelectedSeries",
data: jQuery.param({ path: this.name, tvdbid: this.value, qualityProfileId: qualityProfileId }),
error: function (req, status, error) {
alert("Sorry! We could not add " + this.name + "at this time");
}
}
);
$("#result").load('<%=Url.Action("SyncSelectedSeries", "Series") %>', {
checkedRecords: $checkedRecords.map(function () { return jQuery.param({ path: this.name, tvdbid: this.value, qualityProfileId: qualityProfileId }) })
});
//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>

Loading…
Cancel
Save