1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

#35 - Make IBN path configurable

This commit is contained in:
Luke Pulverenti 2013-04-23 15:17:21 -04:00
parent 38397af423
commit e8d26d4158
5 changed files with 167 additions and 67 deletions

View file

@ -1,23 +1,7 @@
var AdvancedConfigurationPage = {
(function ($, document, window) {
onPageShow: function () {
Dashboard.showLoadingMsg();
function loadPage(page, config, systemInfo) {
var promise1 = ApiClient.getServerConfiguration();
var promise2 = ApiClient.getSystemInfo();
$.when(promise1, promise2).done(function (response1, response2) {
AdvancedConfigurationPage.loadPage(response1[0], response2[0]);
});
},
loadPage: function (config, systemInfo) {
var page = $.mobile.activePage;
if (systemInfo.SupportsNativeWebSocket) {
$('#fldWebSocketPortNumber', page).hide();
@ -28,6 +12,19 @@
$('#selectAutomaticUpdateLevel', page).val(config.SystemUpdateLevel).selectmenu('refresh');
$('#txtWebSocketPortNumber', page).val(config.LegacyWebSocketPortNumber);
$('#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");
}
$('#txtPortNumber', page).val(config.HttpServerPortNumber);
$('#chkDebugLog', page).checked(config.EnableDebugLevelLogging).checkboxradio("refresh");
@ -35,31 +32,98 @@
$('#chkRunAtStartup', page).checked(config.RunAtStartup).checkboxradio("refresh");
Dashboard.hideLoadingMsg();
},
}
onSubmit: function () {
$(document).on('pageshow', "#advancedConfigurationPage", function () {
Dashboard.showLoadingMsg();
var form = this;
var page = this;
ApiClient.getServerConfiguration().done(function (config) {
var promise1 = ApiClient.getServerConfiguration();
config.LegacyWebSocketPortNumber = $('#txtWebSocketPortNumber', form).val();
var promise2 = ApiClient.getSystemInfo();
config.HttpServerPortNumber = $('#txtPortNumber', form).val();
config.EnableDebugLevelLogging = $('#chkDebugLog', form).checked();
$('#btnSelectIBNPath', page).on("click.selectDirectory", function () {
config.EnableDeveloperTools = $('#chkEnableDeveloperTools', form).checked();
config.RunAtStartup = $('#chkRunAtStartup', form).checked();
config.SystemUpdateLevel = $('#selectAutomaticUpdateLevel', form).val();
Dashboard.selectDirectory({
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
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."
});
});
// Disable default form submission
return false;
}
};
$('#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");
}
$(document).on('pageshow', "#advancedConfigurationPage", AdvancedConfigurationPage.onPageShow);
});
$.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;
};
}
window.AdvancedConfigurationPage = new advancedConfigurationPage();
})(jQuery, document, window);