TopSlider added for local series searching!

Should be easy to add others (would want to have it close other open ones, I think).
pull/6/head
Mark McDowall 13 years ago
parent 08804208cf
commit 745d9d9355

@ -633,5 +633,51 @@ namespace NzbDrone.Core.Test
series.Should().HaveCount(1);
series[0].NextAiring.Should().Be(DateTime.Today.AddMonths(1));
}
[Test]
public void SearchForSeries_should_return_results_that_start_with_query()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.WhereAll()
.Have(e => e.QualityProfileId = fakeQuality.QualityProfileId)
.Build();
db.InsertMany(fakeSeries);
db.Insert(fakeQuality);
//Act
var series = mocker.Resolve<SeriesProvider>().SearchForSeries("Titl");
//Assert
series.Should().HaveCount(10);
}
[Test]
public void SearchForSeries_should_not_return_results_that_do_not_start_with_query()
{
var mocker = new AutoMoqer(MockBehavior.Strict);
var db = MockLib.GetEmptyDatabase();
mocker.SetConstant(db);
var fakeQuality = Builder<QualityProfile>.CreateNew().Build();
var fakeSeries = Builder<Series>.CreateListOfSize(10)
.WhereAll()
.Have(e => e.QualityProfileId = fakeQuality.QualityProfileId)
.Build();
db.InsertMany(fakeSeries);
db.Insert(fakeQuality);
//Act
var series = mocker.Resolve<SeriesProvider>().SearchForSeries("NotATitle");
//Assert
series.Should().HaveCount(0);
}
}
}

@ -186,6 +186,21 @@ namespace NzbDrone.Core.Providers
return false;
}
public virtual List<Series> SearchForSeries(string title)
{
var query = String.Format(@"SELECT * FROM Series
INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
WHERE Title LIKE '{0}%'", title);
// var series = _database.Fetch<Series, QualityProfile>(@"SELECT * FROM Series
// INNER JOIN QualityProfiles ON Series.QualityProfileId = QualityProfiles.QualityProfileId
// WHERE Title LIKE '@0%'", title);
var series = _database.Fetch<Series, QualityProfile>(query);
return series;
}
/// <summary>
/// Cleans up the AirsTime Component from TheTVDB since it can be garbage that comes in.
/// </summary>

@ -0,0 +1,67 @@
.top-slider {
position: absolute;
opacity: 0.85;
width: 300px;
}
.sliderButton {
border: 0;
}
.sliderContent {
background-color:#333333;
text-align:center;
width: 100%;
color:#FFFFFF;
font-weight:bold;
margin: 0px;
display: none;
@*Rounded Edges*@
border:1px solid #444444;
-moz-border-radius-bottomright: 8px;
-webkit-border-bottom-right-radius: 8px;
-moz-border-radius-bottomleft: 8px;
-webkit-border-bottom-left-radius: 8px;
}
.openCloseWrapper {
width: 100%;
text-align: center;
font-size:12px;
font-weight:bold;
color:#FFFFFF;
}
.sliderButtonContainer {
width: 70px;
margin-left:auto;
margin-right:auto;
background-color:#333333;
cursor:pointer;
@*Rounded Edges*@
border: 1px solid #444444;
border-top: 0px;
-moz-border-radius-bottomright: 10px;
-webkit-border-bottom-right-radius: 10px;
-moz-border-radius-bottomleft: 10px;
-webkit-border-bottom-left-radius: 10px;
}
.sliderImage {
width: 16px;
height: 16px;
display: inline-block;
margin-bottom: -3px;
margin-right: -5px;
margin-left: 2px;
}
.sliderClosed {
background:url('../../Content/Images/ui-icons_2e83ff_256x240.png') -64px -16px no-repeat;
}
.sliderOpened {
background:url('../../Content/Images/ui-icons_2e83ff_256x240.png') 0px -16px no-repeat;
}

@ -98,25 +98,17 @@ namespace NzbDrone.Web.Controllers
}
}
public ActionResult SearchForSeries(string seriesName)
public JsonResult LocalSearch(string term)
{
var model = new List<SeriesSearchResultModel>();
//Get Results from the local DB and return
//Get Results from TvDb and convert them to something we can use.
foreach (var tvdbSearchResult in _tvDbProvider.SearchSeries(seriesName))
var results = _seriesProvider.SearchForSeries(term).Select(s => new SeriesSearchResultModel
{
model.Add(new SeriesSearchResultModel
{
TvDbId = tvdbSearchResult.Id,
TvDbName = tvdbSearchResult.SeriesName,
FirstAired = tvdbSearchResult.FirstAired
});
}
//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) });
Id = s.SeriesId,
Title = s.Title
}).ToList();
return PartialView("SeriesSearchResults", model);
return Json(results, JsonRequestBehavior.AllowGet);
}
[HttpPost]

