@tiledesk/tiledesk-whatsapp-connector 0.1.15 → 0.1.17

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.
Files changed (41) hide show
  1. package/index.js +62 -28
  2. package/package.json +1 -1
  3. package/template/configure.html +218 -145
  4. package/template/css/configure.css +362 -0
  5. package/template/css/detail.css +213 -0
  6. package/template/css/style.css +206 -110
  7. package/template/detail.html +107 -32
  8. package/template/old_configure.html +206 -0
  9. package/tiledesk/TiledeskWhatsappTranslator.js +16 -15
  10. /package/tmp/{media-1wy7l3.jpeg → media-1z2nit.jpeg} +0 -0
  11. package/tmp/media-1z2nkr.mp4 +0 -0
  12. package/tmp/media-1wy8f7.mp4 +0 -0
  13. package/tmp/media-1wy8mz.jpeg +0 -0
  14. package/tmp/media-1wyb62.jpeg +0 -0
  15. package/tmp/media-1wyb7k.mp4 +0 -0
  16. package/tmp/media-1wyb98.pdf +0 -0
  17. package/tmp/media-1wybp7.pdf +0 -0
  18. package/tmp/media-1y8xpl.jpeg +0 -0
  19. package/tmp/media-1y8xpv.jpeg +0 -0
  20. package/tmp/media-1y8xqd.jpeg +0 -0
  21. package/tmp/media-1y8xr4.jpeg +0 -0
  22. package/tmp/media-1y8xty.jpeg +0 -0
  23. package/tmp/media-1y8xvp.jpeg +0 -0
  24. package/tmp/media-1y8xx5.jpeg +0 -0
  25. package/tmp/media-1y8y0g.jpeg +0 -0
  26. package/tmp/media-1y8y4x.jpeg +0 -0
  27. package/tmp/media-1y8y5k.jpeg +0 -0
  28. package/tmp/media-1y8ya4.jpeg +0 -0
  29. package/tmp/media-1y8ya7.jpeg +0 -0
  30. package/tmp/media-1y8yek.jpeg +0 -0
  31. package/tmp/media-1y8yfg.jpeg +0 -0
  32. package/tmp/media-1y8ygr.jpeg +0 -0
  33. package/tmp/media-1y8yh4.jpeg +0 -0
  34. package/tmp/media-1y8yi1.jpeg +0 -0
  35. package/tmp/media-1y8yid.jpeg +0 -0
  36. package/tmp/media-1y8yks.jpeg +0 -0
  37. package/tmp/media-1y8ym4.mp4 +0 -0
  38. package/tmp/media-1y8yqe.jpeg +0 -0
  39. package/tmp/media-1y8yuv.jpeg +0 -0
  40. package/tmp/media-1y8yv9.jpeg +0 -0
  41. package/tmp/media-1y8yy2.jpeg +0 -0
package/index.js CHANGED
@@ -7,6 +7,7 @@ const appRoot = require('app-root-path');
7
7
  const handlebars = require('handlebars');
8
8
  const fs = require('fs');
9
9
  const path = require('path');
10
+ const pjson = require('./package.json');
10
11
 
11
12
  // tiledesk clients
12
13
  const { TiledeskClient } = require('@tiledesk/tiledesk-client');
