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

125 lines
3.1 KiB
JavaScript
Raw Normal View History

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