2016-06-06 18:55:16 -07:00
|
|
|
|
define(['scripts/livetvcomponents'], function () {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
|
|
|
|
function getRecordingGroupHtml(group) {
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<paper-icon-item>';
|
|
|
|
|
|
|
|
|
|
html += '<paper-fab mini class="blue" icon="live-tv" item-icon></paper-fab>';
|
|
|
|
|
|
|
|
|
|
html += '<paper-item-body two-line>';
|
|
|
|
|
html += '<a href="livetvrecordinglist.html?groupid=' + group.Id + '" class="clearLink">';
|
|
|
|
|
|
|
|
|
|
html += '<div>';
|
|
|
|
|
html += group.Name;
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '<div secondary>';
|
|
|
|
|
if (group.RecordingCount == 1) {
|
|
|
|
|
html += Globalize.translate('ValueItemCount', group.RecordingCount);
|
|
|
|
|
} else {
|
|
|
|
|
html += Globalize.translate('ValueItemCountPlural', group.RecordingCount);
|
|
|
|
|
}
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
html += '</a>';
|
|
|
|
|
html += '</paper-item-body>';
|
|
|
|
|
html += '</paper-icon-item>';
|
|
|
|
|
|
|
|
|
|
return html;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderRecordingGroups(context, groups) {
|
|
|
|
|
|
|
|
|
|
if (groups.length) {
|
2016-06-06 18:55:16 -07:00
|
|
|
|
context.querySelector('#recordingGroups').classList.remove('hide');
|
2016-05-15 10:11:26 -07:00
|
|
|
|
} else {
|
2016-06-06 18:55:16 -07:00
|
|
|
|
context.querySelector('#recordingGroups').classList.add('hide');
|
2016-05-15 10:11:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var html = '';
|
|
|
|
|
|
|
|
|
|
html += '<div class="paperList">';
|
|
|
|
|
|
|
|
|
|
for (var i = 0, length = groups.length; i < length; i++) {
|
|
|
|
|
|
|
|
|
|
html += getRecordingGroupHtml(groups[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
context.querySelector('#recordingGroupItems').innerHTML = html;
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 22:46:23 -07:00
|
|
|
|
function enableScrollX() {
|
|
|
|
|
return browserInfo.mobile && AppInfo.enableAppLayouts;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-15 10:11:26 -07:00
|
|
|
|
function renderRecordings(elem, recordings) {
|
|
|
|
|
|
|
|
|
|
if (recordings.length) {
|
|
|
|
|
elem.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var recordingItems = elem.querySelector('.recordingItems');
|
2016-05-15 22:46:23 -07:00
|
|
|
|
|
|
|
|
|
if (enableScrollX()) {
|
|
|
|
|
recordingItems.classList.add('hiddenScrollX');
|
|
|
|
|
} else {
|
|
|
|
|
recordingItems.classList.remove('hiddenScrollX');
|
|
|
|
|
}
|
2016-06-06 18:55:16 -07:00
|
|
|
|
|
2016-05-15 10:11:26 -07:00
|
|
|
|
recordingItems.innerHTML = LibraryBrowser.getPosterViewHtml({
|
|
|
|
|
items: recordings,
|
2016-05-18 10:02:56 -07:00
|
|
|
|
shape: (enableScrollX() ? 'autooverflow' : 'auto'),
|
2016-05-15 10:11:26 -07:00
|
|
|
|
showTitle: true,
|
|
|
|
|
showParentTitle: true,
|
|
|
|
|
coverImage: true,
|
|
|
|
|
lazy: true,
|
2016-05-18 10:02:56 -07:00
|
|
|
|
cardLayout: true
|
2016-05-15 10:11:26 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ImageLoader.lazyChildren(recordingItems);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderActiveRecordings(context) {
|
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
ApiClient.getLiveTvTimers({
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
IsActive: true
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
// 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 = [];
|
|
|
|
|
}
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
renderTimers(context.querySelector('#activeRecordings'), result.Items, {
|
|
|
|
|
indexByDate: false
|
|
|
|
|
});
|
2016-05-15 10:11:26 -07:00
|
|
|
|
});
|
2016-06-19 10:41:49 -07:00
|
|
|
|
|
|
|
|
|
//ApiClient.getLiveTvRecordings({
|
|
|
|
|
|
|
|
|
|
// userId: Dashboard.getCurrentUserId(),
|
|
|
|
|
// IsInProgress: true,
|
|
|
|
|
// Fields: 'CanDelete'
|
|
|
|
|
|
|
|
|
|
//}).then(function (result) {
|
|
|
|
|
|
|
|
|
|
// renderRecordings(context.querySelector('#activeRecordings'), result.Items);
|
|
|
|
|
|
|
|
|
|
//});
|
2016-05-15 10:11:26 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderLatestRecordings(context) {
|
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvRecordings({
|
|
|
|
|
|
|
|
|
|
userId: Dashboard.getCurrentUserId(),
|
2016-05-18 10:02:56 -07:00
|
|
|
|
limit: enableScrollX() ? 12 : 4,
|
2016-05-15 10:11:26 -07:00
|
|
|
|
IsInProgress: false,
|
2016-06-20 10:08:13 -07:00
|
|
|
|
Fields: 'CanDelete,PrimaryImageAspectRatio',
|
|
|
|
|
EnableTotalRecordCount: false
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
|
|
|
|
renderRecordings(context.querySelector('#latestRecordings'), result.Items);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
function renderTimers(context, timers, options) {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
LiveTvHelpers.getTimersHtml(timers, options).then(function (html) {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
var elem = context;
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
|
|
|
|
if (html) {
|
|
|
|
|
elem.classList.remove('hide');
|
|
|
|
|
} else {
|
|
|
|
|
elem.classList.add('hide');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
elem.querySelector('.recordingItems').innerHTML = html;
|
|
|
|
|
|
|
|
|
|
ImageLoader.lazyChildren(elem);
|
2016-06-02 12:32:15 -07:00
|
|
|
|
LibraryBrowser.createCardMenus(elem);
|
2016-05-15 10:11:26 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderUpcomingRecordings(context) {
|
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
ApiClient.getLiveTvTimers({
|
|
|
|
|
IsActive: false
|
|
|
|
|
}).then(function (result) {
|
2016-05-15 10:11:26 -07:00
|
|
|
|
|
2016-06-19 10:41:49 -07:00
|
|
|
|
renderTimers(context.querySelector('#upcomingRecordings'), result.Items);
|
2016-05-15 10:11:26 -07:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function reload(context) {
|
|
|
|
|
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
renderUpcomingRecordings(context);
|
|
|
|
|
renderActiveRecordings(context);
|
|
|
|
|
renderLatestRecordings(context);
|
|
|
|
|
|
|
|
|
|
ApiClient.getLiveTvRecordingGroups({
|
|
|
|
|
|
|
|
|
|
userId: Dashboard.getCurrentUserId()
|
|
|
|
|
|
|
|
|
|
}).then(function (result) {
|
|
|
|
|
|
|
|
|
|
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
|
|
|
|
|
renderRecordingGroups(context, result.Items);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return function (view, params, tabContent) {
|
|
|
|
|
|
|
|
|
|
var self = this;
|
2016-06-19 10:41:49 -07:00
|
|
|
|
tabContent.querySelector('#activeRecordings .recordingItems').addEventListener('timercancelled', function () {
|
|
|
|
|
reload(tabContent);
|
|
|
|
|
});
|
2016-05-15 10:11:26 -07:00
|
|
|
|
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
|
|
|
|
|
reload(tabContent);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
self.renderTab = function () {
|
|
|
|
|
reload(tabContent);
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|