fix(all): check onlyModels server side
This commit is contained in:
@@ -1,12 +1,4 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function getOnlyModelsValue(input) {
|
|
||||||
var cleanOnlyModels = [];
|
|
||||||
input.forEach(function(value) {
|
|
||||||
cleanOnlyModels = cleanOnlyModels.concat(value.split(','));
|
|
||||||
});
|
|
||||||
return cleanOnlyModels;
|
|
||||||
}
|
|
||||||
|
|
||||||
RED.nodes.registerType('xiaomi-all', {
|
RED.nodes.registerType('xiaomi-all', {
|
||||||
category: 'xiaomi',
|
category: 'xiaomi',
|
||||||
color: '#3FADB5',
|
color: '#3FADB5',
|
||||||
@@ -32,7 +24,7 @@
|
|||||||
if (configNodeID) {
|
if (configNodeID) {
|
||||||
var configNode = RED.nodes.node(configNodeID);
|
var configNode = RED.nodes.node(configNodeID);
|
||||||
if(configNode) {
|
if(configNode) {
|
||||||
onlyModels = getOnlyModelsValue(onlyModels || $('#node-input-onlyModels').val() || []);
|
onlyModels = onlyModels || $('#node-input-onlyModels').val() || [];
|
||||||
excludedSids = excludedSids || $('#node-input-excludedSids').val() || [];
|
excludedSids = excludedSids || $('#node-input-excludedSids').val() || [];
|
||||||
$('#node-input-excludedSids').empty();
|
$('#node-input-excludedSids').empty();
|
||||||
for (key in configNode.deviceList) {
|
for (key in configNode.deviceList) {
|
||||||
@@ -61,7 +53,6 @@
|
|||||||
if(!$('#node-input-excludedSids').val()) {
|
if(!$('#node-input-excludedSids').val()) {
|
||||||
this.excludedSids = [];
|
this.excludedSids = [];
|
||||||
}
|
}
|
||||||
this.onlyModels = getOnlyModelsValue(this.onlyModels);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,15 +1,22 @@
|
|||||||
module.exports = (RED) => {
|
module.exports = (RED) => {
|
||||||
|
function getOnlyModelsValue(input) {
|
||||||
|
var cleanOnlyModels = [];
|
||||||
|
input.forEach((value) => {
|
||||||
|
cleanOnlyModels = cleanOnlyModels.concat(value.split(','));
|
||||||
|
});
|
||||||
|
return cleanOnlyModels;
|
||||||
|
}
|
||||||
|
|
||||||
function XiaomiAllNode(config) {
|
function XiaomiAllNode(config) {
|
||||||
RED.nodes.createNode(this, config);
|
RED.nodes.createNode(this, config);
|
||||||
this.gateway = RED.nodes.getNode(config.gateway);
|
this.gateway = RED.nodes.getNode(config.gateway);
|
||||||
this.onlyModels = config.onlyModels;
|
this.onlyModels = getOnlyModelsValue(config.onlyModels || []);
|
||||||
this.excludedSids = config.excludedSids;
|
this.excludedSids = config.excludedSids;
|
||||||
console.log(this.onlyModels);
|
console.log(this.onlyModels);
|
||||||
|
|
||||||
|
|
||||||
this.isDeviceValid = (device) => {
|
this.isDeviceValid = (device) => {
|
||||||
|
console.log(device.sid, device.model, this.onlyModels, this.excludeSids);
|
||||||
if((!this.onlyModels || this.onlyModels.length == 0) && (!this.excludedSids || this.excludedSids.length == 0)) {
|
if((!this.onlyModels || this.onlyModels.length == 0) && (!this.excludedSids || this.excludedSids.length == 0)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "node-red-contrib-mi-devices",
|
"name": "node-red-contrib-mi-devices",
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"description": "A set of nodes to control some of the popular Xiaomi sensors which are connected to the Xiaomi Gateway, and the Gateway itself.",
|
"description": "A set of nodes to control some of the popular Xiaomi sensors which are connected to the Xiaomi Gateway, and the Gateway itself.",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
Reference in New Issue
Block a user