2020-05-04 12:44:12 +02:00
|
|
|
define(['jQuery', 'loading', 'globalize', 'fnchecked', 'emby-checkbox', 'emby-textarea', 'emby-input', 'emby-select', 'emby-button'], function ($, loading, globalize) {
|
|
|
|
'use strict';
|
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;
|
|
|
|
$('#chkAutoRunWebApp', page).checked(config.AutoRunWebApp);
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2019-03-07 22:00:13 +00:00
|
|
|
if (systemInfo.CanLaunchWebBrowser) {
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#fldAutoRunWebApp').classList.remove('hide');
|
2019-03-07 22:00:13 +00:00
|
|
|
} else {
|
2020-05-04 12:44:12 +02:00
|
|
|
page.querySelector('#fldAutoRunWebApp').classList.add('hide');
|
2019-03-07 22:00:13 +00:00
|
|
|
}
|
2020-01-22 03:30:33 +03:00
|
|
|
|
2020-05-04 12:44:12 +02:00
|
|
|
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;
|
2019-03-07 22:00:13 +00:00
|
|
|
if (systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('.autoUpdatesContainer', page).removeClass('hide');
|
2019-03-07 22:00:13 +00:00
|
|
|
} else {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('.autoUpdatesContainer', page).addClass('hide');
|
2019-03-07 22:00:13 +00:00
|
|
|
}
|
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();
|
|
|
|
var 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-01-22 03:30:33 +03:00
|
|
|
var requiresReload = config.UICulture !== currentLanguage;
|
2020-05-04 12:44:12 +02:00
|
|
|
config.AutoRunWebApp = $('#chkAutoRunWebApp', form).checked();
|
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-05-04 12:44:12 +02:00
|
|
|
require(['alert'], function (alert) {
|
|
|
|
alert(globalize.translate('DefaultErrorMessage'));
|
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
|
|
|
|
|
|
|
var currentBrandingOptions;
|
|
|
|
var currentLanguage;
|
2020-05-04 12:44:12 +02:00
|
|
|
var brandingConfigKey = 'branding';
|
2020-01-22 03:30:33 +03:00
|
|
|
return function (view, params) {
|
2020-05-04 12:44:12 +02:00
|
|
|
$('#btnSelectCachePath', view).on('click.selectDirectory', function () {
|
|
|
|
require(['directorybrowser'], function (directoryBrowser) {
|
2020-01-22 03:30:33 +03:00
|
|
|
var 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 () {
|
|
|
|
require(['directorybrowser'], function (directoryBrowser) {
|
2019-03-07 22:00:13 +00:00
|
|
|
var 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 () {
|
2019-03-07 22:00:13 +00:00
|
|
|
var promiseConfig = ApiClient.getServerConfiguration();
|
2020-05-04 12:44:12 +02:00
|
|
|
var promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl('Localization/Options'));
|
2019-03-07 22:00:13 +00:00
|
|
|
var 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-01-22 03:30:33 +03:00
|
|
|
};
|
2019-01-03 21:05:17 +01:00
|
|
|
});
|