mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-18 03:18:19 -07:00
216 lines
6.5 KiB
JavaScript
216 lines
6.5 KiB
JavaScript
define(['components/categorysyncbuttons', 'cardBuilder', 'scripts/livetvcomponents', 'emby-button', 'listViewStyle', 'emby-itemscontainer'], function (categorysyncbuttons, cardBuilder) {
|
|
|
|
function enableScrollX() {
|
|
return browserInfo.mobile && AppInfo.enableAppLayouts;
|
|
}
|
|
|
|
function renderRecordings(elem, recordings, cardOptions) {
|
|
|
|
if (recordings.length) {
|
|
elem.classList.remove('hide');
|
|
} else {
|
|
elem.classList.add('hide');
|
|
}
|
|
|
|
var recordingItems = elem.querySelector('.recordingItems');
|
|
|
|
if (enableScrollX()) {
|
|
recordingItems.classList.add('hiddenScrollX');
|
|
recordingItems.classList.remove('vertical-wrap');
|
|
} else {
|
|
recordingItems.classList.remove('hiddenScrollX');
|
|
recordingItems.classList.add('vertical-wrap');
|
|
}
|
|
|
|
recordingItems.innerHTML = cardBuilder.getCardsHtml(Object.assign({
|
|
items: recordings,
|
|
shape: (enableScrollX() ? 'autooverflow' : 'auto'),
|
|
showTitle: true,
|
|
showParentTitle: true,
|
|
coverImage: true,
|
|
lazy: true,
|
|
cardLayout: true,
|
|
allowBottomPadding: !enableScrollX()
|
|
}, cardOptions || {}));
|
|
|
|
ImageLoader.lazyChildren(recordingItems);
|
|
}
|
|
|
|
function renderActiveRecordings(context) {
|
|
|
|
ApiClient.getLiveTvTimers({
|
|
|
|
IsActive: true
|
|
|
|
}).then(function (result) {
|
|
|
|
// The IsActive param is new, so handle older servers that don't support it
|
|
if (result.Items.length && result.Items[0].Status != 'InProgress') {
|
|
result.Items = [];
|
|
}
|
|
|
|
renderTimers(context.querySelector('#activeRecordings'), result.Items, {
|
|
indexByDate: false
|
|
});
|
|
});
|
|
|
|
//ApiClient.getLiveTvRecordings({
|
|
|
|
// userId: Dashboard.getCurrentUserId(),
|
|
// IsInProgress: true,
|
|
// Fields: 'CanDelete'
|
|
|
|
//}).then(function (result) {
|
|
|
|
// renderRecordings(context.querySelector('#activeRecordings'), result.Items);
|
|
|
|
//});
|
|
}
|
|
|
|
function renderLatestRecordings(context) {
|
|
|
|
ApiClient.getLiveTvRecordings({
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
IsInProgress: false,
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
EnableTotalRecordCount: false
|
|
|
|
}).then(function (result) {
|
|
|
|
renderRecordings(context.querySelector('#latestRecordings'), result.Items);
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
});
|
|
}
|
|
|
|
function renderMovieRecordings(context) {
|
|
|
|
ApiClient.getLiveTvRecordings({
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
IsInProgress: false,
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
EnableTotalRecordCount: false,
|
|
IsMovie: true
|
|
|
|
}).then(function (result) {
|
|
|
|
renderRecordings(context.querySelector('#movieRecordings'), result.Items, {
|
|
showYear: true,
|
|
showParentTitle: false
|
|
});
|
|
});
|
|
}
|
|
|
|
function renderEpisodeRecordings(context) {
|
|
|
|
ApiClient.getLiveTvRecordings({
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
IsInProgress: false,
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
EnableTotalRecordCount: false,
|
|
IsSeries: true
|
|
|
|
}).then(function (result) {
|
|
|
|
renderRecordings(context.querySelector('#episodeRecordings'), result.Items);
|
|
});
|
|
}
|
|
|
|
function renderProgramRecordings(context) {
|
|
|
|
ApiClient.getLiveTvRecordings({
|
|
|
|
UserId: Dashboard.getCurrentUserId(),
|
|
Limit: enableScrollX() ? 12 : 8,
|
|
IsInProgress: false,
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio,BasicSyncInfo',
|
|
EnableTotalRecordCount: false,
|
|
IsMovie: false,
|
|
IsSeries: false
|
|
|
|
}).then(function (result) {
|
|
|
|
renderRecordings(context.querySelector('#programRecordings'), result.Items, {
|
|
showYear: true,
|
|
showParentTitle: false
|
|
});
|
|
});
|
|
}
|
|
|
|
function renderTimers(context, timers, options) {
|
|
|
|
LiveTvHelpers.getTimersHtml(timers, options).then(function (html) {
|
|
|
|
var elem = context;
|
|
|
|
if (html) {
|
|
elem.classList.remove('hide');
|
|
} else {
|
|
elem.classList.add('hide');
|
|
}
|
|
|
|
elem.querySelector('.recordingItems').innerHTML = html;
|
|
|
|
ImageLoader.lazyChildren(elem);
|
|
});
|
|
}
|
|
|
|
function reload(context) {
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
renderActiveRecordings(context);
|
|
renderLatestRecordings(context);
|
|
renderMovieRecordings(context);
|
|
renderEpisodeRecordings(context);
|
|
renderProgramRecordings(context);
|
|
}
|
|
|
|
function onMoreClick(e) {
|
|
|
|
var type = this.getAttribute('data-type');
|
|
|
|
switch(type) {
|
|
case 'latest':
|
|
Dashboard.navigate('livetvitems.html?type=Recordings');
|
|
break;
|
|
case 'movies':
|
|
Dashboard.navigate('livetvitems.html?type=Recordings&IsMovie=true');
|
|
break;
|
|
case 'episodes':
|
|
Dashboard.navigate('livetvitems.html?type=Recordings&IsSeries=true');
|
|
break;
|
|
case 'programs':
|
|
Dashboard.navigate('livetvitems.html?type=Recordings&IsSeries=false&IsMovie=false');
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return function (view, params, tabContent) {
|
|
|
|
var self = this;
|
|
|
|
categorysyncbuttons.init(tabContent);
|
|
|
|
var moreButtons = tabContent.querySelectorAll('.more');
|
|
for (var i = 0, length = moreButtons.length; i < length; i++) {
|
|
moreButtons[i].addEventListener('click', onMoreClick);
|
|
}
|
|
|
|
tabContent.querySelector('#activeRecordings .recordingItems').addEventListener('timercancelled', function () {
|
|
reload(tabContent);
|
|
});
|
|
|
|
self.renderTab = function () {
|
|
reload(tabContent);
|
|
};
|
|
};
|
|
|
|
}); |