forked from jayathuam/node-red-contrib-advance-logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadvance-logger.html
173 lines (163 loc) · 6.59 KB
/
advance-logger.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
<script type="text/javascript">
RED.nodes.registerType('logger', {
category: 'output',
color: '#B2EBF2',
defaults: {
name: {
value: ""
},
filename: {
value: "node-red.log",
required: true
},
maxsize: {
value: 1,
required: true,
validate: function(v) {
return v >= 1
}
},
maxfiles: {
value: 10,
required: true,
validate: function(v) {
return v >= 1
}
},
complete: {
value: "false",
required: true
},
console: {
value: false
},
file: {
value: false
},
debug: {
value: false
},
zip: {
value: false
},
logtype: {
value: "info",
required: true
}
// info: {
// type: "info"
// },
// warn: {
// type: "warn"
// },
// error: {
// type: "error"
// }
},
inputs: 1,
outputs: 0,
icon: "log.png",
align: "right",
label: function() {
return this.name || "logger";
},
oneditprepare: function() {
$("#node-input-typed-complete").typedInput({
types: ['msg', {
value: "full",
label: RED._("node-red:debug.msgobj"),
hasValue: false
}]
});
if (this.complete === "true" || this.complete === true) {
// show complete message object
$("#node-input-typed-complete").typedInput('type', 'full');
} else {
var property = (!this.complete || (this.complete === "false")) ? "payload" : this.complete + "";
$("#node-input-typed-complete").typedInput('type', 'msg');
$("#node-input-typed-complete").typedInput('value', property);
}
$("#node-input-typed-complete").on('change', function() {
if ($("#node-input-typed-complete").typedInput('type') === 'msg' &&
$("#node-input-typed-complete").typedInput('value') === ''
) {
$("#node-input-typed-complete").typedInput('value', 'payload');
}
});
$("#node-input-file").on("change", function() {
if ($("#node-input-file").is(':checked')) {
$("#node-input-file").attr("file", "file");
$("#filefields").show();
} else {
$("#node-input-file").removeAttr("file");
$("#filefields").hide();
}
});
$("#node-input-logtype").on("change", function() {
if ($("#node-input-logtype").val() === 'info') {
$("#completerow").show();
} else {
$("#completerow").hide();
}
});
},
oneditsave: function() {
var type = $("#node-input-typed-complete").typedInput('type');
if (type === 'full') {
$("#node-input-complete").val("true");
} else {
$("#node-input-complete").val($("#node-input-typed-complete").typedInput('value'));
}
}
});
</script>
<script type="text/x-red" data-template-name="logger">
<div class="form-row">
<label for="node-input-name" style="width: 28%;"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row" style="border: 1px solid black; padding: 5px;">
<label style="width: 28%;"><i class="fa fa-rocket"></i> Log transports</label>
<input type="checkbox" id="node-input-console" placeholder="spawn" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-console" style="width: 18%;"> Console</label>
<input type="checkbox" id="node-input-debug" placeholder="spawn" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-debug" style="width: 18%;"> Debug</label>
<input type="checkbox" id="node-input-file" placeholder="spawn" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-file" style="width: 18%;"> File</label>
</div>
<div class="form-row">
<label for="node-input-logtype" style="width: 28%;"><i class="fa fa-tasks"></i> Log type</label>
<select id="node-input-logtype">
<option value="info">Info logs</option>
<option value="warn">Warn logs</option>
<option value="error">Error logs</option>
</select>
</div>
<div class="form-row" id="completerow">
<label for="node-input-typed-complete" style="width: 28%;"><i class="fa fa-clone"></i> Info log output</label>
<input id="node-input-typed-complete" type="text">
<input id="node-input-complete" type="hidden">
</div>
<div id="filefields" style="border: 1px solid black; padding: 5px;">
<div class="form-row">
<label for="node-input-filename" style="width: 28%;"><i class="fa fa-camera-retro"></i> File name</label>
<input type="text" id="node-input-filename" placeholder="File Name">
</div>
<div class="form-row">
<label for="node-input-maxsize" style="width: 28%;"><i class="fa fa-file"></i> File size(mb)</label>
<input type="number" id="node-input-maxsize" min="1">
</div>
<div class="form-row">
<label for="node-input-maxfiles"style="width: 28%;"><i class="fa fa-files-o"></i> Num of files</label>
<input type="number" id="node-input-maxfiles" min="1">
</div>
<div class="form-row">
<label for="node-input-zip" style="width: 28%;"> </label>
<input type="checkbox" id="node-input-zip" placeholder="spawn" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-zip" style="width: 25%;"> Archive</label>
</div>
</div>
</script>
<script type="text/x-red" data-help-name="logger">
<p>A simple node that converts the message payloads into all lower-case characters</p>
</script>