-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathadmin.html
93 lines (79 loc) · 3.54 KB
/
admin.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<script type="text/javascript">
(function ()
{
let qrImageWidth = "300";
RED.nodes.registerType('admin',{
category: 'whatsapp',
color: '#25D366',
defaults: {
name: {value:"WA Admin"},
whatsappLink: {value:"", type: "whatsappLink"}
},
outputs:1,
inputs:1,
icon: 'whatsappLink.svg',
label: function() {
return this.name||"admin";
}
});
let removeQrCode = function(NodeID) {
let qrImageElement = document.getElementById("whatsappLink-QRcode-" + NodeID);
if(qrImageElement){
qrImageElement.remove();
}
};
var creatImageContainer = function(NodeID) {
let img = document.getElementById("whatsappLink-QRcode-" + NodeID)
if (!img) {
const container = document.getElementById(NodeID)
if (!container) { return }
const img = document.createElementNS("http://www.w3.org/2000/svg", 'image')
img.setAttribute('id', "whatsappLink-QRcode-" + NodeID)
img.setAttribute('x', '0')
img.setAttribute('y', '45')
img.setAttribute('width', qrImageWidth)
container.insertBefore(img, container.lastChild.nextSibling)
}
};
var renderQrCode = function(id, qrCodeImage){
creatImageContainer(id)
let qrImage = document.getElementById("whatsappLink-QRcode-" + id);
qrImage.setAttribute('href', qrCodeImage)
qrImage.addEventListener("click", ()=> removeQrCode(id), {once:true})
};
RED.comms.subscribe("whatsappLinkQrCode", function (e, msg) {
if (msg.image === null){
removeQrCode(adminNodeId);
}
renderQrCode(msg.id, msg.image);
});
})()
</script>
<script type="text/html" data-template-name="admin">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-whatsappLink"><i class="fa fa-gear"></i> Client</label>
<input type="text" id="node-input-whatsappLink" placeholder="Name">
</div>
</script>
<script type="text/markdown" data-help-name="admin">
Node used for Admin related tasks of whatsapp.
Node used for first time users to connect with whatsapp and other admin related tasks. </br>
Admin Node generate QR Code just below the node for easy connection with whatsapp.
| Inputs | Description |
|--------|-------------- |
| test | Checks the current status of whatsapp and output the same in `msg.payload`|
| destroy| Close the client and destroy the connection.|
| restart | Restart the whatsapp client |
| logout | Simply log you out and close the session. |
| Output | Description |
|--------| ------------|
|`status` | provide status on `msg.payload` for all and each input mentioned in above table. |
| Connecting..| When whatsapp attempting to connect.
| QR Code (image) | when QR code is generated. *This method can also be used to get QR Code (image) generated by whatsapp.*
| Connected | When whatapp is sucessfully connected.|
| Group Joined or Removed | `msg.paylod` : Group Name. </br> `msg.type` : joined / Removed from group.</br> `msg.notification` : Complete notification. </br> `msg.chat` : Complete Group Details.
</script>