2018-10-23 01:05:09 +03:00
|
|
|
define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emby-input", "emby-select", "emby-linkbutton"], function($, loading) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
function loadPage(page, config, languageOptions, systemInfo) {
|
2019-03-05 21:30:06 +09:00
|
|
|
systemInfo.CanLaunchWebBrowser ? page.querySelector("#fldRunWebAppAtStartup").classList.remove("hide") : page.querySelector("#fldRunWebAppAtStartup").classList.add("hide");
|
|
|
|
page.querySelector("#txtCachePath").value = config.CachePath || "";
|
2019-03-05 21:38:14 +09:00
|
|
|
$("#txtMetadataPath", page).val(config.MetadataPath || "");
|
|
|
|
$("#txtMetadataNetworkPath", page).val(config.MetadataNetworkPath || "");
|
2019-03-05 21:30:06 +09:00
|
|
|
$("#selectLocalizationLanguage", page).html(languageOptions.map(function(l) {
|
2018-10-23 01:05:09 +03:00
|
|
|
return '<option value="' + l.Value + '">' + l.Name + "</option>"
|
2019-03-05 21:30:06 +09:00
|
|
|
})).val(config.UICulture);
|
|
|
|
currentLanguage = config.UICulture;
|
|
|
|
systemInfo.CanSelfUpdate ? page.querySelector(".fldAutomaticUpdates").classList.remove("hide") : page.querySelector(".fldAutomaticUpdates").classList.add("hide");
|
|
|
|
$("#chkEnableAutomaticServerUpdates", page).checked(config.EnableAutoUpdate);
|
|
|
|
$("#chkEnableAutomaticRestart", page).checked(config.EnableAutomaticRestart);
|
|
|
|
systemInfo.CanSelfRestart ? page.querySelector("#fldEnableAutomaticRestart").classList.remove("hide") : page.querySelector("#fldEnableAutomaticRestart").classList.add("hide");
|
|
|
|
systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate ? $(".autoUpdatesContainer", page).removeClass("hide") : $(".autoUpdatesContainer", page).addClass("hide");
|
|
|
|
loading.hide();
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSubmit() {
|
|
|
|
loading.show();
|
|
|
|
var form = this;
|
|
|
|
$(form).parents(".page");
|
|
|
|
return ApiClient.getServerConfiguration().then(function(config) {
|
2019-03-05 21:12:13 +09:00
|
|
|
config.UICulture = $("#selectLocalizationLanguage", form).val();
|
|
|
|
config.CachePath = form.querySelector("#txtCachePath").value;
|
2019-03-05 21:38:14 +09:00
|
|
|
config.MetadataPath = $("#txtMetadataPath", form).val();
|
|
|
|
config.MetadataNetworkPath = $("#txtMetadataNetworkPath", form).val();
|
2019-03-05 21:12:13 +09:00
|
|
|
var requiresReload = false;
|
|
|
|
if (config.UICulture !== currentLanguage) {
|
|
|
|
requiresReload = true;
|
|
|
|
}
|
|
|
|
config.EnableAutomaticRestart = $("#chkEnableAutomaticRestart", form).checked();
|
|
|
|
config.EnableAutoUpdate = $("#chkEnableAutomaticServerUpdates", form).checked();
|
|
|
|
ApiClient.updateServerConfiguration(config).then(function() {
|
2018-10-23 01:05:09 +03:00
|
|
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(brandingConfig) {
|
2019-03-05 21:12:13 +09:00
|
|
|
brandingConfig.LoginDisclaimer = form.querySelector("#txtLoginDisclaimer").value;
|
|
|
|
brandingConfig.CustomCss = form.querySelector("#txtCustomCss").value;
|
|
|
|
currentBrandingOptions && brandingConfig.CustomCss !== currentBrandingOptions.CustomCss && (requiresReload = !0);
|
|
|
|
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(function() {
|
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
|
|
|
if (requiresReload && !AppInfo.isNativeApp) {
|
|
|
|
window.location.reload(true);
|
|
|
|
}
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}), !1
|
|
|
|
}
|
2019-03-05 21:30:06 +09:00
|
|
|
|
|
|
|
var currentBrandingOptions;
|
|
|
|
var currentLanguage;
|
|
|
|
var brandingConfigKey = "branding";
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
return function(view, params) {
|
|
|
|
$("#btnSelectCachePath", view).on("click.selectDirectory", function() {
|
|
|
|
require(["directorybrowser"], function(directoryBrowser) {
|
|
|
|
var picker = new directoryBrowser;
|
|
|
|
picker.show({
|
|
|
|
callback: function(path) {
|
2019-03-05 21:30:06 +09:00
|
|
|
path && (view.querySelector("#txtCachePath").value = path);
|
|
|
|
picker.close();
|
2018-10-23 01:05:09 +03:00
|
|
|
},
|
2019-03-05 21:30:06 +09:00
|
|
|
validateWriteable: true,
|
2018-10-23 01:05:09 +03:00
|
|
|
header: Globalize.translate("HeaderSelectServerCachePath"),
|
|
|
|
instruction: Globalize.translate("HeaderSelectServerCachePathHelp")
|
|
|
|
})
|
|
|
|
})
|
2019-03-05 21:12:13 +09:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#btnSelectMetadataPath", view).on("click.selectDirectory", function() {
|
|
|
|
require(["directorybrowser"], function(directoryBrowser) {
|
|
|
|
var picker = new directoryBrowser;
|
|
|
|
picker.show({
|
|
|
|
path: $("#txtMetadataPath", view).val(),
|
|
|
|
networkSharePath: $("#txtMetadataNetworkPath", view).val(),
|
|
|
|
callback: function(path, networkPath) {
|
2019-03-05 21:59:52 +09:00
|
|
|
path && $("#txtMetadataPath", view).val(path);
|
|
|
|
networkPath && $("#txtMetadataNetworkPath", view).val(networkPath);
|
2019-03-05 21:30:06 +09:00
|
|
|
picker.close();
|
2019-03-05 21:12:13 +09:00
|
|
|
},
|
2019-03-05 21:30:06 +09:00
|
|
|
validateWriteable: true,
|
2019-03-05 21:12:13 +09:00
|
|
|
header: Globalize.translate("HeaderSelectMetadataPath"),
|
|
|
|
instruction: Globalize.translate("HeaderSelectMetadataPathHelp"),
|
2019-03-05 21:30:06 +09:00
|
|
|
enableNetworkSharePath: true
|
2019-03-05 21:12:13 +09:00
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
2019-03-05 21:30:06 +09:00
|
|
|
$(".dashboardGeneralForm", view).off("submit", onSubmit).on("submit", onSubmit);
|
|
|
|
view.addEventListener("viewshow", function() {
|
|
|
|
var promise1 = ApiClient.getServerConfiguration();
|
|
|
|
var promise2 = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
|
|
|
|
var promise3 = ApiClient.getSystemInfo();
|
2018-10-23 01:05:09 +03:00
|
|
|
Promise.all([promise1, promise2, promise3]).then(function(responses) {
|
2019-03-05 21:30:06 +09:00
|
|
|
loadPage(view, responses[0], responses[1], responses[2]);
|
|
|
|
});
|
|
|
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(config) {
|
|
|
|
currentBrandingOptions = config;
|
|
|
|
view.querySelector("#txtLoginDisclaimer").value = config.LoginDisclaimer || "";
|
|
|
|
view.querySelector("#txtCustomCss").value = config.CustomCss || "";
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-03 21:05:17 +01:00
|
|
|
});
|