jellyfin-web/dashboard-ui/scripts/moviestudios.js

74 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-07-29 13:06:58 -07:00
define(['libraryBrowser', 'cardBuilder'], function (libraryBrowser, cardBuilder) {
2016-04-03 11:47:49 -07:00
// The base query options
var data = {};
function getQuery(params) {
var key = getSavedQueryKey();
var pageData = data[key];
if (!pageData) {
pageData = data[key] = {
query: {
SortBy: "SortName",
SortOrder: "Ascending",
IncludeItemTypes: "Movie",
Recursive: true,
2016-07-29 13:06:58 -07:00
Fields: "DateCreated,ItemCounts,PrimaryImageAspectRatio",
2016-06-17 11:35:21 -07:00
StartIndex: 0
2016-04-03 11:47:49 -07:00
}
};
pageData.query.ParentId = params.topParentId;
}
return pageData.query;
}
function getSavedQueryKey() {
2016-07-18 20:57:55 -07:00
return libraryBrowser.getSavedQueryKey('studios');
2016-04-03 11:47:49 -07:00
}
2016-06-29 10:43:34 -07:00
function getPromise(context, params) {
2016-04-03 11:47:49 -07:00
var query = getQuery(params);
Dashboard.showLoadingMsg();
2016-06-29 10:43:34 -07:00
return ApiClient.getStudios(Dashboard.getCurrentUserId(), query);
}
function reloadItems(context, params, promise) {
promise.then(function (result) {
2016-04-03 11:47:49 -07:00
2016-07-29 13:06:58 -07:00
var elem = context.querySelector('#items');
cardBuilder.buildCards(result.Items, {
itemsContainer: elem,
2016-04-03 11:47:49 -07:00
shape: "backdrop",
preferThumb: true,
2016-07-29 13:06:58 -07:00
showTitle: false,
scalable: true,
2016-04-03 11:47:49 -07:00
showItemCounts: true,
centerText: true,
2016-07-29 13:06:58 -07:00
overlayMoreButton: true
2016-04-03 11:47:49 -07:00
});
Dashboard.hideLoadingMsg();
});
2015-08-15 11:17:22 -07:00
}
2016-04-03 11:47:49 -07:00
return function (view, params, tabContent) {
2016-06-29 10:43:34 -07:00
var self = this;
var promise;
self.preRender = function () {
promise = getPromise(view, params);
};
2016-04-03 11:47:49 -07:00
self.renderTab = function () {
2016-06-29 10:43:34 -07:00
reloadItems(tabContent, params, promise);
2016-04-03 11:47:49 -07:00
};
};
});