-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui_oprstatus.html
309 lines (265 loc) · 12.6 KB
/
ui_oprstatus.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
<script type="text/javascript">
function mk_conf(NAME) {
var conf = {
category: 'iaCloud Visuals',
color: 'rgb(119, 198, 204)',
defaults: {
confsel: {value:"inchartSet"},
group: {type: 'ui_group', required:true},
label: {value: NAME},
name: {value: ''},
order: {value: 0},
width: {value: 0,
validate: function(v) {
var valid = true
var width = v||0;
var currentGroup = $('#node-input-group').val()|| this.group;
var groupNode = RED.nodes.node(currentGroup);
valid = !groupNode || +width <= +groupNode.width;
$("#node-input-size").toggleClass("input-error",!valid);
return valid;
}},
height: {value: 0},
item: {value: ""},
storeOutMessages: {value: true},
fwdInMessages: {value: true},
templateScope: {value: 'local'},
params: {value:[{}]},
configReady: {value:"", required: true},
sort: {value: "true"},
guide: {value: "display"}
},
inputs:1,
outputs:0,
align: "left",
icon: "ia-cloud.png",
paletteLabel: NAME,
label: function() {
return this.name || this._("oprstatus.paletteLabel");
},
labelStyle: function () {
return this.name?"node_label_italic":"";
},
paletteLabel: function() {
return this._("oprstatus.paletteLabel") || "oprStatus";
},
oneditprepare: function() {
$("#node-input-size").elementSizer({
width: "#node-input-width",
height: "#node-input-height",
group: "#node-input-group"
});
$('input[name="configSel"]:radio').change(function() {
if ($("#node-input-configSel1").is(":checked")) {
$('#node-input-confsel').val("inchartSet");
} else {
$('#node-input-confsel').val("formatSet");
}
});
if($("#node-input-confsel").val() == "inchartSet"){
$('#node-input-configSel1').prop('checked', true);
} else {
$('#node-input-configSel2').prop('checked', true);
}
$('input[name="configSel"]:radio').change();
$('input[name="configGuide"]:radio').change(function() {
if ($("#node-input-configGuide1").is(":checked")) {
$('#node-input-guide').val("display");
} else {
$('#node-input-guide').val("hide");
}
});
if($("#node-input-guide").val() == "display"){
$('#node-input-configGuide1').prop('checked', true);
} else {
$('#node-input-configGuide2').prop('checked', true);
}
$('input[name="configGuide"]:radio').change();
var node = this;
const lblColor = node._("oprstatus.itemObject.statusColor");
const lblValue = node._("oprstatus.itemObject.statusValue");
const lblLabel = node._("oprstatus.itemObject.statusLabel");
// editableList item のhtml要素
const paraForm1 =`
<span>${lblColor}:</span>
<input type="color" class="statusColor" style="width:80px; display:inline-block; text-align:left; margin-right:20px;">
<span>${lblValue}:</span>
<input type="text" class="statusValue" style="width:80px; display:inline-block; text-align:left; margin-right:20px;">`;
const paraForm2 =`
<span style="margin-left:30px;">${lblLabel}:</span>
<input type="text" class="statusLabel" style="width:150px; display:inline-block; text-align:left; margin-right:20px;">`;
// Define editableList.
$("#node-input-list-container").css('min-height','150px').css('min-width','350px').editableList({
sortable: true,
removable: true,
height: 250,
addItem: function(container,index,param) {
var div1 = $('<div></div>').appendTo(container);
var div2 = $('<div></div>',{style:"margin-top:8px;"}).appendTo(container);
$('<span></span>',{class:"index",
style:"display:inline-block;text-align:right; width:30px; padding-right:5px;"})
.text((index + 1) + " :")
.appendTo(div1);
$(paraForm1).appendTo(div1);
// 2nd row of parameter list
$(paraForm2).appendTo(div2);
// 追加ボタンが押されたら、paramは 空{} で呼ばれます。
if(!param.hasOwnProperty("statusColor")) {
param = {
statusColor: "",
statusValue: "",
statusLabel: ""
}
};
// restore parameters
div1.find(".statusColor").val(param.statusColor);
div1.find(".statusValue").val(param.statusValue);
div2.find(".statusLabel").val(param.statusLabel);
},
sortItems: function(items) {
items.each(function(i, elm){
elm.find(".index").text((i + 1));
});
},
removeItem: function(dItem){
var items = $('#node-input-list-container').editableList("items");
items.each(function(i, elm){
elm.find(".index").text((i + 1));
});
},
});
for (var i=0;i<node.params.length;i++) {
var param = node.params[i];
$("#node-input-list-container").editableList('addItem',param);
}
},
oneditsave: function() {
var node = this;
var configReady = "ready";
var items = $("#node-input-list-container").editableList('items');
// paramデータ設定を作成
node.params = [];
items.each(function(i, elm){
var param = {
// reatore parameters
statusColor: elm.find(".statusColor").val(),
statusValue: elm.find(".statusValue").val(),
statusLabel: elm.find(".statusLabel").val()
}
node.params.push(param);
// 必須propertyが揃っているか?
if (!param.statusColor) {
configReady = "";
}
if (!param.statusValue) {
configReady = "";
}
});
// データ設定が一つはある?
if (!node.params.length) {
configReady = "";
}
// 設定完了フラグをセット
$("#node-input-configReady").val(configReady);
},
oneditresize: function(size) {
// エディタがリサイズされたら
var height = size.height;
// node name block height
height -= $("#name-block").outerHeight(true);
// editableList以外の行の高さを引く
var rows = $("#list-property>*:not(.node-input-list-container-row)");
for (var i=0; i<rows.length; i++) {
height -= $(rows[i]).outerHeight(true);
}
// editableListのマージンを引く
const editorRow = $("#list-property>div.node-input-list-container-row");
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
// editableListの高さを設定。editableListが非表示の時は正しく動作しない。
$("#node-input-list-container").editableList('height',height);
}
};
return conf;
}
RED.nodes.registerType('ui_oprstatus', mk_conf('oprStatus'));
</script>
<script type="text/html" data-template-name="ui_oprstatus">
<div id="list-property">
<!-- 隠しのNodeプロパティ -->
<div class="form-row" hidden>
<input type="text" id="node-input-configReady">
</div>
<!-- グループ -->
<div class="form-row" id="template-row-group">
<label for="node-input-group"><i class="fa fa-table"></i> <span data-i18n="oprstatus.label.group"></span></label>
<input type="text" id="node-input-group">
</div>
<!-- 表示サイズ -->
<div class="form-row" id="template-row-size">
<label><i class="fa fa-object-group"></i> <span data-i18n="oprstatus.label.size"></span></label>
<input type="hidden" id="node-input-width">
<input type="hidden" id="node-input-height">
<button class="editor-button" id="node-input-size"></button>
</div>
<!-- ラベル -->
<div class="form-row">
<label for="node-input-label"><i class="fa fa-i-cursor"></i> <span data-i18n="oprstatus.label.label"></span></label>
<input type="text" id="node-input-label">
</div>
<!-- 入力値設定 -->
<label style="width: 100%;" for="node-input-setMode" ><i class="fa fa-list"></i> <span data-i18n="oprstatus.label.input"></span></label>
<div class="form-row">
<input type="text" style="display: none;" id="node-input-confsel" value="inchartSet">
<input type="radio" style="display: inline-block; width: auto; vertical-align: top; margin-left: 30px;"
name="configSel" id="node-input-configSel1"
value="inchartSet" checked="checked">
<label style="width: 40%;" for="node-input-configSel1"> <span data-i18n="oprstatus.input.getchartdata"></span></label>
<input type="radio" style="display: inline-block; width: auto; vertical-align: top;"
name="configSel" id="node-input-configSel2" value="formatSet">
<label style="width: 40%;" for="node-input-configSel2"> <span data-i18n="oprstatus.input.formatdata"></span></label>
</div>
<!-- 凡例表示 -->
<label style="width: 100%;" for="node-input-guide" ><i class="fa fa-list"></i> <span data-i18n="oprstatus.label.guide"></span></label>
<div class="form-row">
<input type="text" style="display: none;" id="node-input-guide" value="display">
<input type="radio" style="display: inline-block; width: auto; vertical-align: top; margin-left: 30px;"
name="configGuide" id="node-input-configGuide1"
value="display" checked="checked">
<label style="width: 40%;" for="node-input-configGuide1"> <span data-i18n="oprstatus.guide.display"></span></label>
<input type="radio" style="display: inline-block; width: auto; vertical-align: top;"
name="configGuide" id="node-input-configGuide2" value="hide">
<label style="width: 40%;" for="node-input-configGuide2"> <span data-i18n="oprstatus.guide.hide"></span></label>
</div>
<!-- ソート -->
<div class="form-row">
<label for="node-input-sort"><i class="fa fa-sort"></i> <span data-i18n="oprstatus.label.sort"></span></label>
<select type="text" style="width:80px;" id="node-input-sort">
<option value="true" data-i18n="oprstatus.sort.asc"></option>
<option value="false" data-i18n="oprstatus.sort.desc"></option>
</select>
</div>
<!-- 項目名 -->
<div class="form-row" id="node-row-item" style="width:300px;">
<div class="form-row">
<label for="node-input-item"><i class="fa fa-clone"></i> <span data-i18n="oprstatus.label.item"></span></label>
<input type="text" id="node-input-item">
</div>
</div>
</div>
<!-- 状態詳細設定 -->
<div id="list-property">
<div class="form-row">
<label for="node-input-series" style="width:200px; margin-left:8px"><span data-i18n="oprstatus.label.itemObject"></span><span style="color: #ff0000;">*</span></label>
</div>
<!-- param propertyの設定 -->
<div class="form-row node-input-list-container-row">
<ol id="node-input-list-container">
</ol>
</div>
</div>
<!-- ノード名 -->
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="oprstatus.label.name"></span></label>
<input type="text" id="node-input-name">
</div>
</script>