mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge branch 'es6' into migrate-to-ES6-23
This commit is contained in:
commit
f084f36757
4 changed files with 143 additions and 106 deletions
|
@ -136,6 +136,9 @@
|
|||
"src/components/syncPlay/playbackPermissionManager.js",
|
||||
"src/components/syncPlay/syncPlayManager.js",
|
||||
"src/components/syncPlay/timeSyncManager.js",
|
||||
"src/controllers/dashboard/apikeys.js",
|
||||
"src/controllers/dashboard/dashboard.js",
|
||||
"src/controllers/dashboard/encodingsettings.js",
|
||||
"src/controllers/dashboard/logs.js",
|
||||
"src/controllers/user/subtitles.js",
|
||||
"src/controllers/dashboard/plugins/repositories.js",
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
define(['datetime', 'loading', 'libraryMenu', 'dom', 'globalize', 'emby-button'], function (datetime, loading, libraryMenu, dom, globalize) {
|
||||
'use strict';
|
||||
import datetime from 'datetime';
|
||||
import loading from 'loading';
|
||||
import libraryMenu from 'libraryMenu';
|
||||
import dom from 'dom';
|
||||
import globalize from 'globalize';
|
||||
import 'emby-button';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
function revoke(page, key) {
|
||||
require(['confirm'], function (confirm) {
|
||||
import('confirm').then(({default: confirm}) => {
|
||||
confirm(globalize.translate('MessageConfirmRevokeApiKey'), globalize.translate('HeaderConfirmRevokeApiKey')).then(function () {
|
||||
loading.show();
|
||||
ApiClient.ajax({
|
||||
|
@ -16,8 +22,8 @@ define(['datetime', 'loading', 'libraryMenu', 'dom', 'globalize', 'emby-button']
|
|||
}
|
||||
|
||||
function renderKeys(page, keys) {
|
||||
var rows = keys.map(function (item) {
|
||||
var html = '';
|
||||
const rows = keys.map(function (item) {
|
||||
let html = '';
|
||||
html += '<tr class="detailTableBodyRow detailTableBodyRow-shaded">';
|
||||
html += '<td class="detailTableBodyCell">';
|
||||
html += '<button type="button" is="emby-button" data-token="' + item.AccessToken + '" class="raised raised-mini btnRevoke" data-mini="true" title="' + globalize.translate('ButtonRevoke') + '" style="margin:0;">' + globalize.translate('ButtonRevoke') + '</button>';
|
||||
|
@ -29,7 +35,7 @@ define(['datetime', 'loading', 'libraryMenu', 'dom', 'globalize', 'emby-button']
|
|||
html += item.AppName || '';
|
||||
html += '</td>';
|
||||
html += '<td class="detailTableBodyCell" style="vertical-align:middle;">';
|
||||
var date = datetime.parseISO8601Date(item.DateCreated, true);
|
||||
const date = datetime.parseISO8601Date(item.DateCreated, true);
|
||||
html += datetime.toLocaleDateString(date) + ' ' + datetime.getDisplayTime(date);
|
||||
html += '</td>';
|
||||
return html += '</tr>';
|
||||
|
@ -46,7 +52,7 @@ define(['datetime', 'loading', 'libraryMenu', 'dom', 'globalize', 'emby-button']
|
|||
}
|
||||
|
||||
function showNewKeyPrompt(page) {
|
||||
require(['prompt'], function (prompt) {
|
||||
import('prompt').then(({default: prompt}) => {
|
||||
prompt({
|
||||
title: globalize.translate('HeaderNewApiKey'),
|
||||
label: globalize.translate('LabelAppName'),
|
||||
|
@ -65,12 +71,12 @@ define(['datetime', 'loading', 'libraryMenu', 'dom', 'globalize', 'emby-button']
|
|||
}
|
||||
|
||||
pageIdOn('pageinit', 'apiKeysPage', function () {
|
||||
var page = this;
|
||||
const page = this;
|
||||
page.querySelector('.btnNewKey').addEventListener('click', function () {
|
||||
showNewKeyPrompt(page);
|
||||
});
|
||||
page.querySelector('.tblApiKeys').addEventListener('click', function (e) {
|
||||
var btnRevoke = dom.parentWithClass(e.target, 'btnRevoke');
|
||||
const btnRevoke = dom.parentWithClass(e.target, 'btnRevoke');
|
||||
|
||||
if (btnRevoke) {
|
||||
revoke(page, btnRevoke.getAttribute('data-token'));
|
||||
|
@ -80,4 +86,5 @@ define(['datetime', 'loading', 'libraryMenu', 'dom', 'globalize', 'emby-button']
|
|||
pageIdOn('pagebeforeshow', 'apiKeysPage', function () {
|
||||
loadData(this);
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -1,11 +1,31 @@
|
|||
define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globalize', 'date-fns', 'dfnshelper', 'loading', 'connectionManager', 'playMethodHelper', 'cardBuilder', 'imageLoader', 'components/activitylog', 'scripts/imagehelper', 'indicators', 'listViewStyle', 'emby-button', 'flexStyles', 'emby-button', 'emby-itemscontainer'], function (datetime, events, itemHelper, serverNotifications, dom, globalize, datefns, dfnshelper, loading, connectionManager, playMethodHelper, cardBuilder, imageLoader, ActivityLog, imageHelper, indicators) {
|
||||
'use strict';
|
||||
import datetime from 'datetime';
|
||||
import events from 'events';
|
||||
import itemHelper from 'itemHelper';
|
||||
import serverNotifications from 'serverNotifications';
|
||||
import dom from 'dom';
|
||||
import globalize from 'globalize';
|
||||
import * as datefns from 'date-fns';
|
||||
import dfnshelper from 'dfnshelper';
|
||||
import loading from 'loading';
|
||||
import connectionManager from 'connectionManager';
|
||||
import playMethodHelper from 'playMethodHelper';
|
||||
import cardBuilder from 'cardBuilder';
|
||||
import imageLoader from 'imageLoader';
|
||||
import ActivityLog from 'components/activitylog';
|
||||
import imageHelper from 'scripts/imagehelper';
|
||||
import indicators from 'indicators';
|
||||
import 'listViewStyle';
|
||||
import 'emby-button';
|
||||
import 'flexStyles';
|
||||
import 'emby-itemscontainer';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
function showPlaybackInfo(btn, session) {
|
||||
require(['alert'], function (alert) {
|
||||
var title;
|
||||
var text = [];
|
||||
var displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
|
||||
import('alert').then(({default: alert}) => {
|
||||
let title;
|
||||
let text = [];
|
||||
const displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
|
||||
|
||||
if (displayPlayMethod === 'DirectStream') {
|
||||
title = globalize.translate('DirectStreaming');
|
||||
|
@ -33,7 +53,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
function showSendMessageForm(btn, session) {
|
||||
require(['prompt'], function (prompt) {
|
||||
import('prompt').then(({default: prompt}) => {
|
||||
prompt({
|
||||
title: globalize.translate('HeaderSendMessage'),
|
||||
label: globalize.translate('LabelMessageText'),
|
||||
|
@ -50,8 +70,8 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
function showOptionsMenu(btn, session) {
|
||||
require(['actionsheet'], function (actionsheet) {
|
||||
var menuItems = [];
|
||||
import('actionsheet').then(({default: actionsheet}) => {
|
||||
const menuItems = [];
|
||||
|
||||
if (session.ServerId && session.DeviceId !== connectionManager.deviceId()) {
|
||||
menuItems.push({
|
||||
|
@ -84,14 +104,14 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
function onActiveDevicesClick(evt) {
|
||||
var btn = dom.parentWithClass(evt.target, 'sessionCardButton');
|
||||
const btn = dom.parentWithClass(evt.target, 'sessionCardButton');
|
||||
|
||||
if (btn) {
|
||||
var card = dom.parentWithClass(btn, 'card');
|
||||
const card = dom.parentWithClass(btn, 'card');
|
||||
|
||||
if (card) {
|
||||
var sessionId = card.id;
|
||||
var session = (DashboardPage.sessionsList || []).filter(function (dashboardSession) {
|
||||
const sessionId = card.id;
|
||||
const session = (DashboardPage.sessionsList || []).filter(function (dashboardSession) {
|
||||
return 'session' + dashboardSession.Id === sessionId;
|
||||
})[0];
|
||||
|
||||
|
@ -113,11 +133,11 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
function filterSessions(sessions) {
|
||||
var list = [];
|
||||
var minActiveDate = new Date().getTime() - 9e5;
|
||||
const list = [];
|
||||
const minActiveDate = new Date().getTime() - 9e5;
|
||||
|
||||
for (var i = 0, length = sessions.length; i < length; i++) {
|
||||
var session = sessions[i];
|
||||
for (let i = 0, length = sessions.length; i < length; i++) {
|
||||
const session = sessions[i];
|
||||
|
||||
if (!session.NowPlayingItem && !session.UserId) {
|
||||
continue;
|
||||
|
@ -139,7 +159,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
EnableTotalRecordCount: false,
|
||||
EnableImageTypes: 'Primary,Thumb,Backdrop'
|
||||
}).then(function (result) {
|
||||
var itemsContainer = view.querySelector('.activeRecordingItems');
|
||||
const itemsContainer = view.querySelector('.activeRecordingItems');
|
||||
|
||||
if (!result.Items.length) {
|
||||
view.querySelector('.activeRecordingsSection').classList.add('hide');
|
||||
|
@ -169,7 +189,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
function reloadSystemInfo(view, apiClient) {
|
||||
apiClient.getSystemInfo().then(function (systemInfo) {
|
||||
view.querySelector('#serverName').innerHTML = globalize.translate('DashboardServerName', systemInfo.ServerName);
|
||||
var localizedVersion = globalize.translate('DashboardVersionNumber', systemInfo.Version);
|
||||
let localizedVersion = globalize.translate('DashboardVersionNumber', systemInfo.Version);
|
||||
|
||||
if (systemInfo.SystemUpdateLevel !== 'Release') {
|
||||
localizedVersion += ' ' + systemInfo.SystemUpdateLevel;
|
||||
|
@ -205,31 +225,31 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
function renderActiveConnections(view, sessions) {
|
||||
var html = '';
|
||||
let html = '';
|
||||
DashboardPage.sessionsList = sessions;
|
||||
var parentElement = view.querySelector('.activeDevices');
|
||||
var cardElem = parentElement.querySelector('.card');
|
||||
const parentElement = view.querySelector('.activeDevices');
|
||||
const cardElem = parentElement.querySelector('.card');
|
||||
|
||||
if (cardElem) {
|
||||
cardElem.classList.add('deadSession');
|
||||
}
|
||||
|
||||
for (var i = 0, length = sessions.length; i < length; i++) {
|
||||
var session = sessions[i];
|
||||
var rowId = 'session' + session.Id;
|
||||
var elem = view.querySelector('#' + rowId);
|
||||
for (let i = 0, length = sessions.length; i < length; i++) {
|
||||
const session = sessions[i];
|
||||
const rowId = 'session' + session.Id;
|
||||
const elem = view.querySelector('#' + rowId);
|
||||
|
||||
if (elem) {
|
||||
DashboardPage.updateSession(elem, session);
|
||||
} else {
|
||||
var nowPlayingItem = session.NowPlayingItem;
|
||||
var className = 'scalableCard card activeSession backdropCard backdropCard-scalable';
|
||||
const nowPlayingItem = session.NowPlayingItem;
|
||||
const className = 'scalableCard card activeSession backdropCard backdropCard-scalable';
|
||||
html += '<div class="' + className + '" id="' + rowId + '">';
|
||||
html += '<div class="cardBox visualCardBox">';
|
||||
html += '<div class="cardScalable visualCardBox-cardScalable">';
|
||||
html += '<div class="cardPadder cardPadder-backdrop"></div>';
|
||||
html += '<div class="cardContent">';
|
||||
var imgUrl = DashboardPage.getNowPlayingImageUrl(nowPlayingItem);
|
||||
const imgUrl = DashboardPage.getNowPlayingImageUrl(nowPlayingItem);
|
||||
|
||||
if (imgUrl) {
|
||||
html += '<div class="sessionNowPlayingContent sessionNowPlayingContent-withbackground"';
|
||||
|
@ -240,7 +260,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
|
||||
html += '<div class="sessionNowPlayingInnerContent">';
|
||||
html += '<div class="sessionAppInfo">';
|
||||
var clientImage = DashboardPage.getClientImage(session);
|
||||
const clientImage = DashboardPage.getClientImage(session);
|
||||
|
||||
if (clientImage) {
|
||||
html += clientImage;
|
||||
|
@ -253,7 +273,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
html += '</div>';
|
||||
|
||||
html += '<div class="sessionNowPlayingDetails">';
|
||||
var nowPlayingName = DashboardPage.getNowPlayingName(session);
|
||||
const nowPlayingName = DashboardPage.getNowPlayingName(session);
|
||||
html += '<div class="sessionNowPlayingInfo" data-imgsrc="' + nowPlayingName.image + '">';
|
||||
html += nowPlayingName.html;
|
||||
html += '</div>';
|
||||
|
@ -261,7 +281,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
html += '</div>';
|
||||
|
||||
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
|
||||
var percent = 100 * (session.PlayState.PositionTicks || 0) / nowPlayingItem.RunTimeTicks;
|
||||
const percent = 100 * (session.PlayState.PositionTicks || 0) / nowPlayingItem.RunTimeTicks;
|
||||
html += indicators.getProgressHtml(percent, {
|
||||
containerClass: 'playbackProgress'
|
||||
});
|
||||
|
@ -273,7 +293,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
|
||||
var percent = session.TranscodingInfo.CompletionPercentage.toFixed(1);
|
||||
const percent = session.TranscodingInfo.CompletionPercentage.toFixed(1);
|
||||
html += indicators.getProgressHtml(percent, {
|
||||
containerClass: 'transcodingProgress'
|
||||
});
|
||||
|
@ -290,7 +310,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
html += '<div class="sessionCardFooter cardFooter">';
|
||||
html += '<div class="sessionCardButtons flex align-items-center justify-content-center">';
|
||||
|
||||
var btnCssClass = session.ServerId && session.NowPlayingItem && session.SupportsRemoteControl ? '' : ' hide';
|
||||
let btnCssClass = session.ServerId && session.NowPlayingItem && session.SupportsRemoteControl ? '' : ' hide';
|
||||
const playIcon = session.PlayState.IsPaused ? 'pause' : 'play_arrow';
|
||||
|
||||
html += '<button is="paper-icon-button-light" class="sessionCardButton btnSessionPlayPause paper-icon-button-light ' + btnCssClass + '"><span class="material-icons ' + playIcon + '"></span></button>';
|
||||
|
@ -308,7 +328,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
html += '</div>';
|
||||
|
||||
html += '<div class="flex align-items-center justify-content-center">';
|
||||
var userImage = DashboardPage.getUserImage(session);
|
||||
const userImage = DashboardPage.getUserImage(session);
|
||||
html += userImage ? '<div class="activitylogUserPhoto" style="background-image:url(\'' + userImage + "');\"></div>" : '<div style="height:1.71em;"></div>';
|
||||
html += '<div class="sessionUserName">';
|
||||
html += DashboardPage.getUsersHtml(session);
|
||||
|
@ -322,7 +342,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
parentElement.insertAdjacentHTML('beforeend', html);
|
||||
var deadSessionElem = parentElement.querySelector('.deadSession');
|
||||
const deadSessionElem = parentElement.querySelector('.deadSession');
|
||||
|
||||
if (deadSessionElem) {
|
||||
deadSessionElem.parentNode.removeChild(deadSessionElem);
|
||||
|
@ -330,7 +350,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
function renderRunningTasks(view, tasks) {
|
||||
var html = '';
|
||||
let html = '';
|
||||
tasks = tasks.filter(function (task) {
|
||||
if ('Idle' != task.State) {
|
||||
return !task.IsHidden;
|
||||
|
@ -345,13 +365,13 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
view.querySelector('.runningTasksContainer').classList.add('hide');
|
||||
}
|
||||
|
||||
for (var i = 0, length = tasks.length; i < length; i++) {
|
||||
var task = tasks[i];
|
||||
for (let i = 0, length = tasks.length; i < length; i++) {
|
||||
const task = tasks[i];
|
||||
html += '<p>';
|
||||
html += task.Name + '<br/>';
|
||||
|
||||
if (task.State === 'Running') {
|
||||
var progress = (task.CurrentProgressPercentage || 0).toFixed(1);
|
||||
const progress = (task.CurrentProgressPercentage || 0).toFixed(1);
|
||||
html += '<progress max="100" value="' + progress + '" title="' + progress + '%">';
|
||||
html += progress + '%';
|
||||
html += '</progress>';
|
||||
|
@ -377,9 +397,9 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
apiClient.sendMessage('ScheduledTasksInfoStop');
|
||||
},
|
||||
getSessionNowPlayingStreamInfo: function (session) {
|
||||
var html = '';
|
||||
var showTranscodingInfo = false;
|
||||
var displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
|
||||
let html = '';
|
||||
let showTranscodingInfo = false;
|
||||
const displayPlayMethod = playMethodHelper.getDisplayPlayMethod(session);
|
||||
|
||||
if (displayPlayMethod === 'DirectStream') {
|
||||
html += globalize.translate('DirectStreaming');
|
||||
|
@ -396,7 +416,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
|
||||
if (showTranscodingInfo) {
|
||||
var line = [];
|
||||
const line = [];
|
||||
|
||||
if (session.TranscodingInfo) {
|
||||
if (session.TranscodingInfo.Bitrate) {
|
||||
|
@ -428,8 +448,8 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
return html;
|
||||
},
|
||||
getSessionNowPlayingTime: function (session) {
|
||||
var nowPlayingItem = session.NowPlayingItem;
|
||||
var html = '';
|
||||
const nowPlayingItem = session.NowPlayingItem;
|
||||
let html = '';
|
||||
|
||||
if (nowPlayingItem) {
|
||||
if (session.PlayState.PositionTicks) {
|
||||
|
@ -453,8 +473,8 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
return session.Client + ' ' + session.ApplicationVersion;
|
||||
},
|
||||
getNowPlayingName: function (session) {
|
||||
var imgUrl = '';
|
||||
var nowPlayingItem = session.NowPlayingItem;
|
||||
let imgUrl = '';
|
||||
const nowPlayingItem = session.NowPlayingItem;
|
||||
// FIXME: It seems that, sometimes, server sends date in the future, so date-fns displays messages like 'in less than a minute'. We should fix
|
||||
// how dates are returned by the server when the session is active and show something like 'Active now', instead of past/future sentences
|
||||
if (!nowPlayingItem) {
|
||||
|
@ -464,8 +484,8 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
};
|
||||
}
|
||||
|
||||
var topText = itemHelper.getDisplayName(nowPlayingItem);
|
||||
var bottomText = '';
|
||||
let topText = itemHelper.getDisplayName(nowPlayingItem);
|
||||
let bottomText = '';
|
||||
|
||||
if (nowPlayingItem.Artists && nowPlayingItem.Artists.length) {
|
||||
bottomText = topText;
|
||||
|
@ -505,13 +525,13 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
};
|
||||
},
|
||||
getUsersHtml: function (session) {
|
||||
var html = [];
|
||||
const html = [];
|
||||
|
||||
if (session.UserId) {
|
||||
html.push(session.UserName);
|
||||
}
|
||||
|
||||
for (var i = 0, length = session.AdditionalUsers.length; i < length; i++) {
|
||||
for (let i = 0, length = session.AdditionalUsers.length; i < length; i++) {
|
||||
html.push(session.AdditionalUsers[i].UserName);
|
||||
}
|
||||
|
||||
|
@ -529,7 +549,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
},
|
||||
updateSession: function (row, session) {
|
||||
row.classList.remove('deadSession');
|
||||
var nowPlayingItem = session.NowPlayingItem;
|
||||
const nowPlayingItem = session.NowPlayingItem;
|
||||
|
||||
if (nowPlayingItem) {
|
||||
row.classList.add('playingSession');
|
||||
|
@ -549,7 +569,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
row.querySelector('.btnSessionInfo').classList.add('hide');
|
||||
}
|
||||
|
||||
var btnSessionPlayPause = row.querySelector('.btnSessionPlayPause');
|
||||
const btnSessionPlayPause = row.querySelector('.btnSessionPlayPause');
|
||||
|
||||
if (session.ServerId && nowPlayingItem && session.SupportsRemoteControl && session.DeviceId !== connectionManager.deviceId()) {
|
||||
btnSessionPlayPause.classList.remove('hide');
|
||||
|
@ -567,18 +587,18 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
row.querySelector('.sessionNowPlayingTime').innerHTML = DashboardPage.getSessionNowPlayingTime(session);
|
||||
row.querySelector('.sessionUserName').innerHTML = DashboardPage.getUsersHtml(session);
|
||||
row.querySelector('.sessionAppSecondaryText').innerHTML = DashboardPage.getAppSecondaryText(session);
|
||||
var nowPlayingName = DashboardPage.getNowPlayingName(session);
|
||||
var nowPlayingInfoElem = row.querySelector('.sessionNowPlayingInfo');
|
||||
const nowPlayingName = DashboardPage.getNowPlayingName(session);
|
||||
const nowPlayingInfoElem = row.querySelector('.sessionNowPlayingInfo');
|
||||
|
||||
if (!(nowPlayingName.image && nowPlayingName.image == nowPlayingInfoElem.getAttribute('data-imgsrc'))) {
|
||||
nowPlayingInfoElem.innerHTML = nowPlayingName.html;
|
||||
nowPlayingInfoElem.setAttribute('data-imgsrc', nowPlayingName.image || '');
|
||||
}
|
||||
|
||||
var playbackProgressElem = row.querySelector('.playbackProgress');
|
||||
const playbackProgressElem = row.querySelector('.playbackProgress');
|
||||
|
||||
if (nowPlayingItem && nowPlayingItem.RunTimeTicks) {
|
||||
var percent = 100 * (session.PlayState.PositionTicks || 0) / nowPlayingItem.RunTimeTicks;
|
||||
const percent = 100 * (session.PlayState.PositionTicks || 0) / nowPlayingItem.RunTimeTicks;
|
||||
playbackProgressElem.outerHTML = indicators.getProgressHtml(percent, {
|
||||
containerClass: 'playbackProgress'
|
||||
});
|
||||
|
@ -588,10 +608,10 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
});
|
||||
}
|
||||
|
||||
var transcodingProgress = row.querySelector('.transcodingProgress');
|
||||
const transcodingProgress = row.querySelector('.transcodingProgress');
|
||||
|
||||
if (session.TranscodingInfo && session.TranscodingInfo.CompletionPercentage) {
|
||||
var percent = session.TranscodingInfo.CompletionPercentage.toFixed(1);
|
||||
const percent = session.TranscodingInfo.CompletionPercentage.toFixed(1);
|
||||
transcodingProgress.outerHTML = indicators.getProgressHtml(percent, {
|
||||
containerClass: 'transcodingProgress'
|
||||
});
|
||||
|
@ -601,8 +621,8 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
});
|
||||
}
|
||||
|
||||
var imgUrl = DashboardPage.getNowPlayingImageUrl(nowPlayingItem) || '';
|
||||
var imgElem = row.querySelector('.sessionNowPlayingContent');
|
||||
const imgUrl = DashboardPage.getNowPlayingImageUrl(nowPlayingItem) || '';
|
||||
const imgElem = row.querySelector('.sessionNowPlayingContent');
|
||||
|
||||
if (imgUrl != imgElem.getAttribute('data-src')) {
|
||||
imgElem.style.backgroundImage = imgUrl ? "url('" + imgUrl + "')" : '';
|
||||
|
@ -616,7 +636,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
},
|
||||
getClientImage: function (connection) {
|
||||
var iconUrl = imageHelper.getDeviceIcon(connection);
|
||||
const iconUrl = imageHelper.getDeviceIcon(connection);
|
||||
return "<img src='" + iconUrl + "' />";
|
||||
},
|
||||
getNowPlayingImageUrl: function (item) {
|
||||
|
@ -646,7 +666,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
});
|
||||
}
|
||||
|
||||
var imageTags = (item || {}).ImageTags || {};
|
||||
const imageTags = (item || {}).ImageTags || {};
|
||||
|
||||
if (item && imageTags.Thumb) {
|
||||
return ApiClient.getScaledImageUrl(item.Id, {
|
||||
|
@ -700,20 +720,20 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
},
|
||||
systemUpdateTaskKey: 'SystemUpdateTask',
|
||||
stopTask: function (btn, id) {
|
||||
var page = dom.parentWithClass(btn, 'page');
|
||||
const page = dom.parentWithClass(btn, 'page');
|
||||
ApiClient.stopScheduledTask(id).then(function () {
|
||||
pollForInfo(page, ApiClient);
|
||||
});
|
||||
},
|
||||
restart: function (btn) {
|
||||
require(['confirm'], function (confirm) {
|
||||
import('confirm').then(({default: confirm}) => {
|
||||
confirm({
|
||||
title: globalize.translate('HeaderRestart'),
|
||||
text: globalize.translate('MessageConfirmRestart'),
|
||||
confirmText: globalize.translate('ButtonRestart'),
|
||||
primary: 'delete'
|
||||
}).then(function () {
|
||||
var page = dom.parentWithClass(btn, 'page');
|
||||
const page = dom.parentWithClass(btn, 'page');
|
||||
page.querySelector('#btnRestartServer').disabled = true;
|
||||
page.querySelector('#btnShutdown').disabled = true;
|
||||
ApiClient.restartServer();
|
||||
|
@ -721,14 +741,14 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
});
|
||||
},
|
||||
shutdown: function (btn) {
|
||||
require(['confirm'], function (confirm) {
|
||||
import('confirm').then(({default: confirm}) => {
|
||||
confirm({
|
||||
title: globalize.translate('HeaderShutdown'),
|
||||
text: globalize.translate('MessageConfirmShutdown'),
|
||||
confirmText: globalize.translate('ButtonShutdown'),
|
||||
primary: 'delete'
|
||||
}).then(function () {
|
||||
var page = dom.parentWithClass(btn, 'page');
|
||||
const page = dom.parentWithClass(btn, 'page');
|
||||
page.querySelector('#btnRestartServer').disabled = true;
|
||||
page.querySelector('#btnShutdown').disabled = true;
|
||||
ApiClient.shutdownServer();
|
||||
|
@ -736,7 +756,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
});
|
||||
}
|
||||
};
|
||||
return function (view, params) {
|
||||
export default function (view, params) {
|
||||
function onRestartRequired(evt, apiClient) {
|
||||
console.debug('onRestartRequired not implemented', evt, apiClient);
|
||||
}
|
||||
|
@ -775,11 +795,11 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
}
|
||||
|
||||
var serverId = ApiClient.serverId();
|
||||
const serverId = ApiClient.serverId();
|
||||
view.querySelector('.activeDevices').addEventListener('click', onActiveDevicesClick);
|
||||
view.addEventListener('viewshow', function () {
|
||||
var page = this;
|
||||
var apiClient = ApiClient;
|
||||
const page = this;
|
||||
const apiClient = ApiClient;
|
||||
|
||||
if (apiClient) {
|
||||
loading.show();
|
||||
|
@ -816,7 +836,7 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
});
|
||||
view.addEventListener('viewbeforehide', function () {
|
||||
var apiClient = ApiClient;
|
||||
const apiClient = ApiClient;
|
||||
events.off(serverNotifications, 'RestartRequired', onRestartRequired);
|
||||
events.off(serverNotifications, 'ServerShuttingDown', onServerShuttingDown);
|
||||
events.off(serverNotifications, 'ServerRestarting', onServerRestarting);
|
||||
|
@ -830,18 +850,19 @@ define(['datetime', 'events', 'itemHelper', 'serverNotifications', 'dom', 'globa
|
|||
}
|
||||
});
|
||||
view.addEventListener('viewdestroy', function () {
|
||||
var page = this;
|
||||
var userActivityLog = page.userActivityLog;
|
||||
const page = this;
|
||||
const userActivityLog = page.userActivityLog;
|
||||
|
||||
if (userActivityLog) {
|
||||
userActivityLog.destroy();
|
||||
}
|
||||
|
||||
var serverActivityLog = page.serverActivityLog;
|
||||
const serverActivityLog = page.serverActivityLog;
|
||||
|
||||
if (serverActivityLog) {
|
||||
serverActivityLog.destroy();
|
||||
}
|
||||
});
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, loading, globalize, dom, libraryMenu) {
|
||||
'use strict';
|
||||
import $ from 'jQuery';
|
||||
import loading from 'loading';
|
||||
import globalize from 'globalize';
|
||||
import dom from 'dom';
|
||||
import libraryMenu from 'libraryMenu';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
function loadPage(page, config, systemInfo) {
|
||||
Array.prototype.forEach.call(page.querySelectorAll('.chkDecodeCodec'), function (c) {
|
||||
|
@ -27,10 +32,10 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
|
||||
function onSaveEncodingPathFailure(response) {
|
||||
loading.hide();
|
||||
var msg = '';
|
||||
let msg = '';
|
||||
msg = globalize.translate('FFmpegSavePathNotFound');
|
||||
|
||||
require(['alert'], function (alert) {
|
||||
import('alert').then(({default: alert}) => {
|
||||
alert(msg);
|
||||
});
|
||||
}
|
||||
|
@ -49,9 +54,9 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
}
|
||||
|
||||
function onSubmit() {
|
||||
var form = this;
|
||||
const form = this;
|
||||
|
||||
var onDecoderConfirmed = function () {
|
||||
const onDecoderConfirmed = function () {
|
||||
loading.show();
|
||||
ApiClient.getNamedConfiguration('encoding').then(function (config) {
|
||||
config.DownMixAudioBoost = $('#txtDownMixAudioBoost', form).val();
|
||||
|
@ -75,7 +80,7 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
ApiClient.updateNamedConfiguration('encoding', config).then(function () {
|
||||
updateEncoder(form);
|
||||
}, function () {
|
||||
require(['alert'], function (alert) {
|
||||
import('alert').then(({default: alert}) => {
|
||||
alert(globalize.translate('DefaultErrorMessage'));
|
||||
});
|
||||
|
||||
|
@ -85,8 +90,8 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
};
|
||||
|
||||
if ($('#selectVideoDecoder', form).val()) {
|
||||
require(['alert'], function (alert) {
|
||||
alert.default({
|
||||
import('alert').then(({default: alert}) => {
|
||||
alert({
|
||||
title: globalize.translate('TitleHardwareAcceleration'),
|
||||
text: globalize.translate('HardwareAccelerationWarning')
|
||||
}).then(onDecoderConfirmed);
|
||||
|
@ -100,7 +105,7 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
|
||||
function setDecodingCodecsVisible(context, value) {
|
||||
value = value || '';
|
||||
var any;
|
||||
let any;
|
||||
Array.prototype.forEach.call(context.querySelectorAll('.chkDecodeCodec'), function (c) {
|
||||
if (-1 === c.getAttribute('data-types').split(',').indexOf(value)) {
|
||||
dom.parentWithTag(c, 'LABEL').classList.add('hide');
|
||||
|
@ -131,7 +136,7 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
}
|
||||
|
||||
$(document).on('pageinit', '#encodingSettingsPage', function () {
|
||||
var page = this;
|
||||
const page = this;
|
||||
page.querySelector('#selectVideoDecoder').addEventListener('change', function () {
|
||||
if ('vaapi' == this.value) {
|
||||
page.querySelector('.fldVaapiDevice').classList.remove('hide');
|
||||
|
@ -150,8 +155,8 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
setDecodingCodecsVisible(page, this.value);
|
||||
});
|
||||
$('#btnSelectEncoderPath', page).on('click.selectDirectory', function () {
|
||||
require(['directorybrowser'], function (directoryBrowser) {
|
||||
var picker = new directoryBrowser.default();
|
||||
import('directorybrowser').then(({default: directoryBrowser}) => {
|
||||
const picker = new directoryBrowser();
|
||||
picker.show({
|
||||
includeFiles: true,
|
||||
callback: function (path) {
|
||||
|
@ -165,8 +170,8 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
});
|
||||
});
|
||||
$('#btnSelectTranscodingTempPath', page).on('click.selectDirectory', function () {
|
||||
require(['directorybrowser'], function (directoryBrowser) {
|
||||
var picker = new directoryBrowser.default();
|
||||
import('directorybrowser').then(({default: directoryBrowser}) => {
|
||||
const picker = new directoryBrowser();
|
||||
picker.show({
|
||||
callback: function (path) {
|
||||
if (path) {
|
||||
|
@ -185,11 +190,12 @@ define(['jQuery', 'loading', 'globalize', 'dom', 'libraryMenu'], function ($, lo
|
|||
}).on('pageshow', '#encodingSettingsPage', function () {
|
||||
loading.show();
|
||||
libraryMenu.setTabs('playback', 0, getTabs);
|
||||
var page = this;
|
||||
const page = this;
|
||||
ApiClient.getNamedConfiguration('encoding').then(function (config) {
|
||||
ApiClient.getSystemInfo().then(function (systemInfo) {
|
||||
loadPage(page, config, systemInfo);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/* eslint-enable indent */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue