mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
extracted connectionManager from site.js
new module ServerConnections for ConnectionManager all code adapted to this new module removed Events and ConnectionManager from eslintrc
This commit is contained in:
parent
923d53bb71
commit
5071aedcea
81 changed files with 446 additions and 397 deletions
|
@ -1,9 +1,9 @@
|
|||
import { ConnectionManager } from 'jellyfin-apiclient';
|
||||
import dom from '../../scripts/dom';
|
||||
import recordingHelper from './recordinghelper';
|
||||
import '../../elements/emby-button/paper-icon-button-light';
|
||||
import '../../elements/emby-button/emby-button';
|
||||
import './recordingfields.css';
|
||||
import ServerConnections from '../ServerConnections';
|
||||
|
||||
function onRecordingButtonClick(e) {
|
||||
const item = this.item;
|
||||
|
@ -53,7 +53,7 @@ class RecordingButton {
|
|||
}
|
||||
|
||||
refresh(serverId, itemId) {
|
||||
const apiClient = ConnectionManager.getApiClient(serverId);
|
||||
const apiClient = ServerConnections.getApiClient(serverId);
|
||||
const self = this;
|
||||
apiClient.getItem(apiClient.getCurrentUserId(), itemId).then(function (item) {
|
||||
self.refreshItem(item);
|
||||
|
|
|
@ -7,7 +7,7 @@ import scrollHelper from '../../scripts/scrollHelper';
|
|||
import datetime from '../../scripts/datetime';
|
||||
import imageLoader from '../images/imageLoader';
|
||||
import recordingFields from './recordingfields';
|
||||
import { ConnectionManager, Events } from 'jellyfin-apiclient';
|
||||
import { Events } from 'jellyfin-apiclient';
|
||||
import '../../elements/emby-button/emby-button';
|
||||
import '../../elements/emby-button/paper-icon-button-light';
|
||||
import '../../elements/emby-checkbox/emby-checkbox';
|
||||
|
@ -16,6 +16,7 @@ import '../../elements/emby-input/emby-input';
|
|||
import '../formdialog.css';
|
||||
import './recordingcreator.css';
|
||||
import 'material-design-icons-iconfont';
|
||||
import ServerConnections from '../ServerConnections';
|
||||
|
||||
let currentDialog;
|
||||
let closeAction;
|
||||
|
@ -101,7 +102,7 @@ function renderRecording(context, defaultTimer, program, apiClient, refreshRecor
|
|||
function reload(context, programId, serverId, refreshRecordingStateOnly) {
|
||||
loading.show();
|
||||
|
||||
const apiClient = ConnectionManager.getApiClient(serverId);
|
||||
const apiClient = ServerConnections.getApiClient(serverId);
|
||||
|
||||
const promise1 = apiClient.getNewLiveTvTimerDefaults({ programId: programId });
|
||||
const promise2 = apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId());
|
||||
|
@ -117,7 +118,7 @@ function reload(context, programId, serverId, refreshRecordingStateOnly) {
|
|||
function executeCloseAction(action, programId, serverId) {
|
||||
if (action === 'play') {
|
||||
import('../playback/playbackmanager').then((playbackManager) => {
|
||||
const apiClient = ConnectionManager.getApiClient(serverId);
|
||||
const apiClient = ServerConnections.getApiClient(serverId);
|
||||
|
||||
apiClient.getLiveTvProgram(programId, apiClient.getCurrentUserId()).then(function (item) {
|
||||
playbackManager.play({
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
import dialogHelper from '../dialogHelper/dialogHelper';
|
||||
import globalize from '../../scripts/globalize';
|
||||
import layoutManager from '../layoutManager';
|
||||
import { ConnectionManager } from 'jellyfin-apiclient';
|
||||
import loading from '../loading/loading';
|
||||
import scrollHelper from '../../scripts/scrollHelper';
|
||||
import '../../assets/css/scrollstyles.css';
|
||||
|
@ -14,6 +13,7 @@ import '../formdialog.css';
|
|||
import './recordingcreator.css';
|
||||
import 'material-design-icons-iconfont';
|
||||
import '../../assets/css/flexstyles.css';
|
||||
import ServerConnections from '../ServerConnections';
|
||||
|
||||
let currentDialog;
|
||||
let recordingDeleted = false;
|
||||
|
@ -42,7 +42,7 @@ function closeDialog(isDeleted) {
|
|||
function onSubmit(e) {
|
||||
const form = this;
|
||||
|
||||
const apiClient = ConnectionManager.getApiClient(currentServerId);
|
||||
const apiClient = ServerConnections.getApiClient(currentServerId);
|
||||
|
||||
apiClient.getLiveTvTimer(currentItemId).then(function (item) {
|
||||
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
||||
|
@ -62,7 +62,7 @@ function init(context) {
|
|||
});
|
||||
|
||||
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
|
||||
const apiClient = ConnectionManager.getApiClient(currentServerId);
|
||||
const apiClient = ServerConnections.getApiClient(currentServerId);
|
||||
|
||||
deleteTimer(apiClient, currentItemId).then(function () {
|
||||
closeDialog(true);
|
||||
|
@ -76,7 +76,7 @@ function reload(context, id) {
|
|||
loading.show();
|
||||
currentItemId = id;
|
||||
|
||||
const apiClient = ConnectionManager.getApiClient(currentServerId);
|
||||
const apiClient = ServerConnections.getApiClient(currentServerId);
|
||||
apiClient.getLiveTvTimer(id).then(function (result) {
|
||||
renderTimer(context, result, apiClient);
|
||||
loading.hide();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import globalize from '../../scripts/globalize';
|
||||
import { ConnectionManager, Events } from 'jellyfin-apiclient';
|
||||
import { Events } from 'jellyfin-apiclient';
|
||||
import serverNotifications from '../../scripts/serverNotifications';
|
||||
import loading from '../loading/loading';
|
||||
import dom from '../../scripts/dom';
|
||||
|
@ -8,6 +8,7 @@ import '../../elements/emby-button/emby-button';
|
|||
import '../../elements/emby-button/paper-icon-button-light';
|
||||
import './recordingfields.css';
|
||||
import '../../assets/css/flexstyles.css';
|
||||
import ServerConnections from '../ServerConnections';
|
||||
|
||||
/*eslint prefer-const: "error"*/
|
||||
|
||||
|
@ -45,7 +46,7 @@ function loadData(parent, program, apiClient) {
|
|||
|
||||
function fetchData(instance) {
|
||||
const options = instance.options;
|
||||
const apiClient = ConnectionManager.getApiClient(options.serverId);
|
||||
const apiClient = ServerConnections.getApiClient(options.serverId);
|
||||
|
||||
options.parent.querySelector('.recordingFields').classList.remove('hide');
|
||||
return apiClient.getLiveTvProgram(options.programId, apiClient.getCurrentUserId()).then(function (program) {
|
||||
|
@ -196,7 +197,7 @@ function onRecordChange(e) {
|
|||
|
||||
const self = this;
|
||||
const options = this.options;
|
||||
const apiClient = ConnectionManager.getApiClient(options.serverId);
|
||||
const apiClient = ServerConnections.getApiClient(options.serverId);
|
||||
|
||||
const button = dom.parentWithTag(e.target, 'BUTTON');
|
||||
const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');
|
||||
|
@ -235,7 +236,7 @@ function onRecordSeriesChange(e) {
|
|||
|
||||
const self = this;
|
||||
const options = this.options;
|
||||
const apiClient = ConnectionManager.getApiClient(options.serverId);
|
||||
const apiClient = ServerConnections.getApiClient(options.serverId);
|
||||
|
||||
const button = dom.parentWithTag(e.target, 'BUTTON');
|
||||
const isChecked = !button.querySelector('.material-icons').classList.contains('recordingIcon-active');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import globalize from '../../scripts/globalize';
|
||||
import loading from '../loading/loading';
|
||||
import { ConnectionManager } from 'jellyfin-apiclient';
|
||||
import ServerConnections from '../ServerConnections';
|
||||
|
||||
/*eslint prefer-const: "error"*/
|
||||
|
||||
|
@ -40,7 +40,7 @@ function cancelTimerWithConfirmation(timerId, serverId) {
|
|||
}).then(function () {
|
||||
loading.show();
|
||||
|
||||
const apiClient = ConnectionManager.getApiClient(serverId);
|
||||
const apiClient = ServerConnections.getApiClient(serverId);
|
||||
cancelTimer(apiClient, timerId, true).then(resolve, reject);
|
||||
}, reject);
|
||||
});
|
||||
|
@ -60,7 +60,7 @@ function cancelSeriesTimerWithConfirmation(timerId, serverId) {
|
|||
}).then(function () {
|
||||
loading.show();
|
||||
|
||||
const apiClient = ConnectionManager.getApiClient(serverId);
|
||||
const apiClient = ServerConnections.getApiClient(serverId);
|
||||
apiClient.cancelLiveTvSeriesTimer(timerId).then(function () {
|
||||
import('../toast/toast').then((toast) => {
|
||||
toast(globalize.translate('SeriesCancelled'));
|
||||
|
@ -141,7 +141,7 @@ function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus,
|
|||
buttons: items
|
||||
|
||||
}).then(function (result) {
|
||||
const apiClient = ConnectionManager.getApiClient(serverId);
|
||||
const apiClient = ServerConnections.getApiClient(serverId);
|
||||
|
||||
if (result === 'canceltimer') {
|
||||
loading.show();
|
||||
|
@ -167,7 +167,7 @@ function showMultiCancellationPrompt(serverId, programId, timerId, timerStatus,
|
|||
}
|
||||
|
||||
function toggleRecording(serverId, programId, timerId, timerStatus, seriesTimerId) {
|
||||
const apiClient = ConnectionManager.getApiClient(serverId);
|
||||
const apiClient = ServerConnections.getApiClient(serverId);
|
||||
const hasTimer = timerId && timerStatus !== 'Cancelled';
|
||||
if (seriesTimerId && hasTimer) {
|
||||
// cancel
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import dialogHelper from '../dialogHelper/dialogHelper';
|
||||
import globalize from '../../scripts/globalize';
|
||||
import layoutManager from '../layoutManager';
|
||||
import { ConnectionManager } from 'jellyfin-apiclient';
|
||||
import loading from '../loading/loading';
|
||||
import scrollHelper from '../../scripts/scrollHelper';
|
||||
import datetime from '../../scripts/datetime';
|
||||
|
@ -15,6 +14,7 @@ import '../formdialog.css';
|
|||
import './recordingcreator.css';
|
||||
import 'material-design-icons-iconfont';
|
||||
import '../../assets/css/flexstyles.css';
|
||||
import ServerConnections from '../ServerConnections';
|
||||
|
||||
/*eslint prefer-const: "error"*/
|
||||
|
||||
|
@ -64,7 +64,7 @@ function closeDialog(isDeleted) {
|
|||
function onSubmit(e) {
|
||||
const form = this;
|
||||
|
||||
const apiClient = ConnectionManager.getApiClient(currentServerId);
|
||||
const apiClient = ServerConnections.getApiClient(currentServerId);
|
||||
|
||||
apiClient.getLiveTvSeriesTimer(currentItemId).then(function (item) {
|
||||
item.PrePaddingSeconds = form.querySelector('#txtPrePaddingMinutes').value * 60;
|
||||
|
@ -92,7 +92,7 @@ function init(context) {
|
|||
});
|
||||
|
||||
context.querySelector('.btnCancelRecording').addEventListener('click', function () {
|
||||
const apiClient = ConnectionManager.getApiClient(currentServerId);
|
||||
const apiClient = ServerConnections.getApiClient(currentServerId);
|
||||
deleteTimer(apiClient, currentItemId).then(function () {
|
||||
closeDialog(true);
|
||||
});
|
||||
|
@ -102,7 +102,7 @@ function init(context) {
|
|||
}
|
||||
|
||||
function reload(context, id) {
|
||||
const apiClient = ConnectionManager.getApiClient(currentServerId);
|
||||
const apiClient = ServerConnections.getApiClient(currentServerId);
|
||||
|
||||
loading.show();
|
||||
if (typeof id === 'string') {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue