-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBJ_parser.html
More file actions
169 lines (145 loc) · 5.07 KB
/
BJ_parser.html
File metadata and controls
169 lines (145 loc) · 5.07 KB
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
<script type="text/javascript">
const allLogTypes = "DEFAULT, INIT, FULL_IN_RUN, RULE_IO, NEW_IN,\
SET_VAR_VAL_SET, SET_VAR_VAL_SUB, SET_VAR_OTHER, SET_ATRIBUTE, CREATE_ATRIBUTE, JSON_CHANGE, SET_SELECTOR_CHECK, SUB_SELECTOR_CHECK, SUB_REPETITION"
// const defLogTypes = "DEFAULT, INIT, FULL_IN_RUN, RULE_IO, NEW_IN,\
// SET_VAR_VAL_SET, SET_VAR_VAL_SUB, SET_VAR_OTHER, SET_ATRIBUTE, CREATE_ATRIBUTE, JSON_CHANGE, SET_SELECTOR_CHECK, SUB_SELECTOR_CHECK, SUB_REPETITION"
RED.nodes.registerType('BJ-parser', {
category: 'common',
// category: 'parser',
color: '#0B99D8',
defaults: {
name: { value: "" },
// alias: { value: "" },
maxBinLen: { value: 64, required: true },
suppressedLogs: {
value: allLogTypes
},
},
align: 'left',
icon: "icon.png",
inputs: 1,
outputs: 1,
label: function () {
return this.name || "parser";
},
});
const availableLogTypes = {
"DEFAULT": true,
"INIT": true,
"FULL_IN_RUN": true,
"RULE_IO": true,
"NEW_IN": true,
"SET_VAR_VAL_SET": true,
"SET_VAR_VAL_SUB": true,
"SET_VAR_OTHER": true,
"SET_ATRIBUTE": true,
"CREATE_ATRIBUTE": true,
"JSON_CHANGE": true,
"SET_SELECTOR_CHECK": true,
"SUB_SELECTOR_CHECK": true,
"SUB_REPETITION": true,
"WARN": true,
"ERR": true
}
function check() {
const maxbinLen_elm = document.getElementById("node-input-maxBinLen");
const suppressedLogs_elm = document.getElementById("node-input-suppressedLogs");
const validLogHeaders = suppressedLogs_elm.value
.toUpperCase()
.split(",")
.reduce((acc, val) => (acc && (!val || val.trim() in availableLogTypes)), true);
const validMaxLen = maxbinLen_elm.value % 1 === 0;
if (!validLogHeaders)
suppressedLogs_elm.setCustomValidity("Err");
else
suppressedLogs_elm.setCustomValidity("");
if (!validMaxLen)
maxbinLen_elm.setCustomValidity("Err");
else
maxbinLen_elm.setCustomValidity("");
}
function selectAllLogHeaders() {
const suppressedLogs_elm = document.getElementById("supr-log-headers").value = allLogTypes;
}
</script>
<style>
.fileInput {
display: flex !important;
justify-content: space-between;
box-sizing: border-box;
height: 34px;
color: #555;
border-radius: 4px;
white-space: nowrap;
border: 1px solid #ccc;
min-width: fit-content;
}
.fileInput:hover {
border: 1px solid #5596e6;
}
.file-input-button {
background: #ccc;
color: #333;
padding: 6px;
font-weight: 500;
}
.fileInputText {
padding: 6px;
font-weight: 400;
}
.fileInputClear {
padding: 6px;
border-left: 1px solid #ccc;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
padding: 0;
}
.input-button-wrap {
display: inline-flex;
flex-direction: column;
align-items: stretch;
width: 70%;
margin-left: 5px;
}
.input-button-wrap>input {
width: 100% !important;
}
</style>
<script type="text/x-red" data-template-name="BJ-parser">
<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-maxBinLen"> Max bin log len </label>
<input type="number" id="node-input-maxBinLen" autocomplete="off" placeholder="'-1' for inf" onchange="check()" >
</div>
<div class="form-row" style="display: flex;">
<label for="node-input-suppressedLogs"> Suppressed headers </label>
<div class="input-button-wrap">
<input type="text" id="node-input-suppressedLogs" placeholder="coma separated" onchange="check()" >
<button class="red-ui-button red-ui-button-small" onClick="selectAllLogHeaders()">
<i class="fa fa-check-square-o"></i>
Select all
</button>
</div>
</div>
</script>
<script type="text/x-red" data-help-name="unipi-input">
<p>
Read README.md
</p>
<!-- <div class="form-row">
<label for="node-input-alias"><i class="fa fa-user-circle-o"></i> Alias</label>
<input type="text" id="node-input-alias" placeholder="Write an Alias" onchange="check()" onkeyup="disable()" onkeydown="enable()" >
</div> -->
<!-- <div class="form-row">
<label for="node-input-seeorig"><i class="fa fa-list-ul"></i> See orig msg</label>
<select type="text" id="node-input-seeorig">
<option value="1">True</option>
<option value="0">False</option>
</select>
</div> -->
</script>