2016-09-11 14:02:32 -07:00
|
|
|
|
define(['jQuery', 'fnchecked', 'emby-checkbox'], function ($) {
|
2016-10-22 22:11:46 -07:00
|
|
|
|
'use strict';
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2015-05-14 10:16:29 -07:00
|
|
|
|
function onSubmit() {
|
|
|
|
|
var form = this;
|
2016-06-07 12:46:55 -07:00
|
|
|
|
var localAddress = form.querySelector('#txtLocalAddress').value;
|
|
|
|
|
var enableUpnp = $('#chkEnableUpnp', form).checked();
|
2015-05-14 10:16:29 -07:00
|
|
|
|
|
2016-06-07 12:46:55 -07:00
|
|
|
|
confirmSelections(localAddress, enableUpnp, function () {
|
2015-05-14 10:16:29 -07:00
|
|
|
|
|
2016-06-07 12:48:40 -07:00
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
2016-06-07 12:46:55 -07:00
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
2015-05-14 10:16:29 -07:00
|
|
|
|
|
2016-06-07 12:46:55 -07:00
|
|
|
|
config.HttpServerPortNumber = $('#txtPortNumber', form).val();
|
|
|
|
|
config.PublicPort = $('#txtPublicPort', form).val();
|
|
|
|
|
config.PublicHttpsPort = $('#txtPublicHttpsPort', form).val();
|
|
|
|
|
config.EnableHttps = $('#chkEnableHttps', form).checked();
|
|
|
|
|
config.HttpsPortNumber = $('#txtHttpsPort', form).val();
|
|
|
|
|
config.EnableUPnP = enableUpnp;
|
|
|
|
|
config.WanDdns = $('#txtDdns', form).val();
|
|
|
|
|
config.CertificatePath = $('#txtCertificatePath', form).val();
|
|
|
|
|
|
|
|
|
|
config.LocalNetworkAddresses = localAddress ? [localAddress] : [];
|
|
|
|
|
|
|
|
|
|
ApiClient.updateServerConfiguration(config).then(Dashboard.processServerConfigurationUpdateResult, Dashboard.processErrorResponse);
|
|
|
|
|
});
|
2015-05-14 10:16:29 -07:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Disable default form submission
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-07 12:46:55 -07:00
|
|
|
|
function confirmSelections(localAddress, enableUpnp, callback) {
|
|
|
|
|
|
2016-06-07 12:48:40 -07:00
|
|
|
|
if (localAddress || !enableUpnp) {
|
2016-06-07 12:46:55 -07:00
|
|
|
|
|
|
|
|
|
require(['alert'], function (alert) {
|
|
|
|
|
alert({
|
|
|
|
|
title: Globalize.translate('TitleHostingSettings'),
|
|
|
|
|
text: Globalize.translate('SettingsWarning')
|
|
|
|
|
}).then(callback);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-13 09:17:52 -07:00
|
|
|
|
function getTabs() {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
href: 'dashboardhosting.html',
|
|
|
|
|
name: Globalize.translate('TabHosting')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
href: 'serversecurity.html',
|
|
|
|
|
name: Globalize.translate('TabSecurity')
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
return function (view, params) {
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
var self = this;
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
function loadPage(page, config) {
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
$('#txtPortNumber', page).val(config.HttpServerPortNumber);
|
|
|
|
|
$('#txtPublicPort', page).val(config.PublicPort);
|
|
|
|
|
$('#txtPublicHttpsPort', page).val(config.PublicHttpsPort);
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2016-06-07 12:46:55 -07:00
|
|
|
|
page.querySelector('#txtLocalAddress').value = config.LocalNetworkAddresses[0] || '';
|
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
var chkEnableHttps = page.querySelector('#chkEnableHttps');
|
|
|
|
|
chkEnableHttps.checked = config.EnableHttps;
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
$('#txtHttpsPort', page).val(config.HttpsPortNumber);
|
|
|
|
|
|
|
|
|
|
$('#txtDdns', page).val(config.WanDdns || '');
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
var txtCertificatePath = page.querySelector('#txtCertificatePath');
|
|
|
|
|
txtCertificatePath.value = config.CertificatePath || '';
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
$('#chkEnableUpnp', page).checked(config.EnableUPnP);
|
2015-01-22 23:15:15 -07:00
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
onCertPathChange.call(txtCertificatePath);
|
|
|
|
|
|
|
|
|
|
Dashboard.hideLoadingMsg();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onCertPathChange() {
|
|
|
|
|
|
|
|
|
|
if (this.value) {
|
|
|
|
|
view.querySelector('#txtDdns').setAttribute('required', 'required');
|
|
|
|
|
} else {
|
|
|
|
|
view.querySelector('#txtDdns').removeAttribute('required');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#btnSelectCertPath', view).on("click.selectDirectory", function () {
|
2015-01-22 23:15:15 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
require(['directorybrowser'], function (directoryBrowser) {
|
2015-01-22 23:15:15 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
var picker = new directoryBrowser();
|
2015-01-22 23:15:15 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
picker.show({
|
2015-01-22 23:15:15 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
includeFiles: true,
|
|
|
|
|
includeDirectories: true,
|
2015-01-22 23:15:15 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
callback: function (path) {
|
2015-01-22 23:15:15 -07:00
|
|
|
|
|
2015-10-13 12:22:45 -07:00
|
|
|
|
if (path) {
|
2016-05-18 14:46:56 -07:00
|
|
|
|
$('#txtCertificatePath', view).val(path);
|
2015-10-13 12:22:45 -07:00
|
|
|
|
}
|
|
|
|
|
picker.close();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
header: Globalize.translate('HeaderSelectCertificatePath')
|
|
|
|
|
});
|
2015-01-22 23:15:15 -07:00
|
|
|
|
});
|
|
|
|
|
});
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2015-05-14 10:16:29 -07:00
|
|
|
|
$('.dashboardHostingForm').off('submit', onSubmit).on('submit', onSubmit);
|
2015-01-18 21:29:57 -07:00
|
|
|
|
|
2016-05-18 14:46:56 -07:00
|
|
|
|
view.querySelector('#txtCertificatePath').addEventListener('change', onCertPathChange);
|
|
|
|
|
|
|
|
|
|
view.addEventListener('viewshow', function (e) {
|
|
|
|
|
LibraryMenu.setTabs('adminadvanced', 0, getTabs);
|
|
|
|
|
Dashboard.showLoadingMsg();
|
|
|
|
|
|
|
|
|
|
ApiClient.getServerConfiguration().then(function (config) {
|
|
|
|
|
|
|
|
|
|
loadPage(view, config);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
2016-03-18 21:26:17 -07:00
|
|
|
|
});
|