mirror of https://github.com/Radarr/Radarr
SeriesId is now passed back to the controller when adding a new/existing series.
This commit is contained in:
parent
d330c65165
commit
7786f6a914
|
@ -69,7 +69,6 @@ namespace NzbDrone.Web.Controllers
|
|||
return View();
|
||||
}
|
||||
|
||||
|
||||
public ActionResult ExistingSeries()
|
||||
{
|
||||
var result = new ExistingSeriesModel();
|
||||
|
@ -81,7 +80,7 @@ namespace NzbDrone.Web.Controllers
|
|||
unmappedList.AddRange(_rootFolderProvider.GetUnmappedFolders(folder.Path));
|
||||
}
|
||||
|
||||
result.ExistingSeries = new List<Tuple<string, string>>();
|
||||
result.ExistingSeries = new List<Tuple<string, string, int>>();
|
||||
|
||||
foreach (var folder in unmappedList)
|
||||
{
|
||||
|
@ -89,12 +88,14 @@ namespace NzbDrone.Web.Controllers
|
|||
var tvdbResult = _tvDbProvider.SearchSeries(foldername).FirstOrDefault();
|
||||
|
||||
var title = String.Empty;
|
||||
var seriesId = 0;
|
||||
if (tvdbResult != null)
|
||||
{
|
||||
title = tvdbResult.SeriesName;
|
||||
seriesId = tvdbResult.Id;
|
||||
}
|
||||
|
||||
result.ExistingSeries.Add(new Tuple<string, string>(folder, title));
|
||||
result.ExistingSeries.Add(new Tuple<string, string, int>(folder, title, seriesId));
|
||||
}
|
||||
|
||||
var defaultQuality = Convert.ToInt32(_configProvider.DefaultQualityProfile);
|
||||
|
@ -104,23 +105,21 @@ namespace NzbDrone.Web.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult AddNewSeries(string path, string seriesName, int qualityProfileId)
|
||||
public JsonResult AddNewSeries(string path, string seriesName, int seriesId, int qualityProfileId)
|
||||
{
|
||||
path = Path.Combine(path, MediaFileProvider.CleanFilename(seriesName));
|
||||
return AddExistingSeries(path, seriesName, qualityProfileId);
|
||||
return AddExistingSeries(path, seriesName, seriesId, qualityProfileId);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult AddExistingSeries(string path, string seriesName, int qualityProfileId)
|
||||
public JsonResult AddExistingSeries(string path, string seriesName, int seriesId, int qualityProfileId)
|
||||
{
|
||||
try
|
||||
{
|
||||
//Create the folder for the new series and then Add it
|
||||
_diskProvider.CreateDirectory(path);
|
||||
|
||||
var series = _tvDbProvider.SearchSeries(seriesName).Where(s => s.SeriesName == seriesName).Single();
|
||||
|
||||
_seriesProvider.AddSeries(path, series.Id, qualityProfileId);
|
||||
_seriesProvider.AddSeries(path, seriesId, qualityProfileId);
|
||||
ScanNewSeries();
|
||||
return Json(new NotificationResult() { Title = seriesName, Text = "Was added successfully" });
|
||||
}
|
||||
|
|
|
@ -8,6 +8,6 @@ namespace NzbDrone.Web.Models
|
|||
{
|
||||
public SelectList Quality { get; set; }
|
||||
|
||||
public List<Tuple<string, string>> ExistingSeries { get; set; }
|
||||
public List<Tuple<string, string, int>> ExistingSeries { get; set; }
|
||||
}
|
||||
}
|
|
@ -683,9 +683,7 @@
|
|||
<Content Include="Scripts\Plugins\MicrosoftAjax.js" />
|
||||
<Content Include="Scripts\Plugins\MicrosoftMvcAjax.debug.js" />
|
||||
<Content Include="Scripts\Plugins\MicrosoftMvcAjax.js" />
|
||||
<Content Include="Scripts\Plugins\yui-min.js" />
|
||||
<Content Include="Scripts\seriesDetails.js" />
|
||||
<Content Include="Scripts\Plugins\jquery.livequery.js" />
|
||||
<Content Include="Scripts\settingsForm.js" />
|
||||
<Content Include="Scripts\Plugins\doTimeout.js" />
|
||||
<Content Include="Scripts\episodeSearch.js" />
|
||||
|
|
|
@ -40,6 +40,7 @@ function bindSeriesAutoComplete(selector) {
|
|||
delay: 500,
|
||||
select: function (event, ui) {
|
||||
$(this).val(ui.item.Title);
|
||||
$(this).siblings('.seriesId').val(ui.item.Id);
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
|
|
@ -23,6 +23,7 @@ $(".addExistingButton").live('click', function () {
|
|||
var root = $(this).parents(".existingSeries");
|
||||
|
||||
var title = $(this).siblings(".seriesLookup").val();
|
||||
var seriesId = $(this).siblings(".seriesId").val();
|
||||
var qualityId = $(this).siblings(".qualitySelector").val();
|
||||
|
||||
var path = root.find(".seriesPathValue Label").text();
|
||||
|
@ -30,7 +31,7 @@ $(".addExistingButton").live('click', function () {
|
|||
$.ajax({
|
||||
type: "POST",
|
||||
url: addSeriesUrl,
|
||||
data: jQuery.param({ path: path, seriesName: title, qualityProfileId: qualityId }),
|
||||
data: jQuery.param({ path: path, seriesName: title, seriesId: seriesId, qualityProfileId: qualityId }),
|
||||
error: function (req, status, error) {
|
||||
alert("Sorry! We could not add " + path + " at this time. " + error);
|
||||
},
|
||||
|
@ -79,13 +80,14 @@ function refreshRoot() {
|
|||
//AddNew
|
||||
$('#saveNewSeries').live('click', function () {
|
||||
var seriesTitle = $("#newSeriesLookup").val();
|
||||
var seriesId = $("#newSeriesId").val();
|
||||
var qualityId = $("#qualityList").val();
|
||||
var path = $('#newSeriesPath').val();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: addNewSeriesUrl,
|
||||
data: jQuery.param({ path: path, seriesName: seriesTitle, qualityProfileId: qualityId }),
|
||||
data: jQuery.param({ path: path, seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId }),
|
||||
error: function (req, status, error) {
|
||||
alert("Sorry! We could not add " + path + " at this time. " + error);
|
||||
},
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
<div>
|
||||
<div>
|
||||
<input id="newSeriesLookup" class="seriesLookup" type="text" style="width: 400px" />
|
||||
@Html.Hidden("newSeriesId", 0, new { @class = "seriesId" })
|
||||
</div>
|
||||
@*<input id="newSeriesPath" class="folderLookup" type="text" style="width: 400px" />*@
|
||||
@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" })
|
||||
<button id="saveNewSeries">
|
||||
|
|
|
@ -42,7 +42,7 @@ else
|
|||
</div>
|
||||
|
||||
}
|
||||
@foreach (var series in Model.ExistingSeries)
|
||||
@foreach (var series in Model.ExistingSeries)
|
||||
{
|
||||
<span class="existingSeries">
|
||||
<div>
|
||||
|
@ -52,6 +52,7 @@ else
|
|||
</div>
|
||||
<div>
|
||||
<input class="seriesLookup" type="text" style="width: 400px" value="@series.Item2" />
|
||||
@Html.Hidden("seriesId", series.Item3, new { @class = "seriesId" })
|
||||
@Html.DropDownList(Guid.NewGuid().ToString(), Model.Quality, new { @class = "qualitySelector" })
|
||||
<button class="addExistingButton">
|
||||
Add</button>
|
||||
|
|
Loading…
Reference in New Issue