Dashboard 2 UI control. Unable to hide button at the start of the node

Is there any way to hide some button the moment node red start in dashboard 2.0?
I believe I tried to use inject node with "inject once after" option several second but the dashboard stay still with all button shown.
It only hidden right after I inject it myself.

Thank you very much

Hi @nightmareside15 Try using Event Node instead Inject node or increase Seconds.

Can you post the nodes that hide the button please so we can see exactly how you are doing it and try for ourselves? Export just the inject node and whatever you are feeding it into and paste them here.

Hi. I've already made it into 3 second. The thing is if I re-deploy it from node-red, it is working as intended. Could you make example on how to use the event node?

Sure. Here it is:

[
    {
        "id": "7cc14da64e26c505",
        "type": "ui-control",
        "z": "b6f57b27b0d45aea",
        "name": "",
        "ui": "51acbbf07e66ef1f",
        "events": "all",
        "x": 440,
        "y": 340,
        "wires": [
            []
        ]
    },
    {
        "id": "3d982beef72cccc1",
        "type": "function",
        "z": "b6f57b27b0d45aea",
        "name": "function 6",
        "func": "msg.payload = {\n\n    groups: {\n        show: [\"test:X\", \"test:ptcHeaterContent\"],\n        hide: [\"test:Y\"]\n    }\n}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 280,
        "y": 340,
        "wires": [
            [
                "7cc14da64e26c505"
            ]
        ]
    },
    {
        "id": "53bdd95d93d3cded",
        "type": "ui-button",
        "z": "b6f57b27b0d45aea",
        "group": "d3d31cf881e50e9f",
        "name": "",
        "label": "IQC",
        "order": 0,
        "width": "3",
        "height": "1",
        "passthru": false,
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 100,
        "y": 400,
        "wires": [
            [
                "a4a51cf8bda2b6f4"
            ]
        ]
    },
    {
        "id": "2ed5812093b17fd5",
        "type": "ui-control",
        "z": "b6f57b27b0d45aea",
        "name": "",
        "ui": "51acbbf07e66ef1f",
        "events": "all",
        "x": 440,
        "y": 400,
        "wires": [
            []
        ]
    },
    {
        "id": "a4a51cf8bda2b6f4",
        "type": "function",
        "z": "b6f57b27b0d45aea",
        "name": "function 7",
        "func": "msg.payload = {\n\n    groups: {\n       \n        hide: [\"test:ptcHeaterContent\"]\n    }\n}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 280,
        "y": 400,
        "wires": [
            [
                "2ed5812093b17fd5"
            ]
        ]
    },
    {
        "id": "d0b7a6dee6187b73",
        "type": "ui-control",
        "z": "b6f57b27b0d45aea",
        "name": "",
        "ui": "51acbbf07e66ef1f",
        "events": "all",
        "x": 555,
        "y": 508.1111145019531,
        "wires": [
            []
        ]
    },
    {
        "id": "ecb6b6cf0824c0f8",
        "type": "function",
        "z": "b6f57b27b0d45aea",
        "name": "function 8",
        "func": "// Code added here will be run once\n// whenever the node is started.\nmsg.payload = {\n\n    groups: {\n        show: [\"test:Y\", \"test:X\"],\n        hide: [\"test:ptcHeaterContent\", \"test:ptcHeaterContentNGType\"]\n    }\n}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 375,
        "y": 468.1111145019531,
        "wires": [
            [
                "d0b7a6dee6187b73"
            ]
        ]
    },
    {
        "id": "c42a3a11ee8c61fb",
        "type": "ui-dropdown",
        "z": "b6f57b27b0d45aea",
        "group": "4eb0d1bf71f37caa",
        "name": "",
        "label": "NG Type",
        "tooltip": "",
        "order": 0,
        "width": 0,
        "height": 0,
        "passthru": false,
        "multiple": false,
        "options": [
            {
                "label": "Electrical",
                "value": "electrical",
                "type": "str"
            },
            {
                "label": "Appearance",
                "value": "appearance",
                "type": "str"
            },
            {
                "label": "Others",
                "value": "others",
                "type": "str"
            }
        ],
        "payload": "",
        "topic": "topic",
        "topicType": "msg",
        "className": "",
        "x": 760,
        "y": 540,
        "wires": [
            []
        ]
    },
    {
        "id": "4844b872f19d745e",
        "type": "ui-text-input",
        "z": "b6f57b27b0d45aea",
        "group": "69e42cdee1eb4a85",
        "name": "",
        "label": "NG Quantity",
        "order": 2,
        "width": 0,
        "height": 0,
        "topic": "topic",
        "topicType": "msg",
        "mode": "number",
        "delay": "0",
        "passthru": true,
        "sendOnDelay": false,
        "sendOnBlur": true,
        "sendOnEnter": true,
        "className": "",
        "x": 765,
        "y": 608.1111145019531,
        "wires": [
            []
        ]
    },
    {
        "id": "f34cf4498dc442b9",
        "type": "ui-button",
        "z": "b6f57b27b0d45aea",
        "group": "1dc5d54232f015b9",
        "name": "",
        "label": "HEATER",
        "order": 1,
        "width": "3",
        "height": "1",
        "passthru": false,
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 115,
        "y": 288.1111145019531,
        "wires": [
            [
                "3d982beef72cccc1"
            ]
        ]
    },
    {
        "id": "89764e8df08cd094",
        "type": "inject",
        "z": "b6f57b27b0d45aea",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "3",
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 210,
        "y": 480,
        "wires": [
            [
                "ecb6b6cf0824c0f8"
            ]
        ]
    },
    {
        "id": "56c81e735dfe5fb2",
        "type": "ui-template",
        "z": "b6f57b27b0d45aea",
        "group": "3c78bb667cb5cdb6",
        "page": "",
        "ui": "",
        "name": "",
        "order": 4,
        "width": "3",
        "height": "1",
        "head": "",
        "format": "<template>\n    <div style=\"width: 100px; height: 100px;  display: block;\n  margin-left: auto;\n  margin-right: auto;\n  margin-top: auto;\n  margin-bottom: 2%;\n  width: 50%;\">\n\n    <img src=\"\">\n    </div>\n</template>",
        "storeOutMessages": true,
        "passthru": true,
        "resendOnRefresh": true,
        "templateScope": "local",
        "className": "",
        "x": 535,
        "y": 568.1111145019531,
        "wires": [
            []
        ]
    },
    {
        "id": "51acbbf07e66ef1f",
        "type": "ui-base",
        "name": "UI Name",
        "path": "/dashboard",
        "includeClientData": true,
        "acceptsClientConfig": [
            "ui-notification",
            "ui-control"
        ],
        "showPathInSidebar": false
    },
    {
        "id": "d3d31cf881e50e9f",
        "type": "ui-group",
        "name": "Y",
        "page": "975e9a684fe100cc",
        "width": "3",
        "height": "1",
        "order": 3,
        "showTitle": false,
        "className": "",
        "visible": "true",
        "disabled": "false"
    },
    {
        "id": "4eb0d1bf71f37caa",
        "type": "ui-group",
        "name": "ptcHeaterContent",
        "page": "975e9a684fe100cc",
        "width": "3",
        "height": "1",
        "order": 4,
        "showTitle": false,
        "className": "",
        "visible": "true",
        "disabled": "false"
    },
    {
        "id": "69e42cdee1eb4a85",
        "type": "ui-group",
        "name": "ptcHeaterContentNGType",
        "page": "975e9a684fe100cc",
        "width": "3",
        "height": "1",
        "order": 5,
        "showTitle": false,
        "className": "",
        "visible": "true",
        "disabled": "false"
    },
    {
        "id": "1dc5d54232f015b9",
        "type": "ui-group",
        "name": "X",
        "page": "975e9a684fe100cc",
        "width": "3",
        "height": "1",
        "order": 2,
        "showTitle": false,
        "className": "",
        "visible": "true",
        "disabled": "false"
    },
    {
        "id": "3c78bb667cb5cdb6",
        "type": "ui-group",
        "name": "tex",
        "page": "975e9a684fe100cc",
        "width": "3",
        "height": "1",
        "order": 1,
        "showTitle": false,
        "className": "",
        "visible": "true",
        "disabled": "false"
    },
    {
        "id": "975e9a684fe100cc",
        "type": "ui-page",
        "name": "test",
        "ui": "51acbbf07e66ef1f",
        "path": "/page2",
        "icon": "home",
        "layout": "notebook",
        "theme": "c96c5c22ab511c72",
        "order": -1,
        "className": "",
        "visible": false,
        "disabled": "false"
    },
    {
        "id": "c96c5c22ab511c72",
        "type": "ui-theme",
        "name": "Theme Name",
        "colors": {
            "surface": "#ffffff",
            "primary": "#0094ce",
            "bgPage": "#eeeeee",
            "groupBg": "#ffffff",
            "groupOutline": "#cccccc"
        },
        "sizes": {
            "pagePadding": "12px",
            "groupGap": "12px",
            "groupBorderRadius": "4px",
            "widgetGap": "12px"
        }
    }
]

Well, it actually a dropdown which is triggered by button. I want it to be hidden at the start, and un hidden it when I press the button. If I re-deploy it, it is working as intended but as soon as I run node-red, it seems nothing happened

If you deploy and see it working, and then open a new browser tab on the dashboard, is it hidden in the new tab?

It is working ok for me. When I restart node-red the dropdown and text widgets are hidden, just the buttons being visible.

Make sure you refresh the browser after you make any changes to the flow that involve ui nodes.

2 Likes

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