2020-08-14 08:46:34 +02:00
|
|
|
import 'jquery';
|
2023-02-07 16:17:36 -05:00
|
|
|
|
2020-08-14 08:46:34 +02:00
|
|
|
import loading from '../../components/loading/loading';
|
2024-08-14 13:31:34 -04:00
|
|
|
import globalize from '../../lib/globalize';
|
2020-08-14 08:46:34 +02:00
|
|
|
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';
|
2022-04-10 02:22:13 -04:00
|
|
|
import Dashboard from '../../utils/dashboard';
|
2020-10-18 15:18:15 +01:00
|
|
|
import alert from '../../components/alert';
|
2020-07-09 08:54:47 +01:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function loadPage(page, config, languageOptions, systemInfo) {
|
|
|
|
page.querySelector('#txtServerName').value = systemInfo.ServerName;
|
|
|
|
page.querySelector('#txtCachePath').value = systemInfo.CachePath || '';
|
|
|
|
page.querySelector('#chkQuickConnectAvailable').checked = config.QuickConnectAvailable === true;
|
|
|
|
$('#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>';
|
|
|
|
})).val(config.UICulture);
|
2024-05-10 11:44:16 -04:00
|
|
|
page.querySelector('#txtLibraryScanFanoutConcurrency').value = config.LibraryScanFanoutConcurrency || '';
|
2023-04-19 01:56:05 -04:00
|
|
|
page.querySelector('#txtParallelImageEncodingLimit').value = config.ParallelImageEncodingLimit || '';
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
loading.hide();
|
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
function onSubmit() {
|
|
|
|
loading.show();
|
|
|
|
const form = this;
|
|
|
|
$(form).parents('.page');
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
|
|
|
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();
|
|
|
|
config.QuickConnectAvailable = form.querySelector('#chkQuickConnectAvailable').checked;
|
2024-05-10 11:44:16 -04:00
|
|
|
config.LibraryScanFanoutConcurrency = parseInt(form.querySelector('#txtLibraryScanFanoutConcurrency').value || '0', 10);
|
2023-04-19 01:56:05 -04:00
|
|
|
config.ParallelImageEncodingLimit = parseInt(form.querySelector('#txtParallelImageEncodingLimit').value || '0', 10);
|
2018-10-23 01:05:09 +03:00
|
|
|
|
2024-11-20 18:06:44 -05:00
|
|
|
return ApiClient.updateServerConfiguration(config)
|
|
|
|
.then(() => {
|
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
|
|
|
}).catch(() => {
|
|
|
|
loading.hide();
|
|
|
|
alert(globalize.translate('ErrorDefault'));
|
2020-01-22 03:30:33 +03:00
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
return false;
|
|
|
|
}
|
2019-03-05 21:30:06 +09:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
export default function (view) {
|
|
|
|
$('#btnSelectCachePath', view).on('click.selectDirectory', function () {
|
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
|
|
|
const picker = new DirectoryBrowser();
|
|
|
|
picker.show({
|
|
|
|
callback: function (path) {
|
|
|
|
if (path) {
|
|
|
|
view.querySelector('#txtCachePath').value = path;
|
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
validateWriteable: true,
|
|
|
|
header: globalize.translate('HeaderSelectServerCachePath'),
|
|
|
|
instruction: globalize.translate('HeaderSelectServerCachePathHelp')
|
2020-01-22 03:30:33 +03:00
|
|
|
});
|
2019-03-05 21:12:13 +09:00
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
$('#btnSelectMetadataPath', view).on('click.selectDirectory', function () {
|
|
|
|
import('../../components/directorybrowser/directorybrowser').then(({ default: DirectoryBrowser }) => {
|
|
|
|
const picker = new DirectoryBrowser();
|
|
|
|
picker.show({
|
|
|
|
path: $('#txtMetadataPath', view).val(),
|
|
|
|
networkSharePath: $('#txtMetadataNetworkPath', view).val(),
|
|
|
|
callback: function (path, networkPath) {
|
|
|
|
if (path) {
|
|
|
|
$('#txtMetadataPath', view).val(path);
|
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
if (networkPath) {
|
|
|
|
$('#txtMetadataNetworkPath', view).val(networkPath);
|
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2023-04-19 01:56:05 -04:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
validateWriteable: true,
|
|
|
|
header: globalize.translate('HeaderSelectMetadataPath'),
|
2024-01-12 17:34:49 -05:00
|
|
|
instruction: globalize.translate('HeaderSelectMetadataPathHelp')
|
2020-01-22 03:30:33 +03:00
|
|
|
});
|
2019-03-05 21:12:13 +09:00
|
|
|
});
|
2023-04-19 01:56:05 -04:00
|
|
|
});
|
|
|
|
$('.dashboardGeneralForm', view).off('submit', onSubmit).on('submit', onSubmit);
|
|
|
|
view.addEventListener('viewshow', function () {
|
|
|
|
const promiseConfig = ApiClient.getServerConfiguration();
|
|
|
|
const promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl('Localization/Options'));
|
|
|
|
const promiseSystemInfo = ApiClient.getSystemInfo();
|
|
|
|
Promise.all([promiseConfig, promiseLanguageOptions, promiseSystemInfo]).then(function (responses) {
|
|
|
|
loadPage(view, responses[0], responses[1], responses[2]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2020-07-09 08:54:47 +01:00
|
|
|
|