mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #1762 from Camc314/migrate-to-ES6-62
Migration of recordinghelper and seriesrecordingeditor to ES6 modules
This commit is contained in:
commit
949c60b9ae
6 changed files with 390 additions and 368 deletions
|
@ -153,6 +153,8 @@
|
||||||
"src/components/playlisteditor/playlisteditor.js",
|
"src/components/playlisteditor/playlisteditor.js",
|
||||||
"src/components/playmenu.js",
|
"src/components/playmenu.js",
|
||||||
"src/components/prompt/prompt.js",
|
"src/components/prompt/prompt.js",
|
||||||
|
"src/components/recordingcreator/seriesrecordingeditor.js",
|
||||||
|
"src/components/recordingcreator/recordinghelper.js",
|
||||||
"src/components/refreshdialog/refreshdialog.js",
|
"src/components/refreshdialog/refreshdialog.js",
|
||||||
"src/components/sanatizefilename.js",
|
"src/components/sanatizefilename.js",
|
||||||
"src/components/scrollManager.js",
|
"src/components/scrollManager.js",
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
define(['globalize', 'connectionManager', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields'], function (globalize, connectionManager, require, loading, appHost, dom, recordingHelper, events) {
|
define(['globalize', 'connectionManager', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields'], function (globalize, connectionManager, require, loading, appHost, dom, recordingHelper, events) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
recordingHelper = recordingHelper.default || recordingHelper;
|
||||||
|
|
||||||
function onRecordingButtonClick(e) {
|
function onRecordingButtonClick(e) {
|
||||||
var item = this.item;
|
var item = this.item;
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
function deleteTimer(apiClient, timerId) {
|
function deleteTimer(apiClient, timerId) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
require(['recordingHelper'], function (recordingHelper) {
|
require(['recordingHelper'], function (recordingHelper) {
|
||||||
|
recordingHelper = recordingHelper.default || recordingHelper;
|
||||||
|
|
||||||
recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
|
recordingHelper.cancelTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields', 'flexStyles'], function (globalize, connectionManager, serverNotifications, require, loading, appHost, dom, recordingHelper, events) {
|
define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loading', 'apphost', 'dom', 'recordingHelper', 'events', 'paper-icon-button-light', 'emby-button', 'css!./recordingfields', 'flexStyles'], function (globalize, connectionManager, serverNotifications, require, loading, appHost, dom, recordingHelper, events) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
recordingHelper = recordingHelper.default || recordingHelper;
|
||||||
loading = loading.default || loading;
|
loading = loading.default || loading;
|
||||||
|
|
||||||
function loadData(parent, program, apiClient) {
|
function loadData(parent, program, apiClient) {
|
||||||
|
|
|
@ -1,194 +1,195 @@
|
||||||
define(['globalize', 'loading', 'connectionManager'], function (globalize, loading, connectionManager) {
|
import globalize from 'globalize';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
|
||||||
loading = loading.default || loading;
|
/*eslint prefer-const: "error"*/
|
||||||
|
|
||||||
function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCancellation) {
|
function changeRecordingToSeries(apiClient, timerId, programId, confirmTimerCancellation) {
|
||||||
loading.show();
|
loading.show();
|
||||||
|
|
||||||
return apiClient.getItem(apiClient.getCurrentUserId(), programId).then(function (item) {
|
return apiClient.getItem(apiClient.getCurrentUserId(), programId).then(function (item) {
|
||||||
if (item.IsSeries) {
|
if (item.IsSeries) {
|
||||||
// create series
|
// create series
|
||||||
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (timerDefaults) {
|
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (timerDefaults) {
|
||||||
return apiClient.createLiveTvSeriesTimer(timerDefaults).then(function () {
|
return apiClient.createLiveTvSeriesTimer(timerDefaults).then(function () {
|
||||||
loading.hide();
|
loading.hide();
|
||||||
sendToast(globalize.translate('SeriesRecordingScheduled'));
|
sendToast(globalize.translate('SeriesRecordingScheduled'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// cancel
|
||||||
|
if (confirmTimerCancellation) {
|
||||||
|
return cancelTimerWithConfirmation(timerId, apiClient.serverId());
|
||||||
|
}
|
||||||
|
|
||||||
|
return cancelTimer(apiClient.serverId(), timerId, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelTimerWithConfirmation(timerId, serverId) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('confirm').then(({ default: confirm }) => {
|
||||||
|
confirm.default({
|
||||||
|
|
||||||
|
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
||||||
|
primary: 'delete',
|
||||||
|
confirmText: globalize.translate('HeaderCancelRecording'),
|
||||||
|
cancelText: globalize.translate('HeaderKeepRecording')
|
||||||
|
|
||||||
|
}).then(function () {
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
||||||
|
}, reject);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelSeriesTimerWithConfirmation(timerId, serverId) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('confirm').then(({ default: confirm }) => {
|
||||||
|
confirm.default({
|
||||||
|
|
||||||
|
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
||||||
|
primary: 'delete',
|
||||||
|
confirmText: globalize.translate('HeaderCancelSeries'),
|
||||||
|
cancelText: globalize.translate('HeaderKeepSeries')
|
||||||
|
|
||||||
|
}).then(function () {
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
|
||||||
|
import('toast').then(({default: toast}) => {
|
||||||
|
toast(globalize.translate('SeriesCancelled'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
resolve();
|
||||||
|
}, reject);
|
||||||
|
}, reject);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancelTimer(apiClient, timerId, hideLoading) {
|
||||||
|
loading.show();
|
||||||
|
return apiClient.cancelLiveTvTimer(timerId).then(function () {
|
||||||
|
if (hideLoading !== false) {
|
||||||
|
loading.hide();
|
||||||
|
sendToast(globalize.translate('RecordingCancelled'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createRecording(apiClient, programId, isSeries) {
|
||||||
|
loading.show();
|
||||||
|
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (item) {
|
||||||
|
const promise = isSeries ?
|
||||||
|
apiClient.createLiveTvSeriesTimer(item) :
|
||||||
|
apiClient.createLiveTvTimer(item);
|
||||||
|
|
||||||
|
return promise.then(function () {
|
||||||
|
loading.hide();
|
||||||
|
sendToast(globalize.translate('RecordingScheduled'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendToast(msg) {
|
||||||
|
import('toast').then(({ default: toast }) => {
|
||||||
|
toast(msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('dialog').then(({ default: dialog }) => {
|
||||||
|
const items = [];
|
||||||
|
|
||||||
|
items.push({
|
||||||
|
name: globalize.translate('HeaderKeepRecording'),
|
||||||
|
id: 'cancel',
|
||||||
|
type: 'submit'
|
||||||
|
});
|
||||||
|
|
||||||
|
if (timerStatus === 'InProgress') {
|
||||||
|
items.push({
|
||||||
|
name: globalize.translate('HeaderStopRecording'),
|
||||||
|
id: 'canceltimer',
|
||||||
|
type: 'cancel'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// cancel
|
items.push({
|
||||||
if (confirmTimerCancellation) {
|
name: globalize.translate('HeaderCancelRecording'),
|
||||||
return cancelTimerWithConfirmation(timerId, apiClient.serverId());
|
id: 'canceltimer',
|
||||||
}
|
type: 'cancel'
|
||||||
|
});
|
||||||
return cancelTimer(apiClient.serverId(), timerId, true);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelTimerWithConfirmation(timerId, serverId) {
|
items.push({
|
||||||
return new Promise(function (resolve, reject) {
|
name: globalize.translate('HeaderCancelSeries'),
|
||||||
require(['confirm'], function (confirm) {
|
id: 'cancelseriestimer',
|
||||||
confirm.default({
|
type: 'cancel'
|
||||||
|
|
||||||
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
|
||||||
primary: 'delete',
|
|
||||||
confirmText: globalize.translate('HeaderCancelRecording'),
|
|
||||||
cancelText: globalize.translate('HeaderKeepRecording')
|
|
||||||
|
|
||||||
}).then(function () {
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
|
||||||
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
|
||||||
}, reject);
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelSeriesTimerWithConfirmation(timerId, serverId) {
|
dialog({
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
require(['confirm'], function (confirm) {
|
|
||||||
confirm.default({
|
|
||||||
|
|
||||||
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
||||||
primary: 'delete',
|
buttons: items
|
||||||
confirmText: globalize.translate('HeaderCancelSeries'),
|
|
||||||
cancelText: globalize.translate('HeaderKeepSeries')
|
|
||||||
|
|
||||||
}).then(function () {
|
}).then(function (result) {
|
||||||
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
|
|
||||||
|
if (result === 'canceltimer') {
|
||||||
loading.show();
|
loading.show();
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
||||||
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
|
} else if (result === 'cancelseriestimer') {
|
||||||
require(['toast'], function (toast) {
|
loading.show();
|
||||||
|
|
||||||
|
apiClient.cancelLiveTvSeriesTimer(seriesTimerId).then(function () {
|
||||||
|
import('toast').then(({ default: toast }) => {
|
||||||
toast(globalize.translate('SeriesCancelled'));
|
toast(globalize.translate('SeriesCancelled'));
|
||||||
});
|
});
|
||||||
|
|
||||||
loading.hide();
|
loading.hide();
|
||||||
resolve();
|
resolve();
|
||||||
}, reject);
|
}, reject);
|
||||||
}, reject);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function cancelTimer(apiClient, timerId, hideLoading) {
|
|
||||||
loading.show();
|
|
||||||
return apiClient.cancelLiveTvTimer(timerId).then(function () {
|
|
||||||
if (hideLoading !== false) {
|
|
||||||
loading.hide();
|
|
||||||
sendToast(globalize.translate('RecordingCancelled'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function createRecording(apiClient, programId, isSeries) {
|
|
||||||
loading.show();
|
|
||||||
return apiClient.getNewLiveTvTimerDefaults({ programId: programId }).then(function (item) {
|
|
||||||
var promise = isSeries ?
|
|
||||||
apiClient.createLiveTvSeriesTimer(item) :
|
|
||||||
apiClient.createLiveTvTimer(item);
|
|
||||||
|
|
||||||
return promise.then(function () {
|
|
||||||
loading.hide();
|
|
||||||
sendToast(globalize.translate('RecordingScheduled'));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function sendToast(msg) {
|
|
||||||
require(['toast'], function (toast) {
|
|
||||||
toast(msg);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
require(['dialog'], function (dialog) {
|
|
||||||
var items = [];
|
|
||||||
|
|
||||||
items.push({
|
|
||||||
name: globalize.translate('HeaderKeepRecording'),
|
|
||||||
id: 'cancel',
|
|
||||||
type: 'submit'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (timerStatus === 'InProgress') {
|
|
||||||
items.push({
|
|
||||||
name: globalize.translate('HeaderStopRecording'),
|
|
||||||
id: 'canceltimer',
|
|
||||||
type: 'cancel'
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
items.push({
|
resolve();
|
||||||
name: globalize.translate('HeaderCancelRecording'),
|
|
||||||
id: 'canceltimer',
|
|
||||||
type: 'cancel'
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
}, reject);
|
||||||
items.push({
|
|
||||||
name: globalize.translate('HeaderCancelSeries'),
|
|
||||||
id: 'cancelseriestimer',
|
|
||||||
type: 'cancel'
|
|
||||||
});
|
|
||||||
|
|
||||||
dialog({
|
|
||||||
|
|
||||||
text: globalize.translate('MessageConfirmRecordingCancellation'),
|
|
||||||
buttons: items
|
|
||||||
|
|
||||||
}).then(function (result) {
|
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
|
||||||
|
|
||||||
if (result === 'canceltimer') {
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
|
||||||
} else if (result === 'cancelseriestimer') {
|
|
||||||
loading.show();
|
|
||||||
|
|
||||||
apiClient.cancelLiveTvSeriesTimer(seriesTimerId).then(function () {
|
|
||||||
require(['toast'], function (toast) {
|
|
||||||
toast(globalize.translate('SeriesCancelled'));
|
|
||||||
});
|
|
||||||
|
|
||||||
loading.hide();
|
|
||||||
resolve();
|
|
||||||
}, reject);
|
|
||||||
} else {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
}, reject);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
||||||
var apiClient = connectionManager.getApiClient(serverId);
|
const apiClient = connectionManager.getApiClient(serverId);
|
||||||
var hasTimer = timerId && timerStatus !== 'Cancelled';
|
const hasTimer = timerId && timerStatus !== 'Cancelled';
|
||||||
if (seriesTimerId && hasTimer) {
|
if (seriesTimerId && hasTimer) {
|
||||||
// cancel
|
// cancel
|
||||||
return showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId);
|
return showMultiCancellationPrompt(serverId, programId, timerId, timerStatus, seriesTimerId);
|
||||||
} else if (hasTimer && programId) {
|
} else if (hasTimer && programId) {
|
||||||
// change to series recording, if possible
|
// change to series recording, if possible
|
||||||
// otherwise cancel individual recording
|
// otherwise cancel individual recording
|
||||||
return changeRecordingToSeries(apiClient, timerId, programId, true);
|
return changeRecordingToSeries(apiClient, timerId, programId, true);
|
||||||
} else if (programId) {
|
} else if (programId) {
|
||||||
// schedule recording
|
// schedule recording
|
||||||
return createRecording(apiClient, programId);
|
return createRecording(apiClient, programId);
|
||||||
} else {
|
} else {
|
||||||
return Promise.reject();
|
return Promise.reject();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
cancelTimer: cancelTimer,
|
||||||
|
createRecording: createRecording,
|
||||||
|
changeRecordingToSeries: changeRecordingToSeries,
|
||||||
|
toggleRecording: toggleRecording,
|
||||||
|
cancelTimerWithConfirmation: cancelTimerWithConfirmation,
|
||||||
|
cancelSeriesTimerWithConfirmation: cancelSeriesTimerWithConfirmation
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
|
||||||
cancelTimer: cancelTimer,
|
|
||||||
createRecording: createRecording,
|
|
||||||
changeRecordingToSeries: changeRecordingToSeries,
|
|
||||||
toggleRecording: toggleRecording,
|
|
||||||
cancelTimerWithConfirmation: cancelTimerWithConfirmation,
|
|
||||||
cancelSeriesTimerWithConfirmation: cancelSeriesTimerWithConfirmation
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,143 +1,200 @@
|
||||||
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'datetime', 'scrollStyles', 'emby-button', 'emby-checkbox', 'emby-input', 'emby-select', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader, datetime) {
|
import dialogHelper from 'dialogHelper';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import loading from 'loading';
|
||||||
|
import scrollHelper from 'scrollHelper';
|
||||||
|
import datetime from 'datetime';
|
||||||
|
import 'scrollStyles';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'css!./../formdialog';
|
||||||
|
import 'css!./recordingcreator';
|
||||||
|
import 'material-icons';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
loading = loading.default || loading;
|
/*eslint prefer-const: "error"*/
|
||||||
|
|
||||||
var currentDialog;
|
let currentDialog;
|
||||||
var recordingUpdated = false;
|
let recordingUpdated = false;
|
||||||
var recordingDeleted = false;
|
let recordingDeleted = false;
|
||||||
var currentItemId;
|
let currentItemId;
|
||||||
var currentServerId;
|
let currentServerId;
|
||||||
|
|
||||||
function deleteTimer(apiClient, timerId) {
|
function deleteTimer(apiClient, timerId) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
require(['recordingHelper'], function (recordingHelper) {
|
import('recordingHelper').then(({ default: recordingHelper }) => {
|
||||||
recordingHelper.cancelSeriesTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
|
recordingHelper.cancelSeriesTimerWithConfirmation(timerId, apiClient.serverId()).then(resolve, reject);
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderTimer(context, item) {
|
||||||
|
context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60;
|
||||||
|
context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60;
|
||||||
|
|
||||||
|
context.querySelector('.selectChannels').value = item.RecordAnyChannel ? 'all' : 'one';
|
||||||
|
context.querySelector('.selectAirTime').value = item.RecordAnyTime ? 'any' : 'original';
|
||||||
|
|
||||||
|
context.querySelector('.selectShowType').value = item.RecordNewOnly ? 'new' : 'all';
|
||||||
|
context.querySelector('.chkSkipEpisodesInLibrary').checked = item.SkipEpisodesInLibrary;
|
||||||
|
context.querySelector('.selectKeepUpTo').value = item.KeepUpTo || 0;
|
||||||
|
|
||||||
|
if (item.ChannelName || item.ChannelNumber) {
|
||||||
|
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('ChannelNameOnly', item.ChannelName || item.ChannelNumber);
|
||||||
|
} else {
|
||||||
|
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('OneChannel');
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderTimer(context, item, apiClient) {
|
context.querySelector('.optionAroundTime').innerHTML = globalize.translate('AroundTime', datetime.getDisplayTime(datetime.parseISO8601Date(item.StartDate)));
|
||||||
context.querySelector('#txtPrePaddingMinutes').value = item.PrePaddingSeconds / 60;
|
|
||||||
context.querySelector('#txtPostPaddingMinutes').value = item.PostPaddingSeconds / 60;
|
|
||||||
|
|
||||||
context.querySelector('.selectChannels').value = item.RecordAnyChannel ? 'all' : 'one';
|
loading.hide();
|
||||||
context.querySelector('.selectAirTime').value = item.RecordAnyTime ? 'any' : 'original';
|
}
|
||||||
|
|
||||||
context.querySelector('.selectShowType').value = item.RecordNewOnly ? 'new' : 'all';
|
function closeDialog(isDeleted) {
|
||||||
context.querySelector('.chkSkipEpisodesInLibrary').checked = item.SkipEpisodesInLibrary;
|
recordingUpdated = true;
|
||||||
context.querySelector('.selectKeepUpTo').value = item.KeepUpTo || 0;
|
recordingDeleted = isDeleted;
|
||||||
|
|
||||||
if (item.ChannelName || item.ChannelNumber) {
|
dialogHelper.close(currentDialog);
|
||||||
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('ChannelNameOnly', item.ChannelName || item.ChannelNumber);
|
}
|
||||||
} else {
|
|
||||||
context.querySelector('.optionChannelOnly').innerHTML = globalize.translate('OneChannel');
|
|
||||||
}
|
|
||||||
|
|
||||||
context.querySelector('.optionAroundTime').innerHTML = globalize.translate('AroundTime', datetime.getDisplayTime(datetime.parseISO8601Date(item.StartDate)));
|
function onSubmit(e) {
|
||||||
|
const form = this;
|
||||||
|
|
||||||
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
|
||||||
|
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
|
||||||
|
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
||||||
|
item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60;
|
||||||
|
item.RecordAnyChannel = form.querySelector('.selectChannels').value === 'all';
|
||||||
|
item.RecordAnyTime = form.querySelector('.selectAirTime').value === 'any';
|
||||||
|
item.RecordNewOnly = form.querySelector('.selectShowType').value === 'new';
|
||||||
|
item.SkipEpisodesInLibrary = form.querySelector('.chkSkipEpisodesInLibrary').checked;
|
||||||
|
item.KeepUpTo = form.querySelector('.selectKeepUpTo').value;
|
||||||
|
|
||||||
|
apiClient.updateLiveTvSeriesTimer(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Disable default form submission
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function init(context) {
|
||||||
|
fillKeepUpTo(context);
|
||||||
|
|
||||||
|
context.querySelector('.btnCancel').addEventListener('click', function () {
|
||||||
|
closeDialog(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
|
||||||
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
deleteTimer(apiClient, currentItemId).then(function () {
|
||||||
|
closeDialog(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
context.querySelector('form').addEventListener('submit', onSubmit);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reload(context, id) {
|
||||||
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
if (typeof id === 'string') {
|
||||||
|
currentItemId = id;
|
||||||
|
|
||||||
|
apiClient.getLiveTvSeriesTimer(id).then(function (result) {
|
||||||
|
renderTimer(context, result);
|
||||||
|
loading.hide();
|
||||||
|
});
|
||||||
|
} else if (id) {
|
||||||
|
currentItemId = id.Id;
|
||||||
|
|
||||||
|
renderTimer(context, id);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function closeDialog(isDeleted) {
|
function fillKeepUpTo(context) {
|
||||||
recordingUpdated = true;
|
let html = '';
|
||||||
recordingDeleted = isDeleted;
|
|
||||||
|
|
||||||
dialogHelper.close(currentDialog);
|
for (let i = 0; i <= 50; i++) {
|
||||||
}
|
let text;
|
||||||
|
|
||||||
function onSubmit(e) {
|
if (i === 0) {
|
||||||
var form = this;
|
text = globalize.translate('AsManyAsPossible');
|
||||||
|
} else if (i === 1) {
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
text = globalize.translate('ValueOneEpisode');
|
||||||
|
} else {
|
||||||
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
|
text = globalize.translate('ValueEpisodeCount', i);
|
||||||
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
|
||||||
item.PostPaddingSeconds = form.querySelector('#txtPostPaddingMinutes').value * 60;
|
|
||||||
item.RecordAnyChannel = form.querySelector('.selectChannels').value === 'all';
|
|
||||||
item.RecordAnyTime = form.querySelector('.selectAirTime').value === 'any';
|
|
||||||
item.RecordNewOnly = form.querySelector('.selectShowType').value === 'new';
|
|
||||||
item.SkipEpisodesInLibrary = form.querySelector('.chkSkipEpisodesInLibrary').checked;
|
|
||||||
item.KeepUpTo = form.querySelector('.selectKeepUpTo').value;
|
|
||||||
|
|
||||||
apiClient.updateLiveTvSeriesTimer(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
// Disable default form submission
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function init(context) {
|
|
||||||
fillKeepUpTo(context);
|
|
||||||
|
|
||||||
context.querySelector('.btnCancel').addEventListener('click', function () {
|
|
||||||
closeDialog(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
|
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
|
||||||
deleteTimer(apiClient, currentItemId).then(function () {
|
|
||||||
closeDialog(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
context.querySelector('form').addEventListener('submit', onSubmit);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reload(context, id) {
|
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
|
||||||
|
|
||||||
loading.show();
|
|
||||||
if (typeof id === 'string') {
|
|
||||||
currentItemId = id;
|
|
||||||
|
|
||||||
apiClient.getLiveTvSeriesTimer(id).then(function (result) {
|
|
||||||
renderTimer(context, result, apiClient);
|
|
||||||
loading.hide();
|
|
||||||
});
|
|
||||||
} else if (id) {
|
|
||||||
currentItemId = id.Id;
|
|
||||||
|
|
||||||
renderTimer(context, id, apiClient);
|
|
||||||
loading.hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillKeepUpTo(context) {
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
for (var i = 0; i <= 50; i++) {
|
|
||||||
var text;
|
|
||||||
|
|
||||||
if (i === 0) {
|
|
||||||
text = globalize.translate('AsManyAsPossible');
|
|
||||||
} else if (i === 1) {
|
|
||||||
text = globalize.translate('ValueOneEpisode');
|
|
||||||
} else {
|
|
||||||
text = globalize.translate('ValueEpisodeCount', i);
|
|
||||||
}
|
|
||||||
|
|
||||||
html += '<option value="' + i + '">' + text + '</option>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.querySelector('.selectKeepUpTo').innerHTML = html;
|
html += '<option value="' + i + '">' + text + '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFieldChange(e) {
|
context.querySelector('.selectKeepUpTo').innerHTML = html;
|
||||||
this.querySelector('.btnSubmit').click();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function embed(itemId, serverId, options) {
|
function onFieldChange() {
|
||||||
|
this.querySelector('.btnSubmit').click();
|
||||||
|
}
|
||||||
|
|
||||||
|
function embed(itemId, serverId, options) {
|
||||||
|
recordingUpdated = false;
|
||||||
|
recordingDeleted = false;
|
||||||
|
currentServerId = serverId;
|
||||||
|
loading.show();
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
import('text!./seriesrecordingeditor.template.html').then(({ default: template }) => {
|
||||||
|
const dialogOptions = {
|
||||||
|
removeOnClose: true,
|
||||||
|
scrollY: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
dialogOptions.size = 'fullscreen';
|
||||||
|
} else {
|
||||||
|
dialogOptions.size = 'small';
|
||||||
|
}
|
||||||
|
|
||||||
|
const dlg = options.context;
|
||||||
|
|
||||||
|
dlg.classList.add('hide');
|
||||||
|
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
||||||
|
|
||||||
|
dlg.querySelector('.formDialogHeader').classList.add('hide');
|
||||||
|
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
||||||
|
dlg.querySelector('.formDialogContent').className = '';
|
||||||
|
dlg.querySelector('.dialogContentInner').className = '';
|
||||||
|
dlg.classList.remove('hide');
|
||||||
|
|
||||||
|
dlg.removeEventListener('change', onFieldChange);
|
||||||
|
dlg.addEventListener('change', onFieldChange);
|
||||||
|
|
||||||
|
currentDialog = dlg;
|
||||||
|
|
||||||
|
init(dlg);
|
||||||
|
|
||||||
|
reload(dlg, itemId);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function showEditor(itemId, serverId, options) {
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
recordingUpdated = false;
|
recordingUpdated = false;
|
||||||
recordingDeleted = false;
|
recordingDeleted = false;
|
||||||
currentServerId = serverId;
|
currentServerId = serverId;
|
||||||
loading.show();
|
loading.show();
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
require(['text!./seriesrecordingeditor.template.html'], function (template) {
|
import('text!./seriesrecordingeditor.template.html').then(({ default: template }) => {
|
||||||
var dialogOptions = {
|
const dialogOptions = {
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
scrollY: false
|
scrollY: false
|
||||||
};
|
};
|
||||||
|
@ -148,101 +205,58 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
dialogOptions.size = 'small';
|
dialogOptions.size = 'small';
|
||||||
}
|
}
|
||||||
|
|
||||||
var dlg = options.context;
|
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
|
|
||||||
dlg.classList.add('hide');
|
dlg.classList.add('formDialog');
|
||||||
dlg.innerHTML = globalize.translateHtml(template, 'core');
|
dlg.classList.add('recordingDialog');
|
||||||
|
|
||||||
dlg.querySelector('.formDialogHeader').classList.add('hide');
|
if (!layoutManager.tv) {
|
||||||
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
dlg.style['min-width'] = '20%';
|
||||||
dlg.querySelector('.formDialogContent').className = '';
|
}
|
||||||
dlg.querySelector('.dialogContentInner').className = '';
|
|
||||||
dlg.classList.remove('hide');
|
|
||||||
|
|
||||||
dlg.removeEventListener('change', onFieldChange);
|
let html = '';
|
||||||
dlg.addEventListener('change', onFieldChange);
|
|
||||||
|
html += globalize.translateHtml(template, 'core');
|
||||||
|
|
||||||
|
dlg.innerHTML = html;
|
||||||
|
|
||||||
|
if (options.enableCancel === false) {
|
||||||
|
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
||||||
|
}
|
||||||
|
|
||||||
currentDialog = dlg;
|
currentDialog = dlg;
|
||||||
|
|
||||||
|
dlg.addEventListener('closing', function () {
|
||||||
|
if (!recordingDeleted) {
|
||||||
|
this.querySelector('.btnSubmit').click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dlg.addEventListener('close', function () {
|
||||||
|
if (recordingUpdated) {
|
||||||
|
resolve({
|
||||||
|
updated: true,
|
||||||
|
deleted: recordingDeleted
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
reject();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (layoutManager.tv) {
|
||||||
|
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
||||||
|
}
|
||||||
|
|
||||||
init(dlg);
|
init(dlg);
|
||||||
|
|
||||||
reload(dlg, itemId);
|
reload(dlg, itemId);
|
||||||
|
|
||||||
|
dialogHelper.open(dlg);
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showEditor(itemId, serverId, options) {
|
export default {
|
||||||
return new Promise(function (resolve, reject) {
|
show: showEditor,
|
||||||
recordingUpdated = false;
|
embed: embed
|
||||||
recordingDeleted = false;
|
};
|
||||||
currentServerId = serverId;
|
|
||||||
loading.show();
|
|
||||||
options = options || {};
|
|
||||||
|
|
||||||
require(['text!./seriesrecordingeditor.template.html'], function (template) {
|
|
||||||
var dialogOptions = {
|
|
||||||
removeOnClose: true,
|
|
||||||
scrollY: false
|
|
||||||
};
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
dialogOptions.size = 'fullscreen';
|
|
||||||
} else {
|
|
||||||
dialogOptions.size = 'small';
|
|
||||||
}
|
|
||||||
|
|
||||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
|
||||||
|
|
||||||
dlg.classList.add('formDialog');
|
|
||||||
dlg.classList.add('recordingDialog');
|
|
||||||
|
|
||||||
if (!layoutManager.tv) {
|
|
||||||
dlg.style['min-width'] = '20%';
|
|
||||||
}
|
|
||||||
|
|
||||||
var html = '';
|
|
||||||
|
|
||||||
html += globalize.translateHtml(template, 'core');
|
|
||||||
|
|
||||||
dlg.innerHTML = html;
|
|
||||||
|
|
||||||
if (options.enableCancel === false) {
|
|
||||||
dlg.querySelector('.formDialogFooter').classList.add('hide');
|
|
||||||
}
|
|
||||||
|
|
||||||
currentDialog = dlg;
|
|
||||||
|
|
||||||
dlg.addEventListener('closing', function () {
|
|
||||||
if (!recordingDeleted) {
|
|
||||||
this.querySelector('.btnSubmit').click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
dlg.addEventListener('close', function () {
|
|
||||||
if (recordingUpdated) {
|
|
||||||
resolve({
|
|
||||||
updated: true,
|
|
||||||
deleted: recordingDeleted
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
reject();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
|
||||||
scrollHelper.centerFocus.on(dlg.querySelector('.formDialogContent'), false);
|
|
||||||
}
|
|
||||||
|
|
||||||
init(dlg);
|
|
||||||
|
|
||||||
reload(dlg, itemId);
|
|
||||||
|
|
||||||
dialogHelper.open(dlg);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
show: showEditor,
|
|
||||||
embed: embed
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue