2020-08-14 08:46:34 +02:00
|
|
|
import 'jquery';
|
|
|
|
import loading from '../../components/loading/loading';
|
|
|
|
import globalize from '../../scripts/globalize';
|
|
|
|
import '../../elements/emby-checkbox/emby-checkbox';
|
|
|
|
import '../../elements/emby-textarea/emby-textarea';
|
|
|
|
import '../../elements/emby-input/emby-input';
|
|
|
|
import '../../elements/emby-select/emby-select';
|
|
|
|
import '../../elements/emby-button/emby-button';
|
2020-10-12 22:17:25 +01:00
|
|
|
import AppInfo from '../../components/AppInfo';
|
2020-10-12 23:08:55 +01:00
|
|
|
import Dashboard from '../../scripts/clientUtils';
|
2020-07-09 08:54:47 +01:00
|
|
|
|
|
|
|
/* eslint-disable indent */
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function loadPage(page, config, languageOptions, systemInfo) {
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#txtServerName').value = systemInfo.ServerName;
|
|
|
|
page.querySelector('#txtCachePath').value = systemInfo.CachePath || '';
|
|
|
|
$('#txtMetadataPath', page).val(systemInfo.InternalMetadataPath || '');
|
|
|
|
$('#txtMetadataNetworkPath', page).val(systemInfo.MetadataNetworkPath || '');
|
|
|
|
$('#selectLocalizationLanguage', page).html(languageOptions.map(function (language) {
|
|
|
|
return '<option value="' + language.Value + '">' + language.Name + '</option>';
|
2019-03-05 21:30:06 +09:00
|
|
|
})).val(config.UICulture);
|
|
|
|
currentLanguage = config.UICulture;
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2019-03-05 21:30:06 +09:00
|
|
|
loading.hide();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSubmit() {
|
|
|
|
loading.show();
|
2020-07-16 11:25:17 +01:00
|
|
|
const form = this;
|
2020-05-04 12:44:12 +02:00
|
|
|
$(form).parents('.page');
|
2020-01-22 03:30:33 +03:00
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
2020-05-04 12:44:12 +02:00
|
|
|
config.ServerName = $('#txtServerName', form).val();
|
|
|
|
config.UICulture = $('#selectLocalizationLanguage', form).val();
|
|
|
|
config.CachePath = form.querySelector('#txtCachePath').value;
|
|
|
|
config.MetadataPath = $('#txtMetadataPath', form).val();
|
|
|
|
config.MetadataNetworkPath = $('#txtMetadataNetworkPath', form).val();
|
2020-07-16 11:25:17 +01:00
|
|
|
let requiresReload = config.UICulture !== currentLanguage;
|
2019-03-05 21:12:13 +09:00
|
|
|
ApiClient.updateServerConfiguration(config).then(function() {
|
2018-10-23 01:05:09 +03:00
|
|
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(brandingConfig) {
|
2020-05-04 12:44:12 +02:00
|
|
|
brandingConfig.LoginDisclaimer = form.querySelector('#txtLoginDisclaimer').value;
|
|
|
|
brandingConfig.CustomCss = form.querySelector('#txtCustomCss').value;
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2019-03-07 22:00:13 +00:00
|
|
|
if (currentBrandingOptions && brandingConfig.CustomCss !== currentBrandingOptions.CustomCss) {
|
|
|
|
requiresReload = true;
|
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
|
|
|
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(function () {
|
2019-03-05 21:12:13 +09:00
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2019-03-05 21:12:13 +09:00
|
|
|
if (requiresReload && !AppInfo.isNativeApp) {
|
|
|
|
window.location.reload(true);
|
|
|
|
}
|
|
|
|
});
|
2020-01-22 03:30:33 +03:00
|
|
|
});
|
2020-02-24 22:25:08 +09:00
|
|
|
}, function () {
|
2020-08-14 08:46:34 +02:00
|
|
|
import('../../components/alert').then(({default: alert}) => {
|
2020-08-02 01:23:57 +09:00
|
|
|
alert(globalize.translate('ErrorDefault'));
|
2020-02-24 22:25:08 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
2020-01-22 03:30:33 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
return false;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-03-05 21:30:06 +09:00
|
|
|
|
2020-07-16 11:25:17 +01:00
|
|
|
let currentBrandingOptions;
|
|
|
|
let currentLanguage;
|
|
|
|
const brandingConfigKey = 'branding';
|
2020-07-09 08:54:47 +01:00
|
|
|
export default function (view, params) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#btnSelectCachePath', view).on('click.selectDirectory', function () {
|
2020-08-14 08:46:34 +02:00
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
|
2020-07-16 11:25:17 +01:00
|
|
|
const picker = new directoryBrowser();
|
2018-10-23 01:05:09 +03:00
|
|
|
picker.show({
|
2020-01-22 03:30:33 +03:00
|
|
|
callback: function (path) {
|
2019-03-07 22:00:13 +00:00
|
|
|
if (path) {
|
2020-05-04 12:44:12 +02:00
|
|
|
view.querySelector('#txtCachePath').value = path;
|
2019-03-07 22:00:13 +00:00
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2019-03-05 21:30:06 +09:00
|
|
|
picker.close();
|
2018-10-23 01:05:09 +03:00
|
|
|
},
|
2019-03-05 21:30:06 +09:00
|
|
|
validateWriteable: true,
|
2020-05-04 12:44:12 +02:00
|
|
|
header: globalize.translate('HeaderSelectServerCachePath'),
|
|
|
|
instruction: globalize.translate('HeaderSelectServerCachePathHelp')
|
2020-01-22 03:30:33 +03:00
|
|
|
});
|
|
|
|
});
|
2019-03-05 21:12:13 +09:00
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#btnSelectMetadataPath', view).on('click.selectDirectory', function () {
|
2020-08-14 08:46:34 +02:00
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({default: directoryBrowser}) => {
|
2020-07-16 11:25:17 +01:00
|
|
|
const picker = new directoryBrowser();
|
2019-03-05 21:12:13 +09:00
|
|
|
picker.show({
|
2020-05-04 12:44:12 +02:00
|
|
|
path: $('#txtMetadataPath', view).val(),
|
|
|
|
networkSharePath: $('#txtMetadataNetworkPath', view).val(),
|
2020-01-22 03:30:33 +03:00
|
|
|
callback: function (path, networkPath) {
|
2019-03-07 22:00:13 +00:00
|
|
|
if (path) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtMetadataPath', view).val(path);
|
2019-03-07 22:00:13 +00:00
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2019-03-10 07:06:28 +09:00
|
|
|
if (networkPath) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#txtMetadataNetworkPath', view).val(networkPath);
|
2019-03-07 22:00:13 +00:00
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2019-03-06 18:53:31 +09:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
validateWriteable: true,
|
2020-05-04 12:44:12 +02:00
|
|
|
header: globalize.translate('HeaderSelectMetadataPath'),
|
|
|
|
instruction: globalize.translate('HeaderSelectMetadataPathHelp'),
|
2019-03-10 07:06:28 +09:00
|
|
|
enableNetworkSharePath: true
|
2020-01-22 03:30:33 +03:00
|
|
|
});
|
|
|
|
});
|
2019-03-05 21:12:13 +09:00
|
|
|
});
|
2020-05-04 12:44:12 +02:00
|
|
|
$('.dashboardGeneralForm', view).off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
view.addEventListener('viewshow', function () {
|
2020-07-16 11:25:17 +01:00
|
|
|
const promiseConfig = ApiClient.getServerConfiguration();
|
|
|
|
const promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl('Localization/Options'));
|
|
|
|
const promiseSystemInfo = ApiClient.getSystemInfo();
|
2020-01-22 03:30:33 +03:00
|
|
|
Promise.all([promiseConfig, promiseLanguageOptions, promiseSystemInfo]).then(function (responses) {
|
2019-03-05 21:30:06 +09:00
|
|
|
loadPage(view, responses[0], responses[1], responses[2]);
|
|
|
|
});
|
2020-01-22 03:30:33 +03:00
|
|
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function (config) {
|
2019-03-05 21:30:06 +09:00
|
|
|
currentBrandingOptions = config;
|
2020-05-04 12:44:12 +02:00
|
|
|
view.querySelector('#txtLoginDisclaimer').value = config.LoginDisclaimer || '';
|
|
|
|
view.querySelector('#txtCustomCss').value = config.CustomCss || '';
|
2019-03-05 21:30:06 +09:00
|
|
|
});
|
|
|
|
});
|
2020-07-16 11:25:17 +01:00
|
|
|
}
|
2020-07-09 08:54:47 +01:00
|
|
|
|
|
|
|
/* eslint-enable indent */
|