@jambonz/node-red-contrib-jambonz 2.4.7 → 2.4.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/node-red-contrib-jambonz",
3
- "version": "2.4.7",
3
+ "version": "2.4.8",
4
4
  "description": "Node-RED nodes for jambonz platform",
5
5
  "keywords": [
6
6
  "node-red"
@@ -1,12 +1,11 @@
1
1
  <!-- Javascript -->
2
2
  <script type="text/javascript">
3
3
  var mustacheType = {
4
- value: 'mustache',
5
- label: 'mustache',
6
- hasvalue: true,
7
- icon: 'resources/@jambonz/node-red-contrib-jambonz/icons/mustache.svg'
4
+ value: 'mustache',
5
+ label: 'mustache',
6
+ hasvalue: true,
7
+ icon: 'resources/@jambonz/node-red-contrib-jambonz/icons/mustache.svg'
8
8
  }
9
-
10
9
  RED.nodes.registerType('lcc',{
11
10
  category: 'jambonz',
12
11
  color: '#aebfb9',
@@ -38,6 +37,7 @@
38
37
  return action !== 'start_call_recording' || v.length > 0;
39
38
  }},
40
39
  siprecServerURLType: {value: 'str'},
40
+ siprecHeaders: {value: []},
41
41
  recordingID: {value: ''},
42
42
  recordingIDType: {value: 'str'},
43
43
  },
@@ -166,6 +166,61 @@
166
166
  vendorElem.change(onVendorChanged);
167
167
  langElem.change(onLangChanged);
168
168
  voiceElem.change(onVoiceChanged);
169
+
170
+ $('#node-input-siprecHeaders-container').css('min-height','120px').css('min-width','450px').editableList({
171
+ addItem: function(container, i, opt) {
172
+ var header = opt;
173
+ if (!header.hasOwnProperty('h')) {
174
+ header = {h: '', v: ''};
175
+ }
176
+ container.css({
177
+ overflow: 'hidden',
178
+ whiteSpace: 'nowrap'
179
+ });
180
+ let fragment = document.createDocumentFragment();
181
+ var row1 = $('<div/>',{style:"display:flex;"}).appendTo(fragment);
182
+ $('<input/>', {
183
+ class:"node-input-header-property-name",
184
+ type:"text",
185
+ placeholder: 'SIP Header'
186
+ })
187
+ .appendTo(row1);
188
+ $('<input/>', {
189
+ class:"node-input-value-property-name",
190
+ type:"text",
191
+ placeholder: 'value'
192
+ })
193
+ .appendTo(row1);
194
+ row1.find('.node-input-header-property-name').val(header.h);
195
+ row1.find('.node-input-value-property-name').val(header.v);
196
+ container[0].appendChild(fragment);
197
+ },
198
+ removable: true
199
+ });
200
+ if (!this.siprecHeaders) {
201
+ var header = {
202
+ h: '',
203
+ v: '',
204
+ };
205
+ this.siprecHeaders = [header];
206
+ }
207
+ for (var i=0; i < this.siprecHeaders.length; i++) {
208
+ var header = this.siprecHeaders[i];
209
+ $("#node-input-siprecHeaders-container").editableList('addItem', header);
210
+ }
211
+ },
212
+ oneditsave: function () {
213
+ var node = this;
214
+ var headers = [];
215
+ $("#node-input-siprecHeaders-container").editableList('items').each(function(i) {
216
+ var header = $(this);
217
+ var h = header.find(".node-input-header-property-name").val();
218
+ var v = header.find(".node-input-value-property-name").val();
219
+ var obj = {};
220
+ obj[h] = v;
221
+ headers.push({h, v});
222
+ });
223
+ node.siprecHeaders = headers;
169
224
  }
170
225
  });
171
226
  </script>
@@ -259,6 +314,14 @@
259
314
  <input type="text" id="node-input-recordingID" placeholder="545362a9-4cb3-4a55-85b8-b33ca83a6517">
260
315
  <input type="hidden" id="node-input-recordingIDType">
261
316
  </div>
317
+ <fieldset>
318
+ <div class="form-row" style="margin-bottom:0;">
319
+ <label style="width:100%"><i class="fa fa-list"></i> <span>Add custom SIPREC headers</span></label>
320
+ </div>
321
+ <div class="form-row node-input-siprecHeaders-container-row">
322
+ <ol id="node-input-siprecHeaders-container"></ol>
323
+ </div>
324
+ </fieldset>
262
325
  </div>
263
326
  </script>
264
327
 
package/src/nodes/lcc.js CHANGED
@@ -76,6 +76,16 @@ function lcc(config) {
76
76
  siprecServerURL: new_resolve(RED, config.siprecServerURL, config.siprecServerURLType, node, msg),
77
77
  recordingID: new_resolve(RED, config.recordingID, config.recordingIDType, node, msg) || crypto.randomUUID()
78
78
  };
79
+ // SIPREC headers
80
+ if (config.siprecHeaders) {
81
+ var headers = {};
82
+ config.siprecHeaders.forEach(function(h) {
83
+ if (h.h.length && h.v.length) headers[h.h] = h.v;
84
+ });
85
+ if (Object.keys(headers).length) {
86
+ Object.assign(opts.record, {headers});
87
+ }
88
+ }
79
89
  break;
80
90
  case 'stop_call_recording':
81
91
  opts.record = { action: 'stopCallRecording' };