@chat21/chat21-web-widget 5.0.52-rc.4 → 5.0.53-rc.1
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/CHANGELOG.md +10 -0
- package/angular.json +1 -3
- package/dist/assets/twp/chatbot-panel.html +4 -64
- package/dist/base_script.html +57 -0
- package/dist/launch.js +4 -61
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/src/app/app.component.ts +4 -12
- package/src/app/app.module.ts +2 -0
- package/src/app/component/conversation-detail/conversation/conversation.component.html +13 -1
- package/src/app/component/conversation-detail/conversation/conversation.component.scss +19 -0
- package/src/app/component/conversation-detail/conversation/conversation.component.ts +51 -30
- package/src/app/component/conversation-detail/conversation-content/conversation-content.component.ts +0 -1
- package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +22 -2
- package/src/app/component/conversation-detail/conversation-preview/conversation-preview.component.ts +0 -1
- package/src/app/component/eyeeye-catcher-card/eyeeye-catcher-card.component.ts +1 -2
- package/src/app/component/form/prechat-form/prechat-form.component.ts +0 -12
- package/src/app/component/home/home.component.html +7 -15
- package/src/app/component/home-conversations/home-conversations.component.ts +12 -72
- package/src/app/component/list-conversations/list-conversations.component.ts +1 -57
- package/src/app/component/message/avatar/avatar.component.ts +0 -1
- package/src/app/component/message/bubble-message/bubble-message.component.ts +0 -2
- package/src/app/component/message/image/image.component.ts +0 -1
- package/src/app/providers/global-settings.service.ts +2 -3
- package/src/app/providers/translator.service.ts +0 -2
- package/src/app/utils/globals.ts +1 -7
- package/src/app/utils/rules.ts +13 -0
- package/src/assets/twp/chatbot-panel.html +4 -64
- package/src/base_script.html +57 -0
- package/src/chat21-core/providers/abstract/logger.service.ts +1 -0
- package/src/chat21-core/providers/firebase/firebase-archivedconversations-handler.ts +0 -41
- package/src/chat21-core/providers/firebase/firebase-conversation-handler.ts +0 -4
- package/src/chat21-core/providers/firebase/firebase-image-repo.ts +0 -2
- package/src/chat21-core/providers/firebase/firebase-notifications.ts +1 -75
- package/src/chat21-core/providers/logger/customLogger.ts +4 -0
- package/src/chat21-core/providers/mqtt/chat-service.ts +1 -3
- package/src/chat21-core/providers/mqtt/mqtt-archivedconversations-handler.ts +0 -1
- package/src/chat21-core/providers/mqtt/mqtt-notifications.ts +0 -2
- package/src/chat21-core/providers/mqtt/mqtt-presence.service.ts +0 -13
- package/src/launch.js +4 -61
- package/dist/test-auth-remote.html +0 -95
- package/dist/test-auth.html +0 -49
- package/dist/test-buttons.html +0 -147
- package/src/test-auth-remote.html +0 -95
- package/src/test-auth.html +0 -49
- package/src/test-buttons.html +0 -147
|
@@ -54,10 +54,8 @@ export class BubbleMessageComponent implements OnInit {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
ngOnChanges() {
|
|
57
|
-
// console.log('BUBBLE-MSG Hello !!!! this.message ', this.message)
|
|
58
57
|
if (this.message && this.message.metadata && typeof this.message.metadata === 'object' ) {
|
|
59
58
|
this.sizeImage = this.getMetadataSize(this.message.metadata)
|
|
60
|
-
// console.log('BUBBLE-MSG ngOnChanges message > metadata', this.message.metadata)
|
|
61
59
|
}
|
|
62
60
|
|
|
63
61
|
}
|
|
@@ -44,7 +44,6 @@ export class ImageComponent implements OnInit {
|
|
|
44
44
|
console.log('Image COMP - IMAGE FILENAME ', fileName)
|
|
45
45
|
fileName? null: fileName = decodeURIComponent(decodeURIComponent(url).split('/').pop())
|
|
46
46
|
// const a: any = document.createElement('a');
|
|
47
|
-
// console.log('ellll', this.el)
|
|
48
47
|
// a.href = this.sanitizer.bypassSecurityTrustUrl(url);
|
|
49
48
|
// a.download = fileName;
|
|
50
49
|
// document.body.appendChild(a);
|
|
@@ -79,7 +79,6 @@ export class GlobalSettingsService {
|
|
|
79
79
|
// const projectid = globals.projectid;
|
|
80
80
|
this.getProjectParametersById(projectid).subscribe( response => {
|
|
81
81
|
const project = response['project'];
|
|
82
|
-
// console.log('1 - setParameters ', project);
|
|
83
82
|
if (project) {
|
|
84
83
|
that.globals.project.initialize(
|
|
85
84
|
project['id'],
|
|
@@ -1674,12 +1673,12 @@ export class GlobalSettingsService {
|
|
|
1674
1673
|
|
|
1675
1674
|
TEMP = getParameterByName(windowContext, 'tiledesk_singleConversation');
|
|
1676
1675
|
if (TEMP) {
|
|
1677
|
-
globals.singleConversation = stringToBoolean(TEMP)
|
|
1676
|
+
globals.singleConversation = stringToBoolean(TEMP);
|
|
1678
1677
|
}
|
|
1679
1678
|
|
|
1680
1679
|
TEMP = getParameterByName(windowContext, 'tiledesk_restartConversation');
|
|
1681
1680
|
if (TEMP) {
|
|
1682
|
-
globals.restartConversation = TEMP;
|
|
1681
|
+
globals.restartConversation = stringToBoolean(TEMP);
|
|
1683
1682
|
}
|
|
1684
1683
|
|
|
1685
1684
|
TEMP = getParameterByName(windowContext, 'tiledesk_nativeRating');
|
|
@@ -69,10 +69,8 @@ export class TranslatorService {
|
|
|
69
69
|
if (browserLang === 'it') {
|
|
70
70
|
this._translate.use('it');
|
|
71
71
|
this.http.get(this.baseLocation + `/assets/i18n/${browserLang}.json`).subscribe(data=> {
|
|
72
|
-
console.log('ress lang', JSON.parse(data['_body']))
|
|
73
72
|
this._translate.setTranslation('it', JSON.parse(data['_body']));
|
|
74
73
|
this._translate.get('LABEL_PREVIEW').subscribe(res => {
|
|
75
|
-
console.log('default translate --> ', res)
|
|
76
74
|
});
|
|
77
75
|
})
|
|
78
76
|
// this._translate.setTranslation('it', './assets/i18n/en.json')
|
package/src/app/utils/globals.ts
CHANGED
|
@@ -221,30 +221,24 @@ export class Globals {
|
|
|
221
221
|
messangerPageTitle: string; // ******* new ********
|
|
222
222
|
telegramUsername: string; // ******* new ********
|
|
223
223
|
constructor(
|
|
224
|
-
) {
|
|
225
|
-
// console.log(' ---------------- 1: initDefafultParameters ---------------- ');
|
|
226
|
-
}
|
|
224
|
+
) { }
|
|
227
225
|
|
|
228
226
|
|
|
229
227
|
/**
|
|
230
228
|
* 1: initParameters
|
|
231
229
|
*/
|
|
232
230
|
initDefafultParameters() {
|
|
233
|
-
// console.log('initDefafultParameters, ', window, window.frameElement);
|
|
234
231
|
this.globalsParameters = {};
|
|
235
232
|
this.filterSystemMsg = true;
|
|
236
233
|
|
|
237
234
|
let wContext: any = window;
|
|
238
|
-
// console.log('windowContext 0', wContext);
|
|
239
235
|
if (window.frameElement && window.frameElement.getAttribute('tiledesk_context') === 'parent') {
|
|
240
236
|
wContext = window.parent;
|
|
241
237
|
}
|
|
242
|
-
// console.log('windowContext 1', wContext);
|
|
243
238
|
const windowcontextFromWindow = getParameterByName(window, 'windowcontext');
|
|
244
239
|
if (windowcontextFromWindow !== null && windowcontextFromWindow === 'window.parent') {
|
|
245
240
|
wContext = window.parent;
|
|
246
241
|
}
|
|
247
|
-
// console.log('windowContext 2', wContext);
|
|
248
242
|
// this.parameters['windowContext'] = windowContext;
|
|
249
243
|
this.windowContext = wContext;
|
|
250
244
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
|
|
2
|
+
import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
|
|
3
|
+
export class Rules {
|
|
4
|
+
|
|
5
|
+
private url = window.location
|
|
6
|
+
|
|
7
|
+
private logger: LoggerService = LoggerInstance.getInstance()
|
|
8
|
+
constructor(){}
|
|
9
|
+
|
|
10
|
+
initRules(){
|
|
11
|
+
console.log('locationnnnnnn', this.url)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -231,10 +231,11 @@
|
|
|
231
231
|
}
|
|
232
232
|
</script> -->
|
|
233
233
|
|
|
234
|
-
|
|
235
|
-
<meta property="og:
|
|
234
|
+
|
|
235
|
+
<meta property="og:title" content="Try Tiledesk now!" />
|
|
236
|
+
<meta property="og:description" content="Qualify your leads to increase your sales faster. It's really easy to do it with the Tiledesk conversational form builder" />
|
|
237
|
+
<meta property="og:image" content="https://tiledesk.com/wp-content/uploads/2022/12/6029654-02-min.png" />
|
|
236
238
|
<meta property="og:locale" content="en">
|
|
237
|
-
<meta property="og:image" content="">
|
|
238
239
|
|
|
239
240
|
<link rel="icon" type="image/png" href="./tiledesk_widget_files/logo-short.png">
|
|
240
241
|
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
|
|
@@ -345,71 +346,10 @@
|
|
|
345
346
|
if(urlToConsole){
|
|
346
347
|
baseUrlConsole = urlToConsole;
|
|
347
348
|
}
|
|
348
|
-
|
|
349
|
-
|
|
350
349
|
|
|
351
350
|
var currentUrl = window.location.href
|
|
352
351
|
var baseUrl = window.location.origin
|
|
353
|
-
function shareOnFacebook() {
|
|
354
|
-
var fbShareUrl = "https://www.facebook.com/sharer.php?u=" + encodeURIComponent(currentUrl);
|
|
355
|
-
window.open(
|
|
356
|
-
fbShareUrl,
|
|
357
|
-
'_blank'
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
352
|
|
|
361
|
-
function shareOnTwitter() {
|
|
362
|
-
var TwShareUrl = "https://twitter.com/share?url=" + encodeURIComponent(currentUrl);
|
|
363
|
-
window.open(
|
|
364
|
-
TwShareUrl,
|
|
365
|
-
'_blank'
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
function shareOnLinkedin() {
|
|
370
|
-
var LinkedinShareUrl = "https://www.linkedin.com/shareArticle?mini=true&url=" + encodeURIComponent(currentUrl);
|
|
371
|
-
window.open(
|
|
372
|
-
LinkedinShareUrl,
|
|
373
|
-
'_blank'
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
function shareOnTelegram() {
|
|
378
|
-
var TelegramShareUrl = "tg://msg_url?url=" + encodeURIComponent(currentUrl) ;
|
|
379
|
-
// console.log('TelegramShareUrl ', TelegramShareUrl )
|
|
380
|
-
window.open(
|
|
381
|
-
TelegramShareUrl,
|
|
382
|
-
'_blank'
|
|
383
|
-
);
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
function shareOnWhatsapp() {
|
|
387
|
-
var WhatsappShareUrl = "whatsapp://send?text=" + currentUrl;
|
|
388
|
-
window.open(
|
|
389
|
-
WhatsappShareUrl,
|
|
390
|
-
'_blank'
|
|
391
|
-
);
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
function goToConsole(){
|
|
395
|
-
var url = new URL(currentUrl);
|
|
396
|
-
var tiledesk_projectid = url.searchParams.get("tiledesk_projectid");
|
|
397
|
-
var project_name = url.searchParams.get("project_name");
|
|
398
|
-
var urlConsole = baseUrlConsole + "#/project/"+tiledesk_projectid+"/home";
|
|
399
|
-
//var urlConsole = "dashboard/#/project/"+tiledesk_projectid+"/home";
|
|
400
|
-
window.open(
|
|
401
|
-
urlConsole,
|
|
402
|
-
'_blank'
|
|
403
|
-
);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
function goToTestPage(){
|
|
407
|
-
var urlTestPage = currentUrl.replace('index.html', 'index-dev.html')
|
|
408
|
-
window.open(
|
|
409
|
-
urlTestPage,
|
|
410
|
-
'_blank'
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
353
|
|
|
414
354
|
var url = new URL(currentUrl);
|
|
415
355
|
var tiledesk_projectid = url.searchParams.get("tiledesk_projectid");
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<html lang="en">
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="utf-8">
|
|
4
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
|
5
|
+
<title>Tilechat Widget</title>
|
|
6
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
|
7
|
+
<script>
|
|
8
|
+
var tiledeskScriptBaseLocation = window.location.href.replace("/base_script.html","");
|
|
9
|
+
|
|
10
|
+
var link_2 = document.createElement('link')
|
|
11
|
+
link_2.setAttribute('rel', 'stylesheet')
|
|
12
|
+
link_2.setAttribute('type', 'text/css')
|
|
13
|
+
link_2.setAttribute('href', tiledeskScriptBaseLocation + '/assets/styles/tiledesk_v1.scss')
|
|
14
|
+
link_2.setAttribute('media','all')
|
|
15
|
+
|
|
16
|
+
var script_1 = document.createElement('script')
|
|
17
|
+
script_1.setAttribute('type','text/javascript')
|
|
18
|
+
script_1.setAttribute('src',tiledeskScriptBaseLocation + '/runtime.js')
|
|
19
|
+
var script_2 = document.createElement('script')
|
|
20
|
+
script_2.setAttribute('type','text/javascript')
|
|
21
|
+
script_2.setAttribute('src',tiledeskScriptBaseLocation + '/polyfills.js')
|
|
22
|
+
var link = document.createElement('link')
|
|
23
|
+
link.setAttribute('type','text/css')
|
|
24
|
+
link.setAttribute('rel','stylesheet')
|
|
25
|
+
link.setAttribute('href',tiledeskScriptBaseLocation + '/styles.css')
|
|
26
|
+
link.setAttribute('media','all')
|
|
27
|
+
var script_4 = document.createElement('script')
|
|
28
|
+
script_4.setAttribute('type','text/javascript')
|
|
29
|
+
script_4.setAttribute('src',tiledeskScriptBaseLocation + '/vendor.js')
|
|
30
|
+
var script_5 = document.createElement('script')
|
|
31
|
+
script_5.setAttribute('type','text/javascript')
|
|
32
|
+
script_5.setAttribute('src',tiledeskScriptBaseLocation + '/main.js')
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
window.addEventListener("load", (event) => {
|
|
36
|
+
|
|
37
|
+
let head = document.getElementsByTagName('head')[0]
|
|
38
|
+
head.appendChild(link_2)
|
|
39
|
+
|
|
40
|
+
let body = document.getElementsByTagName('body')[0]
|
|
41
|
+
body.appendChild(script_1)
|
|
42
|
+
body.appendChild(script_2)
|
|
43
|
+
body.appendChild(link)
|
|
44
|
+
body.appendChild(script_4)
|
|
45
|
+
body.appendChild(script_5)
|
|
46
|
+
});
|
|
47
|
+
</script>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
<chat-root></chat-root>
|
|
51
|
+
<!-- <script type="text/javascript" src="http://localhost:4202/runtime.js"></script>
|
|
52
|
+
<script type="text/javascript" src="http://localhost:4202/polyfills.js"></script>
|
|
53
|
+
<script type="text/css" src="http://localhost:4202/styles.css"></script>
|
|
54
|
+
<script type="text/javascript" src="http://localhost:4202/vendor.js"></script>
|
|
55
|
+
<script type="text/javascript" src="http://localhost:4202/main.js"></script> -->
|
|
56
|
+
</body>
|
|
57
|
+
</html>
|
|
@@ -9,6 +9,7 @@ export abstract class LoggerService {
|
|
|
9
9
|
constructor() { }
|
|
10
10
|
|
|
11
11
|
abstract setLoggerConfig(isLogEnabled: boolean, logLevel: string);
|
|
12
|
+
abstract getLoggerConfig(): {isLogEnabled: boolean, logLevel: number};
|
|
12
13
|
abstract debug(...message: any[])
|
|
13
14
|
abstract log(...message: any[])
|
|
14
15
|
abstract warn(...message: any[])
|
|
@@ -214,20 +214,6 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
|
|
|
214
214
|
// ---------------------------------------------------------- //
|
|
215
215
|
// BEGIN PRIVATE FUNCTIONS
|
|
216
216
|
// ---------------------------------------------------------- //
|
|
217
|
-
/**
|
|
218
|
-
*
|
|
219
|
-
*/
|
|
220
|
-
// private getConversationsFromStorage() {
|
|
221
|
-
// const that = this;
|
|
222
|
-
// this.databaseProvider.getConversations()
|
|
223
|
-
// .then((conversations: [ConversationModel]) => {
|
|
224
|
-
// that.loadedConversationsStorage.next(conversations);
|
|
225
|
-
// })
|
|
226
|
-
// .catch((e) => {
|
|
227
|
-
// console.log('error: ', e);
|
|
228
|
-
// });
|
|
229
|
-
// }
|
|
230
|
-
|
|
231
217
|
|
|
232
218
|
// /** DEPRECATED
|
|
233
219
|
// *
|
|
@@ -252,33 +238,6 @@ export class FirebaseArchivedConversationsHandler extends ArchivedConversationsH
|
|
|
252
238
|
}
|
|
253
239
|
}
|
|
254
240
|
|
|
255
|
-
/**
|
|
256
|
-
* @param childSnapshot
|
|
257
|
-
*/
|
|
258
|
-
// private conversationGenerate(childSnapshot: any): ConversationModel {
|
|
259
|
-
// console.log('conversationGenerate: ', childSnapshot.val());
|
|
260
|
-
// const childData: ConversationModel = childSnapshot.val();
|
|
261
|
-
// childData.uid = childSnapshot.key;
|
|
262
|
-
// const conversation = this.completeConversation(childData);
|
|
263
|
-
// if (this.isValidConversation(conversation)) {
|
|
264
|
-
// this.setClosingConversation(childSnapshot.key, false);
|
|
265
|
-
// const index = searchIndexInArrayForUid(this.conversations, conversation.uid);
|
|
266
|
-
// if (index > -1) {
|
|
267
|
-
// this.conversations.splice(index, 1, conversation);
|
|
268
|
-
// } else {
|
|
269
|
-
// this.conversations.splice(0, 0, conversation);
|
|
270
|
-
// }
|
|
271
|
-
// //this.databaseProvider.setConversation(conversation);
|
|
272
|
-
// this.conversations.sort(compareValues('timestamp', 'desc'));
|
|
273
|
-
// if (conversation.is_new) {
|
|
274
|
-
// this.soundMessage();
|
|
275
|
-
// }
|
|
276
|
-
// return conversation;
|
|
277
|
-
// } else {
|
|
278
|
-
// return null;
|
|
279
|
-
// }
|
|
280
|
-
// }
|
|
281
|
-
|
|
282
241
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
|
|
283
242
|
/**
|
|
284
243
|
* 1 - completo la conversazione con i parametri mancanti
|
|
@@ -405,9 +405,7 @@ export class FirebaseConversationHandler extends ConversationHandlerService {
|
|
|
405
405
|
} else if ((message.attributes.messagelabel && message.attributes.messagelabel.key === CHAT_CLOSED)) {
|
|
406
406
|
message.text = INFO_SUPPORT_CHAT_CLOSED;
|
|
407
407
|
} else if ((message.attributes && message.attributes.messagelabel && message.attributes.messagelabel.key === TOUCHING_OPERATOR) && message.sender === "system") {
|
|
408
|
-
// console.log('FIREBASEConversationHandlerSERVICE message text', message.text)
|
|
409
408
|
const textAfterColon = message.text.split(":")[1]
|
|
410
|
-
// console.log('FIREBASEConversationHandlerSERVICE message text - textAfterColon', textAfterColon)
|
|
411
409
|
if (textAfterColon !== undefined) {
|
|
412
410
|
message.text = INFO_A_NEW_SUPPORT_REQUEST_HAS_BEEN_ASSIGNED_TO_YOU + ': ' + textAfterColon;
|
|
413
411
|
}
|
|
@@ -534,7 +532,6 @@ private addCommandMessage(msg: MessageModel){
|
|
|
534
532
|
that.logger.debug('[FIREBASEConversationHandlerSERVICE] addCommandMessage --> type="wait"', command, i, commands.length)
|
|
535
533
|
//publish waiting event to simulate user typing
|
|
536
534
|
if(isJustRecived(that.startTime.getTime(), msg.timestamp)){
|
|
537
|
-
// console.log('message just received::', command, i, commands)
|
|
538
535
|
that.messageWait.next({uid: that.conversationWith, uidUserTypingNow: msg.sender, nameUserTypingNow: msg.sender_fullname, waitTime: command.time, command: command})
|
|
539
536
|
}
|
|
540
537
|
setTimeout(function() {
|
|
@@ -571,7 +568,6 @@ private generateMessageObject(message, command_message, callback) {
|
|
|
571
568
|
|
|
572
569
|
|
|
573
570
|
private isValidMessage(msgToCkeck:MessageModel): boolean{
|
|
574
|
-
// console.log('message to check-->', msgToCkeck)
|
|
575
571
|
// if(!this.isValidField(msgToCkeck.uid)){
|
|
576
572
|
// return false;
|
|
577
573
|
// }
|
|
@@ -41,11 +41,9 @@ export class FirebaseImageRepoService extends ImageRepoService {
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
checkImageExists(url: string, callback: (exist: boolean) => void): void {
|
|
44
|
-
console.log('urllll', url)
|
|
45
44
|
this.http.get(url, { responseType: 'blob' }).subscribe( res => {
|
|
46
45
|
callback(true)
|
|
47
46
|
},(error) => {
|
|
48
|
-
console.log('ressssssss errorr', error);
|
|
49
47
|
callback(false)
|
|
50
48
|
})
|
|
51
49
|
}
|
|
@@ -48,13 +48,7 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
48
48
|
});
|
|
49
49
|
} else {
|
|
50
50
|
this.logger.log("[FIREBASE-NOTIFICATIONS] initialize - Service Worker is supported on this browser - !not registered",)
|
|
51
|
-
|
|
52
|
-
// .then(function (registration) {
|
|
53
|
-
// console.log('Service worker successfully registered.');
|
|
54
|
-
// return registration;
|
|
55
|
-
// }).catch(function (err) {
|
|
56
|
-
// console.error('Unable to register service worker.', err);
|
|
57
|
-
// });
|
|
51
|
+
|
|
58
52
|
}
|
|
59
53
|
});
|
|
60
54
|
}
|
|
@@ -98,61 +92,6 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
98
92
|
}
|
|
99
93
|
}
|
|
100
94
|
|
|
101
|
-
// getNotificationPermissionAndSaveToken(currentUserUid) {
|
|
102
|
-
// // this.tenant = this.getTenant();
|
|
103
|
-
// this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - tenant ', this.tenant)
|
|
104
|
-
// this.logger.log('[FIREBASE-NOTIFICATIONS] calling requestPermission - currentUserUid ', currentUserUid)
|
|
105
|
-
// this.userId = currentUserUid;
|
|
106
|
-
// const messaging = firebase.messaging();
|
|
107
|
-
// if (firebase.messaging.isSupported()) {
|
|
108
|
-
// // messaging.requestPermission()
|
|
109
|
-
// Notification.requestPermission().then((permission) => {
|
|
110
|
-
// if (permission === 'granted') {
|
|
111
|
-
// this.logger.log('[FIREBASE-NOTIFICATIONS] >>>> requestPermission Notification permission granted.');
|
|
112
|
-
// messaging.getToken({ vapidKey: 'BOsgS2ADwspKdWAmiFDZXEYqY1HSYADVfJT3j67wsySh3NxaViJqoabPJH8WM02wb5r8cQIm5TgM0UK047Z1D1c'}).then((currentToken) => {
|
|
113
|
-
// if (currentToken) {
|
|
114
|
-
// this.sendTokenToServer(currentToken);
|
|
115
|
-
// // updateUIForPushEnabled(currentToken);
|
|
116
|
-
|
|
117
|
-
// } else {
|
|
118
|
-
// // Show permission request UI
|
|
119
|
-
// console.log('No registration token available. Request permission to generate one.');
|
|
120
|
-
// // ...
|
|
121
|
-
// }
|
|
122
|
-
// }).catch((err) => {
|
|
123
|
-
// console.log('An error occurred while retrieving token. ', err);
|
|
124
|
-
// // ...
|
|
125
|
-
// });
|
|
126
|
-
|
|
127
|
-
// resetUI()
|
|
128
|
-
|
|
129
|
-
// } else {
|
|
130
|
-
// this.logger.error('Unable to get permission to notify.');
|
|
131
|
-
// }
|
|
132
|
-
// })
|
|
133
|
-
|
|
134
|
-
// }
|
|
135
|
-
// }
|
|
136
|
-
|
|
137
|
-
// sendTokenToServer(currentToken) {
|
|
138
|
-
// if (!this.isTokenSentToServer()) {
|
|
139
|
-
// console.log('Sending token to server...');
|
|
140
|
-
// // TODO(developer): Send the current token to your server.
|
|
141
|
-
// this.setTokenSentToServer(true);
|
|
142
|
-
// } else {
|
|
143
|
-
// console.log('Token already sent to server so won\'t send it again ' +
|
|
144
|
-
// 'unless it changes');
|
|
145
|
-
// }
|
|
146
|
-
// }
|
|
147
|
-
|
|
148
|
-
// isTokenSentToServer() {
|
|
149
|
-
// return window.localStorage.getItem('sentToServer') === '1';
|
|
150
|
-
// }
|
|
151
|
-
|
|
152
|
-
// setTokenSentToServer(sent) {
|
|
153
|
-
// window.localStorage.setItem('sentToServer', sent ? '1' : '0');
|
|
154
|
-
// }
|
|
155
|
-
|
|
156
95
|
removeNotificationsInstance(callback: (string) => void) {
|
|
157
96
|
var self = this;
|
|
158
97
|
firebase.auth().onAuthStateChanged(function (user) {
|
|
@@ -190,19 +129,6 @@ export class FirebaseNotifications extends NotificationsService {
|
|
|
190
129
|
}
|
|
191
130
|
}
|
|
192
131
|
|
|
193
|
-
// removeNotificationsInstance() {
|
|
194
|
-
// let promise = new Promise((resolve, reject) => {
|
|
195
|
-
// this.appStoreService.getInstallation(this.projectId).then((res) => {
|
|
196
|
-
// console.log("Get Installation Response: ", res);
|
|
197
|
-
// resolve(res);
|
|
198
|
-
// }).catch((err) => {
|
|
199
|
-
// console.error("Error getting installation: ", err);
|
|
200
|
-
// reject(err);
|
|
201
|
-
// })
|
|
202
|
-
// })
|
|
203
|
-
// return promise;
|
|
204
|
-
// }
|
|
205
|
-
|
|
206
132
|
|
|
207
133
|
// ********** PRIVATE METHOD - START ****************//
|
|
208
134
|
private updateToken(FCMcurrentToken, currentUserUid) {
|
|
@@ -23,6 +23,10 @@ export class CustomLogger extends LoggerService{
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
getLoggerConfig(): {isLogEnabled: boolean, logLevel: number}{
|
|
27
|
+
return {isLogEnabled: this.isLogEnabled, logLevel: this.logLevel}
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
error(message: any, ...optionalParams: any[]) {
|
|
27
31
|
if (this.isLogEnabled && this.logLevel >= LogLevel.ERROR) {
|
|
28
32
|
this.logger.error(message, ...optionalParams)
|
|
@@ -34,10 +34,8 @@ export class Chat21Service {
|
|
|
34
34
|
}
|
|
35
35
|
if (!this.chatClient) {
|
|
36
36
|
this.chatClient = new Chat21Client(this._config);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
37
|
+
} else {
|
|
39
38
|
console.log("Did you try again to create a Chat21Client istance?");
|
|
40
39
|
}
|
|
41
|
-
// console.log("chatClient init. ID:", this.chatClient.client_id)
|
|
42
40
|
}
|
|
43
41
|
}
|
|
@@ -63,7 +63,6 @@ export class MQTTArchivedConversationsHandler extends ArchivedConversationsHandl
|
|
|
63
63
|
const conversation = this.archivedConversations.find(conv => conv.conversation_with === conversationWith);
|
|
64
64
|
this.logger.log('[MQTTArchivedConversationsHandler] getConversationDetail found locally? *****: ', conversation);
|
|
65
65
|
if (conversation) {
|
|
66
|
-
console.log('found!');
|
|
67
66
|
callback(conversation);
|
|
68
67
|
} else {
|
|
69
68
|
this.logger.log('[MQTTArchivedConversationsHandler] getConversationDetail Not found locally, remote.getConversationDetail *****: ', conversation);
|
|
@@ -35,10 +35,8 @@ export class MQTTNotifications extends NotificationsService {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
getNotificationPermissionAndSaveToken(currentUserUid) {
|
|
38
|
-
console.log("[MQTTNotificationService] getNotificationPermissionAndSaveToken()",currentUserUid );
|
|
39
38
|
this.userId = currentUserUid;
|
|
40
39
|
if (firebase.messaging.isSupported()) {
|
|
41
|
-
console.log("[MQTTNotificationService] firebase.messaging.isSupported -> YES");
|
|
42
40
|
const messaging = firebase.messaging();
|
|
43
41
|
// messaging.requestPermission()
|
|
44
42
|
Notification.requestPermission().then((permission) => {
|
|
@@ -43,19 +43,6 @@ export class MQTTPresenceService extends PresenceService {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
userIsOnline(userid: string): Observable<any> {
|
|
46
|
-
// console.log('userIsOnline', userid);
|
|
47
|
-
// const that = this;
|
|
48
|
-
// const urlNodeConnections = this.urlNodePresence + userid + '/connections';
|
|
49
|
-
// console.log('userIsOnline: ', urlNodeConnections);
|
|
50
|
-
// const connectionsRef = firebase.database().ref().child(urlNodeConnections);
|
|
51
|
-
// connectionsRef.on('value', (child) => {
|
|
52
|
-
// console.log('is-online-' + userid);
|
|
53
|
-
// if (child.val()) {
|
|
54
|
-
// that.events.publish('is-online-' + userid, userid, true);
|
|
55
|
-
// } else {
|
|
56
|
-
// that.events.publish('is-online-' + userid, userid, false);
|
|
57
|
-
// }
|
|
58
|
-
// });
|
|
59
46
|
return this.BSIsOnline
|
|
60
47
|
}
|
|
61
48
|
|
package/src/launch.js
CHANGED
|
@@ -163,69 +163,12 @@ function loadIframe(tiledeskScriptBaseLocation) {
|
|
|
163
163
|
|
|
164
164
|
iDiv.appendChild(ifrm);
|
|
165
165
|
|
|
166
|
-
// buildIframeDOM(ifrm)
|
|
167
166
|
// ifrm.contentWindow.document.open();
|
|
168
|
-
|
|
169
|
-
// ifrm.
|
|
170
|
-
ifrm.contentWindow.document.
|
|
171
|
-
ifrm.contentWindow.document.
|
|
172
|
-
ifrm.contentWindow.document.close();
|
|
173
|
-
|
|
174
|
-
}
|
|
167
|
+
ifrm.src = tiledeskScriptBaseLocation + '/base_script.html'
|
|
168
|
+
// ifrm.contentWindow.document.open();
|
|
169
|
+
// ifrm.contentWindow.document.write(srcTileDesk);
|
|
170
|
+
// ifrm.contentWindow.document.close();
|
|
175
171
|
|
|
176
|
-
function buildIframeDOM(iframe){
|
|
177
|
-
|
|
178
|
-
var meta = document.createElement('meta');
|
|
179
|
-
meta.setAttribute('charset', 'utf-8')
|
|
180
|
-
var meta_2 = document.createElement('meta')
|
|
181
|
-
meta_2.setAttribute('name', 'viewport')
|
|
182
|
-
meta_2.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0')
|
|
183
|
-
var title = document.createElement('title')
|
|
184
|
-
title.title = 'Tilechat Widget'
|
|
185
|
-
var base = document.createElement('base')
|
|
186
|
-
base.setAttribute('href', './')
|
|
187
|
-
var link_1 = document.createElement('link')
|
|
188
|
-
link_1.setAttribute('rel', 'icon')
|
|
189
|
-
link_1.setAttribute('type', 'image/x-icon')
|
|
190
|
-
link_1.setAttribute('href', 'favicon.ico')
|
|
191
|
-
var link_2 = document.createElement('link')
|
|
192
|
-
link_2.setAttribute('rel', 'stylesheet')
|
|
193
|
-
link_2.setAttribute('type', 'text/css')
|
|
194
|
-
link_2.setAttribute('href', tiledeskScriptBaseLocation + '/assets/styles/tiledesk_v1.scss')
|
|
195
|
-
link_2.setAttribute('media','all')
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
let head = iframe.contentWindow.document.getElementsByTagName('head')[0]
|
|
199
|
-
head.appendChild(meta)
|
|
200
|
-
head.appendChild(meta_2)
|
|
201
|
-
head.appendChild(title)
|
|
202
|
-
head.appendChild(base)
|
|
203
|
-
head.appendChild(link_1)
|
|
204
|
-
head.appendChild(link_2)
|
|
205
|
-
|
|
206
|
-
var script_1 = document.createElement('script')
|
|
207
|
-
script_1.setAttribute('type','text/javascript')
|
|
208
|
-
script_1.setAttribute('src',tiledeskScriptBaseLocation + '/runtime.js')
|
|
209
|
-
var script_2 = document.createElement('script')
|
|
210
|
-
script_2.setAttribute('type','text/javascript')
|
|
211
|
-
script_2.setAttribute('src',tiledeskScriptBaseLocation + '/polyfills.js')
|
|
212
|
-
var script_3 = document.createElement('script')
|
|
213
|
-
script_3.setAttribute('type','text/javascript')
|
|
214
|
-
script_3.setAttribute('src',tiledeskScriptBaseLocation + '/styles.css')
|
|
215
|
-
var script_4 = document.createElement('script')
|
|
216
|
-
script_4.setAttribute('type','text/javascript')
|
|
217
|
-
script_4.setAttribute('src',tiledeskScriptBaseLocation + '/vendor.js')
|
|
218
|
-
var script_5 = document.createElement('script')
|
|
219
|
-
script_5.setAttribute('type','text/javascript')
|
|
220
|
-
script_5.setAttribute('src',tiledeskScriptBaseLocation + '/main.js')
|
|
221
|
-
|
|
222
|
-
let body= iframe.contentWindow.document.getElementsByTagName('body')[0]
|
|
223
|
-
body.appendChild(document.createElement('chat-root'))
|
|
224
|
-
body.appendChild(script_1)
|
|
225
|
-
body.appendChild(script_2)
|
|
226
|
-
body.appendChild(script_3)
|
|
227
|
-
body.appendChild(script_4)
|
|
228
|
-
body.appendChild(script_5)
|
|
229
172
|
}
|
|
230
173
|
|
|
231
174
|
|