@jambonz/node-red-contrib-jambonz 2.5.0 → 2.5.2

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.5.0",
3
+ "version": "2.5.2",
4
4
  "description": "Node-RED nodes for jambonz platform",
5
5
  "keywords": [
6
6
  "node-red"
@@ -27,7 +27,8 @@
27
27
  actionHookType: {value: 'str'},
28
28
  statusHook: {},
29
29
  statusHookType: {value: 'str'},
30
- joinMuted : {value: false}
30
+ joinMuted : {value: false},
31
+ distributeDtmf: {value: false}
31
32
  },
32
33
  inputs:1,
33
34
  outputs:1,
@@ -110,6 +111,10 @@
110
111
  <div class="form-row">
111
112
  <label for="node-input-joinMuted">Join muted</label>
112
113
  <input type="checkbox" id="node-input-joinMuted">
114
+ </div>
115
+ <div class="form-row">
116
+ <label for="node-input-distributeDtmf">Distribute DTMF</label>
117
+ <input type="checkbox" id="node-input-distributeDtmf">
113
118
  </div>
114
119
  <div class="form-row">
115
120
  <label for="node-input-maxParticipants">Max participants</label>
@@ -19,7 +19,8 @@ module.exports = function(RED) {
19
19
  beep: config.beep,
20
20
  startConferenceOnEnter: config.startConferenceOnEnter,
21
21
  endConferenceOnExit: config.endConferenceOnExit,
22
- joinMuted: config.joinMuted
22
+ joinMuted: config.joinMuted,
23
+ ...(config.distributeDtmf && {'distributeDtmf': true})
23
24
  });
24
25
  node.send(msg);
25
26
  });
@@ -165,12 +165,14 @@
165
165
  url: `_jambonz/applications/${serverId}`,
166
166
  dataType: 'json',
167
167
  timeout: 5000,
