Skip to content

Commit

Permalink
0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hombach committed Mar 15, 2021
1 parent 4f14551 commit 4c36cf5
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 145 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Adapter for reading go-eCharger data. Adapter creates some states and updates se
To connect to the go-eCharger type in its IP-address in the config.

## Changelog
### 0.6.0 (15.03.2021)
* (HombachC) fix error in forreign state popup
### 0.5.2 (02.03.2021)
* (HombachC) bumped dependencies
### 0.5.1 (06.01.2021)
Expand Down
47 changes: 47 additions & 0 deletions admin/img/info-big.png_README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
We are using selectID.js (iobroker/node_modules/iobroker.admin/www/lib/js/selectID.js).


/**********initSelectId ## How to use
<!-- Somewhere in HTML -->
<div id="dialog-select-member" style="display: none"></div>

// In Javascript
// Name "dialog-select-member" is important, because for that exist the CSS classes
// Important to have "admin/img/info-big.png" in too, because this icon will be loaded if no icon found, elsewise we have endless loop
let selectId;
function initSelectId (cb) {
if (selectId) return cb ? cb(selectId) : selectId;
socket.emit('getObjects', function (err, res) {
if (!err && res) {
selectId = $('#dialog-select-member').selectId('init', {
noMultiselect: true,
objects: res,
imgPath: '../../lib/css/fancytree/',
filter: {type: 'state'},
name: 'adapter-select-state',
texts: {
select: _('Select'),
cancel: _('Cancel'),
all: _('All'),
id: _('ID'),
name: _('Name'),
role: _('Role'),
room: _('Room'),
value: _('Value'),
selectid: _('Select ID'),
from: _('From'),
lc: _('Last changed'),
ts: _('Time stamp'),
wait: _('Processing...'),
ack: _('Acknowledged'),
selectAll: _('Select all'),
unselectAll: _('Deselect all'),
invertSelection: _('Invert selection')
},
columns: ['image', 'name', 'role', 'room', 'value']
});
cb && cb(selectId);
}
});
}
*/
159 changes: 17 additions & 142 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,152 +18,27 @@
<!-- Load our own files -->
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="words.js"></script>
<script type="text/javascript" src="index_m.js"></script>

<style>
</style>

<script type="text/javascript">
// This will be called by the admin adapter when the settings page loads
function load(settings, onChange) {
// example: select elements with id=key and class=value and insert value
if (!settings) return;
$('.value').each(function () {
var $key = $(this);
var id = $key.attr('id');
if ($key.attr('type') === 'checkbox') {
// do not call onChange direct, because onChange could expect some arguments
$key.prop('checked', settings[id])
.on('change', () => onChange())
;
} else {
// do not call onChange direct, because onChange could expect some arguments
$key.val(settings[id])
.on('change', () => onChange())
.on('keyup', () => onChange())
;
}
});

// NEW, NOT WORKING
$('#StateHomeSolarPowerPopUp').on('click', function () {
initSelectId(function (sid) {
sid.selectId('show', $('#StateHomeSolarPower').val(), function (newId) {
if (newId) {
$('#StateHomeSolarPower').val(newId).trigger('change');
}
});
});
});

$('#StateHomeBatSocPopUp').on('click', function () {
window.alert("StateHomeBatSocPopUp! " + $('#StateHomeBatSoc').val());
initSelectId(function (sid) {
sid.selectId('show', $('#StateHomeBatSoc').val(), function (newId) {
if (newId) {
window.alert("NewID!!");
$('#StateHomeBatSoc').val(newId).trigger('change');
}
});
});
});

$('#StateHomePowerConsumptionPopUp').on('click', function () {
initSelectId(function (sid) {
sid.selectId('show', $('#StateHomePowerConsumption').val(), function (newId) {
if (newId) {
$('#StateHomePowerConsumption').val(newId).trigger('change');
}
});
});
});
// END NEW */

onChange(false);
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
if (M) M.updateTextFields();
}


// This will be called by the admin adapter when the user presses the save button
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);
}


// NEW from BlueFox, Not Working
var selectId;
function initSelectId(callback) {
if (selectId) return callback(selectId);
window.alert("initSelectId");
socket.emit('getObjects', function (err, objs) {
selectId = $('#dialog-select-member').selectId('init', {
noMultiselect: true,
objects: objs,
imgPath: '../../lib/css/fancytree/',
name: 'select-foreign-state',
});
window.alert("Error: " + err);
window.alert(res);
callback(selectId);
});
}

/*
function initSelectId(cb) {
if (selectId) return cb(selectId);
window.alert("initSelectId");
socket.emit('getObjects', function (err, res) {
if (!err && res) {
selectId = $('#dialog-select-member').selectId('init', {
noMultiselect: true,
objects: res,
imgPath: '../../lib/css/fancytree/',
filter: { type: 'state' },
name: 'select-foreign-state',
texts: {
select: _('Select'),
cancel: _('Cancel'),
all: _('All'),
id: _('ID'),
name: _('Name'),
role: _('Role'),
room: _('Room'),
value: _('Value'),
selectid: _('Select ID'),
from: _('From'),
lc: _('Last changed'),
ts: _('Time stamp'),
wait: _('Processing...'),
ack: _('Acknowledged'),
selectAll: _('Select all'),
unselectAll: _('Deselect all'),
invertSelection: _('Invert selection')
},
columns: ['image', 'name', 'role', 'room']
});
window.alert("Error: " + err);
window.alert(res);
cb && cb(selectId);
}
});
}
// END NEW */

