|
Bogdan Timofte
authored
2 weeks ago
|
1
|
<script type="text/x-red" data-template-name="msg-status">
|
|
|
2
|
<div class="form-row">
|
|
|
3
|
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
|
4
|
<input type="text" id="node-input-name" placeholder="Name">
|
|
|
5
|
</div>
|
|
|
6
|
<div class="form-row">
|
|
|
7
|
<label for="node-input-msgPath"><i class="fa fa-code"></i> Message path</label>
|
|
|
8
|
<input type="text" id="node-input-msgPath" placeholder="msg.payload.state">
|
|
|
9
|
</div>
|
|
|
10
|
<div class="form-row">
|
|
|
11
|
<label for="node-input-prefix">Prefix (optional)</label>
|
|
|
12
|
<input type="text" id="node-input-prefix" placeholder="State:">
|
|
|
13
|
</div>
|
|
|
14
|
<div class="form-row">
|
|
|
15
|
<label for="node-input-suffix">Suffix (optional)</label>
|
|
|
16
|
<input type="text" id="node-input-suffix" placeholder="(live)">
|
|
|
17
|
</div>
|
|
|
18
|
<div class="form-row">
|
|
|
19
|
<label for="node-input-showTime">Show time</label>
|
|
|
20
|
<input type="checkbox" id="node-input-showTime" style="width:auto; vertical-align:middle;">
|
|
|
21
|
</div>
|
|
|
22
|
<div class="form-row">
|
|
|
23
|
<label for="node-input-fill">Status color</label>
|
|
|
24
|
<select id="node-input-fill">
|
|
|
25
|
<option value="blue">Blue</option>
|
|
|
26
|
<option value="green">Green</option>
|
|
|
27
|
<option value="red">Red</option>
|
|
|
28
|
<option value="yellow">Yellow</option>
|
|
|
29
|
<option value="grey">Grey</option>
|
|
|
30
|
</select>
|
|
|
31
|
</div>
|
|
|
32
|
<div class="form-row">
|
|
|
33
|
<label for="node-input-shape">Status shape</label>
|
|
|
34
|
<select id="node-input-shape">
|
|
|
35
|
<option value="dot">Dot</option>
|
|
|
36
|
<option value="ring">Ring</option>
|
|
|
37
|
</select>
|
|
|
38
|
</div>
|
|
|
39
|
</script>
|
|
|
40
|
|
|
|
41
|
<script type="text/x-red" data-help-name="msg-status">
|
|
|
42
|
<p>
|
|
|
43
|
Displays a configurable part of the incoming message in the node status.
|
|
|
44
|
</p>
|
|
|
45
|
<h3>Configuration</h3>
|
|
|
46
|
<dl class="message-properties">
|
|
|
47
|
<dt>Message path
|
|
|
48
|
<span class="property-type">string</span>
|
|
|
49
|
</dt>
|
|
|
50
|
<dd>
|
|
|
51
|
Dot-notation path to the value to display (e.g., <code>msg.payload.state</code>, <code>msg.topic</code>, <code>msg.payload</code>).
|
|
|
52
|
Supports nested paths like <code>msg.data.nested.value</code>.
|
|
|
53
|
</dd>
|
|
|
54
|
<dt>Prefix <span class="property-type">string (optional)</span></dt>
|
|
|
55
|
<dd>Text to prepend to the status value (e.g., "State: ").</dd>
|
|
|
56
|
<dt>Suffix <span class="property-type">string (optional)</span></dt>
|
|
|
57
|
<dd>Text to append to the status value (e.g., " (live)").</dd>
|
|
|
58
|
<dt>Show time <span class="property-type">boolean</span></dt>
|
|
|
59
|
<dd>When enabled, prefixes the status text with the local time of the last received message in <code>HH:MM:SS</code> format.</dd>
|
|
|
60
|
<dt>Status color
|
|
|
61
|
<span class="property-type">string</span>
|
|
|
62
|
</dt>
|
|
|
63
|
<dd>Color of the status indicator: blue, green, red, yellow, or grey.</dd>
|
|
|
64
|
<dt>Status shape
|
|
|
65
|
<span class="property-type">string</span>
|
|
|
66
|
</dt>
|
|
|
67
|
<dd>Shape of the status indicator: dot or ring.</dd>
|
|
|
68
|
</dl>
|
|
|
69
|
|
|
|
70
|
<h3>Example</h3>
|
|
|
71
|
<p>
|
|
|
72
|
If a message with <code>msg.payload.state = "active"</code> arrives, and you configure:
|
|
|
73
|
</p>
|
|
|
74
|
<ul>
|
|
|
75
|
<li>Message path: <code>msg.payload.state</code></li>
|
|
|
76
|
<li>Prefix: <code>State:</code></li>
|
|
|
77
|
<li>Color: green</li>
|
|
|
78
|
</ul>
|
|
|
79
|
<p>
|
|
|
80
|
The node status will display: <code>12:34:56 State: active</code> with a green dot.
|
|
|
81
|
</p>
|
|
|
82
|
</script>
|
|
|
83
|
|
|
|
84
|
<script>
|
|
|
85
|
RED.nodes.registerType("msg-status", {
|
|
|
86
|
category: "function",
|
|
|
87
|
color: "#87ceeb",
|
|
|
88
|
defaults: {
|
|
|
89
|
name: {value: ""},
|
|
|
90
|
msgPath: {value: "", required: true},
|
|
|
91
|
prefix: {value: ""},
|
|
|
92
|
suffix: {value: ""},
|
|
|
93
|
showTime: {value: true},
|
|
|
94
|
fill: {value: "blue"},
|
|
|
95
|
shape: {value: "dot"}
|
|
|
96
|
},
|
|
|
97
|
inputs: 1,
|
|
|
98
|
outputs: 1,
|
|
|
99
|
icon: "font-awesome/fa-info-circle",
|
|
|
100
|
label: function() {
|
|
|
101
|
return this.name || (this.msgPath ? "status: " + this.msgPath : "msg-status");
|
|
|
102
|
},
|
|
|
103
|
paletteLabel: "msg status"
|
|
|
104
|
});
|
|
|
105
|
</script>
|