2018-10-22 15:05:09 -07: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-22 15:47:01 -07:00
|
|
|
page.querySelector("#txtServerName").value = config.ServerName;
|
2019-03-07 15:00:13 -07:00
|
|
|
if (systemInfo.CanLaunchWebBrowser) {
|
|
|
|
page.querySelector("#fldRunWebAppAtStartup").classList.remove("hide");
|
|
|
|
} else {
|
|
|
|
page.querySelector("#fldRunWebAppAtStartup").classList.add("hide");
|
|
|
|
}
|
2019-03-05 05:30:06 -07:00
|
|
|
page.querySelector("#txtCachePath").value = config.CachePath || "";
|
2019-03-05 05:38:14 -07:00
|
|
|
$("#txtMetadataPath", page).val(config.MetadataPath || "");
|
|
|
|
$("#txtMetadataNetworkPath", page).val(config.MetadataNetworkPath || "");
|
2019-03-08 19:37:40 -07:00
|
|
|
$("#selectLocalizationLanguage", page).html(languageOptions.map(function(language) {
|
|
|
|
return '<option value="' + language.Value + '">' + language.Name + "</option>"
|
2019-03-05 05:30:06 -07:00
|
|
|
})).val(config.UICulture);
|
|
|
|
currentLanguage = config.UICulture;
|
2019-03-07 15:00:13 -07:00
|
|
|
if (systemInfo.CanSelfUpdate) {
|
|
|
|
page.querySelector(".fldAutomaticUpdates").classList.remove("hide");
|
|
|
|
} else {
|
|
|
|
page.querySelector(".fldAutomaticUpdates").classList.add("hide");
|
|
|
|
}
|
2019-03-05 05:30:06 -07:00
|
|
|
$("#chkEnableAutomaticServerUpdates", page).checked(config.EnableAutoUpdate);
|
|
|
|
$("#chkEnableAutomaticRestart", page).checked(config.EnableAutomaticRestart);
|
2019-03-07 15:00:13 -07:00
|
|
|
if (systemInfo.CanSelfRestart) {
|
|
|
|
page.querySelector("#fldEnableAutomaticRestart").classList.remove("hide");
|
|
|
|
} else {
|
|
|
|
page.querySelector("#fldEnableAutomaticRestart").classList.add("hide");
|
|
|
|
}
|
|
|
|
if (systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate) {
|
|
|
|
$(".autoUpdatesContainer", page).removeClass("hide");
|
|
|
|
} else {
|
|
|
|
$(".autoUpdatesContainer", page).addClass("hide");
|
|
|
|
}
|
2019-03-05 05:30:06 -07:00
|
|
|
loading.hide();
|
2018-10-22 15:05:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function onSubmit() {
|
|
|
|
loading.show();
|
|
|
|
var form = this;
|
|
|
|
$(form).parents(".page");
|
|
|
|
return ApiClient.getServerConfiguration().then(function(config) {
|
2019-03-22 15:47:01 -07:00
|
|
|
config.ServerName = $("#txtServerName", form).val();
|
2019-03-05 05:12:13 -07:00
|
|
|
config.UICulture = $("#selectLocalizationLanguage", form).val();
|
|
|
|
config.CachePath = form.querySelector("#txtCachePath").value;
|
2019-03-05 05:38:14 -07:00
|
|
|
config.MetadataPath = $("#txtMetadataPath", form).val();
|
|
|
|
config.MetadataNetworkPath = $("#txtMetadataNetworkPath", form).val();
|
2019-03-08 19:37:40 -07:00
|
|
|
var requiresReload = (config.UICulture !== currentLanguage);
|
2019-03-05 05:12:13 -07:00
|
|
|
config.EnableAutomaticRestart = $("#chkEnableAutomaticRestart", form).checked();
|
|
|
|
config.EnableAutoUpdate = $("#chkEnableAutomaticServerUpdates", form).checked();
|
|
|
|
ApiClient.updateServerConfiguration(config).then(function() {
|
2018-10-22 15:05:09 -07:00
|
|
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(brandingConfig) {
|
2019-03-05 05:12:13 -07:00
|
|
|
brandingConfig.LoginDisclaimer = form.querySelector("#txtLoginDisclaimer").value;
|
|
|
|
brandingConfig.CustomCss = form.querySelector("#txtCustomCss").value;
|
2019-03-07 15:00:13 -07:00
|
|
|
if (currentBrandingOptions && brandingConfig.CustomCss !== currentBrandingOptions.CustomCss) {
|
|
|
|
requiresReload = true;
|
|
|
|
}
|
2019-03-05 05:12:13 -07:00
|
|
|
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(function() {
|
|
|
|
Dashboard.processServerConfigurationUpdateResult();
|
|
|
|
if (requiresReload && !AppInfo.isNativeApp) {
|
|
|
|
window.location.reload(true);
|
|
|
|
}
|
|
|
|
});
|
2018-10-22 15:05:09 -07:00
|
|
|
})
|
|
|
|
})
|
|
|
|
}), !1
|
|
|
|
}
|
2019-03-05 05:30:06 -07:00
|
|
|
|
|
|
|
var currentBrandingOptions;
|
|
|
|
var currentLanguage;
|
|
|
|
var brandingConfigKey = "branding";
|
|
|
|
|
2018-10-22 15:05:09 -07: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-07 15:00:13 -07:00
|
|
|
if (path) {
|
|
|
|
view.querySelector("#txtCachePath").value = path;
|
|
|
|
}
|
2019-03-05 05:30:06 -07:00
|
|
|
picker.close();
|
2018-10-22 15:05:09 -07:00
|
|
|
},
|
2019-03-05 05:30:06 -07:00
|
|
|
validateWriteable: true,
|
2018-10-22 15:05:09 -07:00
|
|
|
header: Globalize.translate("HeaderSelectServerCachePath"),
|
|
|
|
instruction: Globalize.translate("HeaderSelectServerCachePathHelp")
|
|
|
|
})
|
|
|
|
})
|
2019-03-05 05:12:13 -07:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#btnSelectMetadataPath", view).on("click.selectDirectory", function() {
|
|
|
|
require(["directorybrowser"], function(directoryBrowser) {
|
2019-03-07 15:00:13 -07:00
|
|
|
var picker = new directoryBrowser();
|
2019-03-05 05:12:13 -07:00
|
|
|
picker.show({
|
|
|
|
path: $("#txtMetadataPath", view).val(),
|
2019-03-09 15:06:28 -07:00
|
|
|
networkSharePath: $("#txtMetadataNetworkPath", view).val(),
|
|
|
|
callback: function(path, networkPath) {
|
2019-03-07 15:00:13 -07:00
|
|
|
if (path) {
|
|
|
|
$("#txtMetadataPath", view).val(path);
|
|
|
|
}
|
2019-03-09 15:06:28 -07:00
|
|
|
if (networkPath) {
|
2019-03-13 18:34:58 -07:00
|
|
|
$("#txtMetadataNetworkPath", view).val(networkPath);
|
2019-03-07 15:00:13 -07:00
|
|
|
}
|
2019-03-06 02:53:31 -07:00
|
|
|
picker.close();
|
|
|
|
},
|
|
|
|
validateWriteable: true,
|
2019-03-09 15:06:28 -07:00
|
|
|
header: Globalize.translate("HeaderSelectMetadataPath"),
|
|
|
|
instruction: Globalize.translate("HeaderSelectMetadataPathHelp"),
|
|
|
|
enableNetworkSharePath: true
|
2019-03-05 05:12:13 -07:00
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
2019-03-05 05:30:06 -07:00
|
|
|
$(".dashboardGeneralForm", view).off("submit", onSubmit).on("submit", onSubmit);
|
|
|
|
view.addEventListener("viewshow", function() {
|
2019-03-07 15:00:13 -07:00
|
|
|
var promiseConfig = ApiClient.getServerConfiguration();
|
|
|
|
var promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
|
|
|
|
var promiseSystemInfo = ApiClient.getSystemInfo();
|
|
|
|
Promise.all([promiseConfig, promiseLanguageOptions, promiseSystemInfo]).then(function(responses) {
|
2019-03-05 05:30:06 -07: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-22 15:05:09 -07:00
|
|
|
}
|
2019-01-03 13:05:17 -07:00
|
|
|
});
|