iobroker.pvoutputorg
Version:
ioBroker Adapter for PvOutput.org
229 lines (179 loc) • 9.74 kB
HTML
<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">
function showHideSettings() {
var $useWeatherAdapter = $('#useWeatherAdapter');
if ($useWeatherAdapter.prop('checked')) {
console.log('show settings for Weather');
$('.col-OID-WeatherConditions').show();
}
else {
console.log('hide settings for Weather');
$('.col-OID-WeatherConditions').hide();
}
}
// 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) {
if (!settings.hasOwnProperty(key)) continue;
var $value = $('#' + key + '.value');
if ($value.attr('type') === 'checkbox') {
$value.prop('checked', settings[key]).on('change', function () {
showHideSettings();
onChange();
});
} else {
$value.val(settings[key]).on('change', function () {
console.log('on change');
showHideSettings();
onChange();
}).on('keyup', function () {
$(this).trigger('change');
});
}
}
myOnChange = onChange;
// Signal to admin, that no changes yet
onChange(false);
showHideSettings();
M.updateTextFields();
values2table('systems', settings.PVSystems, 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.PVSystems = 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">
<img src="pvoutputorg.png" class="logo">
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input type="text" id="timezone" class="value" />
<label for="timezone" class="translate">timezone</label>
</div>
</div>
<div class="row">
<div class="input-field col s3">
<input class="value number" id="readInterval" size="3" maxlength="3" min="1" max="59" type="number" />
<label for="readInterval" class="translate">readInterval</label>
</div>
<div class="input-field col s3">
<select id="writeInterval" class="value">
<option value="5" class="translate">5 minutes</option>
<option value="10" class="translate">10 minutes</option>
<option value="15" class="translate">15 minutes</option>
</select>
<label for="writeInterval" class="translate">writeInterval</label>
<!--
<input class="value number" id="writeInterval" size="3" maxlength="3" min="1" max="59" type="number" />
<label for="writeInterval" class="translate">writeInterval</label>
-->
</div>
<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="useWeatherAdapter" class="value" />
<label for="useWeatherAdapter" class="translate">useWeatherAdapter</label>
</div>
<div class="input-field col s6 col-OID-WeatherConditions">
<input type="text" id="OID_WeatherConditions" class="value" />
<label for="OID_WeatherConditions" class="translate">OID_WeatherConditions</label>
</div>
</div>
</div>
<!-- settings for systems -->
<div id="tab-systems" class="col s12 page">
<div class="row">
<div class="input-field col s12">
<span class="translate">DeleteSystemNoDeleteDP_hint</span>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<span class="translate">IsDonated_hint</span>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<span class="translate">Upload_hint</span>
</div>
</div>
<div class="row">
<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_col1" data-name="IsActive" data-type="checkbox" style="background: #64b5f6 " class="translate">IsActive</th>
<th id="tableSystems_col2" data-name="Name" style="width: 20%; background: #64b5f6 " class="translate">name</th>
<th id="tableSystems_col3" data-name="SystemId" style=" background: #64b5f6 " class="translate">SystemId</th>
<th id="tableSystems_col4" data-name="ApiKey" style=" background: #64b5f6 " class="translate">ApiKey</th>
<th id="tableSystems_col5" data-name="Upload" data-type="checkbox" style=" background: #64b5f6 " class="translate">Upload</th>
<th id="tableSystems_col6" data-name="CumulativeFlag" data-options="1;2;3" data-type="select" style="background: #64b5f6 " class="translate">CumulativeFlag</th>
<th id="tableSystems_col8" data-name="NetDataFlag" data-type="checkbox" style="background: #64b5f6 " class="translate">NetDataFlag</th>
<th id="tableSystems_col8" data-name="IsDonated" data-type="checkbox" style="background: #64b5f6 " class="translate">IsDonated</th>
<th data-buttons="up down delete" style="width: 100px; background: #64b5f6"></th>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>