-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathnode-red-contrib-alafile.html
executable file
·143 lines (121 loc) · 5.83 KB
/
node-red-contrib-alafile.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
<!-- ALAFILE IN -->
<script type="text/x-red" data-template-name="alafile in">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name of node</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-filename"><i class="icon-tag"></i> Name of file (without extension)</label>
<input type="text" id="node-input-filename" placeholder="file name...">
</div>
<div class="form-row">
<label for="node-input-format"><i class="fa fa-code"></i> Format</label>
<select id="node-input-format" style="width:180px;">
<option value="xlsx">.xlsx</option>
<option value="xls">.xls</option>
<option value="csv">.csv</option>
<option value="json">.json</option>
<option value="tab">.tab</option>
<option value="tsv">.tsv</option>
<option value="txt">.txt</option>
</select>
</div>
<div class="form-row">
<label for="node-input-columns"><i class="icon-tag"></i> Columns </label>
<input type="text" id="node-input-columns" placeholder="Select columns to be stored. Use * to select all">
</div>
<div class="form-row">
<label for="node-input-headers"><i class="fa fa-list"></i> First row must contain column names</label>
<input type="checkbox" id="node-input-headers" style="width:20px">
</div>
<div class="form-tips"><span data-i18n="file.tip">Tip: You should fully path the Filename.</span></div>
</script>
<script type="text/x-red" data-help-name="alafile in">
Reads <code>msg.payload</code> from the specified file in XLSX, CSV, or other formats. The node uses <a href="https://github.com/agershun/alasql" target="_blank">AlaSQL</a> library.</p>
<p>The filename can be configured in the node. If left blank it should be set by <code>msg.filename</code> on the incoming message. <br> In either case, <i>do not</i> include the extension ('.xlsx', '.csv', etc.) as that will be appended to the file path based on the <i>Format</i> configuration parameter.</p>
<p>Note: the 'tab' and 'tsv' formats are identical, both use <code>.tab</code> extension.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('alafile in', {
category: 'storage',
color: "#f7df8e",
inputs: 1,
outputs: 1,
defaults: {
name: {value: ''},
filename: {value: ''},
format: {value: 'xlsx'},
columns: {value: '*'},
headers: {value: true}
},
icon: "alasql.png",
label: function () {
console.log(this.format);
return this.name || this.format || "ala file in";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
}
});
</script>
<!-- ALAFILE OUT -->
<script type="text/x-red" data-template-name="alafile out">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-filename"><i class="icon-tag"></i> File name</label>
<input type="text" id="node-input-filename" placeholder="file name...">
</div>
<div class="form-row">
<label for="node-input-format"><i class="fa fa-code"></i> Format</label>
<select id="node-input-format" style="width:180px;">
<option value="xlsx">.xlsx</option>
<option value="xls">.xls</option>
<option value="csv">.csv</option>
<option value="json">.json</option>
<option value="tab">.tab</option>
<option value="tsv">.tsv</option>
<option value="txt">.txt</option>
</select>
</div>
<div class="form-row">
<label for="node-input-columns"><i class="icon-tag"></i> Columns</label>
<input type="text" id="node-input-columns" placeholder="Select columns to be stored. Use * to select all">
</div>
<div class="form-row">
<label for="node-input-headers"><i class="fa fa-list"></i> First row must contain column names</label>
<input type="checkbox" id="node-input-headers" style="width:20px">
</div>
<div class="form-tips"><span data-i18n="file.tip">Tip: You should fully path the Filename.</span></div>
</script>
<script type="text/x-red" data-help-name="alafile out">
Write <code>msg.payload</code> to a specified fileformat (<code>xlsx</code>, <code>xls</code>, <code>csv</code>, <code>json</code>, <code>tab</code>, <code>tsv</code>, or <code>txt</code>. The node uses <a href="https://github.com/agershun/alasql" target="_blank">AlaSQL</a> library.</p>
<p>The filename can be configured in the node. If left blank it should be set by <code>msg.filename</code> on the incoming message. <br> In either case, <i>do not</i> include the extension ('.xlsx', '.csv', etc.) as that will be appended to the file path based on the <i>Format</i> configuration parameter.</p>
<p>Note: the 'tab' and 'tsv' formatsare identical, both use <code>.tab</code> extension.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('alafile out', {
category: 'storage',
color: "#f7df8e",
inputs: 1,
outputs: 0,
defaults: {
name: {value: ''},
filename: {value: ''},
format: {value: 'xlsx'},
columns: {value: '*'},
headers: {value: true}
},
icon: "alasql.png",
align: "right",
label: function () {
//console.log(this.format);
return this.name || this.format || "alafile out";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
}
});
</script>