jellyfin-web/dashboard-ui/scripts/advancedconfigurationpage.js

130 lines
4.3 KiB
JavaScript
Raw Normal View History

2013-04-23 12:17:21 -07:00
(function ($, document, window) {
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
function loadPage(page, config, systemInfo) {
2013-02-20 18:33:05 -07:00
if (systemInfo.SupportsNativeWebSocket) {
$('#fldWebSocketPortNumber', page).hide();
} else {
$('#fldWebSocketPortNumber', page).show();
}
$('#selectAutomaticUpdateLevel', page).val(config.SystemUpdateLevel).selectmenu('refresh');
2013-02-20 18:33:05 -07:00
$('#txtWebSocketPortNumber', page).val(config.LegacyWebSocketPortNumber);
2013-04-23 12:17:21 -07:00
$('#txtItemsByNamePath', page).val(config.ItemsByNamePath);
var customIbn = config.ItemsByNamePath ? true : false;
$('#chkEnableCustomIBNPath', page).checked(customIbn).checkboxradio("refresh");
if (customIbn) {
$('#fieldEnterIBNPath', page).show();
$('#txtItemsByNamePath', page).attr("required", "required");
} else {
$('#fieldEnterIBNPath', page).hide();
$('#txtItemsByNamePath', page).removeAttr("required");
}
2013-02-20 18:33:05 -07:00
$('#txtPortNumber', page).val(config.HttpServerPortNumber);
$('#chkDebugLog', page).checked(config.EnableDebugLevelLogging).checkboxradio("refresh");
$('#chkEnableDeveloperTools', page).checked(config.EnableDeveloperTools).checkboxradio("refresh");
$('#chkRunAtStartup', page).checked(config.RunAtStartup).checkboxradio("refresh");
Dashboard.hideLoadingMsg();
2013-04-23 12:17:21 -07:00
}
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
$(document).on('pageshow', "#advancedConfigurationPage", function () {
2013-02-20 18:33:05 -07:00
Dashboard.showLoadingMsg();
2013-04-23 12:17:21 -07:00
var page = this;
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
var promise1 = ApiClient.getServerConfiguration();
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
var promise2 = ApiClient.getSystemInfo();
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
$('#btnSelectIBNPath', page).on("click.selectDirectory", function () {
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
Dashboard.selectDirectory({
2013-02-20 18:33:05 -07:00
2013-04-23 12:17:21 -07:00
callback: function (path) {
if (path) {
$('#txtItemsByNamePath', page).val(path);
}
$('#popupDirectoryPicker', page).popup("close");
},
header: "Select Items By Name Path",
instruction: "Browse or enter the path to your items by name folder. The folder must be writeable."
});
2013-02-20 18:33:05 -07:00
});
2013-04-23 12:17:21 -07:00
$('#chkEnableCustomIBNPath', page).on("change.showIBNText", function() {
if (this.checked) {
$('#fieldEnterIBNPath', page).show();
$('#txtItemsByNamePath', page).attr("required", "required");
} else {
$('#fieldEnterIBNPath', page).hide();
$('#txtItemsByNamePath', page).removeAttr("required");
}
});
$.when(promise1, promise2).done(function (response1, response2) {
loadPage(page, response1[0], response2[0]);
});
}).on('pagehide', "#advancedConfigurationPage", function () {
Dashboard.showLoadingMsg();
var page = this;
$('#chkEnableCustomIBNPath', page).off("change.showIBNText");
$('#btnSelectIBNPath', page).off("click.selectDirectory");
});
function advancedConfigurationPage() {
var self = this;
self.onSubmit = function () {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
config.LegacyWebSocketPortNumber = $('#txtWebSocketPortNumber', form).val();
config.HttpServerPortNumber = $('#txtPortNumber', form).val();
config.EnableDebugLevelLogging = $('#chkDebugLog', form).checked();
config.EnableDeveloperTools = $('#chkEnableDeveloperTools', form).checked();
config.RunAtStartup = $('#chkRunAtStartup', form).checked();
config.SystemUpdateLevel = $('#selectAutomaticUpdateLevel', form).val();
if ($('#chkEnableCustomIBNPath', form).checked()) {
config.ItemsByNamePath = $('#txtItemsByNamePath', form).val();
} else {
config.ItemsByNamePath = '';
}
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
};
2013-02-20 18:33:05 -07:00
}
2013-04-23 12:17:21 -07:00
window.AdvancedConfigurationPage = new advancedConfigurationPage();
})(jQuery, document, window);