yunkong2.rest/admin/index.html

213 lines
10 KiB
HTML
Raw Normal View History

2018-09-21 23:46:12 +08:00
<html>
<!-- these 4 files always have to be included -->
<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>
<!-- optional: use jqGrid
<link rel="stylesheet" type="text/css" href="../../lib/css/jqGrid/ui.jqgrid-4.5.4.css"/>
<script type="text/javascript" src="../../lib/js/jqGrid/jquery.jqGrid-4.5.4.min.js"></script>
<script type="text/javascript" src="../../lib/js/jqGrid/i18n/grid.locale-all.js"></script>
-->
<!-- optional: use multiselect
<link rel="stylesheet" type="text/css" href="../../lib/css/jquery.multiselect-1.13.css"/>
<script type="text/javascript" src="../../lib/js/jquery.multiselect-1.13.min.js"></script>
-->
<!-- these two file always have to be included -->
<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>
<!-- you have to define 2 functions in the global scope: -->
<script type="text/javascript">
// Dictionary (systemDictionary is global variable from adapter-settings.js)
systemDictionary = {
2018-09-21 23:49:05 +08:00
"rest adapter settings": {"de": "Beispiel", "ru": "Пример"},
2018-09-21 23:46:12 +08:00
"test1": {"en": "Test 1", "de": "Test 1", "ru": "Тест 1"},
"test2": {"en": "Test 2", "de": "Test 2", "ru": "Тест 2"},
"Run as:": {"de": "Laufen unter Anwender:", "ru": "Запустить от пользователя:"},
"IP:": {"de": "IP:", "ru": "IP:"},
"Port:": {"de": "Port:", "ru": "Порт:"},
"Secure(HTTPS):": {"de": "Verschlüsselung(HTTPS):", "ru": "Шифрование(HTTPS):"},
"Authentication:": {"de": "Authentifikation:", "ru": "Аутентификация:"},
"Listen on all IPs": {"en": "Listen on all IPs", "de": "An allen IP Adressen hören", "ru": "Открыть сокет на всех IP адресах"},
"help_tip": {
"en": "On save the adapter restarts with new configuration immediately",
"de": "Beim Speichern von Einstellungen der Adapter wird sofort neu gestartet.",
"ru": "Сразу после сохранения настроек драйвер перезапуститься с новыми значениями"
},
"Public certificate:": {"en": "Public certificate:", "de": "Publikzertifikat:", "ru": "'Public' сертификат:"},
"Private certificate:": {"en": "Private certificate:", "de": "Privatzertifikat:", "ru": "'Private' сертификат:"},
"Chained certificate:": {"en": "Chained certificate:", "de": "Kettenzertifikat:", "ru": "'Chained' сертификат:"},
"Let's Encrypt settings": {
"en": "Let's Encrypt settings",
"de": "Einstellungen Let's Encrypt",
"ru": "Настройкт Let's Encrypt"
},
"Use Lets Encrypt certificates:": {
"en": "Use Let's Encrypt certificates:",
"de": "Benutzen Let's Encrypt Zertifikate:",
"ru": "Использовать сертификаты Let's Encrypt:"
},
"Use this instance for automatic update:": {
"en": "Use this instance for automatic update:",
"de": "Benutze diese Instanz für automatische Updates:",
"ru": "Обновлять сертификаты в этом драйвере:"
},
"Port to check the domain:": {
"en": "Port to check the domain:",
"de": "Port um die Domain zu prüfen:",
"ru": "Порт для проверки доменного имени:"
}
};
function showHideSettings() {
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')) {
$('#secure').prop('checked', true);
$('#defaultUser').val('admin');
$('.defaultUser').hide();
$('#_ttl').show();
} else {
$('.defaultUser').show();
$('#_ttl').hide();
}
}
// the function loadSettings has to exist ...
function load(settings, onChange) {
if (!settings) return;
// this functions are loaded from library
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);
});
// example: select elements with id=key and class=value and insert value
$('.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() {
onChange();
});
} else {
$('#' + key + '.value').val(settings[key]).change(function() {
onChange();
}).keyup(function() {
onChange();
});
}
});
// Signal to admin, that no changes yet
onChange(false);
// this functions are loaded from library
fillSelectCertificates('#certPublic', 'public', settings.certPublic);
fillSelectCertificates('#certPrivate', 'private', settings.certPrivate);
fillSelectCertificates('#certChained', 'chained', settings.certChained);
fillUsers('#defaultUser', settings.defaultUser);
$('#auth').change(function () {
if ($(this).prop('checked')) $('#secure').prop('checked', true);
showHideSettings();
});
$('#secure').change(function () {
showHideSettings();
});
showHideSettings();
}
// ... 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();
}
});
callback(obj);
}
</script>
<!-- you have to put your config page in a div with id adapter-container -->
<div id="adapter-container">
<table><tr>
2018-09-21 23:49:05 +08:00
<td><img src="rest.png"/></td>
<td><h3 class="translate">rest adapter settings</h3></td>
2018-09-21 23:46:12 +08:00
</tr></table>
<table>
<tr><td class="translate">test1</td><td> <input class="value" id="test1"/></td></tr>
<tr><td class="translate">test2</td><td> <input class="value" id="test2"/></td></tr>
<tr><td colspan="2"><h4 class="translate">Server settings</h4></td></tr>
<tr><td class="translate">IP:</td><td> <select class="value" id="bind"></select></td></tr>
<tr><td class="translate">Port:</td><td> <input class="value" id="port" size="5" maxlength="5"/></td></tr>
<tr><td class="translate">Secure(HTTPS):</td><td> <input class="value" id="secure" type="checkbox" /></td></tr>
<tr><td class="translate">Authentication:</td><td><input class="value" id="auth" type="checkbox" /></td></tr>
<tr id="_certPublic">
<td class="translate">Public certificate:</td>
<td><select id="certPublic" class="value"></select></td>
</tr>
<tr id="_certPrivate">
<td class="translate">Private certificate:</td>
<td><select id="certPrivate" class="value"></select></td>
</tr>
<tr id="_certChained">
<td class="translate">Chained certificate:</td>
<td><select id="certChained" class="value"></select></td>
</tr>
<tr class="defaultUser"><td class="translate">Run as:</td><td><select class="value" id="defaultUser" /></td></tr>
<tr><td colspan="2"><h4 class="translate">Polling settings</h4></td></tr>
<tr><td class="translate">URL:</td><td> <input class="value" id="pollURL"/></td></tr>
<tr><td class="translate">Interval:</td><td> <input class="value" id="interval" size="7" maxlength="7"/></td></tr>
<tr><td colspan="2">&nbsp;</td></tr>
<tr class="le-settings"><td colspan="2"><h3 class="translate">Let's Encrypt settings</h3></tr>
<tr class="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="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="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>