2016-09-04 10:52:43 -07:00
|
|
|
|
define(['scripts/livetvcomponents', 'emby-button', 'emby-itemscontainer'], function () {
|
2016-09-04 08:01:31 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
function renderActiveRecordings(context, promise) {
|
2016-09-06 10:59:10 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
promise.then(function (result) {
|
2016-09-06 10:59:10 -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 = [];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderTimers(context.querySelector('#activeRecordings'), result.Items, {
|
|
|
|
|
indexByDate: false
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-10-02 23:28:45 -07:00
|
|
|
|
|
2016-09-04 08:01:31 -07:00
|
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
function renderUpcomingRecordings(context, promise) {
|
2016-09-04 08:01:31 -07:00
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
promise.then(function (result) {
|
2016-09-04 08:01:31 -07:00
|
|
|
|
|
|
|
|
|
renderTimers(context.querySelector('#upcomingRecordings'), result.Items);
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return function (view, params, tabContent) {
|
|
|
|
|
|
|
|
|
|
var self = this;
|
2016-10-02 23:28:45 -07:00
|
|
|
|
var activeRecordingsPromise;
|
|
|
|
|
var upcomingRecordingsPromise;
|
2016-09-04 08:01:31 -07:00
|
|
|
|
|
2016-09-04 10:52:43 -07:00
|
|
|
|
tabContent.querySelector('#upcomingRecordings .recordingItems').addEventListener('timercancelled', function () {
|
2016-10-02 23:28:45 -07:00
|
|
|
|
self.preRender();
|
|
|
|
|
self.renderTab();
|
2016-09-04 08:01:31 -07:00
|
|
|
|
});
|
|
|
|
|
|
2016-10-02 23:28:45 -07:00
|
|
|
|
self.preRender = function () {
|
|
|
|
|
activeRecordingsPromise = ApiClient.getLiveTvTimers({
|
|
|
|
|
IsActive: true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
upcomingRecordingsPromise = ApiClient.getLiveTvTimers({
|
2016-10-03 22:15:39 -07:00
|
|
|
|
IsActive: false,
|
|
|
|
|
IsScheduled: true
|
2016-10-02 23:28:45 -07:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-09-04 08:01:31 -07:00
|
|
|
|
self.renderTab = function () {
|
2016-10-02 23:28:45 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
renderActiveRecordings(tabContent, activeRecordingsPromise);
|
|
|
|
|
renderUpcomingRecordings(tabContent, upcomingRecordingsPromise);
|
2016-09-04 08:01:31 -07:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|