@ -25,5 +25,11 @@ namespace NzbDrone.Web.Controllers
ViewData["RssTimer"] = _jobProvider.NextScheduledRun(typeof(RssSyncJob)).ToString("yyyyMMddHHmmss");
return PartialView();
}
[ChildActionOnly]
public ActionResult LocalSearch()
{
return PartialView();
}
}
}

@ -4,8 +4,8 @@ namespace NzbDrone.Web.Models
{
public class SeriesSearchResultModel
{
public int TvDbId { get; set; }
public string TvDbName { get; set; }
public int Id { get; set; }
public string Title { get; set; }
public DateTime FirstAired { get; set; }
}
}

@ -329,6 +329,7 @@
<Content Include="Content\2011.2.712\Windows7\slider-v.gif" />
<Content Include="Content\2011.2.712\Windows7\sprite-vertical.png" />
<Content Include="Content\2011.2.712\Windows7\sprite.png" />
<Content Include="Content\Slider.css" />
<Content Include="Content\Grid.css" />
<Content Include="Content\Images\close.png" />
<Content Include="Content\Images\Downloading.png" />
@ -677,6 +678,7 @@
<Content Include="Scripts\2011.2.712\telerik.window.min.js" />
<Content Include="Scripts\AutoComplete.js" />
<Content Include="Scripts\addSeries.js" />
<Content Include="Scripts\slider.js" />
<Content Include="Scripts\Plugins\jquery-1.6.3-vsdoc.js" />
<Content Include="Scripts\Plugins\jquery-1.6.3.js" />
<Content Include="Scripts\Plugins\jquery-1.6.3.min.js" />
@ -723,7 +725,6 @@
<Content Include="Views\Upcoming\Index.cshtml" />
<Content Include="Views\Series\Details.cshtml" />
<Content Include="Views\Series\Index.cshtml" />
<Content Include="Views\Series\SeriesSearchResults.cshtml" />
<Content Include="Views\Shared\Error.cshtml" />
<Content Include="Views\Settings\QualityProfileItem.cshtml" />
<Content Include="Views\System\Indexers.cshtml" />
@ -932,6 +933,9 @@
<ItemGroup>
<Content Include="Views\Shared\QuickAdd.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\Shared\LocalSearch.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.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.

@ -5,6 +5,7 @@
bindFolderAutoComplete(".folderLookup");
bindSeriesAutoComplete(".seriesLookup");
bindLocalSeriesAutoComplete(".localSeriesLookup");
});
function bindFolderAutoComplete(selector) {
@ -52,3 +53,23 @@ function bindSeriesAutoComplete(selector) {
};
});
}
function bindLocalSeriesAutoComplete(selector) {
$(selector).each(function (index, element) {
$(element).autocomplete({
source: "/Series/LocalSearch",
minLength: 3,
delay: 500,
select: function (event, ui) {
window.location = "../Series/Details?seriesId=" + ui.item.Id;
}
})
.data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><strong>" + item.Title + "</strong><br>" + "</a>")
.appendTo(ul);
};
});
}