168
- error: (err) => {
169
- console.error(`Unable to get application list ${err.statusText}`);
168
+ error: (err) => {
169
+ applicationElem.find('option').remove();
170
+ applicationElem.append('<option value="msg.application_sid">--msg.application_sid--</option>');
171
+ console.log(`Unable to get application list ${err.statusText} ${err}`);
170
172
  },
171
173
  success: (res) => {
172
174
  applicationElem.find('option').remove();
173
- var options = '';
175
+ var options = '<option value="msg.application_sid">--msg.application_sid--</option>';
174
176
  res.forEach((app) => {
175
177
  if (node.application === app.application_sid) {
176
178
  options += `<option value="${app.application_sid}" selected>${app.name}</option>`;
@@ -48,7 +48,11 @@ module.exports = function(RED) {
48
48
 
49
49
  switch (config.mode) {
50
50
  case 'app':
51
- opts.application_sid = config.application;
51
+ if (config.application == 'msg.application_sid'){
52
+ opts.application_sid = msg.application_sid
53
+ } else{
54
+ opts.application_sid = config.application;
55
+ }
52
56
  break
53
57
  case 'url':
54
58
  opts.call_hook = {
@@ -373,7 +373,7 @@
373
373
  addItem: function(container, i, opt) {
374
374
  var header = opt;
375
375
  if (!header.hasOwnProperty('h')) {
376
- header = {h: '', v: ''};
376
+ header = {h: '', v: '', vType: 'str'};
377
377
  }
378
378
  container.css({
379
379
  overflow: 'hidden',
@@ -382,20 +382,23 @@
382
382
  let fragment = document.createDocumentFragment();
383
383
  var row1 = $('<div/>',{style:"display:flex;"}).appendTo(fragment);
384
384
  $('<input/>', {
385
- class:"node-input-header-property-name",
386
- type:"text",
385
+ class:"node-input-header-property-name",
386
+ type:"text",
387
387
  placeholder: 'SIP Header'
388
388
  })
389
389
  .appendTo(row1);
390
390
  $('<input/>', {
391
- class:"node-input-value-property-name",
392
- type:"text",
391
+ class:"node-input-value-property-name",
392
+ type:"text",
393
393
  placeholder: 'value'
394
394
  })
395
- .appendTo(row1);
395
+ .appendTo(row1)
396
+ .typedInput({types: ['str', 'msg', 'flow', 'global', 'jsonata', 'env', mustacheType]});
396
397
 
397
398
  row1.find('.node-input-header-property-name').val(header.h);
398
- row1.find('.node-input-value-property-name').val(header.v);
399
+ var valueField = row1.find('.node-input-value-property-name');
400
+ valueField.typedInput('type', header.vType || 'str');
401
+ valueField.typedInput('value', header.v);
399
402
 
400
403
  container[0].appendChild(fragment);
401
404
  },
@@ -406,6 +409,7 @@
406
409
  var header = {
407
410
  h: '',
408
411
  v: '',
412
+ vType: 'str'
409
413
  };
410
414
  this.headers = [header];
411
415
  }
@@ -457,11 +461,13 @@
457
461
  var header = $(this);
458
462
  console.log(`header: ${JSON.stringify(header)}`);
459
463
  var h = header.find(".node-input-header-property-name").val();
460
- var v = header.find(".node-input-value-property-name").val();
461
- console.log(`added ${h}: ${v}`);
464
+ var vField = header.find(".node-input-value-property-name");
465
+ var v = vField.typedInput('value');
466
+ var vType = vField.typedInput('type');
467
+ console.log(`added ${h}: ${v} (type: ${vType})`);
462
468
  var obj = {};
463
469
  obj[h] = v;
464
- headers.push({h, v});
470
+ headers.push({h, v, vType});
465
471
  });
466
472
  node.headers = headers;
467
473
  console.log(`saved headers ${JSON.stringify(node.headers)}`);
package/src/nodes/dial.js CHANGED
@@ -74,9 +74,12 @@ module.exports = function(RED) {
74
74
 
75
75
  // headers
76
76
  const headers = {};
77
- config.headers.forEach(function(h) {
78
- if (h.h.length && h.v.length) headers[h.h] = h.v;
79
- });
77
+ for (const h of config.headers) {
78
+ if (h.h.length && h.v.length) {
79
+ const resolvedValue = await new_resolve(RED, h.v, h.vType || 'str', node, msg);
80
+ if (resolvedValue) headers[h.h] = resolvedValue;
81
+ }
82
+ }
80
83
  Object.assign(data, {headers});
81
84
 
82
85
  // nested listen
@@ -57,8 +57,7 @@ module.exports = function(RED) {
57
57
  if (/^\d+$/.test(config.mindigits)) obj.minDigits = parseInt(config.mindigits);
58
58
  if (/^\d+$/.test(config.maxdigits)) obj.maxDigits = parseInt(config.maxdigits);
59
59
  if (/^\d+$/.test(config.interdigittimeout)) obj.interDigitTimeout = parseInt(config.interdigittimeout);
60
-
61
- if (config.dtmfbargein) obj.dtmfBargein = config.dtmfbargein;
60
+ if (config.dtmfbargein !== undefined) obj.dtmfBargein = config.dtmfbargein;
62
61
  }
63
62
 
64
63
  // prompt
@@ -55,8 +55,9 @@ module.exports = function(RED) {
55
55
  RED.httpAdmin.get('/_jambonz/applications/:serverId', (req, res) => {
56
56
  const conn = RED.nodes.getNode(req.params.serverId);
57
57
  if (conn && conn.credentials && conn.credentials.apiToken) {
58
- const { apiToken } = conn.credentials;
59
- const { url } = conn;
58
+ const url = RED.util.evaluateNodeProperty( conn.url, conn.urlType, conn, {});
59
+ const apiToken = RED.util.evaluateNodeProperty(conn.credentials.apiToken, conn.apiTokenType, conn, {});
60
+
60
61
  fetch(`${url}/v1/Applications`, {
61
62
  method: 'GET',
62
63
  headers: {