Code Monkey home page Code Monkey logo

Comments (8)

dceejay avatar dceejay commented on June 12, 2024

by default a message coming back from the UI has a msg.socketid property attached. If that is then routed back to the UI then it will only go back to that socketid - if you delete that property it will go to all.

I'll update those comments to remove the < > in that example node.

from node-red-ui-nodes.

Christian-Me avatar Christian-Me commented on June 12, 2024

Hi Dave, thank you for your quick reply.
When the user change the ui element a (new) message is sent via `$scope.send({state:color[$scope.config.outFormat]});´

It then pass `beforeSend´ on the backend:

                    beforeSend: function (msg, orig) {
                        if (orig) {
                            var newMsg = {};
                            // Store the switch state in the specified msg state field
                            RED.util.setMessageProperty(newMsg, config.stateField, orig.msg.state, true)
                            //orig.msg = newMsg;
                            var topic = RED.util.evaluateNodeProperty(config.topic,config.topicType || "str",node,msg) || node.topi;
                            if (topic) { newMsg.topic = topic; }
                            console.log('beforeSend:',newMsg);
                            return newMsg;
                        }
                    },

resulting in
beforeSend: { payload: { r: 129, g: 120, b: 255 }, topic: 'colorPicker' }

So no msg.socketid at this point.
Sorry I still don't get it.

Chris

If you like to know what I'm working on: https://github.com/Christian-Me/node-red-contrib-ui-iro-color-picker

from node-red-ui-nodes.

dceejay avatar dceejay commented on June 12, 2024

yeah - but what arrives in a debug node set to show all ?
(And yes very nice - like it)

from node-red-ui-nodes.

Christian-Me avatar Christian-Me commented on June 12, 2024

As expected ... including the socketid
image
But how can I get the dashboard backend to update other clients automatically. (like when I place a slider without any connections and use it on one client other clients follow simultaneously).

If I send a new colour from the flow to the node (without a specific socketid) all clients are updated as expected.

I was searching for a colour picker which is usable in different ways and on mobile devices for a long time. iro.js popped up in the forum from time to time and to be honest I hoped that someone else (with more experience) could do the job. In the end I was procrastinating other jobs and thought it would be a nice small project to learn how to implement a custom ui-node. In reality I was searching for a slider which could set a (or two like upper and lower) value and display the actual value by the bargraph. I have dimmers for my indoor green house which fade (very) slowly to simulate the sun over dark winter days. A combined setpoint and real value is useful for other actuators like heaters and valves too. This would a project for another rainy weekend (or two) - iro.js can do something similar by using the multiple colour feature which I will try out too

from node-red-ui-nodes.

Christian-Me avatar Christian-Me commented on June 12, 2024

After some (hours) of debugging I found it ,,, I already noticed that flag several times but never tested it until I reached ui.js with the debugger ... ;)

storeFrontEndInputAsState: true,

Now I only have to solve that loopback issue as the emitting session now gets its own message back. I somehow have to figure out if a message received in $scope.$watch('msg', function(msg) {...} originates from a different cession or the input of the node in the flow. If it is the own messages (in the meantime the slider may have already changed by the user) it should be dropped. (For me a cession should not get it's own message back from the backend - I already had that problem in ui-table and had not found a satisfying solution back then)

Should be solvable ...

from node-red-ui-nodes.

Christian-Me avatar Christian-Me commented on June 12, 2024

Think I fixed (most) of the tasks around my initial question. (I pushed the latest version to github)

I don't know if it is ok to ask it here but I ask it anyway ;)

Is it a good idea to stop sending new values until the last one is "confirmed" to avoid flooding the backend? In this case the loopback is actually quite useful. Currently the backend (debug window) builds up a long tail if you drag with the option "on user interaction"

Perhaps I have to add a timeout in case a message is lost

from node-red-ui-nodes.

dceejay avatar dceejay commented on June 12, 2024

the built in widgets use a timeout to rate limit the updates from things like the slider etc. But it always a tradeoff between sending too many and making any animation look smooth.

from node-red-ui-nodes.

Christian-Me avatar Christian-Me commented on June 12, 2024

Thank you for the information, I will try both ... The wait until confirmed might be too slow as a little queue in buffer should help in smooth animations The tail animation when the picker is released is funny but a little bit irritating (will try to avoid this with a on release flag to find out when it is ok to handle messages as real updates from somewhere else - somehow.

from node-red-ui-nodes.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.