How to create dashboard node for toast popups?

Trying to build a simple node to show "mdToast" popups on incoming messages. Looking at the existing "Notification" node I see it uses ui.add to insert itself, and not ui.addWidget (like "normal" widgets which belong to a group and have an order do):

module.exports = function(RED) {
    var ui = require('../ui')(RED);

    function ToastNode(config) {
        RED.nodes.createNode(this, config);

        ...

        var done = ui.add({
            node: node,
            control: {},
            storeFrontEndInputAsState: false,
            forwardInputMessages: false,
            beforeSend: function (msg) {
                var m = msg.payload.msg;
                m.topic = node.topic || m.topic;
                return m;
            }
        });

Since what I'm trying to do very closely matches the "Notification" node I'm basically trying to to build a clone of this node - but the add method is not available to me:

    function MyNode(config) {
        if(ui === undefined) {
            ui = RED.require("node-red-dashboard")(RED);
        }

        ...

        var done = ui.add({
        ....

TypeError: ui.add is not a function

How do I add a hidden dashboard widget like ui_toast does?

Hi @clickworkorange,
If I'm not mistaken, the trick was to set the height to -1, like in the node-red-contrib-ui-contextmenu node.
Bart

Thanks! That sounds a bit "bodgy" though :slight_smile: I'd like to reuse as much as possible of the Angular mdToast functionality that's already in there...

It is not that we have abused some kind of backdoor to get it correct. At the time being @dceejay has been so kind to add this functionality for us in the dashboard, as you can read here

No worries, I'm going with a fork of node-red-dashboard and will see if I can add a generic popup API based on mdDialog instead - this seems to be a better fit for my use case than mdToast, and I think the dashboard needs popup functionality anyway.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.