1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/dashboard-ui/scripts/livetvrecordings.js

128 lines
3.2 KiB
JavaScript
Raw Normal View History

2014-10-15 23:26:39 -04:00
(function ($, document) {
2013-11-27 14:04:19 -05:00
2013-12-28 16:37:01 -05:00
function getRecordingGroupHtml(group) {
2013-11-27 14:04:19 -05:00
var html = '';
2015-09-08 00:22:38 -04:00
html += '<paper-icon-item>';
2013-11-27 14:04:19 -05:00
2015-10-26 14:55:46 -04:00
html += '<paper-fab mini class="blue" icon="live-tv" item-icon></paper-fab>';
2015-09-08 00:22:38 -04:00
html += '<paper-item-body two-line>';
html += '<a href="livetvrecordinglist.html?groupid=' + group.Id + '" class="clearLink">';
html += '<div>';
html += group.Name;
2015-09-08 00:22:38 -04:00
html += '</div>';
2013-11-27 14:04:19 -05:00
2015-09-08 00:22:38 -04:00
html += '<div secondary>';
if (group.RecordingCount == 1) {
html += Globalize.translate('ValueItemCount', group.RecordingCount);
} else {
html += Globalize.translate('ValueItemCountPlural', group.RecordingCount);
}
html += '</div>';
2013-11-27 14:04:19 -05:00
2015-09-08 00:22:38 -04:00
html += '</a>';
html += '</paper-item-body>';
html += '</paper-icon-item>';
2013-11-27 14:04:19 -05:00
2013-12-28 16:37:01 -05:00
return html;
}
2013-12-01 01:25:19 -05:00
2013-12-28 16:37:01 -05:00
function renderRecordingGroups(page, groups) {
2013-12-28 18:09:24 -05:00
if (groups.length) {
$('#recordingGroups', page).show();
} else {
$('#recordingGroups', page).hide();
}
2013-12-28 16:37:01 -05:00
var html = '';
2015-09-08 00:22:38 -04:00
html += '<div class="paperList">';
2013-12-28 16:37:01 -05:00
for (var i = 0, length = groups.length; i < length; i++) {
html += getRecordingGroupHtml(groups[i]);
}
2015-09-08 00:22:38 -04:00
html += '</div>';
2013-12-28 16:37:01 -05:00
2015-09-08 00:22:38 -04:00
page.querySelector('#recordingGroupItems').innerHTML = html;
2013-12-28 16:37:01 -05:00
Dashboard.hideLoadingMsg();
}
function renderRecordings(elem, recordings) {
2013-11-27 14:04:19 -05:00
2013-12-28 18:09:24 -05:00
if (recordings.length) {
2015-09-08 00:22:38 -04:00
elem.classList.remove('hide');
2013-12-28 18:09:24 -05:00
} else {
2015-09-08 00:22:38 -04:00
elem.classList.add('hide');
2013-12-28 18:09:24 -05:00
}
2015-09-08 00:22:38 -04:00
var recordingItems = elem.querySelector('.recordingItems');
recordingItems.innerHTML = LibraryBrowser.getPosterViewHtml({
2013-12-28 18:09:24 -05:00
items: recordings,
2014-05-29 10:19:12 -04:00
shape: "auto",
2013-12-28 18:09:24 -05:00
showTitle: true,
showParentTitle: true,
2015-08-22 11:54:29 -04:00
centerText: true,
2015-04-11 21:38:38 -04:00
coverImage: true,
2016-01-19 13:27:55 -05:00
lazy: true,
overlayPlayButton: true
2013-12-28 18:09:24 -05:00
2015-09-08 00:22:38 -04:00
});
ImageLoader.lazyChildren(recordingItems);
2013-12-28 18:09:24 -05:00
}
2013-11-27 14:04:19 -05:00
function reload(page) {
Dashboard.showLoadingMsg();
2014-10-15 23:26:39 -04:00
ApiClient.getLiveTvRecordings({
2013-11-27 14:04:19 -05:00
userId: Dashboard.getCurrentUserId(),
2016-01-19 14:03:46 -05:00
IsInProgress: true,
Fields: 'CanDelete'
2013-12-28 16:37:01 -05:00
2015-12-14 10:43:03 -05:00
}).then(function (result) {
2013-12-28 16:37:01 -05:00
2015-09-08 00:22:38 -04:00
renderRecordings(page.querySelector('#activeRecordings'), result.Items);
2013-11-27 14:04:19 -05:00
});
2013-12-28 18:09:24 -05:00
2014-10-15 23:26:39 -04:00
ApiClient.getLiveTvRecordings({
2013-12-28 18:09:24 -05:00
userId: Dashboard.getCurrentUserId(),
2014-01-13 00:41:00 -05:00
limit: 12,
2016-01-19 14:03:46 -05:00
IsInProgress: false,
Fields: 'CanDelete'
2015-12-14 10:43:03 -05:00
}).then(function (result) {
2015-09-08 00:22:38 -04:00
renderRecordings(page.querySelector('#latestRecordings'), result.Items);
});
2014-10-15 23:26:39 -04:00
ApiClient.getLiveTvRecordingGroups({
userId: Dashboard.getCurrentUserId()
2013-12-28 18:09:24 -05:00
2015-12-14 10:43:03 -05:00
}).then(function (result) {
2013-12-28 18:09:24 -05:00
2015-12-14 10:43:03 -05:00
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
renderRecordingGroups(page, result.Items);
});
2013-12-28 18:09:24 -05:00
});
2013-11-27 14:04:19 -05:00
}
2015-08-18 11:52:48 -04:00
window.LiveTvPage.renderRecordingsTab = function (page, tabContent) {
2013-11-27 14:04:19 -05:00
2015-08-18 11:52:48 -04:00
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
2013-11-27 14:04:19 -05:00
2014-10-15 23:26:39 -04:00
})(jQuery, document);