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

83 lines
2.4 KiB
JavaScript
Raw Normal View History

2016-10-02 23:28:45 -07:00
define(['datetime', 'dom', 'seriesRecordingEditor', 'listView', 'emby-itemscontainer'], function (datetime, dom, seriesRecordingEditor, listView) {
2016-10-22 22:11:46 -07:00
'use strict';
2013-12-15 07:19:24 -07:00
2016-08-11 15:41:25 -07:00
return function (view, params) {
2013-12-14 18:17:57 -07:00
2016-08-11 15:41:25 -07:00
function renderTimer(page, item) {
2013-12-14 18:17:57 -07:00
2016-08-11 15:41:25 -07:00
page.querySelector('.itemName').innerHTML = item.Name;
2013-12-14 18:17:57 -07:00
2016-08-11 15:41:25 -07:00
Dashboard.hideLoadingMsg();
}
2013-12-14 18:17:57 -07:00
2016-10-02 23:28:45 -07:00
function getProgramScheduleHtml(items, options) {
options = options || {};
var html = '';
2016-10-03 22:15:39 -07:00
html += '<div is="emby-itemscontainer" class="itemsContainer vertical-list" data-contextmenu="false">';
2016-10-02 23:28:45 -07:00
html += listView.getListViewHtml({
items: items,
enableUserDataButtons: false,
image: false,
showProgramDateTime: true,
mediaInfo: false,
action: 'none',
2016-10-03 22:15:39 -07:00
moreButton: false,
recordButton: false
2016-10-02 23:28:45 -07:00
});
html += '</div>';
return html;
}
2016-10-01 00:06:00 -07:00
function renderSchedule(page) {
2014-01-07 22:25:21 -07:00
2016-10-03 22:15:39 -07:00
ApiClient.getLiveTvTimers({
2016-10-01 00:06:00 -07:00
UserId: ApiClient.getCurrentUserId(),
ImageTypeLimit: 1,
EnableImageTypes: "Primary,Backdrop,Thumb",
SortBy: "StartDate",
EnableTotalRecordCount: false,
EnableUserData: false,
SeriesTimerId: params.id,
2016-10-03 22:15:39 -07:00
Fields: "ChannelInfo"
2014-01-07 22:25:21 -07:00
2016-10-01 00:06:00 -07:00
}).then(function (result) {
2014-01-07 22:25:21 -07:00
2016-10-01 12:21:42 -07:00
if (result.Items.length && result.Items[0].SeriesTimerId != params.id) {
result.Items = [];
}
2016-10-02 23:28:45 -07:00
var html = getProgramScheduleHtml(result.Items);
2013-12-14 18:17:57 -07:00
2016-10-02 23:28:45 -07:00
var scheduleTab = page.querySelector('.scheduleTab');
scheduleTab.innerHTML = html;
2016-10-01 00:06:00 -07:00
2016-10-02 23:28:45 -07:00
ImageLoader.lazyChildren(scheduleTab);
2016-08-11 15:41:25 -07:00
});
}
2014-01-07 22:25:21 -07:00
2016-08-11 15:41:25 -07:00
function reload() {
2014-01-07 22:25:21 -07:00
2016-08-11 15:41:25 -07:00
var id = params.id;
Dashboard.showLoadingMsg();
2014-01-07 22:25:21 -07:00
2016-08-11 15:41:25 -07:00
ApiClient.getLiveTvSeriesTimer(id).then(function (result) {
2014-01-07 22:25:21 -07:00
2016-08-11 15:41:25 -07:00
renderTimer(view, result);
2014-01-07 22:25:21 -07:00
2016-08-11 15:41:25 -07:00
});
2015-06-08 14:32:20 -07:00
2016-10-01 00:06:00 -07:00
renderSchedule(view);
2016-08-11 15:41:25 -07:00
}
2013-12-14 18:17:57 -07:00
2016-09-30 11:43:59 -07:00
seriesRecordingEditor.embed(params.id, ApiClient.serverId(), {
context: view.querySelector('.recordingEditor')
2016-08-11 15:41:25 -07:00
});
2013-12-14 18:17:57 -07:00
2016-08-11 15:41:25 -07:00
view.querySelector('.scheduleTab').addEventListener('timercancelled', reload);
view.addEventListener('viewbeforeshow', reload);
};
});