-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelastic-search.html
114 lines (107 loc) · 4.25 KB
/
elastic-search.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
<script type="text/javascript">
RED.nodes.registerType('elastic-search', {
category: 'Custom Nodes',
color: '#E9967A',
defaults: {
name: {
value: ""
},
logger: { value: "", type: "elastic-search-logger" },
complete: {
value: "false",
required: true
},
loglevel: {
value: "Debug",
required: true
}
},
inputs: 1,
outputs: 0,
icon: "file.svg",
align: "right",
label: function () {
return this.name || "elastic-search";
},
oneditprepare: function () {
// message
$("#node-input-typed-complete").typedInput({
types: ['msg']
});
$("#node-input-typed-complete").typedInput('type', 'msg');
$("#node-input-typed-complete").typedInput('value', "payload");
$("#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');
}
});
// loglevel
$("#node-input-typed-loglevel").typedInput({
types: [
'msg',
{
value: "level",
label: "level",
options: ["Error", "Warning", "Information", "Debug"]
}
]
});
if (this.loglevel === "Error" ||
this.loglevel === "Warning" ||
this.loglevel === "Information" ||
this.loglevel === "Debug") {
// fixed level
$("#node-input-typed-loglevel").typedInput('type', 'level');
$("#node-input-typed-loglevel").typedInput('value', this.loglevel);
} else {
$("#node-input-typed-loglevel").typedInput('type', 'msg');
$("#node-input-typed-loglevel").typedInput('value', this.loglevel);
}
$("#node-input-typed-loglevel").on('change', function () {
if ($("#node-input-typed-loglevel").typedInput('type') === 'msg') {
var value = $("#node-input-typed-loglevel").typedInput('value')
if (value === "Error" || value === "Warning" || value === "Information" || value === "Debug") {
$("#node-input-typed-loglevel").typedInput('value', 'loglevel');
}
}
});
},
oneditsave: function () {
$("#node-input-complete").val($("#node-input-typed-complete").typedInput('value'));
$("#node-input-loglevel").val($("#node-input-typed-loglevel").typedInput('value'));
}
});
</script>
<script type="text/x-red" data-template-name="elastic-search">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-logger"><i class="fa fa-random"></i> Logger</label>
<input type="text" id="node-input-logger" >
</div>
<div class="form-row">
<label for="node-input-typed-loglevel"><i class="fa fa-list"></i> Log Level</label>
<input id="node-input-typed-loglevel" type="text">
<input id="node-input-loglevel" type="hidden">
</div>
<div class="form-row">
<label for="node-input-typed-complete"><i class="fa fa-list"></i> Output</label>
<input id="node-input-typed-complete" type="text">
<input id="node-input-complete" type="hidden">
</div>
</script>
<script type="text/x-red" data-help-name="elastic-search">
<p>A logging node for Elastic Search using the winston and winston-elastic logging libraries</p>
<h3>Details</h3>
<p>Output <code>msg.payload</code> (or <code>msg.<custom path></code>) or complete <code>msg</code> is used as input of the logged message.</p>
<p>The Log Level (Error, Warning, Information, Debug) used can be configured in the node or can be set
by <code>msg.loglevel</code> (or <code>msg.<custom path></code>).
If the content is not one of ('Error', 'Warning', 'Information', 'Debug'), 'Debug' will be used as fallback</p>
<p>If <code>msg.meta</code> is set, the meta info Object will be added to the file and ElasticSearch output as a JSON string.</p>
<h3>References</h3>
<p>This node is based on parts of node-red-contrib-advance-logger</p>
</script>