LoginSignup
2
1

More than 1 year has passed since last update.

node-redのUIノードを自作したい -調査編-

Posted at

node-redとは

ノードというものを繋げることでプログラミングをするもの

今すぐ簡単に利用するにはenebularがおすすめです

何を隠そうenebularのアドベントカレンダー2021の11日目です!

カスタムノード(自作ノード)の参考サイト

たくさんあるので作り方は省略

node-red-dashbordのすごい魅力

Image from Gyazo

右側に「ダッシュボード」アイコンが追加され、

Image from Gyazo

ダッシュボードを使ったフローを追加し、

Image from Gyazo

レイアウトとかを設定したのち、

Image from Gyazo

UIが作れちゃう
(手順説明ではないです。実際のやり方は公式か、こちらのもっとわかりやすいページからもどうぞ)

自分もUIを自作したい

node-red-dashbordライブラリ内のソースコードを見てみると

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

    function ButtonNode(config) {
        // (略)

        node.on("input", function(msg) {
            node.topi = RED.util.evaluateNodeProperty(config.topic,config.topicType || "str",node,msg);
        });

        var done = ui.add({
            node: node,
            tab: tab,
            group: group,
            emitOnlyNewValues: false,
            forwardInputMessages: config.passthru || false,
            storeFrontEndInputAsState: false,
            control: {
                type: 'button',
                label: config.label,
                tooltip: config.tooltip,
                color: config.color,
                bgcolor: config.bgcolor,
                className: config.className,
                icon: config.icon,
                order: config.order,
                value: payload,
                format: config.bgcolor,
                width: config.width || group.config.width || 3,
                height: config.height || 1
            },
            // (略)
        });
        node.on("close", done);
    }
    RED.nodes.registerType("ui_button", ButtonNode);
};

typeで'button'を渡しているのか…やはり自由にできなさそうなのかな?やりたいけどちょっとまだ調査しきれていないというメモ記事でした…

enebularのよさを出す手前になってしまった無念

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1