@ -0,0 +1,13 @@
$(document).ready(function () {
$(".sliderButtonContainer").live('click', function () {
sliderToggle();
});
});
function sliderToggle() {
$('.sliderContent').slideToggle('slow');
$(".sliderButtonContainer").children('.sliderImage').toggleClass('sliderOpened sliderClosed');
//Prevent the Address Bar from changing
return false;
}

@ -1,30 +0,0 @@
@model List<NzbDrone.Web.Models.SeriesSearchResultModel>
<div id="searchResults">
<fieldset>
<legend>Search Results</legend>
@if (Model.Count == 0)
{
<b>No results found for the series name</b>
}
@{var open = "(";}
@{var close = ")";}
@{int r = 0;}
@foreach (var result in Model)
{
@Html.RadioButton("selectedSeries", result.TvDbId, r == 0,
new {@class = "searchRadio examplePart", id = "searchRadio_" + r})
<b>@result.TvDbName</b> @open @result.FirstAired.ToShortDateString() @close
<br/>
@Html.TextBox(result.TvDbName + "_text", result.TvDbName, new { id = result.TvDbId + "_text", style = "display:none" })
r++;
}
</fieldset>
</div>

@ -1,33 +1,30 @@
<style>
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
</style>
<script>
$(function () {
$("#birds").autocomplete({
source: "/Settings/TestResults",
minLength: 3,
delay: 500,
select: function (event, ui) {
$(this).val(ui.item.Title);
return false;
@{ Layout = null; }
<style type="text/css">
@*Specific to each slider*@
#seriesSearchSlider {
right: 150px;
}
})
.data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a><strong>" + item.Title + "</strong><br>" + item.FirstAired + "</a>")
.appendTo(ul);
};
});
</script>
.sliderContent .localSeriesLookup {
width: 94%;
}
.sliderContent {
height: 53px;
}
</style>
<div class="demo">
<div class="ui-widget">
<label for="birds">Birds: </label>
<input id="birds" />
<div id="seriesSearchSlider" class="top-slider">
<div class="sliderContent">
Local Series Search
<input class="localSeriesLookup" type="text" />
</div>
<div class="openCloseWrapper">
<div class="sliderButtonContainer">
Search<div class="sliderImage sliderClosed"></div>
</div>
</div>
</div>
</div><!-- End demo -->

@ -0,0 +1,29 @@
@{
Layout = null;
}
<style>
#localSeriesSlider {
right: 150px;
}
.sliderContent .localSeriesLookup {
width: 94%;
}
.sliderContent {
height: 53px;
}
</style>
<div id="localSeriesSlider" class="top-slider">
<div class="sliderContent">
Local Series Search
<input class="localSeriesLookup" type="text" />
</div>
<div class="openCloseWrapper">
<div class="sliderButtonContainer">
Search<div class="sliderImage sliderClosed"></div>
</div>
</div>
</div>

@ -15,6 +15,7 @@
<link type="text/css" rel="stylesheet" href="/Content/ActionButton.css" />
<link type="text/css" rel="stylesheet" href="/Content/overrides.css" />
<link type="text/css" rel="stylesheet" href="/Content/Menu.css" />
<link type="text/css" rel="stylesheet" href="/Content/Slider.css" />
<script type="text/javascript" src="/Scripts/Plugins/jquery-1.6.3.min.js"></script>
<script type="text/javascript" src="/Scripts/Plugins/jquery-ui-1.8.16.min.js"></script>
@ -28,12 +29,14 @@
<script type="text/javascript" src="/Scripts/episodeSearch.js"></script>
<script type="text/javascript" src="/Scripts/autocomplete.js"></script>
<script type="text/javascript" src="/Scripts/addSeries.js"></script>
<script type="text/javascript" src="/Scripts/slider.js"></script>
@MvcMiniProfiler.MiniProfiler.RenderIncludes()
@RenderSection("HeaderContent", required: false)
</head>
<body>
<div class="container">
@{Html.RenderAction("LocalSearch", "Shared");}
<div id="menu" class="span-24 last prepend-top append-bottom">
<ul>
@MvcHtmlString.Create(Html.CurrentActionLink("Series", "Index", "Series"))

Loading…
Cancel
Save