</script>
</head>

<body>
<div class="m adapter-container">
<div id="dialog-select-member" class="modal modal-fixed-footer">
<div class="modal-content">
<div class="row">
<div class="col s12 title"></div>
</div>
<div class="row">
<div class="col s12 dialog-content">
</div>
</div>
</div>
<div class="modal-footer">
<a class="modal-action modal-close waves-effect waves-green btn btn-set"><i class="large material-icons left">check_circle</i><span class="translate">Select</span></a>
<a class="modal-action modal-close waves-effect waves-green btn btn-close"><i class="large material-icons left">cancel</i><span class="translate">Cancel</span></a>
</div>
</div>

<div class="row">
<div class="col s12 m4 l2">
Expand Down Expand Up @@ -201,7 +76,7 @@
<a id="StateHomeBatSocPopUp" class="btn"><i class="material-icons">settings</i><span></span></a>
</div>
</div>

<div class="row">
<div class="col s5 m5 l5 input-field">
<input type="text" class="value" id="StateHomePowerConsumption" />
Expand Down
109 changes: 109 additions & 0 deletions admin/index_m.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// This will be called by the admin adapter when the settings page loads
function load(settings, onChange) {
// example: select elements with id=key and class=value and insert value
if (!settings) return;
$('.value').each(function () {
var $key = $(this);
var id = $key.attr('id');
if ($key.attr('type') === 'checkbox') {
// do not call onChange direct, because onChange could expect some arguments
$key.prop('checked', settings[id])
.on('change', () => onChange())
;
} else {
// do not call onChange direct, because onChange could expect some arguments
$key.val(settings[id])
.on('change', () => onChange())
.on('keyup', () => onChange())
;
}
});

$('#StateHomeSolarPowerPopUp').on('click', function () {
initSelectId(function (sid) {
sid.selectId('show', $('#StateHomeSolarPower').val(), function (newId) {
if (newId) {
$('#StateHomeSolarPower').val(newId).trigger('change');
}
});
});
});

$('#StateHomeBatSocPopUp').on('click', function () {
initSelectId(function (sid) {
sid.selectId('show', $('#StateHomeBatSoc').val(), function (newId) {
if (newId) {
$('#StateHomeBatSoc').val(newId).trigger('change');
}
});
});
});

$('#StateHomePowerConsumptionPopUp').on('click', function () {
initSelectId(function (sid) {
sid.selectId('show', $('#StateHomePowerConsumption').val(), function (newId) {
if (newId) {
$('#StateHomePowerConsumption').val(newId).trigger('change');
}
});
});
});

onChange(false);
// reinitialize all the Materialize labels on the page if you are dynamically adding inputs:
if (M) M.updateTextFields();
}


// This will be called by the admin adapter when the user presses the save button
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);
}


let selectId;
function initSelectId(callback) {
if (selectId) return callback(selectId);
socket.emit('getObjects', function (err, objs) {
if (!err && objs) {
selectId = $('#dialog-select-member').selectId('init', {
noMultiselect: true,
objects: objs,
imgPath: '../../lib/css/fancytree/',
filter: { type: 'state' },
name: 'adapter-select-state',
texts: {
select: _('Select'),
cancel: _('Cancel'),
all: _('All'),
id: _('ID'),
name: _('Name'),
role: _('Role'),
room: _('Room'),
value: _('Value'),
selectid: _('Select ID'),
from: _('From'),
lc: _('Last changed'),
ts: _('Time stamp'),
wait: _('Processing...'),
ack: _('Acknowledged'),
selectAll: _('Select all'),
unselectAll: _('Deselect all'),
invertSelection: _('Invert selection')
},
columns: ['image', 'name', 'role']
});
callback(selectId);
}
});
}
6 changes: 5 additions & 1 deletion admin/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
overflow: initial;
}

/* Add your styles here */
/* Add your styles here */

#dialog-select-member {
z-index: 9999 !important;
}
5 changes: 4 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"common": {
"name": "go-e-charger",
"version": "0.5.2",
"version": "0.6.0",
"title": "go-eCharger",
"titleLang": {
"en": "go-eCharger",
Expand Down Expand Up @@ -43,6 +43,9 @@
"connectionType": "local",
"dataSource": "poll",
"news": {
"0.6.0": {
"en": "fix error in forreign state popup"
},
"0.5.2": {
"en": "bumped dependencies"
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iobroker.go-e-charger",
"version": "0.5.2",
"version": "0.6.0",
"description": "Adapter for reading go-eCharger data",
"author": "hombach <NPM@Homba.ch>",
"homepage": "https://github.com/hombach/ioBroker.go-e-charger",
Expand Down

0 comments on commit 4c36cf5

Please sign in to comment.