@chat21/chat21-web-widget 5.0.86 → 5.0.89-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.
Files changed (30) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/package.json +1 -1
  3. package/src/app/app.module.ts +5 -2
  4. package/src/app/component/conversation-detail/conversation/conversation.component.ts +16 -16
  5. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.html +29 -0
  6. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.scss +103 -0
  7. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.spec.ts +23 -0
  8. package/src/app/component/conversation-detail/conversation-audio-recorder/conversation-audio-recorder.component.ts +96 -0
  9. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.html +14 -3
  10. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.scss +26 -10
  11. package/src/app/component/conversation-detail/conversation-footer/conversation-footer.component.ts +168 -77
  12. package/src/app/component/message/audio-track/audio-track.component.html +32 -0
  13. package/src/app/component/message/audio-track/audio-track.component.scss +107 -0
  14. package/src/app/component/message/{audio/audio.component.spec.ts → audio-track/audio-track.component.spec.ts} +6 -6
  15. package/src/app/component/message/audio-track/audio-track.component.ts +147 -0
  16. package/src/app/component/message/bubble-message/bubble-message.component.html +31 -15
  17. package/src/app/component/message/bubble-message/bubble-message.component.scss +7 -0
  18. package/src/app/component/message/bubble-message/bubble-message.component.ts +1 -0
  19. package/src/app/utils/globals.ts +1 -1
  20. package/src/app/utils/utils.ts +45 -0
  21. package/src/assets/twp/blank.html +3 -6
  22. package/src/assets/twp/chatbot-panel.html +5 -13
  23. package/src/assets/twp/index-dev.html +8 -15
  24. package/src/assets/twp/index.html +7 -13
  25. package/src/assets/twp/tiledesk_widget_files/bootstrap.min.css +4 -3
  26. package/src/assets/twp/tiledesk_widget_files/bootstrap.min.js +3 -4
  27. package/src/assets/twp/tiledesk_widget_files/jquery.min.js +2 -2
  28. package/src/app/component/message/audio/audio.component.html +0 -20
  29. package/src/app/component/message/audio/audio.component.scss +0 -122
  30. package/src/app/component/message/audio/audio.component.ts +0 -122
@@ -1,5 +1,6 @@
1
1
  import { Component, ComponentFactoryResolver, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges, ViewChild, ViewContainerRef } from '@angular/core';
2
2
  import { Globals } from 'src/app/utils/globals';
3
+ import { checkAcceptedFile } from 'src/app/utils/utils';
3
4
  import { MessageModel } from 'src/chat21-core/models/message';
4
5
  import { UploadModel } from 'src/chat21-core/models/upload';
5
6
  import { ConversationHandlerService } from 'src/chat21-core/providers/abstract/conversation-handler.service';
@@ -59,6 +60,8 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
59
60
  // ========= end:: send image ========= //
60
61
 
61
62
  // isNewConversation = true;
63
+ isStartRec: boolean = false;
64
+ isStopRec: boolean = false;
62
65
  textInputTextArea: string;
63
66
  conversationHandlerService: ConversationHandlerService
64
67
 
@@ -98,7 +101,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
98
101
  }
99
102
 
