diff --git a/ApiClient.js b/ApiClient.js index 5ac4ecd8f0..f56d3744be 100644 --- a/ApiClient.js +++ b/ApiClient.js @@ -1498,7 +1498,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }; /** - * Gets items based on a query, typicall for children of a folder + * Gets items based on a query, typically for children of a folder * @param {String} userId * @param {Object} options * Options accepts the following properties: @@ -1529,6 +1529,52 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { }); }; + /** + Gets genres from an item + */ + self.getGenres = function (userId, options) { + + if (!userId) { + throw new Error("null userId"); + } + + var parentId = options.parentId || "root"; + + // Don't put these on the query string + delete options.parentId; + + var url = self.getUrl("Users/" + userId + "/Items/" + parentId + "/Genres", options); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + + /** + Gets studios from an item + */ + self.getStudios = function (userId, options) { + + if (!userId) { + throw new Error("null userId"); + } + + var parentId = options.parentId || "root"; + + // Don't put these on the query string + delete options.parentId; + + var url = self.getUrl("Users/" + userId + "/Items/" + parentId + "/Studios", options); + + return self.ajax({ + type: "GET", + url: url, + dataType: "json" + }); + }; + /** * Gets local trailers for an item */ diff --git a/dashboard-ui/boxset.html b/dashboard-ui/boxset.html index 0ffc3dacd6..7f4029d158 100644 --- a/dashboard-ui/boxset.html +++ b/dashboard-ui/boxset.html @@ -13,7 +13,7 @@ Suggested Movies Box Sets - Genres + Genres Actors Directors diff --git a/dashboard-ui/boxsets.html b/dashboard-ui/boxsets.html index 7f695d62e1..55b09a6869 100644 --- a/dashboard-ui/boxsets.html +++ b/dashboard-ui/boxsets.html @@ -12,7 +12,7 @@ Suggested Movies Box Sets - Genres + Genres Actors Directors diff --git a/dashboard-ui/moviegenres.html b/dashboard-ui/moviegenres.html new file mode 100644 index 0000000000..589b040fc3 --- /dev/null +++ b/dashboard-ui/moviegenres.html @@ -0,0 +1,25 @@ + + +
+' + LibraryBrowser.getFiveStarRatingHtml(item) + '
'; } + + var childText; if (item.Type == "BoxSet") { - var movies = item.ChildCount == 1 ? "1 Movie" : item.ChildCount + " Movies"; + childText = item.ChildCount == 1 ? "1 Movie" : item.ChildCount + " Movies"; - html += '' + movies + '
'; - } else { + html += '' + childText + '
'; + } + else if (item.Type == "Genre" || item.Type == "Studio" || item.Type == "Person") { + + childText = item.ChildCount == 1 ? "1 " + options.countNameSingular : item.ChildCount + " " + options.countNamePlural; + + html += '' + childText + '
'; + } + else { html += '' + LibraryBrowser.getMiscInfoHtml(item, false) + '
'; } diff --git a/dashboard-ui/scripts/moviegenres.js b/dashboard-ui/scripts/moviegenres.js new file mode 100644 index 0000000000..b3e6d6b558 --- /dev/null +++ b/dashboard-ui/scripts/moviegenres.js @@ -0,0 +1,60 @@ +(function ($, document) { + + // The base query options + var query = { + + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Movie", + Recursive: true, + Fields: "PrimaryImageAspectRatio,ItemCounts,DateCreated,UserData", + Limit: LibraryBrowser.getDetaultPageSize(), + StartIndex: 0 + }; + + function reloadItems(page) { + + Dashboard.showLoadingMsg(); + + ApiClient.getGenres(Dashboard.getCurrentUserId(), query).done(function (result) { + + var html = ''; + + var showPaging = result.TotalRecordCount > query.Limit; + + if (showPaging) { + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true); + } + + html += LibraryBrowser.getPosterDetailViewHtml({ + items: result.Items, + useAverageAspectRatio: true, + countNameSingular: "Movie", + countNamePlural: "Movies" + }); + + if (showPaging) { + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); + } + + var elem = $('#items', page).html(html).trigger('create'); + + $('select', elem).on('change', function () { + query.StartIndex = (parseInt(this.value) - 1) * query.Limit; + reloadItems(page); + }); + + Dashboard.hideLoadingMsg(); + }); + } + + $(document).on('pagebeforeshow', "#movieGenresPage", function () { + + reloadItems(this); + + }).on('pageshow', "#movieGenresPage", function () { + + + }); + +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/movies.js b/dashboard-ui/scripts/movies.js index 09e6c000bd..01d207ff18 100644 --- a/dashboard-ui/scripts/movies.js +++ b/dashboard-ui/scripts/movies.js @@ -46,12 +46,7 @@ html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); } - var elem = $('#items', page); - - // cleanup existing event handlers - $('select', elem).off('change'); - - elem.html(html).trigger('create'); + var elem = $('#items', page).html(html).trigger('create'); $('select', elem).on('change', function () { query.StartIndex = (parseInt(this.value) - 1) * query.Limit; diff --git a/dashboard-ui/scripts/tvgenres.js b/dashboard-ui/scripts/tvgenres.js new file mode 100644 index 0000000000..63df889a6d --- /dev/null +++ b/dashboard-ui/scripts/tvgenres.js @@ -0,0 +1,60 @@ +(function ($, document) { + + // The base query options + var query = { + + SortBy: "SortName", + SortOrder: "Ascending", + IncludeItemTypes: "Series", + Recursive: true, + Fields: "PrimaryImageAspectRatio,ItemCounts,DateCreated,UserData", + Limit: LibraryBrowser.getDetaultPageSize(), + StartIndex: 0 + }; + + function reloadItems(page) { + + Dashboard.showLoadingMsg(); + + ApiClient.getGenres(Dashboard.getCurrentUserId(), query).done(function (result) { + + var html = ''; + + var showPaging = result.TotalRecordCount > query.Limit; + + if (showPaging) { + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, true); + } + + html += LibraryBrowser.getPosterDetailViewHtml({ + items: result.Items, + useAverageAspectRatio: true, + countNameSingular: "Show", + countNamePlural: "Shows" + }); + + if (showPaging) { + html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); + } + + var elem = $('#items', page).html(html).trigger('create'); + + $('select', elem).on('change', function () { + query.StartIndex = (parseInt(this.value) - 1) * query.Limit; + reloadItems(page); + }); + + Dashboard.hideLoadingMsg(); + }); + } + + $(document).on('pagebeforeshow', "#tvGenresPage", function () { + + reloadItems(this); + + }).on('pageshow', "#tvGenresPage", function () { + + + }); + +})(jQuery, document); \ No newline at end of file diff --git a/dashboard-ui/scripts/tvshows.js b/dashboard-ui/scripts/tvshows.js index e49a9060f2..7eac26db96 100644 --- a/dashboard-ui/scripts/tvshows.js +++ b/dashboard-ui/scripts/tvshows.js @@ -9,7 +9,7 @@ SortOrder: "Ascending", IncludeItemTypes: "Series", Recursive: true, - Fields: "PrimaryImageAspectRatio,SeriesInfo,ItemCounts,DateCreated", + Fields: "PrimaryImageAspectRatio,SeriesInfo,ItemCounts,DateCreated,UserData", Limit: LibraryBrowser.getDetaultPageSize(), StartIndex: 0 }; @@ -46,12 +46,7 @@ html += LibraryBrowser.getPagingHtml(query, result.TotalRecordCount); } - var elem = $('#items', page); - - // cleanup existing event handlers - $('select', elem).off('change'); - - elem.html(html).trigger('create'); + var elem = $('#items', page).html(html).trigger('create'); $('select', elem).on('change', function () { query.StartIndex = (parseInt(this.value) - 1) * query.Limit; diff --git a/dashboard-ui/tvgenres.html b/dashboard-ui/tvgenres.html new file mode 100644 index 0000000000..767aa3a28f --- /dev/null +++ b/dashboard-ui/tvgenres.html @@ -0,0 +1,23 @@ + + + +