@@ -57,6 +58,7 @@ router.get('/detail', async (req, res) => {
57
58
 
58
59
  var template = handlebars.compile(html);
59
60
  var replacements = {
61
+ app_version: pjson.version,
60
62
  project_id: projectId,
61
63
  token: token,
62
64
  app_id: app_id,
@@ -102,6 +104,7 @@ router.post('/install', async (req, res) => {
102
104
 
103
105
  var template = handlebars.compile(html);
104
106
  var replacements = {
107
+ app_version: pjson.version,
105
108
  project_id: project_id,
106
109
  token: token,
107
110
  app_id: app_id,
@@ -142,6 +145,7 @@ router.post('/uninstall', async (req, res) => {
142
145
 
143
146
  var template = handlebars.compile(html);
144
147
  var replacements = {
148
+ app_version: pjson.version,
145
149
  project_id: project_id,
146
150
  token: token,
147
151
  app_id: app_id,
@@ -189,6 +193,7 @@ router.get('/configure', async (req, res) => {
189
193
 
190
194
  var template = handlebars.compile(html);
191
195
  var replacements = {
196
+ app_version: pjson.version,
192
197
  project_id: projectId,
193
198
  token: token,
194
199
  proxy_url: proxy_url,
@@ -214,6 +219,7 @@ router.get('/configure', async (req, res) => {
214
219
 
215
220
  var template = handlebars.compile(html);
216
221
  var replacements = {
222
+ app_version: pjson.version,
217
223
  project_id: projectId,
218
224
  token: token,
219
225
  proxy_url: proxy_url,
@@ -258,10 +264,12 @@ router.post('/update', async (req, res) => {
258
264
 
259
265
  var template = handlebars.compile(html);
260
266
  var replacements = {
267
+ app_version: pjson.version,
261
268
  project_id: projectId,
262
269
  token: token,
263
270
  proxy_url: proxy_url,
264
271
  wab_token: settings.wab_token,
272
+ show_success_modal: true,
265
273
  verify_token: settings.verify_token,
266
274
  subscription_id: settings.subscriptionId,
267
275
  }
@@ -316,9 +324,11 @@ router.post('/update', async (req, res) => {
316
324
 
317
325
  var template = handlebars.compile(html);
318
326
  var replacements = {
327
+ app_version: pjson.version,
319
328
  project_id: projectId,
320
329
  token: token,
321
330
  proxy_url: proxy_url,
331
+ show_success_modal: true,
322
332
  wab_token: settings.wab_token,
323
333
  verify_token: settings.verify_token,
324
334
  subscription_id: settings.subscriptionId,
@@ -332,7 +342,27 @@ router.post('/update', async (req, res) => {
332
342
  })
333
343
 
334
344
  }).catch((err) => {
335
- console.log("\n (ERROR) Subscription: ", err)
345
+
346
+ readHTMLFile('/configure.html', (err, html) => {
347
+ if (err) {
348
+ console.log("(ERROR) Read html file: ", err);
349
+ }
350
+
351
+ var template = handlebars.compile(html);
352
+ var replacements = {
353
+ app_version: pjson.version,
354
+ project_id: projectId,
355
+ token: token,
356
+ proxy_url: proxy_url,
357
+ show_error_modal: true
358
+ }
359
+ if (log) {
360
+ console.log("Replacements: ", replacements);
361
+ }
362
+
363
+ var html = template(replacements);
364
+ res.send(html);
365
+ })
336
366
  })
337
367
 
338
368
  }
@@ -348,6 +378,8 @@ router.post('/disconnect', async (req, res) => {
348
378
  let token = req.body.token;
349
379
  let subscriptionId = req.body.subscription_id;
350
380
 
381
+ console.log("uninstall --> subscriptionId: ", subscriptionId)
382
+
351
383
  let CONTENT_KEY = "whatsapp-" + projectId;
352
384
  await db.remove(CONTENT_KEY);
353
385
  console.log("Content deleted.");
@@ -373,6 +405,7 @@ router.post('/disconnect', async (req, res) => {
373
405
 
374
406
  var template = handlebars.compile(html);
375
407
  var replacements = {
408
+ app_version: pjson.version,
376
409
  project_id: projectId,
377
410
  token: token,
378
411
  proxy_url: proxy_url,
@@ -683,36 +716,37 @@ function startApp(settings, callback) {
683
716
  console.log("GRAPH_URL: ", GRAPH_URL);
684
717
  }
685
718
 
686
- if (!settings.APPS_API_URL) {
687
- throw new Error("settings.APPS_API_URL is mandatory");
688
- } else {
689
- APPS_API_URL = settings.APPS_API_URL;
690
- console.log("APPS_API_URL: ", APPS_API_URL);
691
- }
719
+ if (!settings.APPS_API_URL) {
720
+ throw new Error("settings.APPS_API_URL is mandatory");
721
+ } else {
722
+ APPS_API_URL = settings.APPS_API_URL;
723
+ console.log("APPS_API_URL: ", APPS_API_URL);
724
+ }
725
+
726
+ if (settings.log) {
727
+ log = settings.log;
728
+ }
692
729
 
693
- if (settings.log) {
694
- log = settings.log;
730
+ db.connect(settings.MONGODB_URL, () => {
731
+ console.log("KVBaseMongo successfully connected.");
732
+
733
+ if (callback) {
734
+ callback();
695
735
  }
736
+ })
737
+ }
696
738
 
697
- db.connect(settings.MONGODB_URL, () => {
698
- console.log("KVBaseMongo successfully connected.");
699
- if (callback) {
700
- callback();
739
+ function readHTMLFile(templateName, callback) {
740
+ console.log("Reading file: ", templateName)
741
+ fs.readFile(__dirname + '/template' + templateName, { encoding: 'utf-8' },
742
+ function(err, html) {
743
+ if (err) {
744
+ throw err;
745
+ //callback(err);
746
+ } else {
747
+ callback(null, html)
701
748
  }
702
749
  })
703
- }
704
-
705
- function readHTMLFile(templateName, callback) {
706
- console.log("Reading file: ", templateName)
707
- fs.readFile(__dirname + '/template' + templateName, { encoding: 'utf-8' },
708
- function(err, html) {
709
- if (err) {
710
- throw err;
711
- //callback(err);
712
- } else {
713
- callback(null, html)
714
- }
715
- })
716
- }
750
+ }
717
751
 
718
- module.exports = { router: router, startApp: startApp };
752
+ module.exports = { router: router, startApp: startApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiledesk/tiledesk-whatsapp-connector",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
4
4
  "description": "Tiledesk Whatsapp connector",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -23,172 +23,242 @@
23
23
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
24
24
  integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous">
25
25
  </script>
26
-
27
- <link rel="stylesheet" href="./css/style.css">
28
26
 
27
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
28
+ <link rel="stylesheet" href="./css/configure.css">
29
+
30
+ <style>
31
+ body {
32
+ font-family: 'Poppins', serif;
33
+ }
34
+ </style>
35
+
29
36
  </head>
30
37
 
38
+
31
39
  <body>
40
+
41
+ <!-- Success modal -->
42
+ {{#if show_success_modal}}
43
+ <div id="success-update-modal" class="success-modal">
44
+ <div class="modal-content">
45
+ <img src="https://www.pngall.com/wp-content/uploads/9/Green-Tick-Vector-PNG-Images.png" width="80" height="auto" />
46
+ <p class="modal-text" style="margin-top: 20px; margin-bottom: 20px;">Configuration updated successfully</p>
47
+ <button class="btn cancel-btn" onclick="document.getElementById('success-update-modal').style.display='none'">Close</button>
48
+ </div>
49
+ </div>
50
+ {{/if}}
51
+
52
+ <!-- Error modal -->
53
+ {{#if show_error_modal}}
54
+ <div id="error-update-modal" class="error-modal">
55
+ <div class="modal-content">
56
+ <img src="https://cdn-icons-png.flaticon.com/512/148/148766.png" width="80" height="auto" />
57
+ <p style="margin-top: 20px; margin-bottom: 20px;">An error occurred while updating the configuration</p>
58
+ <button class="btn cancel-btn" onclick="document.getElementById('error-update-modal').style.display='none'">Close</button>
59
+ </div>
60
+ </div>
61
+ {{/if}}
62
+
63
+
32
64
 
33
- <div style="padding: 100px 230px; background-color: #efefef; min-width: 800px; display: flex; justify-content: center;" >
34
-
35
- <div style="background-color: white; border-radius: 8px; padding: 20px; box-shadow: 0px 0px 5px 0px #cfcfcf; min-width: 800px;">
36
-
37
- <div>
38
-
39
- <div style="display: flex; flex-direction: row; align-items: center;">
40
-
41
- <div style="margin-right: 80px;">
42
- <img width="130" height="auto" style="margin-top: 6px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/WhatsApp.svg/479px-WhatsApp.svg.png" alt="..." class="img-rounded">
65
+ <!-- HEADER -->
66
+ <div class="header">
67
+ <div class="header-content">
68
+ <div class="logo-title">
69
+ <div class="logo-container">
70
+ <img src="https://www.clipartmax.com/png/full/205-2058823_whatsapp-ios-icon-whatsapp-ios-icon-png.png" width="60px" height="60px">
71
+ </div>
72
+ <div class="title-version">
73
+ <p class="title">WhatsApp Business Connector</p>
74
+ <div class="status-box" style="padding: 0px 8px; letter-spacing: 1px; height: 18px;">
75
+ <p style="margin-bottom: 0px;">{{ app_version }}</p>
43
76
  </div>
44
-
45
- <div>
46
-
47
- <h1 style="margin-top: 0px; margin-bottom: 2px; min-width: 500px;">WhatsApp Business</h1>
48
- <h7 style="color: rgb(140, 140, 140);">by Tiledesk (v. 0.1.9)</h7>
77
+ </div>
78
+ </div>
79
+ <div class="status-box">
80
+ <p style="margin-bottom: 0px; margin-right: 8px;">Status: </p>
81
+ {{#if wab_token}}
82
+ <i class="fa fa-circle green-circle"></i>
83
+ <p style="margin-bottom: 0px;">Connected</p>
84
+ {{else}}
85
+ <i class="fa fa-circle red-circle"></i>
86
+ <p style="margin-bottom: 0px;">Disconnected</p>
87
+ {{/if}}
88
+ </div>
89
+ </div>
90
+ </div>
49
91
 
50
- {{#if wab_token}}
51
- <div style="margin-top: 20px;">
52
- <h7 style="color: rgb(140, 140, 140);">The Whatsapp Business App is configured on your Tildesk project.</h7>
53
- <form action="./disconnect" method="post">
54
- <input type="hidden" name="project_id" value="{{ project_id }}">
55
- <input type="hidden" name="token" value="{{ token }}">
56
- <input type="hidden" name="subscription_id" value="{{ subscription_id }}">
57
- <input type="submit" class="btn btn-danger" style="margin-top: 10px; width: 160px;" value="Disconnect">
58
- </form>
59
- </div>
60
- {{/if}}
61
-
62
- </div>
92
+ <!-- INFO BOX -->
93
+ <div class="info-box">
94
+ <div class="info-list">
95
+ <ul>
96
+ <div class="list-element">
97
+ <img src="https://cdn-icons-png.flaticon.com/512/1443/1443000.png" width=20 height=20 style="margin-right: 10px;"/>
98
+ <h7>Integrate your Whatsapp number with Tiledesk</h7>
99
+ </div>
100
+ <div class="list-element">
101
+ <img src="https://cdn-icons-png.flaticon.com/512/1443/1443000.png" width=20 height=20 style="margin-right: 10px;"/>
102
+ <h7>Once a chat is initiated on your Whatsapp number, receive an alert on your Tiledesk account</h7>
63
103
  </div>
104
+ <div class="list-element">
105
+ <img src="https://cdn-icons-png.flaticon.com/512/1443/1443000.png" width=20 height=20 style="margin-right: 10px;"/>
106
+ <h7>Enable instant messaging and answer multiple conversations, everything from Tiledesk account</h7>
107
+ </div>
108
+ </ul>
109
+ </div>
110
+ </div>
64
111
 
65
- <!--
66
- <button onClick="javascript:window.open('https://gethelp.tiledesk.com/articles/telegram/', '_blank');" class="btn btn- primary">View Documentation</button>
67
- -->
68
-
69
- <div style="margin-top: 40px; padding: 20px; background-color: aliceblue; border-radius: 8px; min-width: 600px;">
70
- <h7>Receive Whatsapp bot conversations in your Tiledesk dashboard. Seamlessly Chat with your targeted audience on Whatsapp right from the Tiledesk dashboard.</h7>
71
- <ul>
72
- <li>
73
- <h7>Integrate your Whatsapp number with Tiledesk.</h7>
74
- </li>
75
- <li>
76
- <h7>Once a chat is initiated on your Whatsapp number, receive an alert on your Tiledesk account.</h7>
77
- </li>
78
- <li>
79
- <h7>Enable instant messaging and answer multiple conversations - everything from Tiledesk account.</h7>
80
- </li>
81
- </ul>
112
+ <!-- Docs Section -->
113
+ <div class="docs-box">
114
+
115
+
116
+ <div class="docs-section">
117
+ <p style="margin-top: 20px; font-size: 18px; font-weight: 600;">Before you start</p>
118
+ <div style="padding: 20px; background-color: #2fa2dc24; border-radius: 8px; width: 600px; margin-bottom: 5px;">
119
+ <div style="display: flex; flex-direction: row; align-items: baseline;">
120
+ <div>
121
+ <img src="https://freeiconshop.com/wp-content/uploads/edd/arrow-flat.png" width="20px" height="auto" style="margin-right: 10px;">
122
+ </div>
123
+ <div>
124
+ <a href="https://gethelp.tiledesk.com/articles/connect-tiledesk-with-whatsapp-business/" target="_blank">Connect Tiledesk with WhatsApp Business</a>
125
+ <p style="color: grey; margin-bottom: 0px;">A small but very useful guide on how to connect your WhatsApp Business number with Tiledesk</p>
82
126
  </div>
127
+ </div>
128
+ </div>
83
129
 
84
- <div style="margin-top: 10px;">
85
- <a href="https://gethelp.tiledesk.com/categories/whatsapp-business/" target="_blank">View documentation</a>
130
+ <div style="padding: 20px; background-color: #2fa2dc24; border-radius: 8px; width: 600px; margin-bottom: 5px;">
131
+ <div style="display: flex; flex-direction: row; align-items: baseline;">
132
+ <div>
133
+ <img src="https://freeiconshop.com/wp-content/uploads/edd/arrow-flat.png" width="20px" height="auto" style="margin-right: 10px;">
86
134
  </div>
87
-
135
+ <div>
136
+ <a href="https://gethelp.tiledesk.com/articles/configure-a-whatsapp-business-account/" target="_blank">Configure a WhatsApp Business account</a>
137
+ <p style="color: grey; margin-bottom: 0px;">Not sure how to set up a business account? Take a look here.</p>
138
+ </div>
139
+ </div>
140
+ </div>
88
141
 
89
- <hr>
142
+ </div>
143
+ </div>
144
+
90
145
 
91
-
92
- <div>
93
- <h4>Your Configuration</h4>
94
-
95
- <div style="min-width: 600px">
96
- <form action="./update" method="post">
97
-
98
- <div class="form-group" style="width: 490px;">
99
- <label for="proxy_url">Webhook Endpoint
100
- <span style="margin-left: 10px;">
101
- <i class="fa fa-question-circle custom-tooltip" style="color: #337ab7;">
102
- <span class="custom-tooltiptext">This is the endpoint to be reached by WhatsApp. Copy it to the Facebook Developer console in "Callback URL" in Whatsapp Configuration. See documention for more info.</span>
103
- </i>
104
- </span>
105
- </label>
106
- <!--<p style="margin-bottom: 5px; font-size: 12px; color: #a7a7a7;">Copy this URL in the Facebook Developer Dashboad. See documentation for more info.</p> -->
107
- <div style="display: flex; flex-direction: row; justify-content: space-between">
108
- <div style="width: 400px;">
109
- <input type="text" readonly class="form-control" name="proxy_url" id="proxy_url"
110
- value="{{ proxy_url}}">
111
- </div>
112
- <div style="width: 80px;">
113
- <!--
114
- <input type="button" class="btn btn-primary" style="width: 100%;"
115
- onclick="copyTextToClipboard(this, document.getElementById('proxy_url').value)"
116
- value="Copy"></input>
117
- -->
118
- <input type="button" id="copy-btn" class="btn btn-primary" style="width: 100%;"
119
- onclick="copyTextToClipboard()"
120
- value="Copy"></input>
121
- </div>
146
+ <!-- CONFIGURE BOX -->
147
+ <div class="configure-box">
148
+ <div class="configure">
149
+ <p class="title" style="margin-bottom: 20px;">Your Configuration</p>
122
150
 
151
+ <div style="min-width: 600px">
152
+ <form action="./update" method="post">
153
+ <div class="form-group" style="width: 590px;">
154
+ <label class="input-label" for="proxy_url">Webhook Endpoint</label>
155
+ <div style="display: flex; flex-direction: row;">
156
+ <div style="width: 522px;">
157
+ <div style="display: flex; flex-direction: row; align-items: center;">
158
+ <input type="text" readonly class="form-control copy-form custom-input" name="proxy_url" id="proxy_url" value="{{ proxy_url}}">
159
+ <span style="margin-left: 10px;">
160
+ <i class="fa fa-question-circle custom-tooltip">
161
+ <span class="custom-tooltiptext">This is the endpoint to be reached by WhatsApp. Copy it to the Facebook Developer console in "Callback URL" in Whatsapp Configuration.</span>
162
+ </i>
163
+ </span>
164
+
123
165
  </div>
166
+
124
167
  </div>
125
-
126
- <div class="form-group" style="width: 400px;">
127
- <label for="wab_token">Whatsapp Token
128
- <span style="margin-left: 10px;">
129
- <i class="fa fa-question-circle custom-tooltip" style="color: #337ab7;">
130
- <span class="custom-tooltiptext">Paste it the permanent WhatsApp Business token. See documention for more info.</span>
131
- </i>
132
- </span>
133
- </label>
134
- <input type="text" class="form-control" name="wab_token" value="{{ wab_token }}"
135
- placeholder="Enter the Whatsapp Token">
168
+ <div id="copy-div" class="icon-btn-div" onclick="copyTextToClipboard()">
169
+ <i class="fa fa-copy icon-btn"></i>
136
170
  </div>
137
-
138
- <div class="form-group" style="width: 400px;">
139
- <label for="verify_token">Verify Token
140
- <span style="margin-left: 10px;">
141
- <i class="fa fa-question-circle custom-tooltip" style="color: #337ab7;">
142
- <span class="custom-tooltiptext">This is a verification token of your choice. Copy it to the Facebook Developer console in "Verify Token" in Whatsapp Configuration.
143
- See documention for more info.</span>
144
- </i>
145
- </span>
146
- </label>
147
- <input type="password" class="form-control" name="verify_token" value="{{ verify_token }}"
148
- placeholder="Enter your Verify Token">
171
+ <div id="copied-div" class="icon-btn-div" style="visibility: hidden;">
172
+ <i class="fa fa-check icon-btn" style="margin-left: -74px; color: green;"></i>
149
173
  </div>
174
+ </div>
175
+ </div>
150
176
 
151
- <input type="hidden" name="project_id" value="{{ project_id }}" />
152
- <input type="hidden" name="token" value="{{ token }}" />
177
+ <!-- Whatsapp Token -->
178
+ <div class="form-group" style="width: 522px;">
179
+ <label class="input-label" for="wab_token">Whatsapp Token
180
+ </label>
181
+ <div style="display: flex; flex-direction: row; align-items: center;">
182
+ <input type="text" required class="form-control custom-input" name="wab_token" value="{{ wab_token }}" placeholder="Enter the Whatsapp Token">
183
+ <span style="margin-left: 10px;">
184
+ <i class="fa fa-question-circle custom-tooltip">
185
+ <span class="custom-tooltiptext">This is the permanent WhatsApp Business token.</span>
186
+ </i>
187
+ </span>
188
+ </div>
189
+ </div>
153
190
 
154
- {{#if wab_token}}
155
- <div style="width: 400px; text-align: right;">
156
- <input type="submit" class="btn btn-primary" style="width: 35%;" value="Update">
157
- </div>
158
- {{else}}
159
- <div style="width: 400px; text-align: right;">
160
- <input type="submit" class="btn btn-primary" style="width: 35%;" value="Connect">
161
- </div>
162
- {{/if}}
191
+ <!-- Verify Token -->
192
+ <div class="form-group" style="width: 522px;">
193
+ <label class="input-label" for="verify_token">Verify Token</label>
194
+ <div style="display: flex; flex-direction: row; align-items: center;">
195
+ <input type="password" required class="form-control custom-input" name="verify_token" value="{{ verify_token }}" placeholder="Enter your Verify Token">
196
+ <span style="margin-left: 10px;">
197
+ <i class="fa fa-question-circle custom-tooltip">
198
+ <span class="custom-tooltiptext">Choose the verification token end copy it to the Facebook Developer console in "Verify Token" in Whatsapp Configuration</span>
199
+ </i>
200
+ </span>
201
+ </div>
202
+ </div>
163
203
 
164
- </form>
204
+ <input type="hidden" name="project_id" value="{{ project_id }}" />
205
+ <input type="hidden" name="token" value="{{ token }}" />
165
206
 
166
-
167
- </div>
168
- </div>
169
-
170
- </div>
207
+ {{#if wab_token}}
208
+ <div style="width: 500px; text-align: right;">
209
+ <input type="submit" class="btn" style="width: 200px; background-color: #0ba2dc; color: white; font-weight: 500;" value="Update">
210
+ </div>
211
+ {{else}}
212
+ <div style="width: 500px; text-align: right;">
213
+ <input type="submit" class="btn" style="width: 200px; background-color: #0ba2dc; color: white; font-weight: 500;" value="Connect">
214
+ </div>
215
+ {{/if}}
216
+ </form>
217
+ </div>
171
218
 
219
+
220
+
172
221
  </div>
173
222
  </div>
174
223
 
175
- <script>
176
-
177
- function copyTextToClipboard2(btn, text) {
178
- console.log("Button clicked")
179
- // if (!navigator.clipboard) {
180
- // fallbackCopyTextToClipboard(text);
181
- // return;
182
- // }
183
- btn.value = "Copied!"
184
- navigator.clipboard.writeText(text).then(function () {
185
- console.log('Async: Copied to clipboard!');
186
-
187
- }, function (err) {
188
- console.error('Async: Could not copy text: ', err);
189
- });
190
- }
224
+
225
+ <div class="disconnect-box">
226
+ <div class="disconnect">
227
+ <p class="title" style="margin-bottom: 20px;"> Disconnect</p>
228
+
229
+ <!-- Disconnect Button -->
230
+ {{#if wab_token}}
231
+ <div>
232
+ <p style="color: rgb(140, 140, 140);">The WhatsApp Business App is configured on your Tildesk project.</p>
233
+ <p>By clicking on disconnect you will no longer be able to receive messages from the WhatsApp channel</p>
234
+ <form action="./disconnect" method="post">
235
+ <input type="hidden" name="project_id" value="{{ project_id }}">
236
+ <input type="hidden" name="token" value="{{ token }}">
237
+ <input type="hidden" name="subscription_id" value="{{ subscription_id }}">
238
+ <input type="submit" class="btn disconnect-button" style="margin-top: 10px; width: 160px;" value="Disconnect">
239
+ </form>
240
+ </div>
241
+ {{else}}
242
+ <!-- App not configured -->
243
+ <p style="color: rgb(140, 140, 140);">The WhatsApp Business App is not yet configured on your Tildesk project.</p>
244
+ {{/if}}
245
+ </div>
246
+ </div>
247
+
248
+
249
+ <!--
250
+ <div class="version-box">
251
+ <div class="version">
252
+ <p class="version-title">App version: </p>
253
+ <div class="status-box" style="padding: 0px 20px; letter-spacing: 1px; height: 30px;">
254
+ <p style="margin-bottom: 0px;">{{ app_version }}</p>
255
+ </div>
256
+ </div>
257
+ </div>
258
+ -->
191
259
 
260
+ <script>
261
+
192
262
  function copyTextToClipboard() {
193
263
  const proxyUrl = document.getElementById('proxy_url').select()
194
264
 
@@ -196,15 +266,18 @@
196
266
  try {
197
267
  document.execCommand('copy');
198
268
  console.log('Async: Copied to clipboard!');
199
- let btn = document.getElementById('copy-btn');
200
- btn.value = "Copied!";
269
+ let el1 = document.getElementById('copy-div');
270
+ el1.style.visibility = 'hidden';
271
+
272
+ let el2 = document.getElementById('copied-div');
273
+ el2.style.visibility = 'visible';
274
+
275
+ //let btn = document.getElementById('copy-btn');
276
+ //btn.value = "Copied!";
201
277
  } catch (err) {
202
278
  console.error('Async: Could not copy text: ', err);
203
279
  }
204
-
205
-
206
- }
280
+ }
207
281
  </script>
208
282
 
209
-
210
- </body>
283
+ </body>