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

122 lines
3.2 KiB
JavaScript
Raw Normal View History

2014-10-15 20:26:39 -07:00
(function ($, document) {
2013-12-14 18:17:57 -07:00
2014-01-11 16:07:56 -07:00
var query = {
SortBy: "SortName",
SortOrder: "Ascending"
};
function deleteSeriesTimer(page, id) {
2013-12-14 18:17:57 -07:00
2014-05-30 12:23:56 -07:00
Dashboard.confirm(Globalize.translate('MessageConfirmSeriesCancellation'), Globalize.translate('HeaderConfirmSeriesCancellation'), function (result) {
2013-12-14 18:17:57 -07:00
if (result) {
Dashboard.showLoadingMsg();
2015-12-14 08:43:03 -07:00
ApiClient.cancelLiveTvSeriesTimer(id).then(function () {
2013-12-14 18:17:57 -07:00
2014-05-30 12:23:56 -07:00
Dashboard.alert(Globalize.translate('MessageSeriesCancelled'));
2013-12-14 18:17:57 -07:00
reload(page);
});
}
});
}
function renderTimers(page, timers) {
var html = '';
2015-08-16 21:08:33 -07:00
if (timers.length) {
html += '<div class="paperList">';
}
2013-12-14 18:17:57 -07:00
for (var i = 0, length = timers.length; i < length; i++) {
var timer = timers[i];
2015-08-16 21:08:33 -07:00
html += '<paper-icon-item>';
2015-10-26 11:55:46 -07:00
html += '<paper-fab mini icon="live-tv" item-icon></paper-fab>';
2015-08-16 21:08:33 -07:00
2015-08-16 21:56:22 -07:00
html += '<paper-item-body three-line>';
2015-08-16 21:08:33 -07:00
html += '<a class="clearLink" href="livetvseriestimer.html?id=' + timer.Id + '">';
2013-12-14 18:17:57 -07:00
2015-08-16 21:08:33 -07:00
html += '<div>';
2013-12-27 19:46:32 -07:00
html += timer.Name;
2015-08-16 21:08:33 -07:00
html += '</div>';
2013-12-14 18:17:57 -07:00
2015-08-16 21:08:33 -07:00
html += '<div secondary>';
2013-12-14 18:17:57 -07:00
if (timer.DayPattern) {
html += timer.DayPattern;
}
else {
var days = timer.Days || [];
html += days.join(', ');
}
2013-12-27 19:46:32 -07:00
if (timer.RecordAnyTime) {
2013-12-14 18:17:57 -07:00
2014-05-30 12:23:56 -07:00
html += ' - ' + Globalize.translate('LabelAnytime');
2013-12-27 19:46:32 -07:00
} else {
2015-05-22 12:16:14 -07:00
html += ' - ' + LibraryBrowser.getDisplayTime(timer.StartDate);
2013-12-27 19:46:32 -07:00
}
2015-08-16 21:08:33 -07:00
html += '</div>';
2013-12-14 18:17:57 -07:00
2015-08-16 21:08:33 -07:00
html += '<div secondary>';
2013-12-27 19:46:32 -07:00
if (timer.RecordAnyChannel) {
2014-05-30 12:23:56 -07:00
html += Globalize.translate('LabelAllChannels');
2013-12-27 19:46:32 -07:00
}
else if (timer.ChannelId) {
html += timer.ChannelName;
}
2015-08-16 21:08:33 -07:00
html += '</div>';
html += '</a>';
2015-08-16 21:08:33 -07:00
html += '</paper-item-body>';
2013-12-15 07:19:24 -07:00
2015-08-18 21:08:03 -07:00
html += '<paper-icon-button icon="cancel" data-seriestimerid="' + timer.Id + '" title="' + Globalize.translate('ButtonCancelSeries') + '" class="btnCancelSeries"></paper-icon-button>';
2015-08-16 21:08:33 -07:00
html += '</paper-icon-item>';
2013-12-14 18:17:57 -07:00
}
2015-08-16 21:08:33 -07:00
if (timers.length) {
html += '</div>';
}
2013-12-14 18:17:57 -07:00
2015-09-05 21:53:37 -07:00
var elem = $('#items', page).html(html);
2014-05-30 12:23:56 -07:00
$('.btnCancelSeries', elem).on('click', function () {
deleteSeriesTimer(page, this.getAttribute('data-seriestimerid'));
});
2013-12-14 18:17:57 -07:00
Dashboard.hideLoadingMsg();
}
function reload(page) {
Dashboard.showLoadingMsg();
2015-12-14 08:43:03 -07:00
ApiClient.getLiveTvSeriesTimers(query).then(function (result) {
2013-12-14 18:17:57 -07:00
2015-12-14 08:43:03 -07:00
require(['paper-fab', 'paper-item-body', 'paper-icon-item'], function () {
renderTimers(page, result.Items);
});
2013-12-14 18:17:57 -07:00
2015-06-30 10:21:20 -07:00
LibraryBrowser.setLastRefreshed(page);
2013-12-14 18:17:57 -07:00
});
}
2015-08-18 08:52:48 -07:00
window.LiveTvPage.renderSeriesTimersTab = function (page, tabContent) {
2014-01-11 16:07:56 -07:00
2015-08-18 08:52:48 -07:00
if (LibraryBrowser.needsRefresh(tabContent)) {
reload(tabContent);
}
};
2013-12-14 18:17:57 -07:00
2014-10-15 20:26:39 -07:00
})(jQuery, document);