UNPKG

iobroker.amtronwallbox

Version:
149 lines (111 loc) 5.89 kB
<html> <head> <!-- Load ioBroker scripts and styles--> <link rel="stylesheet" type="text/css" href="../../lib/css/fancytree/ui.fancytree.min.css" /> <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="../../lib/js/materialize.js"></script> <script type="text/javascript" src="../../lib/js/jquery-ui.min.js"></script> <script type="text/javascript" src="../../lib/js/jquery.fancytree-all.min.js"></script> <script type="text/javascript" src="../../js/translate.js"></script> <script type="text/javascript" src="../../js/adapter-settings.js"></script> <!-- my own styles --> <link rel="stylesheet" type="text/css" href="style.css" /> <script type="text/javascript" src="words.js"></script> <!-- you have to define 2 functions in the global scope: --> <script type="text/javascript"> // the function loadSettings has to exist ... function load(settings, onChange) { if (!settings) return; // example: select elements with id=key and class=value and insert value for (var key in settings) { // 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 () { $(this).trigger('change'); }); } } myOnChange = onChange; // Signal to admin, that no changes yet onChange(false); M.updateTextFields(); values2table('systems', settings.WallboxSystems, onChange, tableSystemsOnReady); } function tableSystemsOnReady() { } // ... 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); var id = $this.attr('id'); if ($this.attr('type') === 'checkbox') { obj[$this.attr('id')] = $this.prop('checked'); } else { obj[$this.attr('id')] = $this.val(); } }); obj.WallboxSystems = table2values('systems'); 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-systems" class="translate">systems</a></li> </ul> </div> <!-- main - settings --> <div id="tab-main" class="col s12 page"> <div class="row"> <div class="col s6 m4 l2"> <img src="amtronwallbox.png" class="logo"> </div> </div> <div class="row"> <div class="input-field col s12 m4 l3"> <input class="value number" id="readInterval" size="3" maxlength="3" type="number" /> <label for="readInterval" class="translate">readInterval</label> </div> </div> </div> <!-- settings for systems --> <div id="tab-systems" class="col s12 page"> <div class="col s12" id="systems"> <a class="btn-floating waves-effect waves-light blue table-button-add"><i class="material-icons">add</i></a> <div class="table-values-div"> <table id="table_systems" class="table-values" style="width: 100%;"> <thead> <tr> <th id="tableSystems_col5" data-name="IsActive" data-type="checkbox" style="background: #64b5f6 " class="translate">IsActive</th> <th id="tableSystems_col1" data-name="Name" style="width: 20%; background: #64b5f6 " class="translate">name</th> <th id="tableSystems_col2" data-name="IPAddress" style=" background: #64b5f6 " class="translate">IPAddress</th> <th id="tableSystems_col3" data-name="ApiKey" style=" background: #64b5f6 " class="translate">ApiKey</th> <th id="tableSystems_col4" data-name="Type" data-options="Compact;ChargeControl;Xtra" data-type="select" style="background: #64b5f6 " class="translate">Type</th> <th data-buttons="up down delete" style="width: 100px; background: #64b5f6"></th> </tr> </thead> </table> </div> </div> </div> </div> </div> </body> </html>