@flowfuse/node-red-dashboard
Advanced tools
Comparing version 0.11.3-9703846-202401041732.0 to 0.11.3-e633be4-202401051417.0
@@ -409,3 +409,5 @@ const fs = require('fs') | ||
} else { | ||
socket.on(eventName, handler.bind(null, socket)) | ||
widget._onSocketHandlers = widget._socketIO || {} | ||
widget._onSocketHandlers[eventName] = handler.bind(null, socket) | ||
socket.on(eventName, widget._onSocketHandlers[eventName]) | ||
} | ||
@@ -504,3 +506,3 @@ } | ||
async function onChange (conn, id, value) { | ||
console.log('conn:' + conn.id, 'on:widget-change:' + id, value) | ||
// console.log('conn:' + conn.id, 'on:widget-change:' + id, value) | ||
@@ -559,3 +561,3 @@ // get widget node and configuration | ||
async function onLoad (conn, id, msg) { | ||
console.log('conn:' + conn.id, 'on:widget-load:' + id, msg) | ||
// console.log('conn:' + conn.id, 'on:widget-load:' + id, msg) | ||
@@ -866,2 +868,17 @@ const { wNode, widgetEvents } = getWidgetAndConfig(id) | ||
if (widgetNode) { | ||
const widget = node.ui.widgets.get(widgetNode.id) | ||
if (widget.hooks.onSocket) { | ||
// We have some custom socketIO hooks to remove | ||
// loop over SocketIO connections | ||
for (const socket of Object.values(uiShared.connections)) { | ||
// loop over events | ||
for (const [eventName] of Object.entries(widget.hooks.onSocket)) { | ||
// remove the listener for this event | ||
if (widget._onSocketHandlers) { | ||
socket.off(eventName, widget._onSocketHandlers[eventName]) | ||
} | ||
} | ||
} | ||
} | ||
node.ui.widgets.delete(widgetNode.id) | ||
@@ -868,0 +885,0 @@ changes = true |
@@ -20,5 +20,8 @@ { | ||
"pointShape": "Shape", | ||
"pointRadius": "Radius (px)" | ||
"pointRadius": "Radius (px)", | ||
"action": "Action", | ||
"append": "Append", | ||
"replace": "Replace" | ||
} | ||
} | ||
} |
@@ -164,47 +164,11 @@ const statestore = require('../store/state.js') | ||
// this.events = config.events || 'all' | ||
// const sendconnect = function (id, ip) { | ||
// node.send({ payload: 'connect', socketid: id, socketip: ip }) | ||
// } | ||
// const sendlost = function (id, ip) { | ||
// node.send({ payload: 'lost', socketid: id, socketip: ip }) | ||
// } | ||
// const sendchange = function (index, name, id, ip, p) { | ||
// node.send({ payload: 'change', tab: index, name, socketid: id, socketip: ip, params: p }) | ||
// } | ||
// const sendcollapse = function (group, state, id, ip) { | ||
// node.send({ payload: 'group', group, open: state, socketid: id, socketip: ip }) | ||
// } | ||
// if (node.events === 'connect') { | ||
// ui.ev.on('newsocket', sendconnect) | ||
// } else if (node.events === 'change') { | ||
// ui.ev.on('changetab', sendchange) | ||
// ui.ev.on('collapse', sendcollapse) | ||
// } else { | ||
// ui.ev.on('newsocket', sendconnect) | ||
// ui.ev.on('changetab', sendchange) | ||
// ui.ev.on('collapse', sendcollapse) | ||
// ui.ev.on('endsocket', sendlost) | ||
// } | ||
// this.on('close', function () { | ||
// if (node.events === 'connect') { | ||
// ui.ev.removeListener('newsocket', sendconnect) | ||
// } else if (node.events === 'change') { | ||
// ui.ev.removeListener('changetab', sendchange) | ||
// ui.ev.removeListener('collapse', sendcollapse) | ||
// } else { | ||
// ui.ev.removeListener('newsocket', sendconnect) | ||
// ui.ev.removeListener('changetab', sendchange) | ||
// ui.ev.removeListener('collapse', sendcollapse) | ||
// ui.ev.removeListener('endsocket', sendlost) | ||
// } | ||
// }) | ||
node.on('close', function (removed, done) { | ||
if (removed) { | ||
// handle node being removed | ||
ui?.deregister(null, null, node) | ||
} | ||
done() | ||
}) | ||
} | ||
RED.nodes.registerType('ui-control', UiControlNode) | ||
} |
@@ -16,3 +16,7 @@ const { addConnectionCredentials } = require('../utils/index.js') | ||
const wNode = RED.nodes.getNode(node.id) | ||
if (id === node.id) { | ||
if (!wNode) { | ||
console.log('ui-event node not found', id) | ||
} | ||
if (wNode && id === node.id) { | ||
console.log('running ui-event handler', id) | ||
// this was sent by this particular node | ||
@@ -31,5 +35,13 @@ let msg = { | ||
// inform the dashboard UI that we are adding this node | ||
ui.register(null, null, node, config, evts) | ||
ui?.register(null, null, node, config, evts) | ||
node.on('close', function (removed, done) { | ||
if (removed) { | ||
// handle node being removed | ||
ui?.deregister(null, null, node) | ||
} | ||
done() | ||
}) | ||
} | ||
RED.nodes.registerType('ui-event', EventNode) | ||
} |
{ | ||
"name": "@flowfuse/node-red-dashboard", | ||
"version": "0.11.3-9703846-202401041732.0", | ||
"version": "0.11.3-e633be4-202401051417.0", | ||
"description": "A collection of Node-RED nodes that provide functionality to build your own UI applications (inc. forms, buttons, charts) within Node-RED.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
331310