mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	add device filter (#545)
* add device filter * fix jslint error of pushbullet * fix pushbullet.js
This commit is contained in:
		
				
					committed by
					
						
						Dave Conway-Jones
					
				
			
			
				
	
			
			
			
						parent
						
							f20d00a972
						
					
				
				
					commit
					a226e6a308
				
			@@ -491,7 +491,7 @@ module.exports = function(RED) {
 | 
			
		||||
                    res.send("[]");
 | 
			
		||||
                    return onError(err, config);
 | 
			
		||||
                }
 | 
			
		||||
                res.send(JSON.stringify(chans.devices));
 | 
			
		||||
                res.send(JSON.stringify(filterdActiveDevices(chans.devices)));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        else if (cred && cred.apikey) {
 | 
			
		||||
@@ -501,7 +501,7 @@ module.exports = function(RED) {
 | 
			
		||||
                    res.send("[]");
 | 
			
		||||
                    return onError(err, config);
 | 
			
		||||
                }
 | 
			
		||||
                res.send(JSON.stringify(chans.devices));
 | 
			
		||||
                res.send(JSON.stringify(filterdActiveDevices(chans.devices)));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        else if (req.query.apikey) {
 | 
			
		||||
@@ -511,7 +511,7 @@ module.exports = function(RED) {
 | 
			
		||||
                    res.send("[]");
 | 
			
		||||
                    return onError(err, config);
 | 
			
		||||
                }
 | 
			
		||||
                res.send(JSON.stringify(chans.devices));
 | 
			
		||||
                res.send(JSON.stringify(filterdActiveDevices(chans.devices)));
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
@@ -519,6 +519,16 @@ module.exports = function(RED) {
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    function filterdActiveDevices(devices){
 | 
			
		||||
        var activeDevices = [];
 | 
			
		||||
        for(var i=0;i<devices.length;i++){
 | 
			
		||||
            if(devices[i].active){
 | 
			
		||||
                activeDevices.push(devices[i]);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return activeDevices;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function PushbulletIn(n) {
 | 
			
		||||
        RED.nodes.createNode(this, n);
 | 
			
		||||
        var self = this;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user