iobroker.sbfspot
Version:
sbfspot (SMA inverter) Adapter
269 lines (216 loc) • 10.2 kB
HTML
<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 $type = $('#databasetype');
if ($type.prop('value') == "mySQL") {
$('.col-mysql-ip').show();
$('.col-mysql-ip-descr').show();
$('.col-mysql-port').hide();
$('.col-mysql-port-descr').hide();
$('.col-mysql-user').show();
$('.col-mysql-password').show();
$('.col-mysql-name').show();
$('.col-mysql-path').hide();
$('.col-mysql-path-descr').hide();
}
else if ($type.prop('value') == "MariaDB") {
$('.col-mysql-ip').show();
$('.col-mysql-ip-descr').show();
$('.col-mysql-port').show();
$('.col-mysql-port-descr').show();
$('.col-mysql-user').show();
$('.col-mysql-password').show();
$('.col-mysql-name').show();
$('.col-mysql-path').hide();
$('.col-mysql-path-descr').hide();
}
else if ($type.prop('value') == "sqlite") {
$('.col-mysql-ip').hide();
$('.col-mysql-ip-descr').hide();
$('.col-mysql-port').hide();
$('.col-mysql-port-descr').hide();
$('.col-mysql-user').hide();
$('.col-mysql-password').hide();
$('.col-mysql-name').hide();
$('.col-mysql-path').show();
$('.col-mysql-path-descr').show();
}
}
function CheckSettings(settings, onChange) {
console.log("start checksettings");
//just to be compatible with older versions...
if (typeof settings['databasetype'] == 'undefined') {
onChange(true);
$("#databasetype").attr("checked", true);
$('#databasetype.value').prop('checked', settings['databasetype']).change(function () {
onChange();
});
}
}
// 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 () {
showHideSettings();
onChange();
});
} else {
$('#' + key + '.value').val(settings[key]).change(function () {
showHideSettings();
onChange();
}).keyup(function () {
$(this).trigger('change');
});
}
}
// Signal to admin, that no changes yet
onChange(false);
showHideSettings();
CheckSettings(settings, onChange);
M.updateTextFields();
}
// ... 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) {
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();
}
});
callback(obj);
}
</script>
<style>
.adapter-body {
overflow: hidden ;
}
</style>
</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-mysql" class="translate">mySQL / MariaDB</a></li>
<li class="tab col s2 le-settings"><a href="#tab-sqlite" class="translate">SQLITE</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="sbfspot.png" class="logo">
</div>
</div>
<div class="row">
<div class="col s6 ">
<span class="translate">Attention</span>
</div>
</div>
<div class="row">
<form class="col s6 ">
<div class="row">
<label class="translate">install_date</label>
<input type="text" id="install_date" class="value" />
</div>
</form>
<div class="col s6">
<span class="translate">install_date_desc</span>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<select id="databasetype" class="value">
<option value="mySQL" class="translate">mySQL</option>
<option value="MariaDB" class="translate">MariaDB</option>
<option value="sqlite" class="translate">sqlite</option>
</select>
<label for="databasetype" class="translate">type_of_DB</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input type="checkbox" id="GetDataOnlyWhenDaylight" class="value" />
<label for="GetDataOnlyWhenDaylight" class="translate">GetDataOnlyWhenDaylight</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input type="checkbox" id="History4Vis2" class="value" />
<label for="History4Vis2" class="translate">History4Vis2</label>
</div>
</div>
</div>
<!-- settings for mySQL / MariaDB -->
<div id="tab-mysql" class="col s12 page-mysql" >
<div class="row">
<div class="input-field col s6 col-mysql-ip">
<input type="text" id="sbfspotIP" class="value" />
<label for="sbfspotIP" class="translate">sbfspot_DB_IP</label>
</div>
<div class="col s6 m8 l5 col-mysql-ip-descr">
<span class="translate">sbfspot_DB_IP_descr</span>
</div>
</div>
<div class="row">
<div class="input-field col s6 col-mysql-port">
<input type="number" id="sbfspotPort" class="value" />
<label for="sbfspotPort" class="translate">sbfspot_DB_port</label>
</div>
<div class="col s6 col-mysql-port-descr">
<span class="translate">sbfspot_DB_port_descr</span>
</div>
</div>
<div class="row">
<div class="input-field col s6 col-mysql-user">
<input type="text" id="sbfspotUser" class="value" />
<label for="sbfspotUser" class="translate">sbfspot_DB_user</label>
</div>
<div class="input-field col s6 col-mysql-password">
<input type="password" id="sbfspotPassword" class="value" />
<label for="sbfspotPassword" class="translate">sbfspot_DB_password</label>
</div>
</div>
<div class="row">
<div class="input-field col s6 col-mysql-name">
<input type="text" id="sbfspotDatabasename" class="value" />
<label for="sbfspotDatabasename" class="translate">sbfspot_DB_databasename</label>
</div>
</div>
</div>
<!-- settings for sqlite -->
<div id="tab-sqlite" class="col s12 page-sqlite">
<div class="row">
<div class="input-field col s6 col-mysql-path">
<input type="text" id="sqlite_path" class="value" />
<label for="sqlite_path" class="translate">path_to_DB_file</label>
</div>
<div class="col s6 m8 l5 col-mysql-path-descr">
<span class="translate">path_to_DB_file_descr</span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>