UI changes to consume actor searching API

This commit is contained in:
smcpeck 2017-02-23 12:02:58 -06:00
commit 0aa00fd888
5 changed files with 173 additions and 72 deletions

View file

@ -95,7 +95,10 @@ $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
//if ($tvl.mixItUp('isLoaded')) $tvl.mixItUp('destroy');
//$tvl.mixItUp(mixItUpConfig(activeState)); // init or reinit
}
if (target === "#MoviesTab") {
if (target === "#MoviesTab" || target === "#ActorsTab") {
if (target === "#ActorsTab") {
actorLoad();
}
$('#approveMovies,#deleteMovies').show();
if ($tvl.mixItUp('isLoaded')) {
activeState = $tvl.mixItUp('getState');
@ -733,6 +736,36 @@ function initLoad() {
}
function actorLoad() {
var $ml = $('#actorMovieList');
if ($ml.mixItUp('isLoaded')) {
activeState = $ml.mixItUp('getState');
$ml.mixItUp('destroy');
}
$ml.html("");
var url = createBaseUrl(base, '/requests/actor');
$.ajax(url).success(function (results) {
if (results.length > 0) {
results.forEach(function (result) {
var context = buildRequestContext(result, "movie");
var html = searchTemplate(context);
$ml.append(html);
});
$('.customTooltip').tooltipster({
contentCloning: true
});
}
else {
$ml.html(noResultsHtml.format("movie"));
}
$ml.mixItUp(mixItUpConfig());
});
};
function movieLoad() {
var $ml = $('#movieList');
if ($ml.mixItUp('isLoaded')) {

View file

@ -63,6 +63,17 @@ $(function () {
});
// Type in actor search
$("#actorSearchContent").on("input", function () {
if (searchTimer) {
clearTimeout(searchTimer);
}
searchTimer = setTimeout(function () {
moviesFromActor();
}.bind(this), 800);
});
$('#moviesComingSoon').on('click', function (e) {
e.preventDefault();
moviesComingSoon();
@ -300,7 +311,7 @@ $(function () {
function movieSearch() {
var query = $("#movieSearchContent").val();
var url = createBaseUrl(base, '/search/movie/');
query ? getMovies(url + query) : resetMovies();
query ? getMovies(url + query) : resetMovies("#movieList");
}
function moviesComingSoon() {
@ -313,6 +324,12 @@ $(function () {
getMovies(url);
}
function moviesFromActor() {
var query = $("#actorSearchContent").val();
var url = createBaseUrl(base, '/search/actor/');
query ? getMovies(url + query, "#actorMovieList", "#actorSearchButton") : resetMovies("#actorMovieList");
}
function popularShows() {
var url = createBaseUrl(base, '/search/tv/popular');
getTvShows(url, true);
@ -330,30 +347,31 @@ $(function () {
getTvShows(url, true);
}
function getMovies(url) {
resetMovies();
$('#movieSearchButton').attr("class", "fa fa-spinner fa-spin");
function getMovies(url, target, button) {
target = target || "#movieList";
button = button || "#movieSearchButton";
resetMovies(target);
$(button).attr("class", "fa fa-spinner fa-spin");
$.ajax(url).success(function (results) {
if (results.length > 0) {
results.forEach(function (result) {
var context = buildMovieContext(result);
var html = searchTemplate(context);
$("#movieList").append(html);
$(target).append(html);
checkNetflix(context.title, context.id);
});
}
else {
$("#movieList").html(noResultsHtml);
$(target).html(noResultsHtml);
}
$('#movieSearchButton').attr("class", "fa fa-search");
$(button).attr("class", "fa fa-search");
});
};
function resetMovies() {
$("#movieList").html("");
function resetMovies(target) {
$(target).html("");
}
function tvSearch() {

View file

@ -3,7 +3,7 @@
<!--
Microsoft ResX Schema
Version 1.3
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
@ -14,16 +14,17 @@
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
@ -45,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@ -59,18 +60,37 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@ -89,13 +109,13 @@
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="UserLogin_Title" xml:space="preserve">
<value>Login</value>
@ -476,4 +496,7 @@
<data name="UserLogin_AdminUsePassword" xml:space="preserve">
<value>If you are an administrator, please use the other login page</value>
</data>
<data name="Search_Actors" xml:space="preserve">
<value>Actors</value>
</data>
</root>

View file

@ -717,6 +717,15 @@ namespace Ombi.UI.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Actors.
/// </summary>
public static string Search_Actors {
get {
return ResourceManager.GetString("Search_Actors", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Albums.
/// </summary>

View file

@ -25,6 +25,10 @@
<a id="movieTabButton" href="#MoviesTab" aria-controls="home" role="tab" data-toggle="tab"><i class="fa fa-film"></i> @UI.Search_Movies</a>
</li>
<li role="presentation">
<a id="actorTabButton" href="#ActorsTab" aria-controls="profile" role="tab" data-toggle="tab"><i class="fa fa-users"></i> @UI.Search_Actors</a>
</li>
}
@if (Model.Settings.SearchForTvShows)
{
@ -70,8 +74,22 @@
<div id="movieList">
</div>
</div>
}
<!-- Actors tab -->
<div role="tabpanel" class="tab-pane" id="ActorsTab">
<div class="input-group">
<input id="actorSearchContent" type="text" class="form-control form-control-custom form-control-search form-control-withbuttons">
<div class="input-group-addon">
<i id="actorSearchButton" class="fa fa-search"></i>
</div>
</div>
<br />
<br />
<!-- Movie content -->
<div id="actorMovieList">
</div>
</div>
}
@if (Model.Settings.SearchForTvShows)
{