mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge pull request #1572 from Camc314/migrate-to-ES6-11
Migration of dashboard/ to ES6 modules
This commit is contained in:
commit
1aee51e94c
6 changed files with 90 additions and 52 deletions
|
@ -152,6 +152,12 @@
|
||||||
"src/controllers/dashboard/encodingsettings.js",
|
"src/controllers/dashboard/encodingsettings.js",
|
||||||
"src/controllers/dashboard/logs.js",
|
"src/controllers/dashboard/logs.js",
|
||||||
"src/controllers/user/subtitles.js",
|
"src/controllers/user/subtitles.js",
|
||||||
|
"src/controllers/dashboard/general.js",
|
||||||
|
"src/controllers/dashboard/librarydisplay.js",
|
||||||
|
"src/controllers/dashboard/metadataImages.js",
|
||||||
|
"src/controllers/dashboard/metadatanfo.js",
|
||||||
|
"src/controllers/dashboard/plugins/repositories.js",
|
||||||
|
"src/controllers/dashboard/streaming.js",
|
||||||
"src/controllers/dashboard/mediaLibrary.js",
|
"src/controllers/dashboard/mediaLibrary.js",
|
||||||
"src/controllers/dashboard/networking.js",
|
"src/controllers/dashboard/networking.js",
|
||||||
"src/controllers/dashboard/playback.js",
|
"src/controllers/dashboard/playback.js",
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emby-input', 'emby-select', 'emby-button'], function ($, loading, globalize) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-textarea';
|
||||||
|
import 'emby-input';
|
||||||
|
import 'emby-select';
|
||||||
|
import 'emby-button';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function loadPage(page, config, languageOptions, systemInfo) {
|
function loadPage(page, config, languageOptions, systemInfo) {
|
||||||
page.querySelector('#txtServerName').value = systemInfo.ServerName;
|
page.querySelector('#txtServerName').value = systemInfo.ServerName;
|
||||||
|
@ -16,7 +24,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb
|
||||||
|
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
loading.show();
|
loading.show();
|
||||||
var form = this;
|
const form = this;
|
||||||
$(form).parents('.page');
|
$(form).parents('.page');
|
||||||
ApiClient.getServerConfiguration().then(function (config) {
|
ApiClient.getServerConfiguration().then(function (config) {
|
||||||
config.ServerName = $('#txtServerName', form).val();
|
config.ServerName = $('#txtServerName', form).val();
|
||||||
|
@ -24,7 +32,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb
|
||||||
config.CachePath = form.querySelector('#txtCachePath').value;
|
config.CachePath = form.querySelector('#txtCachePath').value;
|
||||||
config.MetadataPath = $('#txtMetadataPath', form).val();
|
config.MetadataPath = $('#txtMetadataPath', form).val();
|
||||||
config.MetadataNetworkPath = $('#txtMetadataNetworkPath', form).val();
|
config.MetadataNetworkPath = $('#txtMetadataNetworkPath', form).val();
|
||||||
var requiresReload = config.UICulture !== currentLanguage;
|
let requiresReload = config.UICulture !== currentLanguage;
|
||||||
ApiClient.updateServerConfiguration(config).then(function() {
|
ApiClient.updateServerConfiguration(config).then(function() {
|
||||||
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(brandingConfig) {
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(brandingConfig) {
|
||||||
brandingConfig.LoginDisclaimer = form.querySelector('#txtLoginDisclaimer').value;
|
brandingConfig.LoginDisclaimer = form.querySelector('#txtLoginDisclaimer').value;
|
||||||
|
@ -43,7 +51,7 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, function () {
|
}, function () {
|
||||||
require(['alert'], function (alert) {
|
import('alert').then(({default: alert}) => {
|
||||||
alert(globalize.translate('DefaultErrorMessage'));
|
alert(globalize.translate('DefaultErrorMessage'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -53,13 +61,13 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentBrandingOptions;
|
let currentBrandingOptions;
|
||||||
var currentLanguage;
|
let currentLanguage;
|
||||||
var brandingConfigKey = 'branding';
|
const brandingConfigKey = 'branding';
|
||||||
return function (view, params) {
|
export default function (view, params) {
|
||||||
$('#btnSelectCachePath', view).on('click.selectDirectory', function () {
|
$('#btnSelectCachePath', view).on('click.selectDirectory', function () {
|
||||||
require(['directorybrowser'], function (directoryBrowser) {
|
import('directorybrowser').then(({default: directoryBrowser}) => {
|
||||||
var picker = new directoryBrowser.default();
|
const picker = new directoryBrowser();
|
||||||
picker.show({
|
picker.show({
|
||||||
callback: function (path) {
|
callback: function (path) {
|
||||||
if (path) {
|
if (path) {
|
||||||
|
@ -75,8 +83,8 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('#btnSelectMetadataPath', view).on('click.selectDirectory', function () {
|
$('#btnSelectMetadataPath', view).on('click.selectDirectory', function () {
|
||||||
require(['directorybrowser'], function (directoryBrowser) {
|
import('directorybrowser').then(({default: directoryBrowser}) => {
|
||||||
var picker = new directoryBrowser.default();
|
const picker = new directoryBrowser();
|
||||||
picker.show({
|
picker.show({
|
||||||
path: $('#txtMetadataPath', view).val(),
|
path: $('#txtMetadataPath', view).val(),
|
||||||
networkSharePath: $('#txtMetadataNetworkPath', view).val(),
|
networkSharePath: $('#txtMetadataNetworkPath', view).val(),
|
||||||
|
@ -100,9 +108,9 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb
|
||||||
});
|
});
|
||||||
$('.dashboardGeneralForm', view).off('submit', onSubmit).on('submit', onSubmit);
|
$('.dashboardGeneralForm', view).off('submit', onSubmit).on('submit', onSubmit);
|
||||||
view.addEventListener('viewshow', function () {
|
view.addEventListener('viewshow', function () {
|
||||||
var promiseConfig = ApiClient.getServerConfiguration();
|
const promiseConfig = ApiClient.getServerConfiguration();
|
||||||
var promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl('Localization/Options'));
|
const promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl('Localization/Options'));
|
||||||
var promiseSystemInfo = ApiClient.getSystemInfo();
|
const promiseSystemInfo = ApiClient.getSystemInfo();
|
||||||
Promise.all([promiseConfig, promiseLanguageOptions, promiseSystemInfo]).then(function (responses) {
|
Promise.all([promiseConfig, promiseLanguageOptions, promiseSystemInfo]).then(function (responses) {
|
||||||
loadPage(view, responses[0], responses[1], responses[2]);
|
loadPage(view, responses[0], responses[1], responses[2]);
|
||||||
});
|
});
|
||||||
|
@ -112,5 +120,6 @@ define(['jQuery', 'loading', 'globalize', 'emby-checkbox', 'emby-textarea', 'emb
|
||||||
view.querySelector('#txtCustomCss').value = config.CustomCss || '';
|
view.querySelector('#txtCustomCss').value = config.CustomCss || '';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
define(['globalize', 'loading', 'libraryMenu', 'emby-checkbox', 'emby-button', 'emby-button'], function(globalize, loading, libraryMenu) {
|
import globalize from 'globalize';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import 'emby-checkbox';
|
||||||
|
import 'emby-button';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function getTabs() {
|
function getTabs() {
|
||||||
return [{
|
return [{
|
||||||
|
@ -17,7 +22,7 @@ define(['globalize', 'loading', 'libraryMenu', 'emby-checkbox', 'emby-button', '
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
return function(view, params) {
|
export default function(view, params) {
|
||||||
function loadData() {
|
function loadData() {
|
||||||
ApiClient.getServerConfiguration().then(function(config) {
|
ApiClient.getServerConfiguration().then(function(config) {
|
||||||
view.querySelector('.chkFolderView').checked = config.EnableFolderView;
|
view.querySelector('.chkFolderView').checked = config.EnableFolderView;
|
||||||
|
@ -33,7 +38,7 @@ define(['globalize', 'loading', 'libraryMenu', 'emby-checkbox', 'emby-button', '
|
||||||
|
|
||||||
view.querySelector('form').addEventListener('submit', function(e) {
|
view.querySelector('form').addEventListener('submit', function(e) {
|
||||||
loading.show();
|
loading.show();
|
||||||
var form = this;
|
const form = this;
|
||||||
ApiClient.getServerConfiguration().then(function(config) {
|
ApiClient.getServerConfiguration().then(function(config) {
|
||||||
config.EnableFolderView = form.querySelector('.chkFolderView').checked;
|
config.EnableFolderView = form.querySelector('.chkFolderView').checked;
|
||||||
config.EnableGroupingIntoCollections = form.querySelector('.chkGroupMoviesIntoCollections').checked;
|
config.EnableGroupingIntoCollections = form.querySelector('.chkGroupMoviesIntoCollections').checked;
|
||||||
|
@ -63,5 +68,6 @@ define(['globalize', 'loading', 'libraryMenu', 'emby-checkbox', 'emby-button', '
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
define(['jQuery', 'dom', 'loading', 'libraryMenu', 'globalize', 'listViewStyle'], function($, dom, loading, libraryMenu, globalize) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import dom from 'dom';
|
||||||
|
import loading from 'loading';
|
||||||
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
import 'listViewStyle';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function populateLanguages(select) {
|
function populateLanguages(select) {
|
||||||
return ApiClient.getCultures().then(function(languages) {
|
return ApiClient.getCultures().then(function(languages) {
|
||||||
var html = '';
|
let html = '';
|
||||||
html += "<option value=''></option>";
|
html += "<option value=''></option>";
|
||||||
for (var i = 0, length = languages.length; i < length; i++) {
|
for (let i = 0, length = languages.length; i < length; i++) {
|
||||||
var culture = languages[i];
|
const culture = languages[i];
|
||||||
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
|
html += "<option value='" + culture.TwoLetterISOLanguageName + "'>" + culture.DisplayName + '</option>';
|
||||||
}
|
}
|
||||||
select.innerHTML = html;
|
select.innerHTML = html;
|
||||||
|
@ -15,10 +21,10 @@ define(['jQuery', 'dom', 'loading', 'libraryMenu', 'globalize', 'listViewStyle']
|
||||||
|
|
||||||
function populateCountries(select) {
|
function populateCountries(select) {
|
||||||
return ApiClient.getCountries().then(function(allCountries) {
|
return ApiClient.getCountries().then(function(allCountries) {
|
||||||
var html = '';
|
let html = '';
|
||||||
html += "<option value=''></option>";
|
html += "<option value=''></option>";
|
||||||
for (var i = 0, length = allCountries.length; i < length; i++) {
|
for (let i = 0, length = allCountries.length; i < length; i++) {
|
||||||
var culture = allCountries[i];
|
const culture = allCountries[i];
|
||||||
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
|
html += "<option value='" + culture.TwoLetterISORegionName + "'>" + culture.DisplayName + '</option>';
|
||||||
}
|
}
|
||||||
select.innerHTML = html;
|
select.innerHTML = html;
|
||||||
|
@ -26,9 +32,9 @@ define(['jQuery', 'dom', 'loading', 'libraryMenu', 'globalize', 'listViewStyle']
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPage(page) {
|
function loadPage(page) {
|
||||||
var promises = [ApiClient.getServerConfiguration(), populateLanguages(page.querySelector('#selectLanguage')), populateCountries(page.querySelector('#selectCountry'))];
|
const promises = [ApiClient.getServerConfiguration(), populateLanguages(page.querySelector('#selectLanguage')), populateCountries(page.querySelector('#selectCountry'))];
|
||||||
Promise.all(promises).then(function(responses) {
|
Promise.all(promises).then(function(responses) {
|
||||||
var config = responses[0];
|
const config = responses[0];
|
||||||
page.querySelector('#selectLanguage').value = config.PreferredMetadataLanguage || '';
|
page.querySelector('#selectLanguage').value = config.PreferredMetadataLanguage || '';
|
||||||
page.querySelector('#selectCountry').value = config.MetadataCountryCode || '';
|
page.querySelector('#selectCountry').value = config.MetadataCountryCode || '';
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
@ -36,7 +42,7 @@ define(['jQuery', 'dom', 'loading', 'libraryMenu', 'globalize', 'listViewStyle']
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
var form = this;
|
const form = this;
|
||||||
return loading.show(), ApiClient.getServerConfiguration().then(function(config) {
|
return loading.show(), ApiClient.getServerConfiguration().then(function(config) {
|
||||||
config.PreferredMetadataLanguage = form.querySelector('#selectLanguage').value;
|
config.PreferredMetadataLanguage = form.querySelector('#selectLanguage').value;
|
||||||
config.MetadataCountryCode = form.querySelector('#selectCountry').value;
|
config.MetadataCountryCode = form.querySelector('#selectCountry').value;
|
||||||
|
@ -67,4 +73,5 @@ define(['jQuery', 'dom', 'loading', 'libraryMenu', 'globalize', 'listViewStyle']
|
||||||
loading.show();
|
loading.show();
|
||||||
loadPage(this);
|
loadPage(this);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading, libraryMenu, globalize) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import loading from 'loading';
|
||||||
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function loadPage(page, config, users) {
|
function loadPage(page, config, users) {
|
||||||
var html = '<option value="" selected="selected">' + globalize.translate('OptionNone') + '</option>';
|
let html = '<option value="" selected="selected">' + globalize.translate('OptionNone') + '</option>';
|
||||||
html += users.map(function (user) {
|
html += users.map(function (user) {
|
||||||
return '<option value="' + user.Id + '">' + user.Name + '</option>';
|
return '<option value="' + user.Id + '">' + user.Name + '</option>';
|
||||||
}).join('');
|
}).join('');
|
||||||
|
@ -16,7 +20,7 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading,
|
||||||
|
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
loading.show();
|
loading.show();
|
||||||
var form = this;
|
const form = this;
|
||||||
ApiClient.getNamedConfiguration(metadataKey).then(function (config) {
|
ApiClient.getNamedConfiguration(metadataKey).then(function (config) {
|
||||||
config.UserId = $('#selectUser', form).val() || null;
|
config.UserId = $('#selectUser', form).val() || null;
|
||||||
config.ReleaseDateFormat = $('#selectReleaseDateFormat', form).val();
|
config.ReleaseDateFormat = $('#selectReleaseDateFormat', form).val();
|
||||||
|
@ -32,10 +36,10 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading,
|
||||||
}
|
}
|
||||||
|
|
||||||
function showConfirmMessage(config) {
|
function showConfirmMessage(config) {
|
||||||
var msg = [];
|
const msg = [];
|
||||||
msg.push(globalize.translate('MetadataSettingChangeHelp'));
|
msg.push(globalize.translate('MetadataSettingChangeHelp'));
|
||||||
|
|
||||||
require(['alert'], function (alert) {
|
import('alert').then(({default: alert}) => {
|
||||||
alert({
|
alert({
|
||||||
text: msg.join('<br/><br/>')
|
text: msg.join('<br/><br/>')
|
||||||
});
|
});
|
||||||
|
@ -58,17 +62,18 @@ define(['jQuery', 'loading', 'libraryMenu', 'globalize'], function ($, loading,
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|
||||||
var metadataKey = 'xbmcmetadata';
|
const metadataKey = 'xbmcmetadata';
|
||||||
$(document).on('pageinit', '#metadataNfoPage', function () {
|
$(document).on('pageinit', '#metadataNfoPage', function () {
|
||||||
$('.metadataNfoForm').off('submit', onSubmit).on('submit', onSubmit);
|
$('.metadataNfoForm').off('submit', onSubmit).on('submit', onSubmit);
|
||||||
}).on('pageshow', '#metadataNfoPage', function () {
|
}).on('pageshow', '#metadataNfoPage', function () {
|
||||||
libraryMenu.setTabs('metadata', 3, getTabs);
|
libraryMenu.setTabs('metadata', 3, getTabs);
|
||||||
loading.show();
|
loading.show();
|
||||||
var page = this;
|
const page = this;
|
||||||
var promise1 = ApiClient.getUsers();
|
const promise1 = ApiClient.getUsers();
|
||||||
var promise2 = ApiClient.getNamedConfiguration(metadataKey);
|
const promise2 = ApiClient.getNamedConfiguration(metadataKey);
|
||||||
Promise.all([promise1, promise2]).then(function (responses) {
|
Promise.all([promise1, promise2]).then(function (responses) {
|
||||||
loadPage(page, responses[1], responses[0]);
|
loadPage(page, responses[1], responses[0]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
define(['jQuery', 'libraryMenu', 'loading', 'globalize'], function ($, libraryMenu, loading, globalize) {
|
import $ from 'jQuery';
|
||||||
'use strict';
|
import libraryMenu from 'libraryMenu';
|
||||||
|
import loading from 'loading';
|
||||||
|
import globalize from 'globalize';
|
||||||
|
|
||||||
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function loadPage(page, config) {
|
function loadPage(page, config) {
|
||||||
$('#txtRemoteClientBitrateLimit', page).val(config.RemoteClientBitrateLimit / 1e6 || '');
|
$('#txtRemoteClientBitrateLimit', page).val(config.RemoteClientBitrateLimit / 1e6 || '');
|
||||||
|
@ -8,7 +12,7 @@ define(['jQuery', 'libraryMenu', 'loading', 'globalize'], function ($, libraryMe
|
||||||
|
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
loading.show();
|
loading.show();
|
||||||
var form = this;
|
const form = this;
|
||||||
ApiClient.getServerConfiguration().then(function (config) {
|
ApiClient.getServerConfiguration().then(function (config) {
|
||||||
config.RemoteClientBitrateLimit = parseInt(1e6 * parseFloat($('#txtRemoteClientBitrateLimit', form).val() || '0'));
|
config.RemoteClientBitrateLimit = parseInt(1e6 * parseFloat($('#txtRemoteClientBitrateLimit', form).val() || '0'));
|
||||||
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
|
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult);
|
||||||
|
@ -35,9 +39,10 @@ define(['jQuery', 'libraryMenu', 'loading', 'globalize'], function ($, libraryMe
|
||||||
}).on('pageshow', '#streamingSettingsPage', function () {
|
}).on('pageshow', '#streamingSettingsPage', function () {
|
||||||
loading.show();
|
loading.show();
|
||||||
libraryMenu.setTabs('playback', 2, getTabs);
|
libraryMenu.setTabs('playback', 2, getTabs);
|
||||||
var page = this;
|
const page = this;
|
||||||
ApiClient.getServerConfiguration().then(function (config) {
|
ApiClient.getServerConfiguration().then(function (config) {
|
||||||
loadPage(page, config);
|
loadPage(page, config);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
/* eslint-enable indent */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue