@iobroker/socket-classes 0.4.1 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -0
- package/lib/socketCommands.js +34 -1
- package/lib/socketCommandsAdmin.js +0 -29
- package/lib/socketCommon.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,15 @@ io.close();
|
|
|
69
69
|
-->
|
|
70
70
|
|
|
71
71
|
## Changelog
|
|
72
|
+
### 0.4.4 (2022-06-09)
|
|
73
|
+
* (bluefox) Do not show requireLog message
|
|
74
|
+
|
|
75
|
+
### 0.4.3 (2022-06-03)
|
|
76
|
+
* (bluefox) Allowed call of getAdapterInstances for non admin
|
|
77
|
+
|
|
78
|
+
### 0.4.2 (2022-05-23)
|
|
79
|
+
* (bluefox) Corrected renameFile command for admin
|
|
80
|
+
|
|
72
81
|
### 0.4.1 (2022-05-23)
|
|
73
82
|
* (bluefox) Corrected changePassword command for admin
|
|
74
83
|
|
package/lib/socketCommands.js
CHANGED
|
@@ -253,6 +253,10 @@ class SocketCommands {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
+
isLogEnabled() {
|
|
257
|
+
return this.logEnabled;
|
|
258
|
+
}
|
|
259
|
+
|
|
256
260
|
subscribe(socket, type, pattern, patternFile) {
|
|
257
261
|
this.subscribes[type] = this.subscribes[type] || {};
|
|
258
262
|
|
|
@@ -800,7 +804,7 @@ class SocketCommands {
|
|
|
800
804
|
|
|
801
805
|
this.commands['renameFile'] = (socket, _adapter, oldName, newName, callback) => {
|
|
802
806
|
if (this._checkPermissions(socket, 'rename', callback, oldName)) {
|
|
803
|
-
this.adapter.
|
|
807
|
+
this.adapter.rename(_adapter, oldName, newName, {user: socket._acl.user}, (err, ...args) =>
|
|
804
808
|
SocketCommands._fixCallback(callback, err, ...args));
|
|
805
809
|
}
|
|
806
810
|
};
|
|
@@ -875,6 +879,35 @@ class SocketCommands {
|
|
|
875
879
|
this.commands['subscribeFiles'] = (socket, id, pattern, callback) => this._subscribeFiles(socket, id, pattern, callback);
|
|
876
880
|
|
|
877
881
|
this.commands['unsubscribeFiles'] = (socket, id, pattern, callback) => this._unsubscribeFiles(socket, id, pattern, callback);
|
|
882
|
+
|
|
883
|
+
this.commands['getAdapterInstances'] = (socket, adapterName, callback) => {
|
|
884
|
+
if (typeof callback === 'function') {
|
|
885
|
+
if (this._checkPermissions(socket, 'getObject', callback)) {
|
|
886
|
+
let _adapterName = adapterName || this.adapterName || '';
|
|
887
|
+
if (_adapterName) {
|
|
888
|
+
_adapterName += '.'
|
|
889
|
+
}
|
|
890
|
+
this.adapter.getObjectView('system', 'instance',
|
|
891
|
+
{startkey: `system.adapter.${_adapterName}`, endkey: `system.adapter.${_adapterName}\u9999`},
|
|
892
|
+
(err, doc) => {
|
|
893
|
+
if (err) {
|
|
894
|
+
callback(err);
|
|
895
|
+
} else {
|
|
896
|
+
callback(null, doc.rows
|
|
897
|
+
.map(item => {
|
|
898
|
+
const obj = item.value;
|
|
899
|
+
if (obj.common) {
|
|
900
|
+
delete obj.common.news;
|
|
901
|
+
}
|
|
902
|
+
this._fixAdminUI(obj);
|
|
903
|
+
return obj;
|
|
904
|
+
})
|
|
905
|
+
.filter(obj => obj && (!adapterName || (obj.common && obj.common.name === adapterName))));
|
|
906
|
+
}
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
};
|
|
878
911
|
}
|
|
879
912
|
|
|
880
913
|
__initCommandsStates() {
|
|
@@ -830,35 +830,6 @@ class SocketCommandsAdmin extends SocketCommands {
|
|
|
830
830
|
}
|
|
831
831
|
};
|
|
832
832
|
|
|
833
|
-
this.commands['getAdapterInstances'] = (socket, adapterName, callback) => {
|
|
834
|
-
if (typeof callback === 'function') {
|
|
835
|
-
if (this._checkPermissions(socket, 'getObject', callback)) {
|
|
836
|
-
let _adapterName = adapterName || this.adapterName || '';
|
|
837
|
-
if (_adapterName) {
|
|
838
|
-
_adapterName += '.'
|
|
839
|
-
}
|
|
840
|
-
this.adapter.getObjectView('system', 'instance',
|
|
841
|
-
{startkey: `system.adapter.${_adapterName}`, endkey: `system.adapter.${_adapterName}\u9999`},
|
|
842
|
-
(err, doc) => {
|
|
843
|
-
if (err) {
|
|
844
|
-
callback(err);
|
|
845
|
-
} else {
|
|
846
|
-
callback(null, doc.rows
|
|
847
|
-
.map(item => {
|
|
848
|
-
const obj = item.value;
|
|
849
|
-
if (obj.common) {
|
|
850
|
-
delete obj.common.news;
|
|
851
|
-
}
|
|
852
|
-
this._fixAdminUI(obj);
|
|
853
|
-
return obj;
|
|
854
|
-
})
|
|
855
|
-
.filter(obj => obj && (!adapterName || (obj.common && obj.common.name === adapterName))));
|
|
856
|
-
}
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
};
|
|
861
|
-
|
|
862
833
|
this.commands['getAdapters'] = (socket, adapterName, callback) => {
|
|
863
834
|
if (typeof callback === 'function' && this._checkPermissions(socket, 'getObject', callback)) {
|
|
864
835
|
this.adapter.getObjectView('system', 'adapter',
|
package/lib/socketCommon.js
CHANGED
|
@@ -266,7 +266,7 @@ class SocketCommon {
|
|
|
266
266
|
this._updateConnectedInfo();
|
|
267
267
|
|
|
268
268
|
// Disable logging if no one browser is connected
|
|
269
|
-
if (this.adapter.requireLog) {
|
|
269
|
+
if (this.adapter.requireLog && this.commands && this.commands.isLogEnabled()) {
|
|
270
270
|
this.adapter.log.debug('Disable logging, because no one socket connected');
|
|
271
271
|
this.adapter.requireLog(!!(this.server && this.server.engine && this.server.engine.clientsCount));
|
|
272
272
|
}
|