@jambonz/node-red-contrib-jambonz 2.3.4 → 2.3.6
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 +1 -1
- package/src/nodes/hangup.html +79 -11
- package/src/nodes/hangup.js +12 -2
package/package.json
CHANGED
package/src/nodes/hangup.html
CHANGED
|
@@ -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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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>
|
package/src/nodes/hangup.js
CHANGED
|
@@ -5,9 +5,19 @@ module.exports = function(RED) {
|
|
|
5
5
|
RED.nodes.createNode(this, config);
|
|
6
6
|
var node = this;
|
|
7
7
|
node.on('input', function(msg) {
|
|
8
|
-
|
|
8
|
+
var data = {
|
|
9
9
|
verb: 'hangup'
|
|
10
|
-
}
|
|
10
|
+
};
|
|
11
|
+
// headers
|
|
12
|
+
var headers = {};
|
|
13
|
+
if (config.headers) {
|
|
14
|
+
config.headers.forEach(function(h) {
|
|
15
|
+
if (h.h.length && h.v.length) headers[h.h] = h.v;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
Object.assign(data, {headers});
|
|
19
|
+
appendVerb(msg, data);
|
|
20
|
+
node.log(`hangup jambonz: ${JSON.stringify(msg.jambonz)}`);
|
|
11
21
|
node.send(msg);
|
|
12
22
|
});
|
|
13
23
|
}
|