@5minds/node-red-contrib-processcube-elasticsearch 0.3.3-feature-3f08f9-m4mvvtkj → 0.3.3-feature-ed2d61-m66bsfzh

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,17 @@
1
1
  <script type="text/javascript">
2
2
  RED.nodes.registerType('elastic-search-logger', {
3
3
  category: 'config',
4
+ credentials: {
5
+ username: { type: 'text' },
6
+ password: { type: 'password' },
7
+ index: { type: 'text' },
8
+ },
4
9
  defaults: {
5
10
  name: { value: '' },
6
- url: { value: 'http://engine:8000' },
11
+ url: { value: 'http://localhost:9200' },
7
12
  urlType: { value: 'str' },
8
- username: { value: '' },
9
13
  usernameType: { value: 'str' },
10
- password: { value: '' },
11
14
  passwordType: { value: 'str' },
12
- index: { value: '' },
13
15
  indexType: { value: 'str' },
14
16
  filename: { value: 'log-elastic.log', required: true },
15
17
  maxsize: {
@@ -33,52 +35,35 @@
33
35
  oneditprepare: function () {
34
36
  // URL
35
37
  $('#node-config-input-url').typedInput({
36
- default: 'str',
38
+ type: this.urlType,
37
39
  types: ['str', 'env'],
40
+ typeField: '#node-config-input-urlType',
41
+ value: this.url,
38
42
  });
39
43
 
40
44
  // Username
41
45
  $('#node-config-input-username').typedInput({
42
- default: 'str',
43
- types: ['str', 'env'],
46
+ type: this.usernameType,
47
+ types: ['str', 'cred', 'env'],
48
+ typeField: '#node-config-input-usernameType',
49
+ value: this.credentials.username,
44
50
  });
45
51
 
46
52
  // Password
47
53
  $('#node-config-input-password').typedInput({
48
- default: 'str',
49
- types: ['str', 'env'],
54
+ type: this.passwordType,
55
+ types: ['str', 'cred', 'env'],
56
+ typeField: '#node-config-input-passwordType',
57
+ value: this.credentials.password,
50
58
  });
51
59
 
52
60
  // Index
53
61
  $('#node-config-input-index').typedInput({
54
- default: 'str',
62
+ type: this.indexType,
55
63
  types: ['str', 'env'],
64
+ typeField: '#node-config-input-indexType',
65
+ value: this.credentials.index,
56
66
  });
57
-
58
- $('#node-config-input-url').typedInput('value', this.url);
59
- $('#node-config-input-url').typedInput('type', this.urlType);
60
-
61
- $('#node-config-input-username').typedInput('value', this.username);
62
- $('#node-config-input-username').typedInput('type', this.usernameType);
63
-
64
- $('#node-config-input-password').typedInput('value', this.password);
65
- $('#node-config-input-password').typedInput('type', this.passwordType);
66
-
67
- $('#node-config-input-index').typedInput('value', this.index);
68
- $('#node-config-input-index').typedInput('type', this.indexType);
69
- },
70
- oneditsave: function () {
71
- this.url = $('#node-config-input-url').typedInput('value');
72
- this.urlType = $('#node-config-input-url').typedInput('type');
73
-
74
- this.username = $('#node-config-input-username').typedInput('value');
75
- this.usernameType = $('#node-config-input-username').typedInput('type');
76
-
77
- this.password = $('#node-config-input-password').typedInput('value');
78
- this.passwordType = $('#node-config-input-password').typedInput('type');
79
-
80
- this.index = $('#node-config-input-index').typedInput('value');
81
- this.indexType = $('#node-config-input-index').typedInput('type');
82
67
  },
83
68
  });
84
69
  </script>
@@ -95,18 +80,22 @@
95
80
  <div class="form-row" style="padding-left:20px;">
96
81
  <label for="node-config-input-url"><i class="fa fa-plug"></i> Elastic URL</label>
97
82
  <input type="text" id="node-config-input-url" />
83
+ <input type="hidden" id="node-config-input-urlType" />
98
84
  </div>
99
85
  <div class="form-row" style="padding-left:20px;">
100
86
  <label for="node-config-input-username"><i class="fa fa-user"></i> Username</label>
101
87
  <input type="text" id="node-config-input-username" />
88
+ <input type="hidden" id="node-config-input-usernameType" />
102
89
  </div>
103
90
  <div class="form-row" style="padding-left:20px;">
104
91
  <label for="node-config-input-password"><i class="fa fa-key"></i> Password</label>
105
92
  <input type="text" id="node-config-input-password" />
93
+ <input type="hidden" id="node-config-input-passwordType" />
106
94
  </div>
107
95
  <div class="form-row" style="padding-left:20px;">
108
96
  <label for="node-config-input-index"><i class="fa fa-tag"></i> Index</label>
109
97
  <input type="text" id="node-config-input-index" />
98
+ <input type="hidden" id="node-config-input-indexType" />
110
99
  </div>
111
100
  </div>
112
101
  </script>
@@ -15,29 +15,29 @@ module.exports = function (RED) {
15
15
  this.error('Elastic search url is not set');
16
16
  }
17
17
 
18
- this.credentials.username = RED.util.evaluateNodeProperty(config.username, config.usernameType, this);
19
- if (this.credentials.username == '') {
18
+ let user = RED.util.evaluateNodeProperty(this.credentials.username, config.usernameType, this);
19
+ if (user == '') {
20
20
  this.error('Elastic search username is not set');
21
21
  }
22
22
 
23
- this.credentials.password = RED.util.evaluateNodeProperty(config.password, config.passwordType, this);
24
- if (this.credentials.password == '') {
23
+ let password = RED.util.evaluateNodeProperty(this.credentials.password, config.passwordType, this);
24
+ if (password == '') {
25
25
  this.error('Elastic search password is not set');
26
26
  }
27
27
 
28
- this.credentials.index = RED.util.evaluateNodeProperty(config.index, config.indexType, this);
29
- if (this.credentials.index == '') {
28
+ let index = RED.util.evaluateNodeProperty(this.credentials.index, config.indexType, this);
29
+ if (index == '') {
30
30
  this.error('Elastic search index is not set');
31
31
  }
32
32
 
33
- this.credentials.index = this.credentials.index.toLowerCase();
33
+ index = index.toLowerCase();
34
34
  if (url) {
35
35
  const elasticSearchTransport = new winstonElasticSearch.ElasticsearchTransport({
36
36
  clientOpts: {
37
- node: this.credentials.url,
37
+ node: url,
38
38
  auth: {
39
- username: this.credentials.username,
40
- password: this.credentials.password,
39
+ username: user,
40
+ password: password,
41
41
  },
42
42
  ssl: {
43
43
  // accept any
@@ -45,7 +45,7 @@ module.exports = function (RED) {
45
45
  },
46
46
  },
47
47
  transformer: (logData) => setElasticFields(logData, this),
48
- index: this.credentials.index,
48
+ index: index,
49
49
  });
50
50
 
51
51
  transports.push(elasticSearchTransport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/node-red-contrib-processcube-elasticsearch",
3
- "version": "0.3.3-feature-3f08f9-m4mvvtkj",
3
+ "version": "0.3.3-feature-ed2d61-m66bsfzh",
4
4
  "license": "MIT",
5
5
  "description": "Node-RED nodes for Elasticsearch",
6
6
  "scripts": {