UNPKG

yunkong2.socketio

Version:

This adapter allows to communicate different web applications with yunkong2.

209 lines (196 loc) 8.78 kB
<html> <head> <link rel="stylesheet" type="text/css" href="../../css/adapter.css"/> <link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css"> <script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script> <script type="text/javascript" src="../../socket.io/socket.io.js"></script> <script type="text/javascript" src="../../js/translate.js"></script> <script type="text/javascript" src="../../lib/js/materialize.js"></script> <script type="text/javascript" src="../../js/adapter-settings.js"></script> <script type="text/javascript" src="words.js"></script> <script type="text/javascript"> function showHideSettings() { var $secure = $('#secure'); var $auth = $('#auth'); if ($secure.prop('checked')) { $('.col-certPublic').show(); $('.col-certPrivate').show(); $('.col-certChained').show(); $('.le-settings').removeClass('disabled'); $auth.removeClass('disabled'); 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 { $('.col-certPublic').hide(); $('.col-certPrivate').hide(); $('.col-certChained').hide(); if ($auth.prop('checked')) { showToast(_('Please activate secure communication')); $auth.prop('checked', false); } $auth.addClass('disabled'); $('.le-settings').addClass('disabled'); } if ($auth.prop('checked')) { $secure.prop('checked', true); $('#defaultUser').val('admin'); $('.col-defaultUser').hide(); $('.col-ttl').show(); } else { $('.col-defaultUser').show(); $('.col-ttl').hide(); } } // the function loadSettings has to exist ... function load(settings, onChange) { if (!settings) return; 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).select(); }); if (!settings.lePort) settings.lePort = 80; $('.value').each(function () { var key = $(this).attr('id'); var $value = $('#' + key + '.value'); if ($value.attr('type') === 'checkbox') { $value.prop('checked', settings[key]).change(function() { showHideSettings(); onChange(); }); } else { $value.val(settings[key]).change(function() { onChange(); }).keyup(function() { onChange(); }); } }); onChange(false); fillSelectCertificates('#certPublic', 'public', settings.certPublic); fillSelectCertificates('#certPrivate', 'private', settings.certPrivate); fillSelectCertificates('#certChained', 'chained', settings.certChained); fillUsers('#defaultUser', settings.defaultUser); showHideSettings(); } function save(callback) { 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())) { showToast(null, _('Set certificates or load it first in the system settings (right top).')); return; } callback(obj); } </script> </head> <body> <!-- you have to put your config page in a div with id adapter-container --> <div class="m adapter-container"> <div class="row"> <div class="col s12"> <ul class="tabs"> <li class="tab col s2"><a href="#tab-main" class="translate active">Main settings</a></li> <li class="tab col s2 le-settings"><a href="#tab-le" class="translate">Let's Encrypt SSL</a></li> </ul> </div> <div id="tab-main" class="col s12 page"> <div class="row"> <div class="col s12 m4 l2"> <img src="socketio.png" class="logo"> </div> </div> <div class="row"> <div class="col s12 m8 l5"> <select class="value" id="bind"></select> <label class="translate" for="bind">IP:</label> </div> <div class="col s12 m4 l1"> <input class="value number" id="port" min="1" max="65565" type="number"/> <label class="translate" for="port">Port:</label> </div> </div> <div class="row"> <div class="col s12 m3"> <input class="value" id="secure" type="checkbox" /> <label class="translate" for="secure">Secure(HTTPS):</label> </div> <div class="col s12 m3 col-certPublic"> <select id="certPublic" class="value"></select> <label class="translate" for="certPublic">Public certificate:</label> </div> <div class="col s12 m3 col-certPrivate"> <select id="certPrivate" class="value"></select> <label class="translate" for="certPrivate">Private certificate:</label> </div> <div class="col s12 m3 col-certChained"> <select id="certChained" class="value"></select> <label class="translate" for="certChained">Chained certificate:</label> </div> </div> <div class="row"> <div class="col s12 m3"> <input class="value" id="auth" type="checkbox" /> <label class="translate" for="auth">Authentication:</label> </div> <div class="col s12 m3 col-defaultUser"> <select class="value" id="defaultUser"></select> <label class="translate" for="defaultUser">Run as:</label> </div> <div class="col s12 m3 col-ttl"> <input class="value" id="ttl" /> <label class="translate" for="ttl">Login timeout(sec):</label> </div> </div> <div class="row socketio"> <div class="col s12 m3"> <input type="checkbox" class="value" id="forceWebSockets"/> <span class="translate" for="forceWebSockets">Force Web-Sockets:</span> </div> </div> </div> <div id="tab-le" class="col s12 page"> <div class="row"> <div class="col s12"> <img src="../../img/le.png" class="logo-le"> </div> </div> <div class="row"> <div class="col s11"> <input class="value" id="leEnabled" type="checkbox" data-link="https://git.spacen.net/yunkong2/yunkong2.admin#lets-encrypt-certificates"/> <label for="leEnabled" class="translate">Use Lets Encrypt certificates:</label> </div> </div> <div class="row le-sub-settings"> <div class="col s11"> <input class="value" id="leUpdate" type="checkbox" data-link="https://git.spacen.net/yunkong2/yunkong2.admin#lets-encrypt-certificates"/> <label for="leUpdate" class="translate">Use this instance for automatic update:</label> </div> </div> <div class="row le-sub-settings le-sub-settings-update"> <div class="col s11 m4 l2"> <input class="value number" id="lePort" type="number" size="5" maxlength="5" data-link="https://git.spacen.net/yunkong2/yunkong2.admin#lets-encrypt-certificates"/> <label for="lePort" class="translate">Port to check the domain:</label> </div> </div> </div> </div> </div> </body> </html>