Migration of recording editor and fields to ES6 modules
This commit is contained in:
parent
a6cd54b661
commit
84b9dc95f6
4 changed files with 353 additions and 328 deletions
|
@ -153,6 +153,8 @@
|
||||||
"src/components/playmenu.js",
|
"src/components/playmenu.js",
|
||||||
"src/components/prompt/prompt.js",
|
"src/components/prompt/prompt.js",
|
||||||
"src/components/refreshdialog/refreshdialog.js",
|
"src/components/refreshdialog/refreshdialog.js",
|
||||||
|
"src/components/recordingcreator/recordingeditor.js",
|
||||||
|
"src/components/recordingcreator/recordingfields.js",
|
||||||
"src/components/sanatizefilename.js",
|
"src/components/sanatizefilename.js",
|
||||||
"src/components/scrollManager.js",
|
"src/components/scrollManager.js",
|
||||||
"src/plugins/htmlVideoPlayer/plugin.js",
|
"src/plugins/htmlVideoPlayer/plugin.js",
|
||||||
|
|
|
@ -168,7 +168,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
|
|
||||||
reload(dlg, itemId, serverId);
|
reload(dlg, itemId, serverId);
|
||||||
|
|
||||||
currentRecordingFields = new recordingFields({
|
currentRecordingFields = new recordingFields.default({
|
||||||
parent: dlg.querySelector('.recordingFields'),
|
parent: dlg.querySelector('.recordingFields'),
|
||||||
programId: itemId,
|
programId: itemId,
|
||||||
serverId: serverId
|
serverId: serverId
|
||||||
|
|
|
@ -1,13 +1,27 @@
|
||||||
define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'connectionManager', 'require', 'loading', 'scrollHelper', 'imageLoader', 'scrollStyles', 'emby-button', 'emby-collapse', 'emby-input', 'paper-icon-button-light', 'css!./../formdialog', 'css!./recordingcreator', 'material-icons', 'flexStyles'], function (dialogHelper, globalize, layoutManager, mediaInfo, appHost, connectionManager, require, loading, scrollHelper, imageLoader) {
|
import dialogHelper from 'dialogHelper';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
import layoutManager from 'layoutManager';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import require from 'require';
|
||||||
|
import loading from 'loading';
|
||||||
|
import scrollHelper from 'scrollHelper';
|
||||||
|
import 'scrollStyles';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'emby-collapse';
|
||||||
|
import 'emby-input';
|
||||||
|
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 recordingDeleted = false;
|
let recordingDeleted = false;
|
||||||
var currentItemId;
|
let currentItemId;
|
||||||
var currentServerId;
|
let currentServerId;
|
||||||
var currentResolve;
|
let currentResolve;
|
||||||
|
|
||||||
function deleteTimer(apiClient, timerId) {
|
function deleteTimer(apiClient, timerId) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
|
@ -31,9 +45,9 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit(e) {
|
function onSubmit(e) {
|
||||||
var form = this;
|
const form = this;
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
|
|
||||||
apiClient.getLiveTvTimer(currentItemId).then(function (item) {
|
apiClient.getLiveTvTimer(currentItemId).then(function (item) {
|
||||||
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
||||||
|
@ -53,7 +67,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
});
|
});
|
||||||
|
|
||||||
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
|
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
deleteTimer(apiClient, currentItemId).then(function () {
|
deleteTimer(apiClient, currentItemId).then(function () {
|
||||||
closeDialog(true);
|
closeDialog(true);
|
||||||
});
|
});
|
||||||
|
@ -66,7 +80,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
loading.show();
|
loading.show();
|
||||||
currentItemId = id;
|
currentItemId = id;
|
||||||
|
|
||||||
var apiClient = connectionManager.getApiClient(currentServerId);
|
const apiClient = connectionManager.getApiClient(currentServerId);
|
||||||
apiClient.getLiveTvTimer(id).then(function (result) {
|
apiClient.getLiveTvTimer(id).then(function (result) {
|
||||||
renderTimer(context, result, apiClient);
|
renderTimer(context, result, apiClient);
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
@ -82,7 +96,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
currentResolve = resolve;
|
currentResolve = resolve;
|
||||||
|
|
||||||
require(['text!./recordingeditor.template.html'], function (template) {
|
require(['text!./recordingeditor.template.html'], function (template) {
|
||||||
var dialogOptions = {
|
const dialogOptions = {
|
||||||
removeOnClose: true,
|
removeOnClose: true,
|
||||||
scrollY: false
|
scrollY: false
|
||||||
};
|
};
|
||||||
|
@ -91,7 +105,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
dialogOptions.size = 'fullscreen';
|
dialogOptions.size = 'fullscreen';
|
||||||
}
|
}
|
||||||
|
|
||||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
const dlg = dialogHelper.createDialog(dialogOptions);
|
||||||
|
|
||||||
dlg.classList.add('formDialog');
|
dlg.classList.add('formDialog');
|
||||||
dlg.classList.add('recordingDialog');
|
dlg.classList.add('recordingDialog');
|
||||||
|
@ -101,7 +115,7 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
dlg.classList.add('dialog-fullscreen-lowres');
|
dlg.classList.add('dialog-fullscreen-lowres');
|
||||||
}
|
}
|
||||||
|
|
||||||
var html = '';
|
let html = '';
|
||||||
|
|
||||||
html += globalize.translateHtml(template, 'core');
|
html += globalize.translateHtml(template, 'core');
|
||||||
|
|
||||||
|
@ -141,7 +155,6 @@ define(['dialogHelper', 'globalize', 'layoutManager', 'mediaInfo', 'apphost', 'c
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
export default {
|
||||||
show: showEditor
|
show: showEditor
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
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) {
|
import globalize from 'globalize';
|
||||||
'use strict';
|
import connectionManager from 'connectionManager';
|
||||||
|
import serverNotifications from 'serverNotifications';
|
||||||
|
import loading from 'loading';
|
||||||
|
import dom from 'dom';
|
||||||
|
import recordingHelper from 'recordingHelper';
|
||||||
|
import events from 'events';
|
||||||
|
import 'paper-icon-button-light';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'css!./recordingfields';
|
||||||
|
import 'flexStyles';
|
||||||
|
|
||||||
loading = loading.default || loading;
|
/*eslint prefer-const: "error"*/
|
||||||
|
|
||||||
function loadData(parent, program, apiClient) {
|
function loadData(parent, program, apiClient) {
|
||||||
if (program.IsSeries) {
|
if (program.IsSeries) {
|
||||||
|
@ -36,8 +45,8 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchData(instance) {
|
function fetchData(instance) {
|
||||||
var options = instance.options;
|
const options = instance.options;
|
||||||
var apiClient = connectionManager.getApiClient(options.serverId);
|
const apiClient = connectionManager.getApiClient(options.serverId);
|
||||||
|
|
||||||
options.parent.querySelector('.recordingFields').classList.remove('hide');
|
options.parent.querySelector('.recordingFields').classList.remove('hide');
|
||||||
return apiClient.getLiveTvProgram(options.programId, apiClient.getCurrentUserId()).then(function (program) {
|
return apiClient.getLiveTvProgram(options.programId, apiClient.getCurrentUserId()).then(function (program) {
|
||||||
|
@ -49,8 +58,8 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
}
|
}
|
||||||
|
|
||||||
function onTimerChangedExternally(e, apiClient, data) {
|
function onTimerChangedExternally(e, apiClient, data) {
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
var refresh = false;
|
let refresh = false;
|
||||||
|
|
||||||
if (data.Id) {
|
if (data.Id) {
|
||||||
if (this.TimerId === data.Id) {
|
if (this.TimerId === data.Id) {
|
||||||
|
@ -69,8 +78,8 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSeriesTimerChangedExternally(e, apiClient, data) {
|
function onSeriesTimerChangedExternally(e, apiClient, data) {
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
var refresh = false;
|
let refresh = false;
|
||||||
|
|
||||||
if (data.Id) {
|
if (data.Id) {
|
||||||
if (this.SeriesTimerId === data.Id) {
|
if (this.SeriesTimerId === data.Id) {
|
||||||
|
@ -88,31 +97,73 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function RecordingEditor(options) {
|
class RecordingEditor {
|
||||||
|
constructor(options) {
|
||||||
this.options = options;
|
this.options = options;
|
||||||
this.embed();
|
this.embed();
|
||||||
|
|
||||||
var timerChangedHandler = onTimerChangedExternally.bind(this);
|
const timerChangedHandler = onTimerChangedExternally.bind(this);
|
||||||
this.timerChangedHandler = timerChangedHandler;
|
this.timerChangedHandler = timerChangedHandler;
|
||||||
|
|
||||||
events.on(serverNotifications, 'TimerCreated', timerChangedHandler);
|
events.on(serverNotifications, 'TimerCreated', timerChangedHandler);
|
||||||
events.on(serverNotifications, 'TimerCancelled', timerChangedHandler);
|
events.on(serverNotifications, 'TimerCancelled', timerChangedHandler);
|
||||||
|
|
||||||
var seriesTimerChangedHandler = onSeriesTimerChangedExternally.bind(this);
|
const seriesTimerChangedHandler = onSeriesTimerChangedExternally.bind(this);
|
||||||
this.seriesTimerChangedHandler = seriesTimerChangedHandler;
|
this.seriesTimerChangedHandler = seriesTimerChangedHandler;
|
||||||
|
|
||||||
events.on(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler);
|
events.on(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler);
|
||||||
events.on(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler);
|
events.on(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
embed() {
|
||||||
|
const self = this;
|
||||||
|
return new Promise(function (resolve, reject) {
|
||||||
|
import('text!./recordingfields.template.html').then(({default: template}) => {
|
||||||
|
const options = self.options;
|
||||||
|
const context = options.parent;
|
||||||
|
context.innerHTML = globalize.translateHtml(template, 'core');
|
||||||
|
|
||||||
|
context.querySelector('.singleRecordingButton').addEventListener('click', onRecordChange.bind(self));
|
||||||
|
context.querySelector('.seriesRecordingButton').addEventListener('click', onRecordSeriesChange.bind(self));
|
||||||
|
context.querySelector('.btnManageRecording').addEventListener('click', onManageRecordingClick.bind(self));
|
||||||
|
context.querySelector('.btnManageSeriesRecording').addEventListener('click', onManageSeriesRecordingClick.bind(self));
|
||||||
|
|
||||||
|
fetchData(self).then(resolve);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
hasChanged() {
|
||||||
|
return this.changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
refresh() {
|
||||||
|
fetchData(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
const timerChangedHandler = this.timerChangedHandler;
|
||||||
|
this.timerChangedHandler = null;
|
||||||
|
|
||||||
|
events.off(serverNotifications, 'TimerCreated', timerChangedHandler);
|
||||||
|
events.off(serverNotifications, 'TimerCancelled', timerChangedHandler);
|
||||||
|
|
||||||
|
const seriesTimerChangedHandler = this.seriesTimerChangedHandler;
|
||||||
|
this.seriesTimerChangedHandler = null;
|
||||||
|
|
||||||
|
events.off(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler);
|
||||||
|
events.off(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function onManageRecordingClick(e) {
|
function onManageRecordingClick(e) {
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
if (!this.TimerId || this.Status === 'Cancelled') {
|
if (!this.TimerId || this.Status === 'Cancelled') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
const self = this;
|
||||||
require(['recordingEditor'], function (recordingEditor) {
|
import('recordingEditor').then(({default: recordingEditor}) => {
|
||||||
recordingEditor.show(self.TimerId, options.serverId, {
|
recordingEditor.show(self.TimerId, options.serverId, {
|
||||||
enableCancel: false
|
enableCancel: false
|
||||||
}).then(function () {
|
}).then(function () {
|
||||||
|
@ -122,15 +173,15 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
}
|
}
|
||||||
|
|
||||||
function onManageSeriesRecordingClick(e) {
|
function onManageSeriesRecordingClick(e) {
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
|
|
||||||
if (!this.SeriesTimerId) {
|
if (!this.SeriesTimerId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
const self = this;
|
||||||
|
|
||||||
require(['seriesRecordingEditor'], function (seriesRecordingEditor) {
|
import('seriesRecordingEditor').then(({default: seriesRecordingEditor}) => {
|
||||||
seriesRecordingEditor.show(self.SeriesTimerId, options.serverId, {
|
seriesRecordingEditor.show(self.SeriesTimerId, options.serverId, {
|
||||||
|
|
||||||
enableCancel: false
|
enableCancel: false
|
||||||
|
@ -144,14 +195,14 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
function onRecordChange(e) {
|
function onRecordChange(e) {
|
||||||
this.changed = true;
|
this.changed = true;
|
||||||
|
|
||||||
var self = this;
|
const self = this;
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
var apiClient = connectionManager.getApiClient(options.serverId);
|
const apiClient = connectionManager.getApiClient(options.serverId);
|
||||||
|
|
||||||
var button = dom.parentWithTag(e.target, 'BUTTON');
|
const button = dom.parentWithTag(e.target, 'BUTTON');
|
||||||
var isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');
|
const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');
|
||||||
|
|
||||||
var hasEnabledTimer = this.TimerId && this.Status !== 'Cancelled';
|
const hasEnabledTimer = this.TimerId && this.Status !== 'Cancelled';
|
||||||
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
if (!hasEnabledTimer) {
|
if (!hasEnabledTimer) {
|
||||||
|
@ -175,7 +226,7 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendToast(msg) {
|
function sendToast(msg) {
|
||||||
require(['toast'], function (toast) {
|
import('toast').then(({default: toast}) => {
|
||||||
toast(msg);
|
toast(msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -183,17 +234,17 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
function onRecordSeriesChange(e) {
|
function onRecordSeriesChange(e) {
|
||||||
this.changed = true;
|
this.changed = true;
|
||||||
|
|
||||||
var self = this;
|
const self = this;
|
||||||
var options = this.options;
|
const options = this.options;
|
||||||
var apiClient = connectionManager.getApiClient(options.serverId);
|
const apiClient = connectionManager.getApiClient(options.serverId);
|
||||||
|
|
||||||
var button = dom.parentWithTag(e.target, 'BUTTON');
|
const button = dom.parentWithTag(e.target, 'BUTTON');
|
||||||
var isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');
|
const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');
|
||||||
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
options.parent.querySelector('.recordSeriesContainer').classList.remove('hide');
|
options.parent.querySelector('.recordSeriesContainer').classList.remove('hide');
|
||||||
if (!this.SeriesTimerId) {
|
if (!this.SeriesTimerId) {
|
||||||
var promise = this.TimerId ?
|
const promise = this.TimerId ?
|
||||||
recordingHelper.changeRecordingToSeries(apiClient, this.TimerId, options.programId) :
|
recordingHelper.changeRecordingToSeries(apiClient, this.TimerId, options.programId) :
|
||||||
recordingHelper.createRecording(apiClient, options.programId, true);
|
recordingHelper.createRecording(apiClient, options.programId, true);
|
||||||
promise.then(function () {
|
promise.then(function () {
|
||||||
|
@ -210,45 +261,4 @@ define(['globalize', 'connectionManager', 'serverNotifications', 'require', 'loa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RecordingEditor.prototype.embed = function () {
|
export default RecordingEditor;
|
||||||
var self = this;
|
|
||||||
return new Promise(function (resolve, reject) {
|
|
||||||
require(['text!./recordingfields.template.html'], function (template) {
|
|
||||||
var options = self.options;
|
|
||||||
var context = options.parent;
|
|
||||||
context.innerHTML = globalize.translateHtml(template, 'core');
|
|
||||||
|
|
||||||
context.querySelector('.singleRecordingButton').addEventListener('click', onRecordChange.bind(self));
|
|
||||||
context.querySelector('.seriesRecordingButton').addEventListener('click', onRecordSeriesChange.bind(self));
|
|
||||||
context.querySelector('.btnManageRecording').addEventListener('click', onManageRecordingClick.bind(self));
|
|
||||||
context.querySelector('.btnManageSeriesRecording').addEventListener('click', onManageSeriesRecordingClick.bind(self));
|
|
||||||
|
|
||||||
fetchData(self).then(resolve);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
RecordingEditor.prototype.hasChanged = function () {
|
|
||||||
return this.changed;
|
|
||||||
};
|
|
||||||
|
|
||||||
RecordingEditor.prototype.refresh = function () {
|
|
||||||
fetchData(this);
|
|
||||||
};
|
|
||||||
|
|
||||||
RecordingEditor.prototype.destroy = function () {
|
|
||||||
var timerChangedHandler = this.timerChangedHandler;
|
|
||||||
this.timerChangedHandler = null;
|
|
||||||
|
|
||||||
events.off(serverNotifications, 'TimerCreated', timerChangedHandler);
|
|
||||||
events.off(serverNotifications, 'TimerCancelled', timerChangedHandler);
|
|
||||||
|
|
||||||
var seriesTimerChangedHandler = this.seriesTimerChangedHandler;
|
|
||||||
this.seriesTimerChangedHandler = null;
|
|
||||||
|
|
||||||
events.off(serverNotifications, 'SeriesTimerCreated', seriesTimerChangedHandler);
|
|
||||||
events.off(serverNotifications, 'SeriesTimerCancelled', seriesTimerChangedHandler);
|
|
||||||
};
|
|
||||||
|
|
||||||
return RecordingEditor;
|
|
||||||
});
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue