Skip to content

Commit

Permalink
Corrected select dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Dec 29, 2024
1 parent 23d89c2 commit bb4bf62
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 1,346 deletions.
46 changes: 24 additions & 22 deletions nodes/ioBroker.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<script type="text/javascript" src="selectID.js"></script>

<script type="text/javascript">
window.ioBrokerAdmin = {"port":8081,"host":"","protocol":"https:"}; // THIS LINE WILL BE CHANGED FOR SELECT ID
window.ioBrokerAdmin = {"port":8081,"host":"","protocol":"http:"}; // THIS LINE WILL BE CHANGED FOR SELECT ID

function readData() {
return new Promise((resolve, reject) => {
console.log('Connecting...');
var socket = new WebSocket('wss://' + window.location.hostname + ':8081?sid=' + Date.now()); // THIS LINE WILL BE CHANGED FOR ADMIN
var socket = new WebSocket('ws://' + window.location.hostname + ':8081?sid=' + Date.now()); // THIS LINE WILL BE CHANGED FOR ADMIN

if (!socket) {
console.warn('Authentication must be disabled to support the objects read!');
Expand Down Expand Up @@ -149,37 +149,39 @@
}).click(function () {
if (window.ioBrokerAdmin) {
let selectDialog = document.getElementById('iob-select-id');
window._iobOnSelected = function (newId, newObj, oldId, oldObj) {
let selectDialog = document.getElementById('iob-select-id');
if (selectDialog) {
selectDialog.setAttribute('open', 'false');
}

if (newId) {
$('#node-input-topic').val(newId);
if (newObj) {
var oldName = $('#node-input-name').val();
if (!oldName || !oldObj || (oldObj.common && oldName === oldObj.common.name && newObj.common)) {
$('#node-input-name').val(newObj.common.name);
}
if (typeof onChange === 'function') {
onChange(newId, oldId, newObj, oldObj);
}
}
}
};
if (!selectDialog) {
selectDialog = document.createElement('iobroker-select-id');
selectDialog.setAttribute('id', 'iob-select-id');
selectDialog.setAttribute('port', window.ioBrokerAdmin.port);
selectDialog.setAttribute('host', window.ioBrokerAdmin.host);
selectDialog.setAttribute('protocol', window.ioBrokerAdmin.protocol);
selectDialog.setAttribute('language', RED.i18n.lang());
window._iobOnSelected = function (newId, newObj, oldId, oldObj) {
let selectDialog = document.getElementById('iob-select-id');
if (selectDialog) {
selectDialog.setAttribute('open', 'false');
}

if (newId) {
$('#node-input-topic').val(newId);
if (newObj) {
var oldName = $('#node-input-name').val();
if (!oldName || !oldObj || (oldObj.common && oldName === oldObj.common.name && newObj.common)) {
$('#node-input-name').val(newObj.common.name);
}
if (typeof onChange === 'function') {
onChange(newId, oldId, newObj, oldObj);
}
}
}
};
selectDialog.setAttribute('onclose', '_iobOnSelected');
selectDialog.setAttribute('all', allowAll ? 'true' : 'false');
selectDialog.setAttribute('selected', $('#node-input-topic').val());
selectDialog.setAttribute('open', 'true');
document.body.appendChild(selectDialog);
} else {
selectDialog.setAttribute('all', allowAll ? 'true' : 'false');
selectDialog.setAttribute('selected', $('#node-input-topic').val());
selectDialog.setAttribute('open', 'true');
}
Expand Down Expand Up @@ -649,7 +651,7 @@
},
oneditprepare: function () {
initSelectId(true, function (newId) {
if (newId.indexOf('*') === -1) {
if (!newId.includes('*')) {
newId += '.*';
$('#node-input-topic').val(newId);
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
"release-patch": "release-script patch --yes",
"release-minor": "release-script minor --yes",
"release-major": "release-script major --yes",
"update-packages": "ncu --upgrade"
"update-packages": "ncu --upgrade && cd src-object-selector && ncu --upgrade",
"npm": "npm i && cd src-object-selector && npm i"
},
"readmeFilename": "README.md"
}
Loading

0 comments on commit bb4bf62

Please sign in to comment.