177 lines
8.4 KiB
HTML
177 lines
8.4 KiB
HTML
<html>
|
|
|
|
<link rel="stylesheet" type="text/css" href="../../lib/css/themes/jquery-ui/redmond/jquery-ui.min.css"/>
|
|
<script type="text/javascript" src="../../lib/js/jquery-1.11.1.min.js"></script>
|
|
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
|
|
<script type="text/javascript" src="../../lib/js/jquery-ui-1.10.3.full.min.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
|
|
<script type="text/javascript" src="../../js/translate.js"></script>
|
|
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
|
|
|
<style>
|
|
.number {
|
|
width: 70px
|
|
}
|
|
</style>
|
|
|
|
<script type="text/javascript" src="words.js"></script>
|
|
|
|
<script type="text/javascript">
|
|
function showHideSettings() {
|
|
if ($('#webInstance').val()) {
|
|
$('.no-if-extend').hide();
|
|
} else {
|
|
$('.no-if-extend').show();
|
|
if ($('#secure').prop('checked')) {
|
|
$('#_certPublic').show();
|
|
$('#_certPrivate').show();
|
|
$('#_certChained').show();
|
|
$('.le-settings').show();
|
|
|
|
if ($('#leEnabled').prop('checked')) {
|
|
$('.le-sub-settings').show();
|
|
if ($('#leUpdate').prop('checked')) {
|
|
$('.le-sub-settings-update').show();
|
|
} else {
|
|
$('.le-sub-settings-update').hide();
|
|
}
|
|
} else {
|
|
$('.le-sub-settings').hide();
|
|
}
|
|
} else {
|
|
$('#_certPublic').hide();
|
|
$('#_certPrivate').hide();
|
|
$('#_certChained').hide();
|
|
$('#auth').prop('checked', false);
|
|
$('.le-settings').hide();
|
|
}
|
|
if ($('#auth').prop('checked')) {
|
|
$('#defaultUser').val('admin');
|
|
$('.defaultUser').hide();
|
|
} else {
|
|
$('.defaultUser').show();
|
|
}
|
|
}
|
|
}
|
|
|
|
// the function loadSettings has to exist ...
|
|
function load(settings, onChange) {
|
|
if (!settings) return;
|
|
|
|
if (!settings.lePort) settings.lePort = 80;
|
|
|
|
getIPs(function(ips) {
|
|
for (var i = 0; i < ips.length; i++) {
|
|
$('#bind').append('<option value="' + ips[i].address + '">' + ips[i].name + '</option>');
|
|
}
|
|
$('#bind.value').val(settings.bind);
|
|
});
|
|
|
|
$('.value').each(function () {
|
|
var key = $(this).attr('id');
|
|
// example: select elements with id=key and class=value and insert value
|
|
if ($('#' + key + '.value').attr('type') == 'checkbox') {
|
|
$('#' + key + '.value').prop('checked', settings[key]).change(function() {
|
|
if ($('#auth').prop('checked')) {
|
|
$('#secure').prop('checked', true);
|
|
}
|
|
showHideSettings();
|
|
onChange();
|
|
});
|
|
} else {
|
|
$('#' + key + '.value').val(settings[key]).change(function() {
|
|
if (key === 'webInstance') showHideSettings();
|
|
onChange();
|
|
}).keyup(function() {
|
|
onChange();
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
fillSelectCertificates('#certPublic', 'public', settings.certPublic);
|
|
fillSelectCertificates('#certPublic', 'public', settings.certPublic);
|
|
fillSelectCertificates('#certPrivate', 'private', settings.certPrivate);
|
|
fillSelectCertificates('#certChained', 'chained', settings.certChained);
|
|
fillUsers('#defaultUser', settings.defaultUser);
|
|
|
|
if (typeof getExtendableInstances !== 'undefined') {
|
|
getExtendableInstances(function (result) {
|
|
if (result) {
|
|
var text = '';
|
|
for (var r = 0; r < result.length; r++) {
|
|
var name = result[r]._id.substring('system.adapter.'.length);
|
|
text += '<option value="' + name + '" ' + (settings.webInstance === name ? 'selected' : '') + '>' + name + '</option>';
|
|
}
|
|
$('#webInstance').append(text);
|
|
showHideSettings();
|
|
}
|
|
});
|
|
} else {
|
|
showHideSettings();
|
|
}
|
|
onChange(false);
|
|
}
|
|
|
|
// ... and the function save has to exist.
|
|
// you have to make sure the callback is called with the settings object as first param!
|
|
function save(callback) {
|
|
// example: select elements with class=value and build settings object
|
|
var obj = {};
|
|
$('.value').each(function () {
|
|
var $this = $(this);
|
|
if ($this.attr('type') == 'checkbox') {
|
|
obj[$this.attr('id')] = $this.prop('checked');
|
|
} else {
|
|
obj[$this.attr('id')] = $this.val();
|
|
}
|
|
});
|
|
|
|
if ($('#secure').prop('checked') && (!$('#certPrivate').val() || !$('#certPublic').val())) {
|
|
showMessage(_('Set certificates or load it first in the system settings (right top).'));
|
|
return;
|
|
}
|
|
|
|
callback(obj);
|
|
}
|
|
</script>
|
|
|
|
<!-- you have to put your config page in a div with id adapter-container -->
|
|
<div id="adapter-container">
|
|
|
|
<table><tr><td><img src="simple-api.png"></td><td><h3 class="translate">simpleAPI adapter settings</h3></td></tr></table>
|
|
|
|
<table>
|
|
<tr><td><label for="webInstance" class="translate">Extend WEB adapter:</label></td><td><select class="value" id="webInstance">
|
|
<option value="" class="translate">none</option>
|
|
<option value="*" class="translate">all</option>
|
|
</select></td></tr>
|
|
<tr class="no-if-extend"><td><label for="bind" class="translate">IP:</label></td><td> <select class="value" id="bind"></select></td></tr>
|
|
<tr class="no-if-extend"><td><label for="port" class="translate">Port:</label></td><td> <input class="value" id="port" size="5" maxlength="5"/></td></tr>
|
|
<tr class="no-if-extend"><td><label for="secure" class="translate">Secure(HTTPS):</label></td><td> <input class="value" id="secure" type="checkbox" /></td></tr>
|
|
<tr class="no-if-extend" id="_certPublic">
|
|
<td><label for="certPublic" class="translate">Public certificate:</label></td>
|
|
<td><select id="certPublic" class="value"></select></td>
|
|
</tr>
|
|
<tr class="no-if-extend" id="_certPrivate">
|
|
<td><label for="certPrivate" class="translate">Private certificate:</label></td>
|
|
<td><select id="certPrivate" class="value"></select></td>
|
|
</tr>
|
|
<tr class="no-if-extend" id="_certChained">
|
|
<td><label for="certChained" class="translate">Chained certificate:</label></td>
|
|
<td><select id="certChained" class="value"></select></td>
|
|
</tr>
|
|
<tr class="no-if-extend"><td><label for="auth" class="translate">Authentication:</label></td><td><input class="value" id="auth" type="checkbox" /></td></tr>
|
|
<tr class="no-if-extend defaultUser"><td><label for="defaultUser" class="translate">Run as:</label></td><td><select class="value" id="defaultUser"></select></td></tr>
|
|
<tr class="no-if-extend defaultUser"><td><label for="onlyAllowWhenUserIsOwner" class="translate">Allow only when User is Owner:</label></td><td><input class="value" id="onlyAllowWhenUserIsOwner" type="checkbox" /></td></tr>
|
|
<tr class="no-if-extend"><td colspan="2"> </td></tr>
|
|
<tr class="no-if-extend le-settings"><td colspan="2"><h3 class="translate">Let's Encrypt settings</h3></tr>
|
|
<tr class="no-if-extend le-settings"><td><label for="leEnabled" class="translate">Use Lets Encrypt certificates:</label></td><td><input class="value" id="leEnabled" type="checkbox" /></td></tr>
|
|
<tr class="no-if-extend le-settings le-sub-settings"><td><label for="leUpdate" class="translate">Use this instance for automatic update:</label></td><td><input class="value" id="leUpdate" type="checkbox" /></td></tr>
|
|
<tr class="no-if-extend le-settings le-sub-settings le-sub-settings-update"><td><label for="lePort" class="translate">Port to check the domain:</label></td><td><input class="value number" id="lePort" type="number" size="5" maxlength="5" /></td></tr>
|
|
|
|
</table>
|
|
</div>
|
|
</html>
|