100
103
  ngAfterViewInit() {
101
- this.logger.debug('[CONV-FOOTER] --------ngAfterViewInit: conversation-footer-------- ');
104
+ this.logger.log('[CONV-FOOTER] --------ngAfterViewInit: conversation-footer-------- ');
102
105
  // setTimeout(() => {
103
106
  this.showEmojiPicker = true
104
107
  // }, 500);
@@ -108,19 +111,18 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
108
111
  // START LOAD IMAGE //
109
112
  /** load the selected image locally and open the pop up preview */
110
113
  detectFiles(event) {
111
- this.logger.debug('[CONV-FOOTER] detectFiles: ', event);
112
-
114
+ this.logger.log('[CONV-FOOTER] detectFiles: ', event);
113
115
  if (event) {
114
116
  this.selectedFiles = event.target.files;
115
- this.logger.debug('[CONV-FOOTER] AppComponent:detectFiles::selectedFiles', this.selectedFiles);
117
+ this.logger.log('[CONV-FOOTER] AppComponent:detectFiles::selectedFiles', this.selectedFiles);
116
118
  // this.onAttachmentButtonClicked.emit(this.selectedFiles)
117
119
  if (this.selectedFiles == null) {
118
120
  this.isFilePendingToUpload = false;
119
121
  } else {
120
122
  this.isFilePendingToUpload = true;
121
123
  }
122
- this.logger.debug('[CONV-FOOTER] AppComponent:detectFiles::selectedFiles::isFilePendingToUpload', this.isFilePendingToUpload);
123
- this.logger.debug('[CONV-FOOTER] fileChange: ', event.target.files);
124
+ this.logger.log('[CONV-FOOTER] AppComponent:detectFiles::selectedFiles::isFilePendingToUpload', this.isFilePendingToUpload);
125
+ this.logger.log('[CONV-FOOTER] fileChange: ', event.target.files);
124
126
  if (event.target.files.length <= 0) {
125
127
  this.isFilePendingToUpload = false;
126
128
  } else {
@@ -129,62 +131,72 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
129
131
 
130
132
  const that = this;
131
133
  if (event.target.files && event.target.files[0]) {
132
- const nameFile = event.target.files[0].name;
133
- const typeFile = event.target.files[0].type;
134
- const size = event.target.files[0].size
135
- const reader = new FileReader();
136
- that.logger.debug('[CONV-FOOTER] OK preload: ', nameFile, typeFile, reader);
137
- reader.addEventListener('load', function () {
138
- that.logger.debug('[CONV-FOOTER] addEventListener load', reader.result);
139
- that.isFileSelected = true;
140
- // se inizia con image
141
- if (typeFile.startsWith('image') && !typeFile.includes('svg')) {
142
- const imageXLoad = new Image;
143
- that.logger.debug('[CONV-FOOTER] onload ', imageXLoad);
144
- imageXLoad.src = reader.result.toString();
145
- imageXLoad.title = nameFile;
146
- imageXLoad.onload = function () {
147
- that.logger.debug('[CONV-FOOTER] onload image');
148
- // that.arrayFilesLoad.push(imageXLoad);
149
- const uid = (new Date().getTime()).toString(36); // imageXLoad.src.substring(imageXLoad.src.length - 16);
150
- that.arrayFilesLoad[0] = { uid: uid, file: imageXLoad, type: typeFile, size: size };
151
- that.logger.debug('[CONV-FOOTER] OK: ', that.arrayFilesLoad[0]);
152
- // SEND MESSAGE
153
- that.loadFile();
154
- };
155
- } else {
156
- that.logger.debug('[CONV-FOOTER] onload file');
157
- const fileXLoad = {
158
- src: reader.result.toString(),
159
- title: nameFile
160
- };
134
+
135
+ const canUploadFile = checkAcceptedFile(event.target.files[0].type, this.fileUploadAccept)
136
+ if(!canUploadFile){
137
+ this.logger.error('[IMAGE-UPLOAD] detectFiles: can not upload current file type--> NOT ALLOWED', this.fileUploadAccept)
138
+ this.isFilePendingToUpload = false;
139
+ return;
140
+ }
141
+
142
+ const nameFile = event.target.files[0].name;
143
+ const typeFile = event.target.files[0].type;
144
+ const size = event.target.files[0].size
145
+ const reader = new FileReader();
146
+ that.logger.debug('[CONV-FOOTER] OK preload: ', nameFile, typeFile, reader);
147
+ reader.addEventListener('load', function () {
148
+ that.logger.debug('[CONV-FOOTER] addEventListener load', reader.result);
149
+ that.isFileSelected = true;
150
+ // se inizia con image
151
+ if (typeFile.startsWith('image') && !typeFile.includes('svg')) {
152
+ const imageXLoad = new Image;
153
+ that.logger.debug('[CONV-FOOTER] onload ', imageXLoad);
154
+ imageXLoad.src = reader.result.toString();
155
+ imageXLoad.title = nameFile;
156
+ imageXLoad.onload = function () {
157
+ that.logger.debug('[CONV-FOOTER] onload image');
161
158
  // that.arrayFilesLoad.push(imageXLoad);
162
159
  const uid = (new Date().getTime()).toString(36); // imageXLoad.src.substring(imageXLoad.src.length - 16);
163
- that.arrayFilesLoad[0] = { uid: uid, file: fileXLoad, type: typeFile, size: size };
160
+ that.arrayFilesLoad[0] = { uid: uid, file: imageXLoad, type: typeFile, size: size };
164
161
  that.logger.debug('[CONV-FOOTER] OK: ', that.arrayFilesLoad[0]);
165
162
  // SEND MESSAGE
166
163
  that.loadFile();
167
- }
168
- }, false);
169
-
170
- if (event.target.files[0]) {
171
- reader.readAsDataURL(event.target.files[0]);
172
- that.logger.debug('[CONV-FOOTER] reader-result: ', event.target.files[0]);
164
+ };
165
+ } else {
166
+ that.logger.debug('[CONV-FOOTER] onload file');
167
+ const fileXLoad = {
168
+ src: reader.result.toString(),
169
+ title: nameFile
170
+ };
171
+ // that.arrayFilesLoad.push(imageXLoad);
172
+ const uid = (new Date().getTime()).toString(36); // imageXLoad.src.substring(imageXLoad.src.length - 16);
173
+ that.arrayFilesLoad[0] = { uid: uid, file: fileXLoad, type: typeFile, size: size };
174
+ that.logger.debug('[CONV-FOOTER] OK: ', that.arrayFilesLoad[0]);
175
+ // SEND MESSAGE
176
+ that.loadFile();
173
177
  }
178
+ }, false);
179
+
180
+ if (event.target.files[0]) {
181
+ reader.readAsDataURL(event.target.files[0]);
182
+ that.logger.debug('[CONV-FOOTER] reader-result: ', event.target.files[0]);
183
+ }
174
184
  }
175
185
  }
176
186
  }
177
187
 
188
+
189
+
178
190
 
179
191
  loadFile() {
180
- this.logger.debug('[CONV-FOOTER] that.fileXLoad: ', this.arrayFilesLoad);
192
+ this.logger.log('[CONV-FOOTER] that.fileXLoad: ', this.arrayFilesLoad);
181
193
  // at the moment I only manage the upload of one image at a time
182
194
  if (this.arrayFilesLoad[0] && this.arrayFilesLoad[0].file) {
183
195
  const fileXLoad = this.arrayFilesLoad[0].file;
184
196
  const uid = this.arrayFilesLoad[0].uid;
185
197
  const type = this.arrayFilesLoad[0].type;
186
198
  const size = this.arrayFilesLoad[0].size
187
- this.logger.debug('[CONV-FOOTER] that.fileXLoad: ', type);
199
+ this.logger.log('[CONV-FOOTER] that.fileXLoad: ', type);
188
200
  let metadata;
189
201
  if (type.startsWith('image') && !type.includes('svg')) {
190
202
  metadata = {
@@ -205,7 +217,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
205
217
  'size': size
206
218
  };
207
219
  }
208
- this.logger.debug('[CONV-FOOTER] metadata -------> ', metadata);
220
+ this.logger.log('[CONV-FOOTER] metadata -------> ', metadata);
209
221
  // this.scrollToBottom();
210
222
  // 1 - aggiungo messaggio localmente
211
223
  // this.addLocalMessageImage(metadata);
@@ -222,17 +234,20 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
222
234
 
223
235
  uploadSingle(metadata, file, messageText?: string) {
224
236
  const that = this;
225
- const send_order_btn = <HTMLInputElement>document.getElementById('chat21-start-upload-doc');
226
- send_order_btn.disabled = true;
227
- that.logger.debug('[CONV-FOOTER] AppComponent::uploadSingle::', metadata, file);
237
+ try {
238
+ const send_order_btn = <HTMLInputElement>document.getElementById('chat21-start-upload-doc');
239
+ send_order_btn.disabled = true;
240
+ } catch (error) {
241
+ that.logger.log('[CONV-FOOTER] error::', error);
242
+ }
243
+ that.logger.log('[CONV-FOOTER] AppComponent::uploadSingle::', metadata, file);
228
244
  // const file = this.selectedFiles.item(0);
229
245
  const currentUpload = new UploadModel(file);
230
-
231
246
  // const uploadTask = this.upSvc.pushUpload(currentUpload);
232
247
  // uploadTask.then(snapshot => {
233
248
  // return snapshot.ref.getDownloadURL(); // Will return a promise with the download link
234
249
  // }).then(downloadURL => {
235
- // that.logger.debug('[CONV-FOOTER] AppComponent::uploadSingle:: downloadURL', downloadURL]);
250
+ // that.logger.log('[CONV-FOOTER] AppComponent::uploadSingle:: downloadURL', downloadURL]);
236
251
  // that.g.wdLog([`Successfully uploaded file and got download link - ${downloadURL}`]);
237
252
 
238
253
  // metadata.src = downloadURL;
@@ -252,8 +267,8 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
252
267
  // this.resetLoadImage();
253
268
 
254
269
  this.uploadService.upload(this.senderId, currentUpload).then(data => {
255
- that.logger.debug('[CONV-FOOTER] AppComponent::uploadSingle:: downloadURL', data);
256
- that.logger.debug(`[CONV-FOOTER] Successfully uploaded file and got download link - ${data}`);
270
+ that.logger.log('[CONV-FOOTER] AppComponent::uploadSingle:: downloadURL', data);
271
+ that.logger.log(`[CONV-FOOTER] Successfully uploaded file and got download link - ${data}`);
257
272
 
258
273
  metadata.src = data.src;
259
274
  metadata.downloadURL = data.downloadURL;
@@ -282,7 +297,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
282
297
  that.logger.error(`[CONV-FOOTER] uploadSingle:: Failed to upload file and get link - ${error}`);
283
298
  that.isFilePendingToUpload = false;
284
299
  });
285
- that.logger.debug('[CONV-FOOTER] reader-result: ', file);
300
+ that.logger.log('[CONV-FOOTER] reader-result: ', file);
286
301
  }
287
302
 
288
303
  /**
@@ -295,7 +310,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
295
310
  sendMessage(msg: string, type: string, metadata?: any, additional_attributes?: any) { // sponziello
296
311
  (metadata) ? metadata = metadata : metadata = '';
297
312
  this.onEmojiiPickerShow.emit(false)
298
- this.logger.debug('[CONV-FOOTER] SEND MESSAGE: ', msg, type, metadata, additional_attributes);
313
+ this.logger.log('[CONV-FOOTER] SEND MESSAGE: ', msg, type, metadata, additional_attributes);
299
314
  if (msg && msg.trim() !== '' || type === TYPE_MSG_IMAGE || type === TYPE_MSG_FILE ) {
300
315
 
301
316
  // msg = htmlEntities(msg);
@@ -378,7 +393,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
378
393
  }
379
394
 
380
395
  private restoreTextArea() {
381
- // that.logger.debug('[CONV-FOOTER] AppComponent:restoreTextArea::restoreTextArea');
396
+ // that.logger.log('[CONV-FOOTER] AppComponent:restoreTextArea::restoreTextArea');
382
397
  this.resizeInputField();
383
398
  const textArea = (<HTMLInputElement>document.getElementById('chat21-main-message-context'));
384
399
  this.textInputTextArea = ''; // clear the textarea
@@ -388,7 +403,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
388
403
  if(textArea.style.height > this.HEIGHT_DEFAULT){
389
404
  document.getElementById('chat21-button-send').style.removeProperty('right')
390
405
  }
391
- this.logger.debug('[CONV-FOOTER] AppComponent:restoreTextArea::restoreTextArea::textArea:', 'restored');
406
+ this.logger.log('[CONV-FOOTER] AppComponent:restoreTextArea::restoreTextArea::textArea:', 'restored');
392
407
  }
393
408
  this.setFocusOnId('chat21-main-message-context');
394
409
  }
@@ -402,7 +417,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
402
417
  try {
403
418
  const target = document.getElementById('chat21-main-message-context') as HTMLInputElement;
404
419
  // tslint:disable-next-line:max-line-length
405
- // that.logger.debug('[CONV-FOOTER] H:: this.textInputTextArea', (document.getElementById('chat21-main-message-context') as HTMLInputElement).value , target.style.height, target.scrollHeight, target.offsetHeight, target.clientHeight);
420
+ // that.logger.log('[CONV-FOOTER] H:: this.textInputTextArea', (document.getElementById('chat21-main-message-context') as HTMLInputElement).value , target.style.height, target.scrollHeight, target.offsetHeight, target.clientHeight);
406
421
  target? target.style.height = '100%': null;
407
422
  if (target && target.value === '\n') {
408
423
  target.value = '';
@@ -422,28 +437,104 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
422
437
  }
423
438
  }
424
439
 
440
+
441
+
442
+ onStartRecording() {
443
+ this.isStartRec = true;
444
+ this.isStopRec = false;
445
+ }
446
+
447
+ onDeleteRecording(){
448
+ this.isStartRec = false;
449
+ this.isStopRec = false;
450
+ }
451
+
452
+ onEndRecording(audioBlob: Blob | null) {
453
+ this.isStartRec = false;
454
+ this.isStopRec = true;
455
+ }
456
+
457
+
458
+
459
+ onSendRecording(audioBlob: Blob | null) {
460
+ this.isStartRec = false;
461
+ if (audioBlob) {
462
+ this.convertBlobToBase64(audioBlob);
463
+ this.isStopRec = false;
464
+ } else {
465
+ this.isStopRec = false;
466
+ }
467
+ }
468
+
469
+
470
+
471
+ // Funzione per convertire Blob in Base64 usando FileReader
472
+ async convertBlobToBase64(audioBlob: Blob) {
473
+ let that = this;
474
+ if (audioBlob) {
475
+ this.isFilePendingToUpload = true;
476
+ } else {
477
+ this.isFilePendingToUpload = false;
478
+ }
479
+ const type = audioBlob.type;
480
+ const size = audioBlob.size;
481
+ const reader = new FileReader();
482
+ reader.readAsDataURL(audioBlob);
483
+ //reader.addEventListener('load', function () {
484
+ reader.onloadend = () => {
485
+ that.isFileSelected = true;
486
+ // const base64data = reader.result as string;
487
+ that.logger.log('[CONV-FOOTER] onload file');
488
+ const fileXLoad = {
489
+ src: reader.result.toString(),
490
+ title: 'audio-file'
491
+ };
492
+ const uid = (new Date().getTime()).toString(36);
493
+ that.arrayFilesLoad[0] = { uid: uid, file: fileXLoad, type: type, size: size };
494
+ that.logger.log('[CONV-FOOTER] OK: ', that.arrayFilesLoad[0]);
495
+ // SEND MESSAGE
496
+ let metadata = {
497
+ 'name': 'audio-file',
498
+ 'src': fileXLoad.src,
499
+ 'type': type,
500
+ 'uid': uid,
501
+ 'size': size
502
+ };
503
+
504
+ const file = new File([audioBlob], "audio-file.mp3", {
505
+ type: audioBlob.type,
506
+ lastModified: Date.now()
507
+ });
508
+
509
+ that.uploadSingle(metadata, file, '');
510
+ };
511
+ //}, false);
512
+ }
513
+
514
+
515
+
425
516
  onTextAreaChange(){
426
517
  this.resizeInputField()
427
518
  this.setWritingMessages(this.textInputTextArea)
428
519
  }
429
520
 
430
521
  onSendPressed(event) {
431
- this.logger.debug('[CONV-FOOTER] onSendPressed:event', event);
522
+ this.logger.log('[CONV-FOOTER] onSendPressed:event', event);
432
523
  event.preventDefault();
433
- this.logger.debug('[CONV-FOOTER] AppComponent::onSendPressed::isFilePendingToUpload:', this.isFilePendingToUpload);
524
+ this.logger.log('[CONV-FOOTER] AppComponent::onSendPressed::isFilePendingToUpload:', this.isFilePendingToUpload);
434
525
  if (this.isFilePendingToUpload) {
435
- this.logger.debug('[CONV-FOOTER] AppComponent::onSendPressed', 'is a file');
526
+ this.logger.log('[CONV-FOOTER] AppComponent::onSendPressed', 'is a file');
436
527
  // its a file
437
528
  this.loadFile();
438
529
  this.isFilePendingToUpload = false;
439
530
  // disabilito pulsanti
440
- this.logger.debug('[CONV-FOOTER] AppComponent::onSendPressed::isFilePendingToUpload:', this.isFilePendingToUpload);
531
+ this.logger.log('[CONV-FOOTER] AppComponent::onSendPressed::isFilePendingToUpload:', this.isFilePendingToUpload);
441
532
  } else {
442
533
  if ( this.textInputTextArea && this.textInputTextArea.length > 0 ) {
443
- this.logger.debug('[CONV-FOOTER] AppComponent::onSendPressed', 'is a message');
534
+ this.logger.log('[CONV-FOOTER] AppComponent::onSendPressed', 'is a message');
444
535
  // its a message
445
536
  if (this.textInputTextArea.trim() !== '') {
446
- // that.logger.debug('[CONV-FOOTER] sendMessage -> ', this.textInputTextArea);
537
+ // that.logger.log('[CONV-FOOTER] sendMessage -> ', this.textInputTextArea);
447
538
  // this.resizeInputField();
448
539
  // this.messagingService.sendMessage(msg, TYPE_MSG_TEXT);
449
540
  // this.setDepartment();
@@ -517,7 +608,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
517
608
  setTimeout(function () {
518
609
  const textarea = document.getElementById(id);
519
610
  if (textarea) {
520
- // that.logger.debug('[CONV-FOOTER] 1--------> FOCUSSSSSS : ', textarea);
611
+ // that.logger.log('[CONV-FOOTER] 1--------> FOCUSSSSSS : ', textarea);
521
612
  textarea.setAttribute('value', ' ');
522
613
  textarea.focus();
523
614
  }
@@ -557,7 +648,7 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
557
648
  this.textInputTextArea = ((document.getElementById('chat21-main-message-context') as HTMLInputElement).value);
558
649
  if (keyCode === 13) { // ENTER pressed
559
650
  if (this.textInputTextArea && this.textInputTextArea.trim() !== '') {
560
- // that.logger.debug('[CONV-FOOTER] sendMessage -> ', this.textInputTextArea);
651
+ // that.logger.log('[CONV-FOOTER] sendMessage -> ', this.textInputTextArea);
561
652
  // this.resizeInputField();
562
653
  // this.messagingService.sendMessage(msg, TYPE_MSG_TEXT);
563
654
  // this.setDepartment();
@@ -589,14 +680,14 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
589
680
  this.resizeInputField()
590
681
  const items = (event.clipboardData || event.originalEvent.clipboardData).items;
591
682
  let file = null;
592
- this.logger.debug('[CONV-FOOTER] onPaste items ', items);
683
+ this.logger.log('[CONV-FOOTER] onPaste items ', items);
593
684
  for (const item of items) {
594
- this.logger.debug('[CONV-FOOTER] onPaste item ', item);
595
- this.logger.debug('[CONV-FOOTER] onPaste item.type ', item.type);
685
+ this.logger.log('[CONV-FOOTER] onPaste item ', item);
686
+ this.logger.log('[CONV-FOOTER] onPaste item.type ', item.type);
596
687
  if (item.type.startsWith("image")) {
597
688
  // SEND TEXT MESSAGE IF EXIST
598
689
  // if(this.textInputTextArea){
599
- // this.logger.debug('[CONV-FOOTER] onPaste texttt ', this.textInputTextArea);
690
+ // this.logger.log('[CONV-FOOTER] onPaste texttt ', this.textInputTextArea);
600
691
  // this.sendMessage(this.textInputTextArea, TYPE_MSG_TEXT)
601
692
  // }
602
693
 
@@ -606,12 +697,12 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
606
697
  this.logger.error('[CONV-FOOTER] onPaste - error while restoring textArea:',e)
607
698
  }
608
699
 
609
- this.logger.debug('[CONV-FOOTER] onPaste item.type', item.type);
700
+ this.logger.log('[CONV-FOOTER] onPaste item.type', item.type);
610
701
  file = item.getAsFile();
611
702
  const data = {target: new ClipboardEvent('').clipboardData || new DataTransfer()};
612
703
  data.target.items.add(new File([file], file.name, { type: file.type }));
613
- this.logger.debug('[CONV-FOOTER] onPaste data', data);
614
- this.logger.debug('[CONV-FOOTER] onPaste file ', file);
704
+ this.logger.log('[CONV-FOOTER] onPaste data', data);
705
+ this.logger.log('[CONV-FOOTER] onPaste file ', file);
615
706
  this.detectFiles(data)
616
707
  }
617
708
  }
@@ -620,15 +711,15 @@ export class ConversationFooterComponent implements OnInit, OnChanges {
620
711
  onDrop(event){
621
712
  const items = event.dataTransfer.files;
622
713
  let file = null;
623
- this.logger.debug('[CONV-FOOTER] onDrop items ', items);
714
+ this.logger.log('[CONV-FOOTER] onDrop items ', items);
624
715
  for (const item of items) {
625
- this.logger.debug('[CONV-FOOTER] onDrop item ', item);
626
- this.logger.debug('[CONV-FOOTER] onDrop item.type ', item.type);
716
+ this.logger.log('[CONV-FOOTER] onDrop item ', item);
717
+ this.logger.log('[CONV-FOOTER] onDrop item.type ', item.type);
627
718
 
628
719
  const data = {target: {files: new DataTransfer()}}
629
720
  data.target.files = items
630
- this.logger.debug('[CONV-FOOTER] onDrop data', data);
631
- this.logger.debug('[CONV-FOOTER] onDrop file ', file);
721
+ this.logger.log('[CONV-FOOTER] onDrop data', data);
722
+ this.logger.log('[CONV-FOOTER] onDrop file ', file);
632
723
  this.detectFiles(data)
633
724
  }
634
725
  }
@@ -0,0 +1,32 @@
1
+
2
+ <!-- <audio *ngIf="metadata" controls>
3
+ <source [src]="metadata.src" type="audio/mpeg">
4
+ </audio> *ngIf="!metadata"-->
5
+ <div class="audio-container">
6
+
7
+ <div class="audio-track">
8
+ <button *ngIf="!isPlaying" class="play-pause" (click)="playPauseAudio()">
9
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px">
10
+ <path d="M320-200v-560l440 280-440 280Z"/>
11
+ </svg>
12
+ <!-- <i class="material-icons">play_arrow</i> -->
13
+ </button>
14
+ <button *ngIf="isPlaying" class="play-pause" (click)="playPauseAudio()">
15
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px">
16
+ <path d="M560-200v-560h160v560H560Zm-320 0v-560h160v560H240Z"/>
17
+ </svg>
18
+ <!-- <i class="material-icons">pause</i> -->
19
+ </button>
20
+ <div class="duration" [style.color]="color" [style.font-size]="fontSize" >
21
+ <span *ngIf="!isPlaying">{{ audioDuration ? formatTime(audioDuration) : '00:00' }}</span>
22
+ <span *ngIf="isPlaying">{{ formatTime(currentTime) }}</span>
23
+ </div>
24
+
25
+ </div>
26
+
27
+ <div class="audio-player-custom">
28
+ <audio #audioElement [src]="audioUrl"></audio>
29
+ <canvas #canvasElement class="waveformCanvas"></canvas>
30
+ </div>
31
+
32
+ </div>
@@ -0,0 +1,107 @@
1
+
2
+ :host {
3
+ --backgroundColor: #{var(--blue)};
4
+ --textColor: #{var(--bck-msg-sent)};
5
+ --hoverBackgroundColor: #{var(--bck-msg-sent)};
6
+ --hoverTextColor: #{var(--blue)};
7
+ --max-width: #{var(--button-in-msg-max-width)};
8
+ }
9
+
10
+ .audio-container{
11
+ position: relative;
12
+ display: inline-flex;
13
+ width: 100%;
14
+ padding: 0px 12px;
15
+ margin: 6px 0px;
16
+ }
17
+
18
+ audio {
19
+ width: 272px;
20
+ height: 30px;
21
+ margin: 0;
22
+ padding: 10px;
23
+ }
24
+
25
+ .audio-recorder {
26
+ text-align: center;
27
+ margin: 0px;
28
+ display: inline-flex;
29
+ align-items: center;
30
+ justify-content: center;
31
+ height: 100%;
32
+ width: 100%;
33
+ float: left;
34
+ }
35
+
36
+ button {
37
+ margin: 0px;
38
+ padding: 0px;
39
+ font-size: 16px;
40
+ border: none;
41
+ background-color: transparent;
42
+ color: var(--icon-fill-color);
43
+ fill: var(--icon-fill-color);
44
+ }
45
+
46
+ .waveformCanvas {
47
+ width: 100%;
48
+ height: 28px;
49
+ z-index: 1;
50
+ padding: 0px;
51
+ margin: 0%;
52
+ }
53
+
54
+ .audio-track {
55
+ // width: 247px;//272px;
56
+ // height: 30px;
57
+ position: relative;
58
+ display: flex;
59
+ align-items: center;
60
+ // margin: 0 13px;
61
+ margin: 0px;
62
+ .play-pause {
63
+ font-size: 20px;
64
+ width: 30px;
65
+ background-color: transparent;
66
+ border-radius: 50%;
67
+ height: 30px;
68
+ margin: 0px;
69
+ transition: background-color 0.5s ease;
70
+
71
+ }
72
+ .play-pause:hover {
73
+ // background-color: #ddd;
74
+ // background-color: rgb(82, 160, 252);
75
+ background-color: #fff;
76
+ svg{
77
+ //fill:#fff;
78
+ fill: rgb(82, 160, 252);
79
+ }
80
+ }
81
+ .duration {
82
+ padding: 0 3px;
83
+ }
84
+ }
85
+
86
+ .audio-player-custom {
87
+ // width: 200px;
88
+ // height: 32px;
89
+ // margin-left: 75px;
90
+ // position: absolute;
91
+ // overflow: hidden;
92
+ // z-index: 1;
93
+ // display: flex;
94
+ // align-items: center;
95
+
96
+ // width: calc(100% - 75px);
97
+ // height: 32px;
98
+ // margin-left: 65px;
99
+ // position: absolute;
100
+ overflow: hidden;
101
+ z-index: 1;
102
+ display: flex;
103
+ align-items: center;
104
+ width: 100%;
105
+ }
106
+
107
+
@@ -1,18 +1,18 @@
1
1
  import { ComponentFixture, TestBed } from '@angular/core/testing';
2
2
 
3
- import { AudioComponent } from './audio.component';
3
+ import { AudioTrackComponent } from './audio-track.component';
4
4
 
5
- describe('AudioComponent', () => {
6
- let component: AudioComponent;
7
- let fixture: ComponentFixture<AudioComponent>;
5
+ describe('AudioTrackComponent', () => {
6
+ let component: AudioTrackComponent;
7
+ let fixture: ComponentFixture<AudioTrackComponent>;
8
8
 
9
9
  beforeEach(async () => {
10
10
  await TestBed.configureTestingModule({
11
- declarations: [ AudioComponent ]
11
+ declarations: [ AudioTrackComponent ]
12
12
  })
13
13
  .compileComponents();
14
14
 
15
- fixture = TestBed.createComponent(AudioComponent);
15
+ fixture = TestBed.createComponent(AudioTrackComponent);
16
16
  component = fixture.componentInstance;
17
17
  fixture.detectChanges();
18
18
  });