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

886 lines
34 KiB
JavaScript
Raw Normal View History

2014-03-02 13:44:48 -07:00
(function ($, document, window) {
2014-03-08 11:17:05 -07:00
var defaultSortBy = "SortName";
2014-03-02 13:44:48 -07:00
// The base query options
var query = {
2014-03-08 11:17:05 -07:00
SortBy: defaultSortBy,
2014-03-02 13:44:48 -07:00
SortOrder: "Ascending",
Recursive: true,
2014-03-22 09:16:43 -07:00
Fields: "MediaSources,DateCreated,Settings,Studios",
2014-03-02 19:17:12 -07:00
StartIndex: 0,
2014-03-03 21:53:48 -07:00
IncludeItemTypes: "Movie",
IsMissing: false,
2014-03-17 07:48:16 -07:00
IsVirtualUnaired: false,
2014-03-20 20:31:40 -07:00
Limit: 200,
2014-03-18 10:05:57 -07:00
CollapseBoxSetItems: false
2014-03-02 13:44:48 -07:00
};
2014-03-03 21:53:48 -07:00
function getHeaderCells(reportType) {
2014-03-02 19:17:12 -07:00
2014-03-03 21:53:48 -07:00
switch (reportType) {
2014-03-03 21:53:48 -07:00
case 'Season':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderSeries'), sortField: 'SeriesSortName,SortName', type: 'Series' },
{ name: Globalize.translate('HeaderSeason'), sortField: 'SortName', type: 'Season' },
{ name: Globalize.translate('HeaderSeasonNumber'), type: 'Season Number', sortField: 'IndexNumber' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' }
2014-03-03 21:53:48 -07:00
];
}
case 'Series':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderNetwork'), sortField: 'Studio,SortName', type: 'Network' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' },
{ name: Globalize.translate('HeaderYear'), sortField: 'ProductionYear,PremiereDate,SortName', type: 'Year' },
{ name: Globalize.translate('HeaderParentalRating'), sortField: 'OfficialRating,SortName', type: 'Parental Rating' },
{ name: Globalize.translate('HeaderCommunityRating'), sortField: 'CommunityRating,SortName', type: 'Community Rating' },
{ name: Globalize.translate('HeaderRuntime'), sortField: 'Runtime,SortName', type: 'Runtime' },
{ name: Globalize.translate('HeaderTrailers'), type: 'Trailers' },
{ name: Globalize.translate('HeaderSpecials'), type: 'Specials' }
2014-03-03 21:53:48 -07:00
];
}
case 'Game':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderGameSystem'), sortField: 'GameSystem,SortName', type: 'Game System' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' },
{ name: Globalize.translate('HeaderReleaseDate'), sortField: 'ProductionYear,PremiereDate,GameSystem,SortName', type: 'Release Date' },
{ name: Globalize.translate('HeaderParentalRating'), sortField: 'OfficialRating,SortName', type: 'Parental Rating' },
{ name: Globalize.translate('HeaderCommunityRating'), sortField: 'CommunityRating,SortName', type: 'Community Rating' },
{ name: Globalize.translate('HeaderPlayers'), type: 'Players', sortField: 'Players,GameSystem,SortName' },
{ name: Globalize.translate('HeaderTrailers'), type: 'Trailers' }
2014-03-03 21:53:48 -07:00
];
}
case 'Audio':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderAlbumArtist'), sortField: 'AlbumArtist,Album,SortName', type: 'Album Artist' },
{ name: Globalize.translate('HeaderAlbum'), type: 'Album', sortField: 'Album,SortName' },
{ name: Globalize.translate('HeaderDisc'), type: 'Disc' },
{ name: Globalize.translate('HeaderTrack'), type: 'Track' },
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' },
{ name: Globalize.translate('HeaderReleaseDate'), sortField: 'ProductionYear,PremiereDate,SortName', type: 'Release Date' },
{ name: Globalize.translate('HeaderRuntime'), sortField: 'Runtime,SortName', type: 'Runtime' },
{ name: Globalize.translate('HeaderAudio'), type: 'Audio' },
{ name: Globalize.translate('HeaderEmbeddedImage'), type: 'Embedded Image' }
2014-03-03 21:53:48 -07:00
];
}
case 'Episode':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderSeries'), sortField: 'SeriesSortName,SortName', type: 'Series' },
{ name: Globalize.translate('HeaderSeason') },
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' },
{ name: Globalize.translate('HeaderReleaseDate'), sortField: 'ProductionYear,PremiereDate,SortName', type: 'Release Date' },
{ name: Globalize.translate('HeaderCommunityRating'), sortField: 'CommunityRating,SortName', type: 'Community Rating' },
{ name: Globalize.translate('HeaderRuntime'), sortField: 'Runtime,SortName', type: 'Runtime' },
{ name: Globalize.translate('HeaderVideo'), type: 'Video' },
{ name: Globalize.translate('HeaderResolution'), type: 'Resolution' },
{ name: Globalize.translate('HeaderAudio'), type: 'Audio' },
{ name: Globalize.translate('HeaderSubtitles'), type: 'Subtitles' }
2014-03-03 21:53:48 -07:00
];
}
case 'BoxSet':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' },
{ name: Globalize.translate('HeaderReleaseDate'), sortField: 'ProductionYear,PremiereDate,SortName', type: 'Release Date' },
{ name: Globalize.translate('HeaderParentalRating'), sortField: 'OfficialRating,SortName', type: 'Parental Rating' },
{ name: Globalize.translate('HeaderCommunityRating'), sortField: 'CommunityRating,SortName', type: 'Community Rating' },
{ name: Globalize.translate('HeaderTrailers'), type: 'Trailers' }
2014-03-03 21:53:48 -07:00
];
}
case 'Book':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderSeries'), type: 'Series' },
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' },
{ name: Globalize.translate('HeaderReleaseDate'), sortField: 'ProductionYear,PremiereDate,SortName', type: 'Release Date' },
{ name: Globalize.translate('HeaderParentalRating'), sortField: 'OfficialRating,SortName', type: 'Parental Rating' },
{ name: Globalize.translate('HeaderCommunityRating'), sortField: 'CommunityRating,SortName', type: 'Community Rating' }
2014-03-03 21:53:48 -07:00
];
}
case 'MusicArtist':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' }
2014-03-03 21:53:48 -07:00
];
}
case 'MusicAlbum':
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderAlbumArtist'), sortField: 'AlbumArtist,SortName', type: 'Album Artist' },
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' },
{ name: Globalize.translate('HeaderReleaseDate'), sortField: 'ProductionYear,PremiereDate,SortName', type: 'Release Date' },
{ name: Globalize.translate('HeaderParentalRating'), sortField: 'OfficialRating,SortName', type: 'Parental Rating' },
{ name: Globalize.translate('HeaderCommunityRating'), sortField: 'CommunityRating,SortName', type: 'Community Rating' },
{ name: Globalize.translate('HeaderRuntime'), sortField: 'Runtime,SortName', type: 'Runtime' }
2014-03-03 21:53:48 -07:00
];
}
default:
{
return [
{},
2014-08-11 07:15:53 -07:00
{ name: Globalize.translate('HeaderName'), sortField: 'SortName', type: 'Name' },
{ name: Globalize.translate('HeaderDateAdded'), sortField: 'DateCreated,SortName', type: 'Date Added' },
{ name: Globalize.translate('HeaderReleaseDate'), sortField: 'ProductionYear,PremiereDate,SortName', type: 'Release Date' },
{ name: Globalize.translate('HeaderParentalRating'), sortField: 'OfficialRating,SortName', type: 'Parental Rating' },
{ name: Globalize.translate('HeaderCommunityRating'), sortField: 'CommunityRating,SortName', type: 'Community Rating' },
{ name: Globalize.translate('HeaderRuntime'), sortField: 'Runtime,SortName', type: 'Runtime' },
{ name: Globalize.translate('HeaderVideo'), type: 'Video' },
{ name: Globalize.translate('HeaderResolution'), type: 'Resolution' },
{ name: Globalize.translate('HeaderAudio'), type: 'Audio' },
{ name: Globalize.translate('HeaderSubtitles'), type: 'Subtitles' },
{ name: Globalize.translate('HeaderTrailers'), type: 'Trailers' },
{ name: Globalize.translate('HeaderSpecials'), type: 'Specials' }
2014-03-03 21:53:48 -07:00
];
}
2014-03-02 13:44:48 -07:00
}
}
function getDefaultSortOrder(reportType) {
switch (reportType) {
case 'Season':
{
return "SeriesSortName,SortName";
}
case 'Series':
{
return "SortName";
}
case 'Game':
{
return "GameSystem,SortName";
}
case 'Audio':
{
return "AlbumArtist,Album,SortName";
}
case 'Episode':
{
return "SeriesSortName,SortName";
}
case 'BoxSet':
{
return "SortName";
}
case 'Book':
{
return "SortName";
}
case 'MusicArtist':
{
return "SortName";
}
case 'MusicAlbum':
{
return "AlbumArtist,SortName";
}
default:
{
return "SortName";
}
}
}
2014-03-03 21:53:48 -07:00
function getItemCellsHtml(item, headercells) {
2014-03-02 13:44:48 -07:00
2014-03-22 09:31:21 -07:00
var primaryVersion = (item.MediaSources || [])[0] || {};
2014-03-02 13:44:48 -07:00
var mediaStreams = primaryVersion.MediaStreams || [];
var videoStream = mediaStreams.filter(function (s) {
2014-03-02 13:44:48 -07:00
return s.Type == 'Video';
})[0];
2014-03-20 20:31:40 -07:00
var audioStream = mediaStreams.filter(function (s) {
return s.Type == 'Audio';
})[0];
return headercells.map(function (cell) {
var html = '';
html += '<td>';
2014-03-20 20:31:40 -07:00
2014-03-03 21:53:48 -07:00
switch (cell.type || cell.name) {
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
case 'Album Artist':
{
html += item.AlbumArtist || '&nbsp;';
break;
}
case 'Album':
{
html += item.Album || '&nbsp;';
break;
}
case 'Series':
{
html += item.SeriesName || '&nbsp;';
break;
}
case 'Game System':
{
html += item.GameSystem || '&nbsp;';
break;
}
case 'Network':
{
html += item.Studios.length ? item.Studios[0].Name : '&nbsp;';
break;
}
2014-03-08 11:17:05 -07:00
case 'Disc':
{
html += item.ParentIndexNumber == null ? '' : item.ParentIndexNumber;
break;
}
2014-07-01 14:13:32 -07:00
case 'Season Number':
2014-03-03 21:53:48 -07:00
case 'Track':
{
html += item.IndexNumber == null ? '' : item.IndexNumber;
break;
}
case 'Players':
{
html += item.Players || '&nbsp;';
break;
}
case 'Audio':
{
if (audioStream) {
var name = (audioStream.Codec || '').toUpperCase();
html += name == 'DCA' ? (audioStream.Profile || '').toUpperCase() : name;
2014-03-03 21:53:48 -07:00
}
break;
}
case 'Video':
{
if (videoStream) {
html += (videoStream.Codec || '').toUpperCase();
2014-03-03 21:53:48 -07:00
}
break;
}
case 'Resolution':
{
if (videoStream && videoStream.Width) {
html += videoStream.Width + "*" + (videoStream.Height || "-");
}
break;
}
2014-03-03 21:53:48 -07:00
case 'Embedded Image':
{
if (videoStream) {
2014-03-03 21:53:48 -07:00
html += '<div class="libraryReportIndicator clearLibraryReportIndicator"><div class="ui-icon-check ui-btn-icon-notext"></div></div>';
}
break;
}
case 'Subtitles':
{
2014-03-20 20:31:40 -07:00
var hasSubtitles = mediaStreams.filter(function (s) {
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
return s.Type == 'Subtitle';
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
}).length;
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
if (hasSubtitles) {
html += '<div class="libraryReportIndicator clearLibraryReportIndicator"><div class="ui-icon-check ui-btn-icon-notext"></div></div>';
2014-03-02 13:44:48 -07:00
}
2014-03-03 21:53:48 -07:00
break;
}
case 'Runtime':
{
if (item.RunTimeTicks) {
html += Dashboard.getDisplayTime(item.RunTimeTicks);
} else {
html += '&nbsp;';
}
break;
}
case 'Trailers':
{
if (item.LocalTrailerCount) {
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
html += '<div class="libraryReportIndicator clearLibraryReportIndicator"><div class="ui-icon-check ui-btn-icon-notext"></div></div>';
}
break;
2014-03-02 13:44:48 -07:00
}
2014-03-03 21:53:48 -07:00
case 'Specials':
{
if (item.SpecialFeatureCount) {
html += '<div class="libraryReportIndicator clearLibraryReportIndicator"><div class="ui-icon-check ui-btn-icon-notext"></div></div>';
}
break;
}
2014-03-08 11:17:05 -07:00
2014-03-03 21:53:48 -07:00
case 'Season':
{
if (item.Type == "Episode") {
html += item.ParentIndexNumber == null ? '' : ('Season ' + item.ParentIndexNumber);
} else {
2014-03-04 19:59:59 -07:00
html += '<a href="edititemmetadata.html?id=' + item.Id + '">' + LibraryBrowser.getPosterViewDisplayName(item, false, false) + '</a>';
2014-03-03 21:53:48 -07:00
}
break;
2014-03-02 13:44:48 -07:00
}
2014-03-03 21:53:48 -07:00
case 'Name':
{
2014-03-04 19:59:59 -07:00
html += '<a href="edititemmetadata.html?id=' + item.Id + '">' + LibraryBrowser.getPosterViewDisplayName(item, false, false) + '</a>';
2014-03-03 21:53:48 -07:00
break;
}
2014-03-08 11:17:05 -07:00
case 'Community Rating':
{
html += item.CommunityRating || '&nbsp;';
break;
}
case 'Parental Rating':
2014-03-03 21:53:48 -07:00
{
html += item.OfficialRating || '&nbsp;';
break;
}
2014-03-08 11:17:05 -07:00
2014-03-03 21:53:48 -07:00
case 'Year':
case 'Release Date':
{
if (item.PremiereDate && item.Type != "Series") {
try {
var date = parseISO8601Date(item.PremiereDate, { toLocal: true });
html += date.toLocaleDateString();
}
catch (e) {
html += '&nbsp;';
}
}
else if (item.ProductionYear) {
html += item.ProductionYear;
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
if (item.Status == "Continuing") {
html += "-Present";
}
else if (item.EndDate) {
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
try {
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
var endYear = parseISO8601Date(item.EndDate, { toLocal: true }).getFullYear();
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
if (endYear != item.ProductionYear) {
html += "-" + parseISO8601Date(item.EndDate, { toLocal: true }).getFullYear();
}
2014-03-03 21:53:48 -07:00
}
catch (e) {
console.log("Error parsing date: " + item.EndDate);
}
}
} else {
html += '&nbsp;';
}
break;
}
case 'Date Added':
{
if (item.DateCreated) {
try {
html += parseISO8601Date(item.DateCreated, { toLocal: true }).toLocaleDateString();
}
catch (e) {
html += '&nbsp;';
}
}
break;
}
default:
{
if (item.LockData) {
html += '<img src="css/images/editor/lock.png" />';
}
if (item.IsUnidentified) {
html += '<div class="libraryReportIndicator"><div class="ui-icon-alert ui-btn-icon-notext"></div></div>';
}
if (!item.LocalTrailerCount && item.Type == "Movie") {
html += '<img src="css/images/editor/missingtrailer.png" title="Missing local trailer." />';
}
2014-03-02 19:17:12 -07:00
2014-03-03 21:53:48 -07:00
if (!item.ImageTags || !item.ImageTags.Primary) {
2014-03-04 19:59:59 -07:00
html += '<a href="edititemimages.html?id=' + item.Id + '"><img src="css/images/editor/missingprimaryimage.png" title="Missing primary image." /></a>';
2014-03-03 21:53:48 -07:00
}
if (!item.BackdropImageTags || !item.BackdropImageTags.length) {
2014-03-17 18:45:41 -07:00
if (item.Type !== "Episode" && item.Type !== "Season" && item.MediaType !== "Audio" && item.Type !== "TvChannel" && item.Type !== "MusicAlbum") {
2014-03-04 19:59:59 -07:00
html += '<a href="edititemimages.html?id=' + item.Id + '"><img src="css/images/editor/missingbackdrop.png" title="Missing backdrop image." /></a>';
2014-03-03 21:53:48 -07:00
}
}
if (!item.ImageTags || !item.ImageTags.Logo) {
if (item.Type == "Movie" || item.Type == "Trailer" || item.Type == "Series" || item.Type == "MusicArtist" || item.Type == "BoxSet") {
2014-03-04 19:59:59 -07:00
html += '<a href="edititemimages.html?id=' + item.Id + '"><img src="css/images/editor/missinglogo.png" title="Missing logo image." /></a>';
2014-03-03 21:53:48 -07:00
}
}
2014-03-02 19:17:12 -07:00
2014-03-03 21:53:48 -07:00
break;
}
}
2014-03-02 19:17:12 -07:00
html += '</td>';
2014-03-03 21:53:48 -07:00
return html;
2014-03-02 19:17:12 -07:00
2014-03-03 21:53:48 -07:00
}).join('');
}
2014-03-02 19:17:12 -07:00
2014-03-08 11:17:05 -07:00
function getReportHtml(items, reportType, currentSortField, currentSortDirection) {
2014-03-02 19:17:12 -07:00
2014-03-03 21:53:48 -07:00
var html = '';
2014-03-02 19:17:12 -07:00
2014-03-08 11:17:05 -07:00
html += '<table id="tblReport" data-role="table" data-mode="reflow" class="tblLibraryReport stripedTable ui-responsive table-stroke detailTable" style="display:table;">';
2014-03-02 19:17:12 -07:00
2014-03-03 21:53:48 -07:00
html += '<thead>';
html += '<tr>';
2014-03-02 19:17:12 -07:00
2014-03-03 21:53:48 -07:00
var cells = getHeaderCells(reportType);
2014-03-02 19:17:12 -07:00
2014-03-03 21:53:48 -07:00
html += cells.map(function (c) {
2014-03-02 13:44:48 -07:00
2014-03-08 11:17:05 -07:00
var cellHtml = '<th data-priority="' + (c.priority || 'persist') + '">';
if (c.sortField) {
cellHtml += '<a class="lnkColumnSort" href="#" data-sortfield="' + c.sortField + '" style="text-decoration:underline;">';
}
cellHtml += (c.name || '&nbsp;');
if (c.sortField) {
2014-03-08 11:17:05 -07:00
cellHtml += '</a>';
if (c.sortField == currentSortField) {
if (currentSortDirection == "Descending") {
2014-05-12 11:04:25 -07:00
cellHtml += '<span style="font-weight:bold;margin-left:5px;vertical-align:top;font-size:14px">&darr;</span>';
2014-03-08 11:17:05 -07:00
} else {
2014-05-12 11:04:25 -07:00
cellHtml += '<span style="font-weight:bold;margin-left:5px;vertical-align:top;font-size:14px;">&uarr;</span>';
2014-03-08 11:17:05 -07:00
}
}
}
cellHtml += '</th>';
return cellHtml;
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
}).join('');
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
html += '</tr>';
html += '</thead>';
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
html += '<tbody>';
for (var i = 0, length = items.length; i < length; i++) {
var item = items[i];
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
html += '<tr>';
html += getItemCellsHtml(item, cells);
2014-03-02 13:44:48 -07:00
html += '</tr>';
}
2014-03-03 21:53:48 -07:00
html += '</tbody>';
html += '</table>';
2014-03-02 13:44:48 -07:00
return html;
}
2014-03-03 21:53:48 -07:00
function renderItems(page, result, reportType) {
2014-03-02 13:44:48 -07:00
// Scroll back up so they can see the results from the beginning
$(document).scrollTop(0);
2014-03-17 07:48:16 -07:00
$('.listTopPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, false, [], false)).trigger('create');
2014-03-02 13:44:48 -07:00
updateFilterControls(page);
2014-03-17 07:48:16 -07:00
$('.listBottomPaging', page).html(LibraryBrowser.getPagingHtml(query, result.TotalRecordCount, false, [], false)).trigger('create');
2014-03-02 13:44:48 -07:00
2014-03-08 11:17:05 -07:00
$('.reportContainer', page).html(getReportHtml(result.Items, reportType, query.SortBy, query.SortOrder)).trigger('create');
2014-03-02 13:44:48 -07:00
$('.btnNextPage', page).on('click', function () {
query.StartIndex += query.Limit;
reloadItems(page);
});
$('.btnPreviousPage', page).on('click', function () {
query.StartIndex -= query.Limit;
reloadItems(page);
});
2014-03-08 11:17:05 -07:00
$('.lnkColumnSort', page).on('click', function () {
var order = this.getAttribute('data-sortfield');
if (query.SortBy == order) {
if (query.SortOrder == "Descending") {
query.SortOrder = "Ascending";
query.SortBy = defaultSortBy;
} else {
query.SortOrder = "Descending";
query.SortBy = order;
}
} else {
query.SortOrder = "Ascending";
query.SortBy = order;
}
query.StartIndex = 0;
reloadItems(page);
});
2014-03-02 13:44:48 -07:00
}
function reloadItems(page) {
var url = ApiClient.getUrl("Items", query);
2014-03-03 21:53:48 -07:00
var reportType = $('#selectView', page).val();
2014-03-02 13:44:48 -07:00
2014-07-01 22:16:59 -07:00
ApiClient.getJSON(url).done(function (result) {
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
renderItems(page, result, reportType);
2014-03-02 13:44:48 -07:00
});
}
function updateFilterControls(page) {
2014-03-02 19:17:12 -07:00
$('#selectView').val(query.IncludeItemTypes).selectmenu('refresh');
2014-03-02 13:44:48 -07:00
$('.chkVideoTypeFilter', page).each(function () {
var filters = "," + (query.VideoTypes || "");
var filterName = this.getAttribute('data-filter');
this.checked = filters.indexOf(',' + filterName) != -1;
}).checkboxradio('refresh');
$('#chk3D', page).checked(query.Is3D == true).checkboxradio('refresh');
$('#chkHD', page).checked(query.IsHD == true).checkboxradio('refresh');
$('#chkSD', page).checked(query.IsHD == false).checkboxradio('refresh');
$('#chkSubtitle', page).checked(query.HasSubtitles == true).checkboxradio('refresh');
2014-05-02 07:49:28 -07:00
$('#chkNoSubtitle', page).checked(query.HasSubtitles === false).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
$('#chkTrailer', page).checked(query.HasTrailer == true).checkboxradio('refresh');
2014-08-22 19:58:48 -07:00
$('#chkNoTrailer', page).checked(query.HasTrailer == false).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
$('#chkSpecialFeature', page).checked(query.HasSpecialFeature == true).checkboxradio('refresh');
$('#chkThemeSong', page).checked(query.HasThemeSong == true).checkboxradio('refresh');
2014-08-22 19:58:48 -07:00
$('#chkNoThemeSong', page).checked(query.HasThemeSong == false).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
$('#chkThemeVideo', page).checked(query.HasThemeVideo == true).checkboxradio('refresh');
2014-08-22 19:58:48 -07:00
$('#chkNoThemeVideo', page).checked(query.HasThemeVideo == false).checkboxradio('refresh');
2014-03-03 21:53:48 -07:00
$('#chkIsPlaceHolder', page).checked(query.IsPlaceHolder == true).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
2014-03-03 21:53:48 -07:00
$('#chkMissingRating', page).checked(query.HasOfficialRating == false).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
$('#chkMissingOverview', page).checked(query.HasOverview == false).checkboxradio('refresh');
$('#chkYearMismatch', page).checked(query.IsYearMismatched == true).checkboxradio('refresh');
$('#chkIsUnidentified', page).checked(query.IsUnidentified == true).checkboxradio('refresh');
$('#chkIsLocked', page).checked(query.IsLocked == true).checkboxradio('refresh');
2014-03-03 21:53:48 -07:00
$('#chkSpecialEpisode', page).checked(query.ParentIndexNumber == 0).checkboxradio('refresh');
$('#chkMissingEpisode', page).checked(query.IsMissing == true).checkboxradio('refresh');
$('#chkFutureEpisode', page).checked(query.IsUnaired == true).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
}
$(document).on('pageinit', "#libraryReportPage", function () {
var page = this;
$('#radioBasicFilters', page).on('change', function () {
if (this.checked) {
$('.basicFilters', page).show();
$('.advancedFilters', page).hide();
} else {
$('.basicFilters', page).hide();
}
});
$('#radioAdvancedFilters', page).on('change', function () {
if (this.checked) {
$('.advancedFilters', page).show();
$('.basicFilters', page).hide();
} else {
$('.advancedFilters', page).hide();
}
});
2014-03-02 19:17:12 -07:00
$('#selectView', page).on('change', function () {
2014-03-02 13:44:48 -07:00
query.StartIndex = 0;
2014-03-02 19:17:12 -07:00
query.IncludeItemTypes = this.value;
2014-03-02 13:44:48 -07:00
query.SortBy = getDefaultSortOrder(this.value);
query.SortOrder = "Ascending";
2014-03-02 13:44:48 -07:00
reloadItems(page);
});
$('.chkVideoTypeFilter', page).on('change', function () {
var filterName = this.getAttribute('data-filter');
var filters = query.VideoTypes || "";
filters = (',' + filters).replace(',' + filterName, '').substring(1);
if (this.checked) {
filters = filters ? (filters + ',' + filterName) : filterName;
}
query.StartIndex = 0;
query.VideoTypes = filters;
reloadItems(page);
});
$('#chk3D', page).on('change', function () {
query.StartIndex = 0;
query.Is3D = this.checked ? true : null;
reloadItems(page);
});
$('#chkHD', page).on('change', function () {
query.StartIndex = 0;
query.IsHD = this.checked ? true : null;
reloadItems(page);
});
$('#chkSD', page).on('change', function () {
query.StartIndex = 0;
query.IsHD = this.checked ? false : null;
reloadItems(page);
});
$('#chkSubtitle', page).on('change', function () {
query.StartIndex = 0;
query.HasSubtitles = this.checked ? true : null;
2014-05-02 07:49:28 -07:00
$('#chkNoSubtitle', page).checked(false).checkboxradio('refresh');
reloadItems(page);
});
$('#chkNoSubtitle', page).on('change', function () {
query.StartIndex = 0;
query.HasSubtitles = this.checked ? false : null;
$('#chkSubtitle', page).checked(false).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
reloadItems(page);
});
$('#chkTrailer', page).on('change', function () {
query.StartIndex = 0;
query.HasTrailer = this.checked ? true : null;
2014-08-22 19:58:48 -07:00
$('#chkNoTrailer', page).checked(false).checkboxradio('refresh');
reloadItems(page);
});
$('#chkNoTrailer', page).on('change', function () {
query.StartIndex = 0;
query.HasTrailer = this.checked ? false : null;
$('#chkTrailer', page).checked(false).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
reloadItems(page);
});
$('#chkSpecialFeature', page).on('change', function () {
query.StartIndex = 0;
query.HasSpecialFeature = this.checked ? true : null;
reloadItems(page);
});
2014-03-03 21:53:48 -07:00
$('#chkIsPlaceHolder', page).on('change', function () {
query.StartIndex = 0;
query.IsPlaceHolder = this.checked ? true : null;
reloadItems(page);
});
2014-03-02 13:44:48 -07:00
$('#chkThemeSong', page).on('change', function () {
query.StartIndex = 0;
query.HasThemeSong = this.checked ? true : null;
2014-08-22 19:58:48 -07:00
$('#chkNoThemeSong', page).checked(false).checkboxradio('refresh');
reloadItems(page);
});
$('#chkNoThemeSong', page).on('change', function () {
query.StartIndex = 0;
query.HasThemeSong = this.checked ? false : null;
$('#chkThemeSong', page).checked(false).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
reloadItems(page);
});
$('#chkThemeVideo', page).on('change', function () {
query.StartIndex = 0;
query.HasThemeVideo = this.checked ? true : null;
2014-08-22 19:58:48 -07:00
$('#chkNoThemeVideo', page).checked(false).checkboxradio('refresh');
reloadItems(page);
});
$('#chkNoThemeVideo', page).on('change', function () {
query.StartIndex = 0;
query.HasThemeVideo = this.checked ? false : null;
$('#chkThemeVideo', page).checked(false).checkboxradio('refresh');
2014-03-02 13:44:48 -07:00
reloadItems(page);
});
$('#chkMissingOverview', page).on('change', function () {
query.StartIndex = 0;
query.HasOverview = this.checked ? false : null;
reloadItems(page);
});
2014-03-03 21:53:48 -07:00
$('#chkMissingRating', page).on('change', function () {
query.StartIndex = 0;
query.HasOfficialRating = this.checked ? false : null;
reloadItems(page);
});
2014-03-02 13:44:48 -07:00
$('#chkYearMismatch', page).on('change', function () {
query.StartIndex = 0;
query.IsYearMismatched = this.checked ? true : null;
reloadItems(page);
});
$('#chkIsUnidentified', page).on('change', function () {
query.StartIndex = 0;
query.IsUnidentified = this.checked ? true : null;
reloadItems(page);
});
$('#chkIsLocked', page).on('change', function () {
query.StartIndex = 0;
query.IsLocked = this.checked ? true : null;
reloadItems(page);
});
2014-03-03 21:53:48 -07:00
$('#chkMissingEpisode', page).on('change', function () {
query.StartIndex = 0;
query.IsMissing = this.checked ? true : false;
reloadItems(page);
});
$('#chkFutureEpisode', page).on('change', function () {
query.StartIndex = 0;
if (this.checked) {
query.IsUnaired = true;
query.IsVirtualUnaired = null;
} else {
query.IsUnaired = null;
query.IsVirtualUnaired = false;
}
reloadItems(page);
});
$('#chkSpecialEpisode', page).on('change', function () {
query.ParentIndexNumber = this.checked ? 0 : null;
reloadItems(page);
});
2014-03-02 13:44:48 -07:00
}).on('pagebeforeshow', "#libraryReportPage", function () {
var page = this;
query.SortBy = getDefaultSortOrder($('#selectView', page).val());
query.SortOrder = "Ascending";
2014-12-08 21:57:18 -07:00
$('#selectView', page).val(query.IncludeItemTypes).selectmenu('refresh').trigger('change');
2014-03-02 13:44:48 -07:00
}).on('pageshow', "#libraryReportPage", function () {
updateFilterControls(this);
});
})(jQuery, document, window);