2022-01-13 17:28:35 +01:00
|
|
|
import { Component, OnChanges, OnInit, Input, SimpleChanges, ChangeDetectorRef, Output, EventEmitter, ViewChild, ElementRef, AfterViewChecked, AfterViewInit, OnDestroy } from '@angular/core';
|
2021-11-22 13:53:37 +01:00
|
|
|
import { ActionSheetController, AnimationController, IonSlides, MenuController, ModalController, PopoverController } from '@ionic/angular';
|
2021-04-13 14:14:55 +01:00
|
|
|
import { AlertService } from 'src/app/services/alert.service';
|
2021-03-04 18:50:26 +01:00
|
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
|
|
|
import { ChatService } from 'src/app/services/chat.service';
|
|
|
|
|
import { ChatPopoverPage } from 'src/app/shared/popover/chat-popover/chat-popover.page';
|
|
|
|
|
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
|
|
|
|
import { NewGroupPage } from '../new-group/new-group.page';
|
|
|
|
|
import { GroupContactsPage } from './group-contacts/group-contacts.page';
|
2021-07-26 19:31:19 +01:00
|
|
|
import { Router } from '@angular/router'
|
2021-08-18 16:40:58 +01:00
|
|
|
import { ChatOptionsPopoverPage } from '../../popover/chat-options-popover/chat-options-popover.page';
|
|
|
|
|
import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page';
|
2021-09-06 16:53:58 +01:00
|
|
|
import { TimeService } from 'src/app/services/functions/time.service';
|
2021-09-13 12:37:58 +01:00
|
|
|
import { FileLoaderService } from 'src/app/services/file/file-loader.service';
|
|
|
|
|
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
2021-09-14 15:57:24 +01:00
|
|
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
|
|
|
|
import { SearchList } from 'src/app/models/search-document';
|
|
|
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
|
|
|
import { FileService } from 'src/app/services/functions/file.service';
|
2021-10-05 16:29:33 +01:00
|
|
|
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
|
2021-10-23 09:53:21 +01:00
|
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
2021-11-22 13:53:37 +01:00
|
|
|
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
|
2021-12-08 20:27:05 +01:00
|
|
|
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
2021-12-22 10:31:10 +01:00
|
|
|
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
2022-01-13 17:28:35 +01:00
|
|
|
import { HttpEventType } from '@angular/common/http';
|
|
|
|
|
import { Storage } from '@ionic/storage';
|
2022-01-13 23:20:36 +01:00
|
|
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
|
2022-01-21 16:55:05 +01:00
|
|
|
import { MessageService } from 'src/app/services/chat/message.service';
|
2022-02-03 21:01:53 +01:00
|
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
2022-02-04 07:42:43 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
import { CameraService } from 'src/app/services/camera.service';
|
|
|
|
|
import { element } from 'protractor';
|
|
|
|
|
import { FileType } from 'src/app/models/fileType';
|
|
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
2022-02-09 15:06:54 +01:00
|
|
|
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
2022-03-14 19:07:46 +01:00
|
|
|
import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, CurrentRecordingStatus } from 'capacitor-voice-recorder';
|
|
|
|
|
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
2022-03-18 11:45:38 +01:00
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
2021-09-21 14:05:59 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
import * as pdfjsLib from 'pdfjs-dist';
|
|
|
|
|
if( pdfjsLib !== undefined ){
|
|
|
|
|
console.log( "set worker...");
|
|
|
|
|
pdfjsLib.GlobalWorkerOptions.workerSrc = "https://npmcdn.com/pdfjs-dist@2.4.456/build/pdf.worker.js";
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-group-messages',
|
|
|
|
|
templateUrl: './group-messages.page.html',
|
|
|
|
|
styleUrls: ['./group-messages.page.scss'],
|
|
|
|
|
})
|
2021-08-23 16:31:06 +01:00
|
|
|
export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy {
|
2021-03-04 18:50:26 +01:00
|
|
|
showLoader: boolean;
|
2022-01-13 17:28:35 +01:00
|
|
|
isGroupCreated: boolean;
|
2021-03-04 18:50:26 +01:00
|
|
|
loggedUser: any;
|
2022-01-13 17:28:35 +01:00
|
|
|
message: any;
|
|
|
|
|
messages: any;
|
|
|
|
|
allUsers: any[] = [];
|
|
|
|
|
documents: SearchList[] = [];
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
room: any = new Array();
|
|
|
|
|
roomName: any;
|
|
|
|
|
members: any;
|
2021-03-12 11:56:54 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
capturedImage: any;
|
|
|
|
|
capturedImageTitle: any;
|
2021-09-13 12:37:58 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
loggedUserChat: any;
|
|
|
|
|
scrollingOnce: boolean = true;
|
2021-08-23 16:31:06 +01:00
|
|
|
private scrollChangeCallback: () => void;
|
|
|
|
|
currentPosition: any;
|
|
|
|
|
startPosition: number;
|
2021-09-24 15:39:25 +01:00
|
|
|
scrollToBottomBtn = false;
|
2022-01-13 17:28:35 +01:00
|
|
|
roomCountDownDate: string;
|
|
|
|
|
roomCountDownTime: string;
|
2021-08-23 16:31:06 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
@Input() roomId: string;
|
|
|
|
|
@Output() closeAllDesktopComponents: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
|
@Output() showEmptyContainer: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
|
@Output() openGroupContacts: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
|
@Output() openEditGroupPage: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
|
@Output() openNewEventPage: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
|
@Output() getGroups: EventEmitter<any> = new EventEmitter<any>();
|
2021-03-04 18:50:26 +01:00
|
|
|
|
2021-07-26 09:44:11 +01:00
|
|
|
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
|
|
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
pdfurl = "http://www.africau.edu/images/default/sample.pdf";
|
2022-01-13 17:28:35 +01:00
|
|
|
downloadFile: any;
|
2022-03-14 19:07:46 +01:00
|
|
|
showAvatar = false;
|
|
|
|
|
|
|
|
|
|
recording = false;
|
|
|
|
|
allowTyping = true;
|
|
|
|
|
storedFileNames = [];
|
|
|
|
|
lastAudioRecorded = '';
|
2022-04-05 13:22:17 +01:00
|
|
|
audioRecorded: any = "";
|
|
|
|
|
audioDownloaded: any = "";
|
2022-03-14 19:07:46 +01:00
|
|
|
durationDisplay = '';
|
|
|
|
|
duration = 0;
|
2021-09-21 14:05:59 +01:00
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
constructor(
|
2022-01-26 12:51:24 +01:00
|
|
|
public wsChatMethodsService: WsChatMethodsService,
|
2021-03-04 18:50:26 +01:00
|
|
|
private modalController: ModalController,
|
|
|
|
|
public popoverController: PopoverController,
|
|
|
|
|
private chatService: ChatService,
|
|
|
|
|
private authService: AuthService,
|
2021-03-18 09:25:59 +01:00
|
|
|
private animationController: AnimationController,
|
2021-04-13 14:14:55 +01:00
|
|
|
private alertService: AlertService,
|
2021-09-06 16:53:58 +01:00
|
|
|
private route: Router,
|
|
|
|
|
private timeService: TimeService,
|
2021-09-13 12:37:58 +01:00
|
|
|
private fileLoaderService: FileLoaderService,
|
|
|
|
|
private fileToBase64Service: FileToBase64Service,
|
2021-09-14 15:57:24 +01:00
|
|
|
private processesService: ProcessesService,
|
|
|
|
|
private fileService: FileService,
|
2021-11-22 13:53:37 +01:00
|
|
|
public ThemeService: ThemeService,
|
2022-01-13 17:28:35 +01:00
|
|
|
private changeDetectorRef: ChangeDetectorRef,
|
2022-01-19 09:12:30 +01:00
|
|
|
private storage: Storage,
|
2022-02-03 21:01:53 +01:00
|
|
|
private AttachmentsService: AttachmentsService,
|
2022-02-09 14:32:21 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
private CameraService: CameraService,
|
|
|
|
|
private toastService: ToastService,
|
2022-03-18 11:45:38 +01:00
|
|
|
private sanitiser: DomSanitizer,
|
2022-01-26 12:51:24 +01:00
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
) {
|
2022-01-26 12:51:24 +01:00
|
|
|
console.log('OnCONSTRUCTOR');
|
2021-07-23 14:43:51 +01:00
|
|
|
this.loggedUserChat = authService.ValidatedUserChat['data'];
|
2021-03-04 18:50:26 +01:00
|
|
|
this.isGroupCreated = true;
|
2021-11-03 15:35:01 +01:00
|
|
|
this.roomCountDownDate = "";
|
|
|
|
|
this.roomCountDownTime = "";
|
2021-09-21 14:05:59 +01:00
|
|
|
|
2021-03-12 11:56:54 +01:00
|
|
|
}
|
|
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
2022-01-26 12:51:24 +01:00
|
|
|
console.log('OnCHANGES');
|
|
|
|
|
|
2021-10-07 09:42:18 +01:00
|
|
|
this.getRoomInfo();
|
2021-08-23 16:31:06 +01:00
|
|
|
//this.scrollToBottom();
|
2022-02-09 17:06:12 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
|
2022-01-29 19:21:46 +01:00
|
|
|
// console.log('MESSAGES'+ this.wsChatMethodsService.getGroupRoom(this.roomId).messages);
|
|
|
|
|
this.wsChatMethodsService.openRoom(this.roomId)
|
2022-01-14 14:50:47 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
2022-01-14 14:58:47 +01:00
|
|
|
|
2022-02-24 15:32:23 +01:00
|
|
|
this.showAvatar = false
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
setTimeout(() => {
|
2022-01-14 14:58:47 +01:00
|
|
|
this.scrollToBottomClicked()
|
2022-02-24 15:32:23 +01:00
|
|
|
this.showAvatar = true
|
2022-01-14 14:58:47 +01:00
|
|
|
}, 50)
|
|
|
|
|
|
2022-03-18 11:45:38 +01:00
|
|
|
this.deleteRecording();
|
2022-03-14 20:34:29 +01:00
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
2022-04-05 13:22:17 +01:00
|
|
|
this.loggedUser = this.loggedUserChat;
|
2022-01-26 12:51:24 +01:00
|
|
|
setTimeout(() => {
|
|
|
|
|
this.getRoomInfo();
|
|
|
|
|
}, 1000);
|
2021-09-09 11:47:49 +01:00
|
|
|
this.getChatMembers();
|
2022-01-13 17:28:35 +01:00
|
|
|
//this.getMessageDB();
|
2022-03-14 19:07:46 +01:00
|
|
|
VoiceRecorder.requestAudioRecordingPermission();
|
2022-03-18 11:45:38 +01:00
|
|
|
this.deleteRecording();
|
2022-03-14 19:07:46 +01:00
|
|
|
this.loadFiles();
|
2022-01-13 17:28:35 +01:00
|
|
|
|
2021-11-03 15:35:01 +01:00
|
|
|
}
|
2021-09-21 14:05:59 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
showDateDuration(start: any) {
|
2021-11-03 15:35:01 +01:00
|
|
|
return this.timeService.showDateDuration(start);
|
2021-03-17 11:13:09 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
countDownDate() {
|
2021-11-03 15:35:01 +01:00
|
|
|
//this.roomCountDownTime = this.timeService.countDownDateTimer(this.roomCountDownDate, this.room._id);
|
|
|
|
|
return this.timeService.countDownDateTimer(this.roomCountDownDate, this.roomId);
|
|
|
|
|
}
|
2021-09-21 14:05:59 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
setStatus(status: string) {
|
2021-08-23 16:31:06 +01:00
|
|
|
let body = {
|
|
|
|
|
message: '',
|
|
|
|
|
status: status,
|
|
|
|
|
}
|
|
|
|
|
this.chatService.setUserStatus(body).subscribe(res => {
|
2021-09-21 14:05:59 +01:00
|
|
|
//console.log(res);
|
2021-08-23 16:31:06 +01:00
|
|
|
})
|
2021-07-26 09:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scrollToBottom(): void {
|
|
|
|
|
try {
|
2022-01-13 17:28:35 +01:00
|
|
|
if (this.scrollingOnce) {
|
2021-08-23 16:31:06 +01:00
|
|
|
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
|
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
} catch (err) { }
|
2021-08-23 16:31:06 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-14 14:50:47 +01:00
|
|
|
scrollToBottomClicked = () => {
|
2021-09-24 15:39:25 +01:00
|
|
|
try {
|
|
|
|
|
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
2022-01-13 17:28:35 +01:00
|
|
|
} catch (err) { }
|
2021-09-24 15:39:25 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-22 10:31:10 +01:00
|
|
|
async goToEvent(eventId: any) {
|
|
|
|
|
let classs;
|
|
|
|
|
if (window.innerWidth < 701) {
|
|
|
|
|
classs = 'modal modal-desktop'
|
|
|
|
|
} else {
|
|
|
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewEventPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
eventId: eventId,
|
|
|
|
|
},
|
|
|
|
|
cssClass: classs,
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res) => {
|
|
|
|
|
console.log(res);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
ngAfterViewInit() {
|
|
|
|
|
this.scrollChangeCallback = () => this.onContentScrolled(event);
|
|
|
|
|
window.addEventListener('scroll', this.scrollChangeCallback, true);
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-24 15:39:25 +01:00
|
|
|
onContentScrolled(e) {
|
2021-08-23 16:31:06 +01:00
|
|
|
this.startPosition = e.srcElement.scrollTop;
|
|
|
|
|
let scroll = e.srcElement.scrollTop;
|
2021-09-24 15:39:25 +01:00
|
|
|
let windowHeight = e.srcElement.scrollHeight;
|
2021-09-24 16:10:24 +01:00
|
|
|
let containerHeight = windowHeight - e.srcElement.clientHeight;
|
2021-09-24 15:39:25 +01:00
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
if (scroll > this.currentPosition) {
|
2021-09-24 15:39:25 +01:00
|
|
|
//alert('BOTTOM');
|
2021-08-23 16:31:06 +01:00
|
|
|
} else {
|
2021-09-24 15:39:25 +01:00
|
|
|
//alert('UP');
|
2021-08-23 16:31:06 +01:00
|
|
|
this.scrollingOnce = false;
|
2021-07-26 09:44:11 +01:00
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
if ((containerHeight - 100) > scroll) {
|
2021-09-24 15:39:25 +01:00
|
|
|
this.scrollToBottomBtn = true;
|
|
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else {
|
2021-09-24 15:39:25 +01:00
|
|
|
this.scrollToBottomBtn = false;
|
|
|
|
|
}
|
2021-08-23 16:31:06 +01:00
|
|
|
this.currentPosition = scroll;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 19:07:46 +01:00
|
|
|
calculateDuration() {
|
|
|
|
|
if (!this.recording) {
|
|
|
|
|
this.duration = 0;
|
|
|
|
|
this.durationDisplay = '';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.duration += 1;
|
|
|
|
|
const minutes = Math.floor(this.duration / 60);
|
|
|
|
|
const seconds = (this.duration % 60).toString().padStart(2, '0');
|
|
|
|
|
this.durationDisplay = `${minutes}:${seconds}`;
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.calculateDuration();
|
|
|
|
|
}, 1000)
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
async getFile(fileName?: any) {
|
2022-03-14 19:07:46 +01:00
|
|
|
const audioFile = await Filesystem.readFile({
|
|
|
|
|
path: fileName,
|
|
|
|
|
directory: Directory.Data
|
|
|
|
|
})
|
|
|
|
|
const base64sound = audioFile.data;
|
|
|
|
|
const base64Response = await fetch(`data:audio/ogg;base64,${base64sound}`);
|
|
|
|
|
this.audioRecorded = base64Response.url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async loadFiles() {
|
2022-03-22 14:23:38 +01:00
|
|
|
try {
|
|
|
|
|
this.storage.get('fileName').then((fileName) => {
|
|
|
|
|
this.lastAudioRecorded = fileName;
|
|
|
|
|
})
|
2022-03-27 15:18:54 +01:00
|
|
|
|
2022-03-22 14:23:38 +01:00
|
|
|
this.storage.get('recordData').then((recordData) => {
|
|
|
|
|
console.log(recordData);
|
2022-04-05 13:22:17 +01:00
|
|
|
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData?.value?.recordDataBase64);
|
2022-03-22 14:23:38 +01:00
|
|
|
}
|
2022-04-05 13:22:17 +01:00
|
|
|
else {
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
|
2022-03-22 14:23:38 +01:00
|
|
|
}
|
|
|
|
|
});
|
2022-04-05 13:22:17 +01:00
|
|
|
} catch (error) { }
|
2022-03-18 11:45:38 +01:00
|
|
|
|
2022-03-27 15:18:54 +01:00
|
|
|
|
2022-03-14 19:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
startRecording() {
|
|
|
|
|
console.log('Recording');
|
|
|
|
|
|
|
|
|
|
if (this.recording) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.recording = true;
|
|
|
|
|
VoiceRecorder.startRecording();
|
|
|
|
|
this.calculateDuration();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stopRecording() {
|
2022-03-18 11:45:38 +01:00
|
|
|
this.deleteRecording();
|
2022-03-14 19:07:46 +01:00
|
|
|
this.allowTyping = false;
|
|
|
|
|
console.log('Stop');
|
|
|
|
|
if (!this.recording) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.recording = false;
|
|
|
|
|
VoiceRecorder.stopRecording().then(async (result: RecordingData) => {
|
2022-03-18 11:45:38 +01:00
|
|
|
console.log(result);
|
2022-03-14 19:07:46 +01:00
|
|
|
this.recording = false;
|
|
|
|
|
if (result.value && result.value.recordDataBase64) {
|
|
|
|
|
const recordData = result.value.recordDataBase64;
|
2022-03-18 11:45:38 +01:00
|
|
|
//console.log(recordData);
|
2022-03-18 16:42:59 +01:00
|
|
|
const fileName = new Date().getTime() + ".mp3";
|
2022-03-18 11:45:38 +01:00
|
|
|
//Save file
|
2022-04-05 13:22:17 +01:00
|
|
|
this.storage.set('fileName', fileName);
|
|
|
|
|
this.storage.set('recordData', result).then(() => {
|
2022-03-18 11:45:38 +01:00
|
|
|
console.log('Audio recorded saved');
|
2022-03-14 19:07:46 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
setTimeout(async () => {
|
|
|
|
|
this.loadFiles();
|
2022-03-18 11:45:38 +01:00
|
|
|
}, 1000);
|
2022-03-14 19:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
async deleteRecording() {
|
2022-03-18 11:45:38 +01:00
|
|
|
this.storage.remove('fileName');
|
|
|
|
|
this.storage.remove('recordData');
|
|
|
|
|
|
2022-03-14 19:07:46 +01:00
|
|
|
this.allowTyping = true;
|
|
|
|
|
this.lastAudioRecorded = '';
|
|
|
|
|
this.loadFiles();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
|
window.removeEventListener('scroll', this.scrollChangeCallback, true);
|
2021-04-13 14:14:55 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
async getChatMembers() {
|
2021-09-09 11:47:49 +01:00
|
|
|
//return await this.chatService.getMembers(roomId).toPromise();
|
2022-01-13 17:28:35 +01:00
|
|
|
this.chatService.getAllUsers().subscribe(res => {
|
2021-09-21 14:05:59 +01:00
|
|
|
//console.log(res);
|
2021-09-09 11:47:49 +01:00
|
|
|
|
|
|
|
|
this.allUsers = res['users'].filter(data => data.username != this.loggedUserChat.me.username);
|
2021-09-21 14:05:59 +01:00
|
|
|
//console.log(this.allUsers);
|
2021-09-09 11:47:49 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
openGroupContactsPage() {
|
2021-03-17 11:13:09 +01:00
|
|
|
this.openGroupContacts.emit(this.roomId);
|
2021-03-04 18:50:26 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
openBookMeetingComponent() {
|
2021-08-18 16:40:58 +01:00
|
|
|
let data = {
|
|
|
|
|
roomId: this.roomId,
|
|
|
|
|
members: this.members
|
|
|
|
|
}
|
|
|
|
|
this.openNewEventPage.emit(data);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
close() {
|
2021-03-04 18:50:26 +01:00
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
doRefresh(ev: any) {
|
2021-03-12 11:56:54 +01:00
|
|
|
this.getRoomInfo();
|
2021-03-04 18:50:26 +01:00
|
|
|
ev.target.complete();
|
|
|
|
|
}
|
2021-07-26 09:44:11 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
get watch() {
|
2021-03-12 11:56:54 +01:00
|
|
|
this.getRoomInfo();
|
|
|
|
|
console.log('here watching');
|
|
|
|
|
return this.roomId;
|
|
|
|
|
}
|
2021-08-23 16:31:06 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
async getRoomInfo() {
|
2022-02-09 17:06:12 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
|
2021-11-03 15:35:01 +01:00
|
|
|
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
|
2022-01-13 17:28:35 +01:00
|
|
|
this.room = room['room'];
|
|
|
|
|
if (this.room.name) {
|
2021-11-03 15:35:01 +01:00
|
|
|
this.roomName = this.room.name.split('-').join(' ');
|
|
|
|
|
}
|
2021-10-27 08:45:37 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
if (this.room.customFields.countDownDate) {
|
2021-11-03 15:35:01 +01:00
|
|
|
this.roomCountDownDate = this.room.customFields.countDownDate;
|
|
|
|
|
}
|
2021-10-27 08:45:37 +01:00
|
|
|
|
2021-11-03 15:35:01 +01:00
|
|
|
this.getGroupContacts(this.room);
|
2021-03-12 11:56:54 +01:00
|
|
|
}
|
2021-03-04 18:50:26 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
getGroupContacts(room: any) {
|
2021-03-04 18:50:26 +01:00
|
|
|
this.showLoader = true;
|
|
|
|
|
//If group is private call getGroupMembers
|
2022-01-13 17:28:35 +01:00
|
|
|
if (room.t === 'p') {
|
|
|
|
|
this.chatService.getGroupMembers(this.roomId).subscribe(res => {
|
2021-09-21 14:05:59 +01:00
|
|
|
//console.log(res);
|
2021-03-04 18:50:26 +01:00
|
|
|
this.members = res['members'];
|
|
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
//Otherwise call getChannelMembers for públic groups
|
2022-01-13 17:28:35 +01:00
|
|
|
else {
|
|
|
|
|
this.chatService.getChannelMembers(this.roomId).subscribe(res => {
|
2021-03-04 18:50:26 +01:00
|
|
|
console.log(res);
|
|
|
|
|
this.members = res['members'];
|
|
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-23 16:31:06 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
sendMessage() {
|
2022-02-04 00:22:35 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).send({})
|
2021-03-04 18:50:26 +01:00
|
|
|
}
|
2021-09-28 15:23:51 +01:00
|
|
|
|
2022-03-21 21:09:05 +01:00
|
|
|
base64toBlob(base64Data, contentType) {
|
|
|
|
|
contentType = contentType || '';
|
|
|
|
|
var sliceSize = 1024;
|
|
|
|
|
var byteCharacters = atob(base64Data);
|
|
|
|
|
var bytesLength = byteCharacters.length;
|
|
|
|
|
var slicesCount = Math.ceil(bytesLength / sliceSize);
|
|
|
|
|
var byteArrays = new Array(slicesCount);
|
|
|
|
|
|
|
|
|
|
for (var sliceIndex = 0; sliceIndex < slicesCount; ++sliceIndex) {
|
2022-04-05 13:22:17 +01:00
|
|
|
var begin = sliceIndex * sliceSize;
|
|
|
|
|
var end = Math.min(begin + sliceSize, bytesLength);
|
2022-03-21 21:09:05 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
var bytes = new Array(end - begin);
|
|
|
|
|
for (var offset = begin, i = 0; offset < end; ++i, ++offset) {
|
|
|
|
|
bytes[i] = byteCharacters[offset].charCodeAt(0);
|
|
|
|
|
}
|
|
|
|
|
byteArrays[sliceIndex] = new Uint8Array(bytes);
|
2022-03-21 21:09:05 +01:00
|
|
|
}
|
|
|
|
|
return new Blob(byteArrays, { type: contentType });
|
2022-04-05 13:22:17 +01:00
|
|
|
}
|
2022-03-21 21:09:05 +01:00
|
|
|
|
2022-03-14 19:07:46 +01:00
|
|
|
async sendAudio(fileName) {
|
|
|
|
|
const roomId = this.roomId
|
2022-03-21 21:09:05 +01:00
|
|
|
let audioFile;
|
2022-03-18 11:45:38 +01:00
|
|
|
this.storage.get('recordData').then((recordData) => {
|
|
|
|
|
console.log(recordData);
|
2022-03-21 21:09:05 +01:00
|
|
|
audioFile = recordData;
|
2022-04-05 13:22:17 +01:00
|
|
|
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = recordData?.value?.recordDataBase64;
|
2022-03-18 11:45:38 +01:00
|
|
|
}
|
2022-04-05 13:22:17 +01:00
|
|
|
else {
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
2022-03-18 11:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-27 15:18:54 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
//Converting base64 to blob
|
|
|
|
|
const encodedData = btoa(this.audioRecorded);
|
|
|
|
|
const blob = this.base64toBlob(encodedData, recordData.value.mimeType)
|
|
|
|
|
console.log(blob)
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-03-14 19:07:46 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(roomId).send({
|
|
|
|
|
file: {
|
|
|
|
|
"type": "application/audio",
|
|
|
|
|
"msDuration": audioFile.value.msDuration,
|
|
|
|
|
"mimeType": audioFile.value.mimeType,
|
|
|
|
|
},
|
|
|
|
|
attachments: [{
|
|
|
|
|
"title": fileName,
|
|
|
|
|
"title_link_download": true,
|
|
|
|
|
"type": "audio"
|
|
|
|
|
}],
|
|
|
|
|
temporaryData: formData
|
|
|
|
|
})
|
2022-03-14 19:07:46 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
});
|
2022-03-21 21:09:05 +01:00
|
|
|
this.deleteRecording();
|
2022-03-14 19:07:46 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-10 18:07:06 +01:00
|
|
|
deleteMessage(msgId: string) {
|
|
|
|
|
const room = this.wsChatMethodsService.getGroupRoom(this.roomId)
|
2022-01-28 15:31:52 +01:00
|
|
|
this.alertService.confirmDeleteMessage(msgId, room);
|
2021-09-28 15:23:51 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-18 09:25:59 +01:00
|
|
|
async openGroupMessagesOptions() {
|
|
|
|
|
|
|
|
|
|
const enterAnimation = (baseEl: any) => {
|
|
|
|
|
const backdropAnimation = this.animationController.create()
|
|
|
|
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
|
|
|
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
|
|
|
|
|
|
|
|
const wrapperAnimation = this.animationController.create()
|
|
|
|
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
|
|
|
|
.keyframes([
|
|
|
|
|
{ offset: 0, opacity: '1', right: '-100%' },
|
|
|
|
|
{ offset: 1, opacity: '1', right: '0px' }
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return this.animationController.create()
|
|
|
|
|
.addElement(baseEl)
|
|
|
|
|
.easing('ease-out')
|
|
|
|
|
.duration(500)
|
|
|
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
|
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
|
|
|
}
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-03-18 09:25:59 +01:00
|
|
|
|
|
|
|
|
/* const popover = await this.popoverController.create({
|
|
|
|
|
component: MessagesOptionsPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
roomId: this.dm._id,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'messages-options',
|
|
|
|
|
event: ev,
|
|
|
|
|
translucent: true,
|
|
|
|
|
});
|
|
|
|
|
return await popover.present(); */
|
|
|
|
|
|
2022-01-26 09:19:54 +01:00
|
|
|
console.log(this.roomId);
|
|
|
|
|
|
|
|
|
|
|
2021-03-18 09:25:59 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
enterAnimation,
|
|
|
|
|
leaveAnimation,
|
|
|
|
|
component: ChatPopoverPage,
|
|
|
|
|
cssClass: 'model profile-modal search-submodal',
|
|
|
|
|
componentProps: {
|
|
|
|
|
roomId: this.roomId,
|
2022-01-24 19:09:26 +01:00
|
|
|
members: this.members,
|
2021-03-18 09:25:59 +01:00
|
|
|
}
|
|
|
|
|
});
|
2021-04-15 23:57:14 +01:00
|
|
|
await modal.present();
|
2022-01-13 17:28:35 +01:00
|
|
|
modal.onDidDismiss().then(res => {
|
2021-04-15 23:57:14 +01:00
|
|
|
console.log(res);
|
2022-01-13 17:28:35 +01:00
|
|
|
if (res.data == 'leave') {
|
2021-09-08 14:36:49 +01:00
|
|
|
this.getRoomInfo();
|
|
|
|
|
this.closeAllDesktopComponents.emit();
|
|
|
|
|
this.showEmptyContainer.emit();
|
2022-02-11 17:15:01 +01:00
|
|
|
this.wsChatMethodsService.hidingRoom(this.roomId);
|
2021-04-15 23:57:14 +01:00
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else if (res.data == 'delete') {
|
2021-04-15 23:57:14 +01:00
|
|
|
this.closeAllDesktopComponents.emit();
|
|
|
|
|
this.showEmptyContainer.emit();
|
|
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else if (res.data == 'cancel') {
|
2021-04-15 23:57:14 +01:00
|
|
|
console.log('CANCEL');
|
|
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else if (res.data == 'edit') {
|
2021-04-16 11:25:10 +01:00
|
|
|
console.log(this.roomId);
|
|
|
|
|
//this.closeAllDesktopComponents.emit();
|
|
|
|
|
this.openEditGroupPage.emit(this.roomId);
|
2021-04-16 09:57:08 +01:00
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else {
|
2021-04-15 23:57:14 +01:00
|
|
|
this.roomName = res.data.name.split('-').join(' ');
|
|
|
|
|
console.log(this.roomName);
|
|
|
|
|
};
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-04-15 23:57:14 +01:00
|
|
|
});
|
2021-03-18 09:25:59 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
openSendGroupMessageOptions(ev?: any) {
|
|
|
|
|
if (window.innerWidth <= 701) {
|
2021-03-18 16:30:03 +01:00
|
|
|
console.log('mobile');
|
|
|
|
|
this.openChatOptions(ev);
|
|
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else {
|
2021-03-18 16:30:03 +01:00
|
|
|
console.log('desktop');
|
|
|
|
|
this._openChatOptions();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
|
2021-03-18 16:30:03 +01:00
|
|
|
async openOptions(ev: any) {
|
2021-03-04 18:50:26 +01:00
|
|
|
const popover = await this.popoverController.create({
|
|
|
|
|
component: ChatPopoverPage,
|
2021-04-23 14:30:18 +01:00
|
|
|
cssClass: 'chat-popover modal-desktop',
|
2021-03-04 18:50:26 +01:00
|
|
|
event: ev,
|
|
|
|
|
componentProps: {
|
|
|
|
|
room: this.room,
|
|
|
|
|
},
|
|
|
|
|
translucent: true
|
|
|
|
|
});
|
|
|
|
|
await popover.present();
|
2022-01-13 17:28:35 +01:00
|
|
|
popover.onDidDismiss().then(res => {
|
2021-03-04 18:50:26 +01:00
|
|
|
console.log(res);
|
2022-01-13 17:28:35 +01:00
|
|
|
if (res.data) {
|
2021-08-23 16:31:06 +01:00
|
|
|
//this.getRoomInfo();
|
2021-07-23 14:43:51 +01:00
|
|
|
//this.modalController.dismiss();
|
2021-03-04 18:50:26 +01:00
|
|
|
};
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
async openChatOptions(ev: any) {
|
|
|
|
|
const popover = await this.popoverController.create({
|
|
|
|
|
component: ChatOptionsPopoverPage,
|
|
|
|
|
cssClass: 'chat-options-popover',
|
|
|
|
|
event: ev,
|
|
|
|
|
componentProps: {
|
|
|
|
|
room: this.room,
|
2021-08-18 16:40:58 +01:00
|
|
|
members: this.members,
|
2021-03-04 18:50:26 +01:00
|
|
|
},
|
|
|
|
|
translucent: true
|
|
|
|
|
});
|
2021-09-13 12:37:58 +01:00
|
|
|
await popover.present();
|
2022-01-13 17:28:35 +01:00
|
|
|
await popover.onDidDismiss().then(() => {
|
2021-09-13 12:37:58 +01:00
|
|
|
});
|
2021-03-04 18:50:26 +01:00
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
async addContacts() {
|
2021-03-04 18:50:26 +01:00
|
|
|
console.log(this.members);
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: GroupContactsPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
isCreated: this.isGroupCreated,
|
|
|
|
|
room: this.room,
|
|
|
|
|
members: this.members,
|
|
|
|
|
name: this.room.name,
|
2021-07-23 14:43:51 +01:00
|
|
|
},
|
2021-03-04 18:50:26 +01:00
|
|
|
cssClass: 'contacts',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
modal.onDidDismiss().then(() => {
|
2021-08-23 16:31:06 +01:00
|
|
|
//this.getRoomInfo();
|
2021-03-04 18:50:26 +01:00
|
|
|
});
|
|
|
|
|
}
|
2021-03-18 16:30:03 +01:00
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
async addDocGestaoDocumental() {
|
2021-09-14 15:57:24 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: SearchPage,
|
|
|
|
|
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
|
|
|
|
select: true,
|
|
|
|
|
showSearchInput: true,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
2022-01-13 17:28:35 +01:00
|
|
|
modal.onDidDismiss().then(async res => {
|
|
|
|
|
if (res) {
|
2021-09-14 15:57:24 +01:00
|
|
|
const data = res.data;
|
|
|
|
|
this.documents.push(data.selected);
|
2022-02-09 14:32:21 +01:00
|
|
|
|
2022-02-04 08:00:10 +01:00
|
|
|
this.addFileWebtrix()
|
2021-09-14 15:57:24 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
viewDocument(file: any, url?: string) {
|
|
|
|
|
if (file.type == "application/webtrix") {
|
|
|
|
|
this.openViewDocumentModal(file);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let fullUrl = "https://www.tabularium.pt" + url;
|
|
|
|
|
this.fileService.viewDocumentByUrl(fullUrl);
|
|
|
|
|
}
|
2021-10-05 16:29:33 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
async openViewDocumentModal(file: any) {
|
2021-10-09 20:24:34 +01:00
|
|
|
let task = {
|
|
|
|
|
serialNumber: '',
|
|
|
|
|
taskStartDate: '',
|
|
|
|
|
isEvent: true,
|
|
|
|
|
workflowInstanceDataFields: {
|
|
|
|
|
FolderID: '',
|
|
|
|
|
Subject: file.Assunto,
|
|
|
|
|
SourceSecFsID: file.ApplicationId,
|
|
|
|
|
SourceType: 'DOC',
|
|
|
|
|
SourceID: file.DocId,
|
|
|
|
|
DispatchNumber: ''
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let doc = {
|
2022-01-13 17:28:35 +01:00
|
|
|
"Id": "",
|
|
|
|
|
"ParentId": "",
|
|
|
|
|
"Source": 1,
|
|
|
|
|
"ApplicationId": file.ApplicationId,
|
|
|
|
|
"CreateDate": "",
|
|
|
|
|
"Data": null,
|
|
|
|
|
"Description": "",
|
|
|
|
|
"Link": null,
|
|
|
|
|
"SourceId": file.DocId,
|
|
|
|
|
"SourceName": file.Assunto,
|
|
|
|
|
"Stakeholders": "",
|
2021-10-09 20:24:34 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-05 16:29:33 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewDocumentPage,
|
|
|
|
|
componentProps: {
|
2021-10-09 20:24:34 +01:00
|
|
|
trustedUrl: '',
|
|
|
|
|
file: {
|
|
|
|
|
title: file.Assunto,
|
|
|
|
|
url: '',
|
|
|
|
|
title_link: '',
|
|
|
|
|
},
|
|
|
|
|
Document: doc,
|
|
|
|
|
applicationId: file.ApplicationId,
|
|
|
|
|
docId: file.DocId,
|
|
|
|
|
folderId: '',
|
|
|
|
|
task: task
|
2021-10-05 16:29:33 +01:00
|
|
|
},
|
2021-10-09 20:24:34 +01:00
|
|
|
cssClass: 'modal modal-desktop'
|
2021-10-05 16:29:33 +01:00
|
|
|
});
|
|
|
|
|
await modal.present();
|
2021-09-14 15:57:24 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-09 15:06:54 +01:00
|
|
|
async takePictureMobile() {
|
|
|
|
|
const roomId = this.roomId
|
|
|
|
|
|
|
|
|
|
const file = await Camera.getPhoto({
|
|
|
|
|
quality: 90,
|
|
|
|
|
// allowEditing: true,
|
|
|
|
|
resultType: CameraResultType.Base64,
|
|
|
|
|
source: CameraSource.Camera
|
|
|
|
|
});
|
|
|
|
|
console.log('ADDFILECHAT', file)
|
|
|
|
|
//const imageData = await this.fileToBase64Service.convert(file)
|
|
|
|
|
//console.log('ADDFILECHAT', imageData)
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
|
2022-02-09 15:06:54 +01:00
|
|
|
const blob = await response.blob();
|
|
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-02-11 15:08:27 +01:00
|
|
|
|
2022-02-09 15:27:21 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(roomId).send({
|
2022-02-09 15:06:54 +01:00
|
|
|
file: {
|
|
|
|
|
"type": "application/img",
|
|
|
|
|
"guid": '',
|
|
|
|
|
},
|
|
|
|
|
temporaryData: formData,
|
|
|
|
|
attachments: [{
|
2022-04-05 13:22:17 +01:00
|
|
|
"title": file.path,
|
|
|
|
|
"image_url": 'data:image/jpeg;base64,' + file.base64String,
|
2022-02-09 15:06:54 +01:00
|
|
|
"text": "description",
|
|
|
|
|
"title_link_download": false,
|
|
|
|
|
}]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
async takePicture() {
|
|
|
|
|
const roomId = this.roomId
|
2022-02-09 14:32:21 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
const image = await this.CameraService.takePicture();
|
2022-02-04 07:42:43 +01:00
|
|
|
await this.fileService.saveImage(image)
|
|
|
|
|
const lastphoto: any = await this.fileService.loadFiles();
|
2022-04-05 13:22:17 +01:00
|
|
|
const { capturedImage, capturedImageTitle } = await this.fileService.loadFileData(lastphoto);
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-07 17:55:00 +01:00
|
|
|
const base64 = await fetch(capturedImage);
|
|
|
|
|
const blob = await base64.blob();
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
|
|
|
|
|
2022-02-09 15:03:13 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(roomId).send({
|
2022-02-04 00:22:35 +01:00
|
|
|
file: {
|
|
|
|
|
"type": "application/img",
|
2022-02-08 17:44:15 +01:00
|
|
|
"guid": ''
|
2022-02-04 00:22:35 +01:00
|
|
|
},
|
|
|
|
|
attachments: [{
|
2022-04-05 13:22:17 +01:00
|
|
|
"title": capturedImageTitle,
|
2022-02-07 20:52:07 +01:00
|
|
|
"image_url": capturedImage,
|
2022-02-04 00:57:46 +01:00
|
|
|
"text": "description",
|
2022-02-04 00:22:35 +01:00
|
|
|
"title_link_download": false,
|
2022-02-07 20:18:48 +01:00
|
|
|
}],
|
|
|
|
|
temporaryData: formData
|
2022-02-04 00:22:35 +01:00
|
|
|
})
|
|
|
|
|
|
2021-10-06 17:27:49 +01:00
|
|
|
}
|
2022-02-09 14:32:21 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
async addImage() {
|
2022-02-09 15:27:21 +01:00
|
|
|
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
|
2021-10-06 17:27:49 +01:00
|
|
|
}
|
2022-02-09 14:32:21 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
async addFile() {
|
|
|
|
|
this.addFileToChat(['.doc', '.docx', '.pdf'])
|
2021-10-06 17:27:49 +01:00
|
|
|
}
|
2022-02-03 21:01:53 +01:00
|
|
|
|
|
|
|
|
async addFileWebtrix() {
|
2022-02-04 08:11:49 +01:00
|
|
|
const roomId = this.roomId
|
|
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: SearchPage,
|
|
|
|
|
cssClass: 'group-messages modal-desktop search-modal search-modal-to-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
|
|
|
|
select: true,
|
|
|
|
|
showSearchInput: true,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
2022-04-05 13:22:17 +01:00
|
|
|
modal.onDidDismiss().then(async res => {
|
2022-02-03 21:01:53 +01:00
|
|
|
const data = res.data;
|
|
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
if (data.selected) {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-09 14:32:21 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(roomId).send({
|
2022-04-05 13:22:17 +01:00
|
|
|
file: {
|
2022-02-03 21:01:53 +01:00
|
|
|
"name": res.data.selected.Assunto,
|
|
|
|
|
"type": "application/webtrix",
|
|
|
|
|
"ApplicationId": res.data.selected.ApplicationType,
|
|
|
|
|
"DocId": res.data.selected.Id,
|
|
|
|
|
"Assunto": res.data.selected.Assunto,
|
|
|
|
|
},
|
2022-02-04 00:22:35 +01:00
|
|
|
attachments: [{
|
|
|
|
|
"title": res.data.selected.Assunto,
|
|
|
|
|
"description": res.data.selected.DocTypeDesc,
|
|
|
|
|
// "title_link": url_no_options,
|
|
|
|
|
"title_link_download": true,
|
|
|
|
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
|
|
|
|
// "message_link": url_no_options,
|
2022-02-04 08:00:10 +01:00
|
|
|
"type": "webtrix",
|
2022-02-07 17:55:00 +01:00
|
|
|
//"thumb_url": "assets/images/webtrix-logo.png",
|
2022-02-04 08:00:10 +01:00
|
|
|
"text": res.data.selected.DocTypeDesc,
|
|
|
|
|
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
2022-02-07 20:18:48 +01:00
|
|
|
}],
|
|
|
|
|
temporaryData: res
|
2022-02-03 21:01:53 +01:00
|
|
|
})
|
2022-02-04 00:22:35 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
2021-10-06 17:27:49 +01:00
|
|
|
}
|
2022-04-05 13:22:17 +01:00
|
|
|
async addFileToChatMobile(types: typeof FileType[]) {
|
2022-02-09 15:27:21 +01:00
|
|
|
const roomId = this.roomId
|
|
|
|
|
|
|
|
|
|
const file = await Camera.getPhoto({
|
|
|
|
|
quality: 90,
|
|
|
|
|
// allowEditing: true,
|
|
|
|
|
resultType: CameraResultType.Base64,
|
|
|
|
|
source: CameraSource.Photos
|
|
|
|
|
});
|
|
|
|
|
console.log('ADDFILECHAT', file)
|
|
|
|
|
//const imageData = await this.fileToBase64Service.convert(file)
|
|
|
|
|
//console.log('ADDFILECHAT', imageData)
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
|
2022-02-09 15:27:21 +01:00
|
|
|
const blob = await response.blob();
|
|
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-02-11 15:08:27 +01:00
|
|
|
|
2022-02-09 15:27:21 +01:00
|
|
|
this.wsChatMethodsService.getGroupRoom(roomId).send({
|
|
|
|
|
file: {
|
|
|
|
|
"type": "application/img",
|
|
|
|
|
"guid": ''
|
|
|
|
|
},
|
|
|
|
|
temporaryData: formData,
|
|
|
|
|
attachments: [{
|
2022-04-05 13:22:17 +01:00
|
|
|
"title": file.path,
|
|
|
|
|
"image_url": 'data:image/jpeg;base64,' + file.base64String,
|
2022-02-09 15:27:21 +01:00
|
|
|
"text": "description",
|
|
|
|
|
"title_link_download": false,
|
|
|
|
|
}]
|
|
|
|
|
})
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-09 15:27:21 +01:00
|
|
|
}
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-04 00:22:35 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
async addFileToChat(types: typeof FileType[]) {
|
2022-03-03 08:21:22 +01:00
|
|
|
|
2022-02-04 08:11:49 +01:00
|
|
|
const roomId = this.roomId
|
2022-02-09 14:32:21 +01:00
|
|
|
|
2022-02-07 13:41:27 +01:00
|
|
|
const file: any = await this.fileService.getFileFromDevice(types);
|
2022-03-03 08:21:22 +01:00
|
|
|
console.log('Add file', file)
|
2022-02-04 00:22:35 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
|
2022-04-05 13:22:17 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
const encodedData = btoa(JSON.stringify(await this.getBase64(file)));
|
|
|
|
|
const blob = this.base64toBlob(encodedData, file.type)
|
|
|
|
|
console.log('Add Blob file', blob)
|
2022-04-05 13:22:17 +01:00
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-03-03 08:21:22 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(roomId).send({
|
2022-03-03 08:21:22 +01:00
|
|
|
file: {
|
|
|
|
|
"type": file.type,
|
|
|
|
|
"guid": '',
|
|
|
|
|
},
|
|
|
|
|
attachments: [{
|
2022-04-05 13:22:17 +01:00
|
|
|
"title": file.name,
|
|
|
|
|
"name": file.name,
|
2022-04-06 16:25:47 +01:00
|
|
|
//"image_url": res,
|
2022-03-03 08:21:22 +01:00
|
|
|
// "text": "description",
|
|
|
|
|
"title_link_download": false,
|
|
|
|
|
}],
|
|
|
|
|
temporaryData: formData
|
|
|
|
|
})
|
2022-04-06 16:25:47 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
} else {
|
|
|
|
|
console.log('File type invalid')
|
|
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
|
2022-02-09 14:32:21 +01:00
|
|
|
|
2021-10-06 17:27:49 +01:00
|
|
|
}
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
getFileReader(): FileReader {
|
|
|
|
|
const fileReader = new FileReader();
|
|
|
|
|
const zoneOriginalInstance = (fileReader as any)["__zone_symbol__originalInstance"];
|
|
|
|
|
return zoneOriginalInstance || fileReader;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getBase64(file) {
|
|
|
|
|
var reader = this.getFileReader();
|
|
|
|
|
reader.readAsDataURL(file);
|
2022-03-03 08:21:22 +01:00
|
|
|
return new Promise(resolve => {
|
2022-04-06 16:25:47 +01:00
|
|
|
reader.onload = function () {
|
|
|
|
|
resolve(reader.result)
|
|
|
|
|
};
|
|
|
|
|
reader.onerror = function (error) {
|
|
|
|
|
console.log('Error: ', error);
|
2022-03-03 08:21:22 +01:00
|
|
|
};
|
|
|
|
|
});
|
2022-04-06 16:25:47 +01:00
|
|
|
|
|
|
|
|
}
|
2022-03-03 08:21:22 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
bookMeeting() {
|
2021-10-06 17:27:49 +01:00
|
|
|
let data = {
|
|
|
|
|
roomId: this.roomId,
|
|
|
|
|
members: this.members
|
|
|
|
|
}
|
|
|
|
|
this.openNewEventPage.emit(data);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-18 16:30:03 +01:00
|
|
|
async _openChatOptions() {
|
2021-08-18 16:40:58 +01:00
|
|
|
|
2021-03-18 16:30:03 +01:00
|
|
|
const enterAnimation = (baseEl: any) => {
|
|
|
|
|
const backdropAnimation = this.animationController.create()
|
|
|
|
|
.addElement(baseEl.querySelector('ion-backdrop')!)
|
|
|
|
|
.fromTo('opacity', '0.01', 'var(--backdrop-opacity)');
|
|
|
|
|
|
|
|
|
|
const wrapperAnimation = this.animationController.create()
|
|
|
|
|
.addElement(baseEl.querySelector('.modal-wrapper')!)
|
|
|
|
|
.keyframes([
|
|
|
|
|
{ offset: 0, opacity: '1', right: '-100%' },
|
|
|
|
|
{ offset: 1, opacity: '1', right: '0px' }
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return this.animationController.create()
|
|
|
|
|
.addElement(baseEl)
|
|
|
|
|
.easing('ease-out')
|
2022-02-03 21:01:53 +01:00
|
|
|
.duration(500)
|
2021-03-18 16:30:03 +01:00
|
|
|
.addAnimation([backdropAnimation, wrapperAnimation]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const leaveAnimation = (baseEl: any) => {
|
|
|
|
|
return enterAnimation(baseEl).direction('reverse');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
enterAnimation,
|
|
|
|
|
leaveAnimation,
|
2021-08-18 16:40:58 +01:00
|
|
|
component: ChatOptionsFeaturesPage,
|
|
|
|
|
cssClass: 'model profile-modal search-submodal',
|
2021-03-18 16:30:03 +01:00
|
|
|
componentProps: {
|
|
|
|
|
roomId: this.roomId,
|
2021-08-18 16:40:58 +01:00
|
|
|
members: this.members,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
2022-04-05 13:22:17 +01:00
|
|
|
modal.onDidDismiss().then(async (res) => {
|
2022-02-03 21:01:53 +01:00
|
|
|
console.log(res['data']);
|
|
|
|
|
const roomId = this.roomId;
|
|
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
if (res['data'] == 'meeting') {
|
2021-08-18 16:40:58 +01:00
|
|
|
//this.closeAllDesktopComponents.emit();
|
|
|
|
|
let data = {
|
|
|
|
|
roomId: this.roomId,
|
|
|
|
|
members: this.members
|
|
|
|
|
}
|
|
|
|
|
this.openNewEventPage.emit(data);
|
2021-03-18 16:30:03 +01:00
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else if (res['data'] == 'take-picture') {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-04 08:00:10 +01:00
|
|
|
this.takePicture()
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2021-09-23 12:13:20 +01:00
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else if (res['data'] == 'add-picture') {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
|
|
|
|
this.addImage()
|
|
|
|
|
|
2021-09-13 12:37:58 +01:00
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
else if (res['data'] == 'add-document') {
|
2021-08-18 16:40:58 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
this.addFile()
|
2021-03-18 16:30:03 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
}
|
|
|
|
|
else if (res['data'] == 'documentoGestaoDocumental') {
|
2021-12-08 20:27:05 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
this.addFileWebtrix()
|
2022-02-09 14:32:21 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
this.showLoader = false;
|
2021-09-14 15:57:24 +01:00
|
|
|
}
|
2021-12-08 20:27:05 +01:00
|
|
|
|
2021-03-18 16:30:03 +01:00
|
|
|
});
|
2022-01-13 17:28:35 +01:00
|
|
|
}
|
2021-12-08 20:27:05 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
|
2022-01-21 16:55:05 +01:00
|
|
|
downloadFileMsg(msg: MessageService) {
|
2022-03-22 16:11:30 +01:00
|
|
|
msg.downloadFileMsg()
|
2022-01-13 17:28:35 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
downloadFileFromBrowser(fileName: string, data: any): void {
|
|
|
|
|
const linkSource = data;
|
|
|
|
|
const downloadLink = document.createElement("a");
|
|
|
|
|
downloadLink.href = linkSource;
|
|
|
|
|
downloadLink.download = fileName;
|
|
|
|
|
downloadLink.click();
|
|
|
|
|
}
|
2022-01-21 16:55:05 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
async openPreview(msg) {
|
2022-01-21 16:55:05 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
if(msg.file.type === "application/webtrix") {
|
|
|
|
|
this.viewDocument(msg.file, msg.attachments.image_url)
|
2022-01-21 16:55:05 +01:00
|
|
|
} else {
|
2022-04-05 13:22:17 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
|
|
|
|
|
this.downloadFileMsg(msg)
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
var str = msg.attachments[0].image_url;
|
|
|
|
|
str = str.substring(1, ((str.length) - 1));
|
|
|
|
|
|
|
|
|
|
this.downloadFileFromBrowser(msg.attachments[0].name, str)
|
|
|
|
|
|
|
|
|
|
/* const modal = await this.modalController.create({
|
|
|
|
|
component: ViewMediaPage,
|
|
|
|
|
cssClass: 'modal modal-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
image: str,
|
|
|
|
|
type: msg.file.type,
|
|
|
|
|
username: msg.u.name,
|
|
|
|
|
_updatedAt: msg._updatedAt
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
modal.present(); */
|
|
|
|
|
}
|
2022-01-13 17:28:35 +01:00
|
|
|
}
|
2022-01-21 16:55:05 +01:00
|
|
|
|
2022-01-13 17:28:35 +01:00
|
|
|
}
|
2021-09-23 12:13:20 +01:00
|
|
|
|
2022-03-21 21:09:05 +01:00
|
|
|
async audioPreview(msg) {
|
|
|
|
|
console.log(msg);
|
|
|
|
|
if (!msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') {
|
|
|
|
|
this.downloadFileMsg(msg)
|
2022-04-05 13:22:17 +01:00
|
|
|
} else { }
|
2022-03-21 21:09:05 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-04 18:50:26 +01:00
|
|
|
}
|
2021-03-12 11:56:54 +01:00
|
|
|
|