@jambonz/node-red-contrib-jambonz 2.3.4 → 2.3.5

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.3.4",
3
+ "version": "2.3.5",
4
4
  "description": "Node-RED nodes for jambonz platform",
5
5
  "keywords": [
6
6
  "node-red"
@@ -5,34 +5,102 @@
5
5
  color: '#bbabaa',
6
6
  defaults: {
7
7
  name: {value: ''},
8
+ headers: {value: []},
8
9
  },
9
10
  inputs:1,
10
11
  outputs:1,
11
12
  icon: "font-awesome/fa-cubes",
12
13
  label: function() { return this.name || 'hangup';},
14
+ oneditprepare: function() {
15
+ $('#node-input-headers-container').css('min-height','120px').css('min-width','450px').editableList({
16
+ addItem: function(container, i, opt) {
17
+ var header = opt;
18
+ if (!header.hasOwnProperty('h')) {
19
+ header = {h: '', v: ''};
20
+ }
21
+ container.css({
22
+ overflow: 'hidden',
23
+ whiteSpace: 'nowrap'
24
+ });
25
+ let fragment = document.createDocumentFragment();
26
+ var row1 = $('<div/>',{style:"display:flex;"}).appendTo(fragment);
27
+ $('<input/>', {
28
+ class:"node-input-header-property-name",
29
+ type:"text",
30
+ placeholder: 'SIP Header'
31
+ })
32
+ .appendTo(row1);
33
+ $('<input/>', {
34
+ class:"node-input-value-property-name",
35
+ type:"text",
36
+ placeholder: 'value'
37
+ })
38
+ .appendTo(row1);
39
+ row1.find('.node-input-header-property-name').val(header.h);
40
+ row1.find('.node-input-value-property-name').val(header.v);
41
+ container[0].appendChild(fragment);
42
+ },
43
+ removable: true
44
+ });
45
+ if (!this.headers) {
46
+ var header = {
47
+ h: '',
48
+ v: '',
49
+ };
50
+ this.headers = [header];
51
+ }
52
+ for (var i=0; i < this.headers.length; i++) {
53
+ var header = this.headers[i];
54
+ $("#node-input-headers-container").editableList('addItem', header);
55
+ }
56
+ },
57
+ oneditsave: function () {
58
+ var node = this;
59
+ var headers = [];
60
+ $("#node-input-headers-container").editableList('items').each(function(i) {
61
+ var header = $(this);
62
+ var h = header.find(".node-input-header-property-name").val();
63
+ var v = header.find(".node-input-value-property-name").val();
64
+ var obj = {};
65
+ obj[h] = v;
66
+ headers.push({h, v});
67
+ });
68
+ node.headers = headers;
69
+ }
13
70
  });
14
71
  </script>
15
72
 
16
73
  <!-- HTML -->
17
74
  <script type="text/html" data-template-name="hangup">
18
- <div class="form-row">
19
- <label for="node-input-name"><i class="icon-tag"></i> Name</label>
20
- <input type="text" id="node-input-name" placeholder="Name">
75
+ <div class="form-row">
76
+ <label for="node-input-name"><i class="icon-tag"></i> Name</label>
77
+ <input type="text" id="node-input-name" placeholder="Name">
21
78
  </div>
79
+ <fieldset>
80
+ <legend>SIP Headers</legend>
81
+ <div class="form-row" style="margin-bottom:0;">
82
+ <label style="width:100%"><i class="fa fa-list"></i> <span>Add custom headers on hangup</span></label>
83
+ </div>
84
+ <div class="form-row node-input-headers-container-row">
85
+ <ol id="node-input-headers-container"></ol>
86
+ </div>
87
+ </fieldset>
22
88
  </script>
23
89
 
24
90
  <!-- Help Text -->
25
91
  <script type="text/html" data-help-name="hangup">
26
- <p>Hangup the call</p>
27
-
92
+ <p>Hangup the call</p>
93
+ <h3>Properties</h3>
94
+ <p><code>SIP Headers</code> -
95
+ <dd>SIP headers to include in the BYE request</p>
28
96
  <h3>Outputs</h3>
29
- <dl class="message-properties">
30
- <dt>jambonz<span class="property-type">object</span></dt>
31
- <dd> <code>msg.jambonz</code> will contain any previous actions provided to the input with the new <code>hangup</code> action appended </dd>
32
- </dl>
33
-
97
+ <dl class="message-properties">
98
+ <dt>jambonz<span class="property-type">object</span></dt>
99
+ <dd> <code>msg.jambonz</code> will contain any previous actions provided to the input with the new <code>hangup</code> action appended </dd>
100
+ </dl>
101
+
34
102
  <h3>Details</h3>
35
- The hangup verb hangs up the current call.
103
+ The hangup command terminates the call and ends the application.
36
104
  <h3>References</h3>
37
105
  <ul>
38
106
  <li><a href="https://www.jambonz.org/docs/webhooks/hangup/">Jambonz hangup reference</a></li>
@@ -5,9 +5,17 @@ module.exports = function(RED) {
5
5
  RED.nodes.createNode(this, config);
6
6
  var node = this;
7
7
  node.on('input', function(msg) {
8
- appendVerb(msg, {
8
+ var data = {
9
9
  verb: 'hangup'
10
+ };
11
+ // headers
12
+ var headers = {};
13
+ config.headers.forEach(function(h) {
14
+ if (h.h.length && h.v.length) headers[h.h] = h.v;
10
15
  });
16
+ Object.assign(data, {headers});
17
+ appendVerb(msg, data);
18
+ node.log(`hangup jambonz: ${JSON.stringify(msg.jambonz)}`);
11
19
  node.send(msg);
12
20
  });
13
21
  }