Added QuickAdd for adding series, not displayed currently, needs some prettifying.

This commit is contained in:
Mark McDowall 2011-10-19 08:16:34 -07:00
parent d62345f6d7
commit a9bcbfad8c
8 changed files with 77 additions and 8 deletions

View File

@ -236,3 +236,10 @@ select, button, input[type="button"], input[type="submit"], input[type="reset"]
min-width: 60px; min-width: 60px;
width: auto; width: auto;
} }
#quickAdd
{
position: fixed;
top: 30px;
right: 15px;
}

View File

@ -53,9 +53,7 @@ namespace NzbDrone.Web.Controllers
var defaultQuality = _configProvider.DefaultQualityProfile; var defaultQuality = _configProvider.DefaultQualityProfile;
var qualityProfiles = _qualityProvider.All(); var qualityProfiles = _qualityProvider.All();
ViewData["qualityList"] = qualityProfiles; ViewData["qualityProfiles"] = new SelectList(
ViewData["quality"] = new SelectList(
qualityProfiles, qualityProfiles,
"QualityProfileId", "QualityProfileId",
"Name", "Name",
@ -132,6 +130,19 @@ namespace NzbDrone.Web.Controllers
} }
} }
[HttpPost]
public JsonResult QuickAddNewSeries(string seriesName, int seriesId, int qualityProfileId)
{
var path = _rootFolderProvider.GetMostFreeRootDir();
path = Path.Combine(path, MediaFileProvider.CleanFilename(seriesName));
//Create the folder for the new series
//Use the created folder name when adding the series
path = _diskProvider.CreateDirectory(path);
return AddExistingSeries(path, seriesName, seriesId, qualityProfileId);
}
public JsonResult AddSeries(string path, int seriesId, int qualityProfileId) public JsonResult AddSeries(string path, int seriesId, int qualityProfileId)
{ {
//Get TVDB Series Name //Get TVDB Series Name
@ -145,6 +156,21 @@ namespace NzbDrone.Web.Controllers
return new JsonResult { Data = "ok" }; return new JsonResult { Data = "ok" };
} }
[ChildActionOnly]
public ActionResult QuickAdd()
{
var defaultQuality = _configProvider.DefaultQualityProfile;
var qualityProfiles = _qualityProvider.All();
ViewData["qualityProfiles"] = new SelectList(
qualityProfiles,
"QualityProfileId",
"Name",
defaultQuality);
return PartialView();
}
//Root Directory //Root Directory
[HttpPost] [HttpPost]

View File

@ -929,6 +929,9 @@
<ItemGroup> <ItemGroup>
<Content Include="Views\Settings\System.cshtml" /> <Content Include="Views\Settings\System.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Views\Shared\QuickAdd.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -1,6 +1,7 @@
//URLs //URLs
var addSeriesUrl = '../AddSeries/AddExistingSeries'; var addSeriesUrl = '../AddSeries/AddExistingSeries';
var addNewSeriesUrl = '../AddSeries/AddNewSeries'; var addNewSeriesUrl = '../AddSeries/AddNewSeries';
var quickAddNewSeriesUrl = '../AddSeries/QuickAddNewSeries';
var existingSeriesUrl = '../AddSeries/ExistingSeries'; var existingSeriesUrl = '../AddSeries/ExistingSeries';
var addNewUrl = '../AddSeries/AddNew'; var addNewUrl = '../AddSeries/AddNew';
@ -105,6 +106,26 @@ function reloadAddNew() {
} }
//QuickAddNew
$('#quickAddNew').live('click', function () {
var seriesTitle = $("#newSeriesLookup").val();
var seriesId = $("#newSeriesId").val();
var qualityId = $("#qualityList").val();
$.ajax({
type: "POST",
url: quickAddNewSeriesUrl,
data: jQuery.param({ seriesName: seriesTitle, seriesId: seriesId, qualityProfileId: qualityId }),
error: function (req, status, error) {
alert("Sorry! We could not add " + path + " at this time. " + error);
},
success: function () {
$("#newSeriesLookup").val("");
//$('#newSeriesPath').val("");
}
});
});
//On load //On load
jQuery(document).ready(function () { jQuery(document).ready(function () {
//RootDir //RootDir

View File

@ -7,7 +7,7 @@
@Html.Hidden("newSeriesId", 0, new { @class = "seriesId" }) @Html.Hidden("newSeriesId", 0, new { @class = "seriesId" })
</div> </div>
@Html.DropDownList("newSeriesPath", new SelectList((IList)ViewData["RootDirs"]), new { style = "width: 406px; margin-left: 0px;" }) @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" }) @Html.DropDownList("qualityList", (SelectList)ViewData["QualityProfiles"], new { @class = "qualitySelector" })
<button id="saveNewSeries"> <button id="saveNewSeries">
Add</button> Add</button>
</div> </div>

View File

@ -3,10 +3,6 @@
Add Series Add Series
} }
@section HeaderContent{
<script src="../../Scripts/addSeries.js" type="text/javascript"></script>
}
@section MainContent{ @section MainContent{
<h2>Add New Series</h2> <h2>Add New Series</h2>
<div id="addNewSeries"> <div id="addNewSeries">

View File

@ -0,0 +1,15 @@
@using System.Collections
@using NzbDrone.Core
<div id="quickAdd">
<input id="quickSeriesLookup" class="seriesLookup" type="text" style="width: 400px" />
@Html.Hidden("newSeriesId", 0, new { @class = "seriesId" })
@Html.DropDownList("qualityList", (SelectList)ViewData["QualityProfiles"], new { @class = "qualitySelector" })
<button id="quickAddNew">Add</button>
</div>
<script type="text/javascript">
jQuery(document).ready(function () {
//AddNew
$('#quickSeriesLookup').watermark('Title of the series you want to add...');
});
</script>

1
SharedLiveTemplates.xml Normal file
View File

@ -0,0 +1 @@
<TemplatesExport />