mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
general.js
This commit is contained in:
parent
e706f8bee0
commit
f1429d007b
1 changed files with 41 additions and 30 deletions
|
@ -1,38 +1,45 @@
|
||||||
define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emby-input", "emby-select", "emby-button"], function($, loading) {
|
define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emby-input", "emby-select", "emby-button"], function ($, loading) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
function loadPage(page, config, languageOptions, systemInfo) {
|
function loadPage(page, config, languageOptions, systemInfo) {
|
||||||
page.querySelector("#txtServerName").value = systemInfo.ServerName;
|
page.querySelector("#txtServerName").value = systemInfo.ServerName;
|
||||||
$("#chkAutoRunWebApp", page).checked(config.AutoRunWebApp);
|
$("#chkAutoRunWebApp", page).checked(config.AutoRunWebApp);
|
||||||
|
|
||||||
if (systemInfo.CanLaunchWebBrowser) {
|
if (systemInfo.CanLaunchWebBrowser) {
|
||||||
page.querySelector("#fldAutoRunWebApp").classList.remove("hide");
|
page.querySelector("#fldAutoRunWebApp").classList.remove("hide");
|
||||||
} else {
|
} else {
|
||||||
page.querySelector("#fldAutoRunWebApp").classList.add("hide");
|
page.querySelector("#fldAutoRunWebApp").classList.add("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
page.querySelector("#txtCachePath").value = systemInfo.CachePath || "";
|
page.querySelector("#txtCachePath").value = systemInfo.CachePath || "";
|
||||||
$("#txtMetadataPath", page).val(systemInfo.InternalMetadataPath || "");
|
$("#txtMetadataPath", page).val(systemInfo.InternalMetadataPath || "");
|
||||||
$("#txtMetadataNetworkPath", page).val(systemInfo.MetadataNetworkPath || "");
|
$("#txtMetadataNetworkPath", page).val(systemInfo.MetadataNetworkPath || "");
|
||||||
$("#selectLocalizationLanguage", page).html(languageOptions.map(function(language) {
|
$("#selectLocalizationLanguage", page).html(languageOptions.map(function (language) {
|
||||||
return '<option value="' + language.Value + '">' + language.Name + "</option>"
|
return '<option value="' + language.Value + '">' + language.Name + "</option>";
|
||||||
})).val(config.UICulture);
|
})).val(config.UICulture);
|
||||||
currentLanguage = config.UICulture;
|
currentLanguage = config.UICulture;
|
||||||
|
|
||||||
if (systemInfo.CanSelfUpdate) {
|
if (systemInfo.CanSelfUpdate) {
|
||||||
page.querySelector(".fldAutomaticUpdates").classList.remove("hide");
|
page.querySelector(".fldAutomaticUpdates").classList.remove("hide");
|
||||||
} else {
|
} else {
|
||||||
page.querySelector(".fldAutomaticUpdates").classList.add("hide");
|
page.querySelector(".fldAutomaticUpdates").classList.add("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#chkEnableAutomaticServerUpdates", page).checked(config.EnableAutoUpdate);
|
$("#chkEnableAutomaticServerUpdates", page).checked(config.EnableAutoUpdate);
|
||||||
$("#chkEnableAutomaticRestart", page).checked(config.EnableAutomaticRestart);
|
$("#chkEnableAutomaticRestart", page).checked(config.EnableAutomaticRestart);
|
||||||
|
|
||||||
if (systemInfo.CanSelfRestart) {
|
if (systemInfo.CanSelfRestart) {
|
||||||
page.querySelector("#fldEnableAutomaticRestart").classList.remove("hide");
|
page.querySelector("#fldEnableAutomaticRestart").classList.remove("hide");
|
||||||
} else {
|
} else {
|
||||||
page.querySelector("#fldEnableAutomaticRestart").classList.add("hide");
|
page.querySelector("#fldEnableAutomaticRestart").classList.add("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate) {
|
if (systemInfo.CanSelfRestart || systemInfo.CanSelfUpdate) {
|
||||||
$(".autoUpdatesContainer", page).removeClass("hide");
|
$(".autoUpdatesContainer", page).removeClass("hide");
|
||||||
} else {
|
} else {
|
||||||
$(".autoUpdatesContainer", page).addClass("hide");
|
$(".autoUpdatesContainer", page).addClass("hide");
|
||||||
}
|
}
|
||||||
|
|
||||||
loading.hide();
|
loading.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,92 +47,96 @@ define(["jQuery", "loading", "fnchecked", "emby-checkbox", "emby-textarea", "emb
|
||||||
loading.show();
|
loading.show();
|
||||||
var form = this;
|
var form = this;
|
||||||
$(form).parents(".page");
|
$(form).parents(".page");
|
||||||
return ApiClient.getServerConfiguration().then(function(config) {
|
ApiClient.getServerConfiguration().then(function (config) {
|
||||||
config.ServerName = $("#txtServerName", form).val();
|
config.ServerName = $("#txtServerName", form).val();
|
||||||
config.UICulture = $("#selectLocalizationLanguage", form).val();
|
config.UICulture = $("#selectLocalizationLanguage", form).val();
|
||||||
config.CachePath = form.querySelector("#txtCachePath").value;
|
config.CachePath = form.querySelector("#txtCachePath").value;
|
||||||
config.MetadataPath = $("#txtMetadataPath", form).val();
|
config.MetadataPath = $("#txtMetadataPath", form).val();
|
||||||
config.MetadataNetworkPath = $("#txtMetadataNetworkPath", form).val();
|
config.MetadataNetworkPath = $("#txtMetadataNetworkPath", form).val();
|
||||||
var requiresReload = (config.UICulture !== currentLanguage);
|
var requiresReload = config.UICulture !== currentLanguage;
|
||||||
config.AutoRunWebApp = $("#chkAutoRunWebApp", form).checked();
|
config.AutoRunWebApp = $("#chkAutoRunWebApp", form).checked();
|
||||||
config.EnableAutomaticRestart = $("#chkEnableAutomaticRestart", form).checked();
|
config.EnableAutomaticRestart = $("#chkEnableAutomaticRestart", form).checked();
|
||||||
config.EnableAutoUpdate = $("#chkEnableAutomaticServerUpdates", form).checked();
|
config.EnableAutoUpdate = $("#chkEnableAutomaticServerUpdates", form).checked();
|
||||||
ApiClient.updateServerConfiguration(config).then(function() {
|
ApiClient.updateServerConfiguration(config).then(function () {
|
||||||
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(brandingConfig) {
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function (brandingConfig) {
|
||||||
brandingConfig.LoginDisclaimer = form.querySelector("#txtLoginDisclaimer").value;
|
brandingConfig.LoginDisclaimer = form.querySelector("#txtLoginDisclaimer").value;
|
||||||
brandingConfig.CustomCss = form.querySelector("#txtCustomCss").value;
|
brandingConfig.CustomCss = form.querySelector("#txtCustomCss").value;
|
||||||
|
|
||||||
if (currentBrandingOptions && brandingConfig.CustomCss !== currentBrandingOptions.CustomCss) {
|
if (currentBrandingOptions && brandingConfig.CustomCss !== currentBrandingOptions.CustomCss) {
|
||||||
requiresReload = true;
|
requiresReload = true;
|
||||||
}
|
}
|
||||||
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(function() {
|
|
||||||
|
ApiClient.updateNamedConfiguration(brandingConfigKey, brandingConfig).then(function () {
|
||||||
Dashboard.processServerConfigurationUpdateResult();
|
Dashboard.processServerConfigurationUpdateResult();
|
||||||
|
|
||||||
if (requiresReload && !AppInfo.isNativeApp) {
|
if (requiresReload && !AppInfo.isNativeApp) {
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
}), !1
|
});
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentBrandingOptions;
|
var currentBrandingOptions;
|
||||||
var currentLanguage;
|
var currentLanguage;
|
||||||
var brandingConfigKey = "branding";
|
var brandingConfigKey = "branding";
|
||||||
|
return function (view, params) {
|
||||||
return function(view, params) {
|
$("#btnSelectCachePath", view).on("click.selectDirectory", function () {
|
||||||
$("#btnSelectCachePath", view).on("click.selectDirectory", function() {
|
require(["directorybrowser"], function (directoryBrowser) {
|
||||||
require(["directorybrowser"], function(directoryBrowser) {
|
var picker = new directoryBrowser();
|
||||||
var picker = new directoryBrowser;
|
|
||||||
picker.show({
|
picker.show({
|
||||||
callback: function(path) {
|
callback: function (path) {
|
||||||
if (path) {
|
if (path) {
|
||||||
view.querySelector("#txtCachePath").value = path;
|
view.querySelector("#txtCachePath").value = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
picker.close();
|
picker.close();
|
||||||
},
|
},
|
||||||
validateWriteable: true,
|
validateWriteable: true,
|
||||||
header: Globalize.translate("HeaderSelectServerCachePath"),
|
header: Globalize.translate("HeaderSelectServerCachePath"),
|
||||||
instruction: Globalize.translate("HeaderSelectServerCachePathHelp")
|
instruction: Globalize.translate("HeaderSelectServerCachePathHelp")
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
$("#btnSelectMetadataPath", view).on("click.selectDirectory", function () {
|
||||||
$("#btnSelectMetadataPath", view).on("click.selectDirectory", function() {
|
require(["directorybrowser"], function (directoryBrowser) {
|
||||||
require(["directorybrowser"], function(directoryBrowser) {
|
|
||||||
var picker = new directoryBrowser();
|
var picker = new directoryBrowser();
|
||||||
picker.show({
|
picker.show({
|
||||||
path: $("#txtMetadataPath", view).val(),
|
path: $("#txtMetadataPath", view).val(),
|
||||||
networkSharePath: $("#txtMetadataNetworkPath", view).val(),
|
networkSharePath: $("#txtMetadataNetworkPath", view).val(),
|
||||||
callback: function(path, networkPath) {
|
callback: function (path, networkPath) {
|
||||||
if (path) {
|
if (path) {
|
||||||
$("#txtMetadataPath", view).val(path);
|
$("#txtMetadataPath", view).val(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (networkPath) {
|
if (networkPath) {
|
||||||
$("#txtMetadataNetworkPath", view).val(networkPath);
|
$("#txtMetadataNetworkPath", view).val(networkPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
picker.close();
|
picker.close();
|
||||||
},
|
},
|
||||||
validateWriteable: true,
|
validateWriteable: true,
|
||||||
header: Globalize.translate("HeaderSelectMetadataPath"),
|
header: Globalize.translate("HeaderSelectMetadataPath"),
|
||||||
instruction: Globalize.translate("HeaderSelectMetadataPathHelp"),
|
instruction: Globalize.translate("HeaderSelectMetadataPathHelp"),
|
||||||
enableNetworkSharePath: true
|
enableNetworkSharePath: true
|
||||||
})
|
});
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dashboardGeneralForm", view).off("submit", onSubmit).on("submit", onSubmit);
|
$(".dashboardGeneralForm", view).off("submit", onSubmit).on("submit", onSubmit);
|
||||||
view.addEventListener("viewshow", function() {
|
view.addEventListener("viewshow", function () {
|
||||||
var promiseConfig = ApiClient.getServerConfiguration();
|
var promiseConfig = ApiClient.getServerConfiguration();
|
||||||
var promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
|
var promiseLanguageOptions = ApiClient.getJSON(ApiClient.getUrl("Localization/Options"));
|
||||||
var promiseSystemInfo = ApiClient.getSystemInfo();
|
var promiseSystemInfo = ApiClient.getSystemInfo();
|
||||||
Promise.all([promiseConfig, promiseLanguageOptions, promiseSystemInfo]).then(function(responses) {
|
Promise.all([promiseConfig, promiseLanguageOptions, promiseSystemInfo]).then(function (responses) {
|
||||||
loadPage(view, responses[0], responses[1], responses[2]);
|
loadPage(view, responses[0], responses[1], responses[2]);
|
||||||
});
|
});
|
||||||
ApiClient.getNamedConfiguration(brandingConfigKey).then(function(config) {
|
ApiClient.getNamedConfiguration(brandingConfigKey).then(function (config) {
|
||||||
currentBrandingOptions = config;
|
currentBrandingOptions = config;
|
||||||
view.querySelector("#txtLoginDisclaimer").value = config.LoginDisclaimer || "";
|
view.querySelector("#txtLoginDisclaimer").value = config.LoginDisclaimer || "";
|
||||||
view.querySelector("#txtCustomCss").value = config.CustomCss || "";
|
view.querySelector("#txtCustomCss").value = config.CustomCss || "";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue