Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b5d0e5b
updates made for firebase 3.x
ssoleman Dec 16, 2016
105f9c0
made more updates to firebase 3.x
ssoleman May 2, 2017
c17326b
Passing value to Queries and using Typed Input
ssoleman May 4, 2017
9bf89aa
Further changes for passing values to queries
ssoleman May 8, 2017
4c16b24
Pulled create user updates from @mm-gmbd
ssoleman May 8, 2017
a8fe538
Create User Update to Firebase 3.X
ssoleman May 10, 2017
726c91a
Added typedInput for childpath
ssoleman May 10, 2017
e81ac82
Fixed last used typedInput bug
ssoleman Jun 1, 2017
09ecf33
Fixed Bugs in on and once nodes
ssoleman Jun 1, 2017
6c7b4b5
Extend Auth Options for JWT
ssoleman Jun 5, 2017
d42b0bc
Fixed JWT bugs and eventtype for .once
ssoleman Jun 6, 2017
5021b0e
Improved Config Node and made Bug Fixes
ssoleman Jun 7, 2017
2656e58
Perfected Query InputTypes
ssoleman Jun 9, 2017
ea1cc40
Little bugfixes
ssoleman Jun 13, 2017
043573b
Added Administrator Authentication Type
ssoleman Jun 14, 2017
42386ab
Updated Package and some bugs
ssoleman Jun 15, 2017
0da3664
Cleaned up files and change node info
ssoleman Jun 20, 2017
dc2c2c7
Fixed Bug: No emitted payload
Jul 4, 2017
8065f03
Bug Fixes
Jul 6, 2017
10343ab
Update node help tab to use the node-red style guide
Jul 11, 2017
3a2f4db
Added typedInput for childpath
Jul 14, 2017
f90ad84
TypedInput for event in modify and ondisconnect
Jul 14, 2017
fe94254
Added server and node red timestamp typed input option
Jul 14, 2017
8b99ec9
Added Typed input for priority and did Clean up
Jul 14, 2017
a363f9f
Added port label support and changed createUser errors
Jul 17, 2017
7c03da3
Added exampleFlows and made some fixes
Jul 17, 2017
a08119e
Merge remote-tracking branch 'refs/remotes/deldrid1/master'
Aug 18, 2017
f9d8b6d
Additions and fixes
Aug 18, 2017
608a490
Hiding query input for certain operators and fixes
Aug 24, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules
186 changes: 186 additions & 0 deletions exampleFlows.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
[
{
"id": "27602cdf.6c9374",
"type": "inject",
"z": "ec28531f.7fa6e",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 140,
"y": 160,
"wires": [
[
"67a1b45e.36ac6c"
]
]
},
{
"id": "67a1b45e.36ac6c",
"type": "debug",
"z": "ec28531f.7fa6e",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 330,
"y": 160,
"wires": []
},
{
"id": "6f5a435e.c29cdc",
"type": "comment",
"z": "ec28531f.7fa6e",
"name": "Creating your first flow Step 1-4",
"info": "",
"x": 190,
"y": 100,
"wires": []
},
{
"id": "56ef1fb0.c0c7d",
"type": "comment",
"z": "ec28531f.7fa6e",
"name": "Creating your first flow Step 5",
"info": "",
"x": 180,
"y": 240,
"wires": []
},
{
"id": "7cd558fa.ed54b8",
"type": "inject",
"z": "ec28531f.7fa6e",
"name": "",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"x": 140,
"y": 320,
"wires": [
[
"c0850a46.42e188"
]
]
},
{
"id": "d722fcd1.f4d5d",
"type": "debug",
"z": "ec28531f.7fa6e",
"name": "",
"active": true,
"console": "false",
"complete": "false",
"x": 490,
"y": 320,
"wires": []
},
{
"id": "c0850a46.42e188",
"type": "function",
"z": "ec28531f.7fa6e",
"name": "convert date",
"func": "// Create a Date object from the payload\nvar date = new Date(msg.payload);\n// Change the payload to be a formatted Date string\nmsg.payload = date.toString();\n// Return the message so it can be sent on\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"x": 310,
"y": 320,
"wires": [
[
"d722fcd1.f4d5d"
]
]
},
{
"id": "a2e654e.e3257a8",
"type": "inject",
"z": "ec28531f.7fa6e",
"name": "Tick",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "*/5 0 * * *",
"once": false,
"x": 130,
"y": 520,
"wires": [
[
"94c52cc.a7310d"
]
]
},
{
"id": "94c52cc.a7310d",
"type": "http request",
"z": "ec28531f.7fa6e",
"name": "UK Power",
"method": "GET",
"url": "http://realtimeweb-prod.nationalgrid.com/SystemData.aspx",
"tls": "",
"x": 260,
"y": 520,
"wires": [
[
"d6f457b0.fd8198"
]
]
},
{
"id": "d6f457b0.fd8198",
"type": "function",
"z": "ec28531f.7fa6e",
"name": "UK Power Demand",
"func": "// does a simple text extract parse of the http output to provide an\n// object containing the uk power demand, frequency and time\n\nif (~msg.payload.indexOf('<span')) {\n var dem = msg.payload.split('Demand:')[1].split(\"MW\")[0];\n var fre = msg.payload.split('Frequency:')[1].split(\"Hz\")[0];\n\n msg.payload = {};\n msg.payload.demand = parseInt(dem.split(\">\")[1].split(\"<\")[0]);\n msg.payload.frequency = parseFloat(fre.split(\">\")[1].split(\"<\")[0]);\n \n msg2 = {};\n msg2.payload = (msg.payload.frequency >= 50) ? true : false;\n\n return [msg,msg2];\n}\n\nreturn null;",
"outputs": "2",
"noerr": 0,
"x": 447,
"y": 520,
"wires": [
[
"4e369b05.d828e4"
],
[
"3bb76581.51381a"
]
]
},
{
"id": "4e369b05.d828e4",
"type": "debug",
"z": "ec28531f.7fa6e",
"name": "",
"active": true,
"complete": false,
"x": 647,
"y": 490,
"wires": []
},
{
"id": "3bb76581.51381a",
"type": "debug",
"z": "ec28531f.7fa6e",
"name": "",
"active": true,
"complete": false,
"x": 648,
"y": 561,
"wires": []
},
{
"id": "266b276c.e6da68",
"type": "comment",
"z": "ec28531f.7fa6e",
"name": "Creating your second flow",
"info": "",
"x": 170,
"y": 420,
"wires": []
}
]
70 changes: 70 additions & 0 deletions firebase/FirebaseUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
this.getType = function(Type,Typevalue,msg,obj){
var value;
if(Type == "msg"){
value = msg[Typevalue];
}
else if(Type=="flow"){
value = obj.context().flow.get(Typevalue);
}
else if(Type =="global"){
value = obj.context().global.get(Typevalue);
}
else if(Type =="str"){
value = Typevalue
}
else if(Type == "date"){
value = Date.now();
}
else{
value = Type;
}
return value;
}

this.getRef = function(ref,queryvalType,queryname,queryvalue,msg,obj){
if(queryvalType == "str"){
if(queryname == "limitToFirst" || queryname == "limitToLast"){
queryvalue = parseInt(queryvalue);
}
ref = ref[queryname](queryvalue);
}
else if (queryvalType == "msg") {
var val = msg[queryvalue];
if(queryname == "limitToFirst" || queryname == "limitToLast"){
val = parseInt(val);
}
ref = ref[queryname](val);
}
else if(queryvalType == "flow"){
var val = obj.context().flow.get(queryvalue);
if(queryname == "limitToFirst" || queryname == "limitToLast"){
val = parseInt(val);
}
ref = ref[queryname](val);
}
else if(queryvalType == "global")
{
var val = obj.context().global.get(queryvalue);
if(queryname == "limitToFirst" || queryname == "limitToLast"){
val = parseInt(val);
}
ref = ref[queryname](val);
}
else if(queryvalType == "num"){

if(queryname == "limitToFirst" || queryname == "limitToLast"){
val = parseInt(queryvalue);
}
else{console.log("hopefully not here")
var val = queryvalue.toString();
}
ref = ref[queryname](val);
}
else if(queryvalType == "json"){
ref = queryvalType;
}
else if(queryvalType == "jsonata"){
ref = queryvalType;
}
return ref;
}
14 changes: 14 additions & 0 deletions firebase/firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const firebase = require ("firebase/app");
require ("firebase/auth");
require ("firebase/database");

//import firebase from 'firebase/app';
//import 'firebase/auth';
//import 'firebase/database';


exports.mainApp = firebase.initializeApp({databaseURL: firebaseurl});

//module.exports.mainApp = mainApp.database();


36 changes: 33 additions & 3 deletions firebase/firebase_auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,36 @@

<script type="text/x-red" data-help-name="firebase auth">
<p>Provides Firebase Auth Data to flows</p>
<p>Select a Firebase Config Node from the dropdown. Any time that Firebase Auth data is changed, this node will send a message.</p>

<h3> Outputs </h3>

<ol class="node-ports">
<dl class="message-properties">
<dt>uid <span class="property-type">string</span></dt>
<dd>The unique ID of the config node chosen</dd>
<dt>email<span class="property-type">string</span></dt>
<dd>The email associated with the config node.</dd>
<dt>emailverified<span class="property-type">bool</span></dt>
<dd>True if the email is verified, False if it is not verified.</dd>
<dt>phoneNumber<span class="property-type">string</span></dt>
<dd>The phone number associated with the config node.</dd>
<dt>apiKey<span class="property-type">string</span></dt>
<dd>The apiKey associated with the config node.</dd>
<dt>appName<span class="property-type">string</span></dt>
<dd>The application name.</dd>
<dt>refreshToken<span class="property-type">string</span></dt>
<dd>The refresh token of the JWT.</dd>
<dt>accessToken<span class="property-type">string</span></dt>
<dd>The accessToken of the JWT.</dd>
<dt>expirationTime<span class="property-type">string</span></dt>
<dd>The time of expiration for the JWT.</dd>
</dl>

</ol>

<h3> Details </h3>

<p>Select a Firebase Config Node from the dropdown. Any time that Firebase Auth data is changed, this node will send a message.</p>
<p>You may also click the inject button to inject the auth currently in use into a flow.</p>
</script>

Expand All @@ -39,10 +68,11 @@
return this.name ? "node_label_italic" : "";
},

outputLabels: function() { {return "auth details for firebaseconfig" } },

button: {
onclick: function() {
var config = RED.nodes.node(this.firebaseconfig); //server side uses RED.nodes.getNode... go figure...

$.ajax({
url: "firebase/"+this.id+"/auth",
type:"POST",
Expand All @@ -62,6 +92,6 @@
}
});
}
}
}
});
</script>
3 changes: 1 addition & 2 deletions firebase/firebase_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ module.exports = function(RED) {
this.send({payload: null})
}.bind(this)


//Register Handlers

this.config.fbConnection.on("authorized", this.fbAuthorized)
Expand All @@ -48,7 +47,7 @@ module.exports = function(RED) {
RED.httpAdmin.post("/firebase/:id/auth", RED.auth.needsPermission("firebase.write"), function(req,res) {
var node = RED.nodes.getNode(req.params.id);
if (node !== null && typeof node !== "undefined" ) {
node.send({payload: node.config.fbConnection.authData});
node.send({payload: node.config.fbConnection.lastEventData}); //lastEventData contains authData from first deploy
res.sendStatus(200)
} else {
res.send(404);
Expand Down
Loading