Adorkable / node-red-contrib-ui-led

A simple LED status indicator for the Node-RED Dashboard
MIT License
16 stars 12 forks source link

Fixed issue #9

Closed seth350 closed 5 years ago

seth350 commented 5 years ago

Fixed issue with node not displaying in dashboard group in the sidebar. The node type must begin with "ui_"

image

yoiang commented 5 years ago

Good catch! I swear it was working at some point, it must have been when it was built half from examples and had ui_ still in the type name ;)

Does lineargauge also have this issue or am I missing a difference between the two?

seth350 commented 5 years ago

Yes, the current version in the repo has the same issue. I have another fork going right now making the changes. I fought with this all day yesterday and finally got an answer today.

yoiang commented 5 years ago

Gotcha! Was this a recently change in node-red-dashboard?

yoiang commented 5 years ago

Thanks a lot btw, didn't say so from the get go 👍

yoiang commented 5 years ago

Hmm, now I'm getting:

TypeError: Cannot read property 'config' of null`

null being the group. It's resolved when I manually add the node to a dashboard group.

Investigating further!

yoiang commented 5 years ago

Right, group should be a required value, this error is valid if one shirks the warning making it required presents. Unrelated to this change!

seth350 commented 5 years ago

Yes, and it is also a good idea to check that the config is defined and that a group is present over in the .js file.

function checkConfig(node, conf) {
        if (!conf || !conf.hasOwnProperty("group")) {
            node.error(RED._("ui_list.error.no-group"));
            return false;
        }
        return true;
    }

Then place this call before you call ui.addWidget

if (checkConfig(node, config)) { 
var html = HTML(config);                   
                done = ui.addWidget({                       
                node: node,           
                .....

        } <-- second bracket for if statement here
    }
        catch (e) {
            console.log(e);
        }