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

86 lines
2.6 KiB
JavaScript
Raw Normal View History

2015-01-18 21:29:57 -07:00
(function ($, document, window) {
function loadPage(page, config) {
$('#txtPortNumber', page).val(config.HttpServerPortNumber);
$('#txtPublicPort', page).val(config.PublicPort);
2015-01-18 21:53:28 -07:00
$('#txtPublicHttpsPort', page).val(config.PublicHttpsPort);
2015-01-18 21:29:57 -07:00
$('#chkEnableHttps', page).checked(config.EnableHttps).checkboxradio('refresh');
$('#txtHttpsPort', page).val(config.HttpsPortNumber);
$('#txtDdns', page).val(config.WanDdns || '');
2015-01-22 23:15:15 -07:00
$('#txtCertificatePath', page).val(config.CertificatePath || '');
2015-01-18 21:29:57 -07:00
$('#chkEnableUpnp', page).checked(config.EnableUPnP).checkboxradio('refresh');
Dashboard.hideLoadingMsg();
}
$(document).on('pageshow', "#dashboardHostingPage", function () {
Dashboard.showLoadingMsg();
var page = this;
ApiClient.getServerConfiguration().done(function (config) {
loadPage(page, config);
});
}).on('pageinit', "#dashboardHostingPage", function () {
var page = this;
2015-01-22 23:15:15 -07:00
$('#btnSelectCertPath', page).on("click.selectDirectory", function () {
var picker = new DirectoryBrowser(page);
picker.show({
includeFiles: true,
includeDirectories: true,
callback: function (path) {
if (path) {
$('#txtCertificatePath', page).val(path);
}
picker.close();
},
header: Globalize.translate('HeaderSelectCertificatePath')
});
});
2015-01-18 21:29:57 -07:00
});
window.DashboardHostingPage = {
onSubmit: function () {
Dashboard.showLoadingMsg();
var form = this;
ApiClient.getServerConfiguration().done(function (config) {
config.HttpServerPortNumber = $('#txtPortNumber', form).val();
config.PublicPort = $('#txtPublicPort', form).val();
2015-01-18 21:53:28 -07:00
config.PublicHttpsPort = $('#txtPublicHttpsPort', form).val();
2015-01-18 21:29:57 -07:00
config.EnableHttps = $('#chkEnableHttps', form).checked();
config.HttpsPortNumber = $('#txtHttpsPort', form).val();
config.EnableUPnP = $('#chkEnableUpnp', form).checked();
config.WanDdns = $('#txtDdns', form).val();
2015-01-22 23:15:15 -07:00
config.CertificatePath = $('#txtCertificatePath', form).val();
2015-01-18 21:29:57 -07:00
ApiClient.updateServerConfiguration(config).done(Dashboard.processServerConfigurationUpdateResult);
});
// Disable default form submission
return false;
}
};
})(jQuery, document, window);