2016-03-19 05:26:17 +01:00
|
|
|
|
define(['jQuery'], function ($) {
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2013-12-28 16:37:01 -05:00
|
|
|
|
function getRecordingGroupHtml(group) {
|
2013-11-29 11:58:24 -05:00
|
|
|
|
|
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>';
|
2014-01-01 13:26:31 -05:00
|
|
|
|
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">';
|
2014-01-01 13:26:31 -05:00
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-01 13:26:31 -05:00
|
|
|
|
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-29 11:58:24 -05:00
|
|
|
|
|
2016-05-06 14:17:02 -04:00
|
|
|
|
function renderActiveRecordings(page) {
|
2013-11-29 11:58:24 -05:00
|
|
|
|
|
2014-10-15 23:26:39 -04:00
|
|
|
|
ApiClient.getLiveTvRecordings({
|
2013-11-27 14:04:19 -05:00
|
|
|
|
|
2014-01-01 13:26:31 -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
|
|
|
|
|
|
|
|
|
});
|
2016-05-06 14:17:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderLatestRecordings(page) {
|
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,
|
2016-02-26 12:15:06 -05:00
|
|
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio'
|
2014-01-01 13:26:31 -05:00
|
|
|
|
|
2015-12-14 10:43:03 -05:00
|
|
|
|
}).then(function (result) {
|
2014-01-01 13:26:31 -05:00
|
|
|
|
|
2015-09-08 00:22:38 -04:00
|
|
|
|
renderRecordings(page.querySelector('#latestRecordings'), result.Items);
|
2014-01-01 13:26:31 -05:00
|
|
|
|
});
|
2016-05-06 14:17:02 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteTimer(page, id) {
|
|
|
|
|
|
|
|
|
|
require(['confirm'], function (confirm) {
|
|
|
|
|
|
|
|
|
|
confirm(Globalize.translate('MessageConfirmRecordingCancellation'), Globalize.translate('HeaderConfirmRecordingCancellation')).then(function () {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.cancelLiveTvTimer(id).then(function () {
|
|
|
|
|
|
|
|
|
|
require(['toast'], function (toast) {
|
|
|
|
|
toast(Globalize.translate('MessageRecordingCancelled'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
reload(page);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderTimers(page, timers) {
|
|
|
|
|
|
|
|
|
|
LiveTvHelpers.getTimersHtml(timers).then(function (html) {
|
|
|
|
|
|
|
|
|
|
var elem = page.querySelector('#upcomingRecordings');
|
|
|
|
|
|
|
|
|
|
if (html) {
|
|
|
|
|
elem.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elem.querySelector('.itemsContainer').innerHTML = html;
|
|
|
|
|
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
|
|
|
|
|
|
|
|
|
$('.btnDeleteTimer', elem).on('click', function () {
|
|
|
|
|
|
|
|
|
|
var id = this.getAttribute('data-timerid');
|
|
|
|
|
|
|
|
|
|
deleteTimer(page, id);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderUpcomingRecordings(page) {
|
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvTimers().then(function (result) {
|
|
|
|
|
|
|
|
|
|
renderTimers(page, result.Items);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload(page) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
renderUpcomingRecordings(page);
|
|
|
|
|
renderActiveRecordings(page);
|
|
|
|
|
renderLatestRecordings(page);
|
2014-01-01 13:26:31 -05:00
|
|
|
|
|
2014-10-15 23:26:39 -04:00
|
|
|
|
ApiClient.getLiveTvRecordingGroups({
|
2014-01-01 13:26:31 -05:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2013-11-29 11:58:24 -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
|
|
|
|
|
2016-03-19 05:26:17 +01:00
|
|
|
|
});
|