2022-04-26 16:53:10 +01:00
|
|
|
import { AfterViewInit, Component, ElementRef, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output, SimpleChanges, ViewChild } from '@angular/core';
|
2022-06-29 11:42:31 +01:00
|
|
|
import { AnimationController, GestureController, IonRange, ModalController, PopoverController } from '@ionic/angular';
|
2021-03-04 18:49:50 +01:00
|
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
|
|
|
import { ChatService } from 'src/app/services/chat.service';
|
2021-07-12 11:13:29 +01:00
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
2021-03-04 18:49:50 +01:00
|
|
|
import { ChatOptionsPopoverPage } from 'src/app/shared/popover/chat-options-popover/chat-options-popover.page';
|
|
|
|
|
import { MessagesOptionsPage } from 'src/app/shared/popover/messages-options/messages-options.page';
|
2021-03-12 11:56:54 +01:00
|
|
|
import { ContactsPage } from '../new-group/contacts/contacts.page';
|
2021-08-18 18:58:02 +01:00
|
|
|
import { ChatOptionsFeaturesPage } from 'src/app/modals/chat-options-features/chat-options-features.page';
|
2021-08-24 14:07:27 +01:00
|
|
|
import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
|
|
|
|
|
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
|
2021-09-06 16:53:58 +01:00
|
|
|
import { TimeService } from 'src/app/services/functions/time.service';
|
2021-09-21 14:05:59 +01:00
|
|
|
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-12-22 10:31:10 +01:00
|
|
|
import { ViewEventPage } from 'src/app/modals/view-event/view-event.page';
|
2022-01-05 21:27:26 +01:00
|
|
|
import { Storage } from '@ionic/storage';
|
2022-01-20 14:31:49 +01:00
|
|
|
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
|
2022-01-14 14:50:47 +01:00
|
|
|
import { WsChatService } from 'src/app/services/chat/ws-chat.service'
|
2022-01-20 14:31:49 +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';
|
|
|
|
|
import { CameraService } from 'src/app/services/camera.service';
|
|
|
|
|
import { FileType } from 'src/app/models/fileType';
|
|
|
|
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
2022-02-09 13:59:41 +01:00
|
|
|
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
2022-03-03 08:21:22 +01:00
|
|
|
import { DocumentViewer, DocumentViewerOptions } from '@ionic-native/document-viewer';
|
2022-04-26 16:14:55 +01:00
|
|
|
import { VoiceRecorder, RecordingData, GenericResponse } from 'capacitor-voice-recorder';
|
|
|
|
|
import { Filesystem, Directory } from '@capacitor/filesystem';
|
2022-03-18 11:45:38 +01:00
|
|
|
import { DomSanitizer } from '@angular/platform-browser';
|
2022-08-02 14:03:52 +01:00
|
|
|
import { Platform } from '@ionic/angular';
|
2022-04-06 16:25:47 +01:00
|
|
|
import { File } from '@awesome-cordova-plugins/file/ngx';
|
2022-04-06 17:35:44 +01:00
|
|
|
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
2022-04-18 15:12:27 +01:00
|
|
|
import { SessionStore } from 'src/app/store/session.service';
|
2022-06-29 11:42:31 +01:00
|
|
|
import { Howl } from 'howler';
|
|
|
|
|
import { runInThisContext } from 'vm';
|
2022-07-06 09:59:22 +01:00
|
|
|
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
2021-03-04 18:49:50 +01:00
|
|
|
|
|
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
const IMAGE_DIR = 'stored-images';
|
2021-03-04 18:49:50 +01:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-messages',
|
|
|
|
|
templateUrl: './messages.page.html',
|
|
|
|
|
styleUrls: ['./messages.page.scss'],
|
|
|
|
|
})
|
2021-08-23 16:31:06 +01:00
|
|
|
export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy {
|
2021-03-04 18:49:50 +01:00
|
|
|
showLoader: boolean;
|
|
|
|
|
|
|
|
|
|
@ViewChild('scrollMe') private myScrollContainer: ElementRef;
|
2021-09-30 08:43:49 +01:00
|
|
|
@ViewChild('message-item') messageContainer: ElementRef;
|
2021-03-04 18:49:50 +01:00
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
messages: any;
|
|
|
|
|
dm: any;
|
|
|
|
|
userPresence = '';
|
|
|
|
|
dmUsers: any;
|
2021-07-26 19:31:19 +01:00
|
|
|
checktimeOut: boolean;
|
2021-12-16 16:36:39 +01:00
|
|
|
members: any;
|
|
|
|
|
downloadProgess = 0;
|
2021-03-04 18:49:50 +01:00
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
@Input() roomId: string;
|
|
|
|
|
@Input() showMessages: string;
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
@Output() openNewEventPage: EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
|
@Output() getDirectMessages: EventEmitter<any> = new EventEmitter<any>();
|
2021-08-20 11:58:28 +01:00
|
|
|
|
2021-08-19 09:10:38 +01:00
|
|
|
|
2021-08-24 14:07:27 +01:00
|
|
|
chatMessageStore = ChatMessageStore
|
|
|
|
|
chatUserStorage = ChatUserStorage
|
|
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
scrollingOnce: boolean = true;
|
2021-08-23 16:31:06 +01:00
|
|
|
private scrollChangeCallback: () => void;
|
|
|
|
|
currentPosition: any;
|
|
|
|
|
startPosition: number;
|
2021-09-24 15:38:50 +01:00
|
|
|
mesageItemDropdownOptions: boolean = false;
|
|
|
|
|
scrollToBottomBtn = false;
|
2021-09-30 08:43:49 +01:00
|
|
|
longPressActive = false;
|
2021-10-18 17:10:33 +01:00
|
|
|
frameUrl: any;
|
2022-03-27 18:54:08 +01:00
|
|
|
downloadFile: string;
|
2022-01-20 14:31:49 +01:00
|
|
|
massages: MessageService[] = []
|
2021-08-20 11:24:42 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
showAvatar = true;
|
|
|
|
|
|
|
|
|
|
recording = false;
|
|
|
|
|
allowTyping = true;
|
|
|
|
|
storedFileNames = [];
|
|
|
|
|
lastAudioRecorded = '';
|
2022-03-31 11:56:49 +01:00
|
|
|
audioRecorded: any = "";
|
|
|
|
|
audioDownloaded: any = "";
|
2022-03-14 17:11:00 +01:00
|
|
|
durationDisplay = '';
|
|
|
|
|
duration = 0;
|
2022-02-24 14:59:47 +01:00
|
|
|
|
2022-07-06 09:59:22 +01:00
|
|
|
audioPermissionStatus: 'granted' | 'denied' | 'prompt' | null = null
|
2022-04-18 15:12:27 +01:00
|
|
|
sessionStore = SessionStore
|
2022-06-29 11:42:31 +01:00
|
|
|
audioPlay: Howl = null;
|
|
|
|
|
isPlaying = false;
|
|
|
|
|
audioProgress = 0;
|
|
|
|
|
audioDuration = 0;
|
2022-07-06 09:59:22 +01:00
|
|
|
audioTimer: any;
|
|
|
|
|
@ViewChild('range', { static: false }) range: IonRange;
|
|
|
|
|
userName = "";
|
2022-07-06 17:50:42 +01:00
|
|
|
room: any = new Array();
|
|
|
|
|
roomName: any;
|
|
|
|
|
isAdmin = false;
|
|
|
|
|
roomCountDownDate: string;
|
2022-04-02 09:40:09 +01:00
|
|
|
|
2021-03-04 18:49:50 +01:00
|
|
|
constructor(
|
|
|
|
|
public popoverController: PopoverController,
|
|
|
|
|
private modalController: ModalController,
|
2021-03-12 11:56:54 +01:00
|
|
|
/* private navParams: NavParams, */
|
2021-03-04 18:49:50 +01:00
|
|
|
private chatService: ChatService,
|
|
|
|
|
private authService: AuthService,
|
2021-03-18 09:25:59 +01:00
|
|
|
private animationController: AnimationController,
|
2021-07-12 11:13:29 +01:00
|
|
|
private toastService: ToastService,
|
2021-09-06 16:53:58 +01:00
|
|
|
private timeService: TimeService,
|
2021-09-21 14:05:59 +01:00
|
|
|
private fileService: FileService,
|
2021-09-30 08:43:49 +01:00
|
|
|
private gestureController: GestureController,
|
2021-11-22 13:53:37 +01:00
|
|
|
public ThemeService: ThemeService,
|
2022-01-19 09:12:30 +01:00
|
|
|
private storage: Storage,
|
2022-01-14 14:50:47 +01:00
|
|
|
public wsChatMethodsService: WsChatMethodsService,
|
2022-02-03 21:01:53 +01:00
|
|
|
public WsChatService: WsChatService,
|
|
|
|
|
private AttachmentsService: AttachmentsService,
|
|
|
|
|
private CameraService: CameraService,
|
2022-03-18 11:45:38 +01:00
|
|
|
private sanitiser: DomSanitizer,
|
2022-04-06 16:25:47 +01:00
|
|
|
private file: File,
|
|
|
|
|
private platform: Platform,
|
2022-04-06 17:35:44 +01:00
|
|
|
private fileOpener: FileOpener,
|
2021-07-23 14:43:51 +01:00
|
|
|
) {
|
2022-04-02 09:40:09 +01:00
|
|
|
|
|
|
|
|
this.checkAudioPermission()
|
2021-03-12 11:56:54 +01:00
|
|
|
}
|
2022-03-21 15:08:43 +01:00
|
|
|
|
2021-03-12 11:56:54 +01:00
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
2022-07-06 17:50:42 +01:00
|
|
|
this.wsChatMethodsService.getAllRooms();
|
2022-02-09 17:06:12 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
|
2022-01-14 14:58:47 +01:00
|
|
|
|
2022-01-29 19:21:46 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
|
2022-01-20 14:31:49 +01:00
|
|
|
|
2022-01-29 19:21:46 +01:00
|
|
|
this.wsChatMethodsService.openRoom(this.roomId)
|
2022-02-04 00:22:35 +01:00
|
|
|
|
|
|
|
|
this.wsChatMethodsService.getDmRoom(this.roomId).uploadAttachment = async (formData) => {
|
|
|
|
|
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-24 14:59:47 +01:00
|
|
|
this.showAvatar = false
|
|
|
|
|
|
2022-01-20 14:31:49 +01:00
|
|
|
setTimeout(() => {
|
2022-01-14 14:58:47 +01:00
|
|
|
this.scrollToBottomClicked()
|
2022-02-24 14:59:47 +01:00
|
|
|
this.showAvatar = true
|
2022-01-29 19:21:46 +01:00
|
|
|
}, 150)
|
2022-01-20 14:31:49 +01:00
|
|
|
|
2022-03-18 11:45:38 +01:00
|
|
|
this.deleteRecording()
|
2022-03-14 20:34:29 +01:00
|
|
|
|
2021-03-04 18:49:50 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-02 09:40:09 +01:00
|
|
|
async checkAudioPermission() {
|
|
|
|
|
const permissionStatus = await navigator.permissions.query({ name: 'microphone' } as any)
|
2022-04-07 15:44:31 +01:00
|
|
|
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-04-02 09:40:09 +01:00
|
|
|
|
|
|
|
|
this.audioPermissionStatus = permissionStatus.state
|
|
|
|
|
|
2022-07-06 09:59:22 +01:00
|
|
|
permissionStatus.onchange = (data: any) => {
|
2022-04-28 09:32:27 +01:00
|
|
|
//
|
|
|
|
|
//
|
2022-04-02 09:40:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-04 18:49:50 +01:00
|
|
|
ngOnInit() {
|
2022-07-06 09:59:22 +01:00
|
|
|
this.wsChatMethodsService.getAllRooms();
|
2022-06-10 09:42:41 +01:00
|
|
|
this.chatService.refreshtoken();
|
2021-07-26 09:44:11 +01:00
|
|
|
this.scrollToBottom();
|
2022-02-03 16:36:05 +01:00
|
|
|
this.getChatMembers();
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-03-18 11:45:38 +01:00
|
|
|
this.deleteRecording();
|
2022-03-14 17:11:00 +01:00
|
|
|
this.loadFiles();
|
2021-07-26 19:31:19 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-20 14:31:49 +01:00
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
onPressingMessage() {
|
2021-09-30 08:43:49 +01:00
|
|
|
const gesture = this.gestureController.create({
|
|
|
|
|
el: this.messageContainer.nativeElement,
|
|
|
|
|
gestureName: 'long-press',
|
2021-12-16 16:36:39 +01:00
|
|
|
onStart: ev => {
|
2021-09-30 08:43:49 +01:00
|
|
|
this.longPressActive = true;
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2021-09-30 08:43:49 +01:00
|
|
|
},
|
|
|
|
|
onEnd: ev => {
|
|
|
|
|
this.longPressActive = false;
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2021-09-30 08:43:49 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
load = () => {
|
2021-07-26 19:31:19 +01:00
|
|
|
this.checktimeOut = true;
|
2021-03-04 18:49:50 +01:00
|
|
|
this.getChatMembers();
|
|
|
|
|
}
|
2021-03-12 11:56:54 +01:00
|
|
|
|
|
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
doRefresh(ev: any) {
|
2021-03-04 18:49:50 +01:00
|
|
|
this.load();
|
|
|
|
|
ev.target.complete();
|
|
|
|
|
}
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2022-01-13 10:26:40 +01:00
|
|
|
scrollToBottom = () => {
|
2021-03-04 18:49:50 +01:00
|
|
|
try {
|
2021-12-16 16:36:39 +01:00
|
|
|
if (this.scrollingOnce) {
|
2021-08-23 16:31:06 +01:00
|
|
|
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
|
|
|
|
//this.scrollingOnce = false;
|
|
|
|
|
}
|
2021-12-16 16:36:39 +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:38:50 +01:00
|
|
|
try {
|
|
|
|
|
this.myScrollContainer.nativeElement.scrollTop = this.myScrollContainer.nativeElement.scrollHeight;
|
|
|
|
|
//this.scrollingOnce = false;
|
2021-12-16 16:36:39 +01:00
|
|
|
} catch (err) { }
|
2021-09-24 15:38:50 +01:00
|
|
|
}
|
|
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
ngAfterViewInit() {
|
|
|
|
|
this.scrollChangeCallback = () => this.onContentScrolled(event);
|
|
|
|
|
window.addEventListener('scroll', this.scrollChangeCallback, true);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 16:36:39 +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:38:50 +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:38:50 +01:00
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
if (scroll > this.currentPosition) {
|
|
|
|
|
//alert('BOTTOM');
|
|
|
|
|
} else {
|
|
|
|
|
//alert('UP');
|
|
|
|
|
this.scrollingOnce = false;
|
2021-07-12 11:13:29 +01:00
|
|
|
}
|
2021-12-16 16:36:39 +01:00
|
|
|
if ((containerHeight - 100) > scroll) {
|
2021-09-24 15:38:50 +01:00
|
|
|
this.scrollToBottomBtn = true;
|
|
|
|
|
}
|
2021-12-16 16:36:39 +01:00
|
|
|
else {
|
2021-09-24 15:38:50 +01:00
|
|
|
this.scrollToBottomBtn = false;
|
|
|
|
|
}
|
2021-08-23 16:31:06 +01:00
|
|
|
this.currentPosition = scroll;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-14 17:11:00 +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-03-31 11:56:49 +01:00
|
|
|
async getFile(fileName?: any) {
|
2022-03-14 17:11:00 +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-18 11:45:38 +01:00
|
|
|
|
2022-03-22 14:23:38 +01:00
|
|
|
this.storage.get('recordData').then((recordData) => {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-03-31 16:48:53 +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-29 00:03:54 +01:00
|
|
|
}
|
2022-07-06 09:59:22 +01:00
|
|
|
else if (recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
|
2022-03-24 17:40:14 +01:00
|
|
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`);
|
2022-03-29 00:03:54 +01:00
|
|
|
}
|
2022-03-22 14:23:38 +01:00
|
|
|
});
|
2022-03-31 16:48:53 +01:00
|
|
|
} catch (error) { }
|
2022-03-18 11:45:38 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
this.storage.get('recordData').then((recordData) => {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-04-18 15:24:01 +01:00
|
|
|
if (recordData?.value?.recordDataBase64?.includes('data:audio')) {
|
2022-03-18 11:45:38 +01:00
|
|
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(recordData.value.recordDataBase64);
|
|
|
|
|
}
|
2022-07-06 09:59:22 +01:00
|
|
|
else if (recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
|
2022-03-18 11:45:38 +01:00
|
|
|
this.audioRecorded = this.sanitiser.bypassSecurityTrustResourceUrl(`data:${recordData.value.mimeType};base64,${recordData.value.recordDataBase64}`);
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-03-14 17:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-07 15:22:25 +01:00
|
|
|
async startRecording() {
|
2022-05-27 16:53:09 +01:00
|
|
|
VoiceRecorder.requestAudioRecordingPermission();
|
2022-07-06 09:59:22 +01:00
|
|
|
if (await VoiceRecorder.canDeviceVoiceRecord().then((result: GenericResponse) => { return result.value })) {
|
|
|
|
|
if (await VoiceRecorder.requestAudioRecordingPermission().then((result: GenericResponse) => { return result.value })) {
|
2022-04-07 15:22:25 +01:00
|
|
|
//if(await this.hasAudioRecordingPermission()){
|
2022-07-06 09:59:22 +01:00
|
|
|
if (this.recording) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.recording = true;
|
|
|
|
|
VoiceRecorder.startRecording();
|
|
|
|
|
this.calculateDuration();
|
2022-04-07 15:22:25 +01:00
|
|
|
//}
|
|
|
|
|
}
|
2022-05-30 16:06:28 +01:00
|
|
|
else {
|
2022-04-07 15:22:25 +01:00
|
|
|
this.toastService._badRequest('Para gravar uma mensagem de voz, permita o acesso do Gabinete Digital ao seu microfone.');
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-30 16:06:28 +01:00
|
|
|
else {
|
2022-04-07 15:22:25 +01:00
|
|
|
this.toastService._badRequest('Este dispositivo não tem capacidade para gravação de áudio!');
|
2022-03-14 17:11:00 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stopRecording() {
|
2022-03-18 11:45:38 +01:00
|
|
|
this.deleteRecording();
|
2022-03-14 17:11:00 +01:00
|
|
|
this.allowTyping = false;
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
if (!this.recording) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this.recording = false;
|
|
|
|
|
VoiceRecorder.stopRecording().then(async (result: RecordingData) => {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
this.recording = false;
|
|
|
|
|
if (result.value && result.value.recordDataBase64) {
|
|
|
|
|
const recordData = result.value.recordDataBase64;
|
2022-04-18 15:27:16 +01:00
|
|
|
//
|
2022-03-18 16:43:15 +01:00
|
|
|
const fileName = new Date().getTime() + ".mp3";
|
2022-03-18 11:45:38 +01:00
|
|
|
//Save file
|
2022-03-31 11:56:49 +01:00
|
|
|
this.storage.set('fileName', fileName);
|
|
|
|
|
this.storage.set('recordData', result).then(() => {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
setTimeout(async () => {
|
|
|
|
|
this.loadFiles();
|
2022-03-18 11:45:38 +01:00
|
|
|
}, 1000);
|
2022-03-14 17:11:00 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-31 11:56:49 +01:00
|
|
|
async deleteRecording() {
|
2022-03-18 11:45:38 +01:00
|
|
|
this.storage.remove('fileName');
|
|
|
|
|
this.storage.remove('recordData');
|
|
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
this.allowTyping = true;
|
|
|
|
|
this.lastAudioRecorded = '';
|
|
|
|
|
this.loadFiles();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 16:31:06 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
|
this.checktimeOut = false;
|
|
|
|
|
window.removeEventListener('scroll', this.scrollChangeCallback, true);
|
2021-07-26 09:44:11 +01:00
|
|
|
}
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
openBookMeetingComponent() {
|
2021-08-20 11:58:28 +01:00
|
|
|
let data = {
|
|
|
|
|
roomId: this.roomId,
|
|
|
|
|
members: this.members
|
|
|
|
|
}
|
|
|
|
|
this.openNewEventPage.emit(data);
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
showDateDuration(start: any) {
|
2021-09-06 16:53:58 +01:00
|
|
|
return this.timeService.showDateDuration(start);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-03 16:31:03 +01:00
|
|
|
async goToEvent(event: any) {
|
2021-12-22 10:31:10 +01:00
|
|
|
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: {
|
2022-08-03 16:31:03 +01:00
|
|
|
eventId: event.id,
|
|
|
|
|
CalendarId: event.calendarId
|
2021-12-22 10:31:10 +01:00
|
|
|
},
|
|
|
|
|
cssClass: classs,
|
|
|
|
|
});
|
|
|
|
|
await modal.present();
|
|
|
|
|
modal.onDidDismiss().then((res) => {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2021-12-22 10:31:10 +01:00
|
|
|
});
|
|
|
|
|
}
|
2021-03-04 18:49:50 +01:00
|
|
|
|
2021-12-22 10:31:10 +01:00
|
|
|
sendMessage() {
|
2022-02-04 00:22:35 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(this.roomId).send({})
|
2021-03-04 18:49:50 +01:00
|
|
|
}
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2022-03-18 16:29:10 +01:00
|
|
|
|
2022-03-14 17:11:00 +01:00
|
|
|
async sendAudio(fileName) {
|
2022-03-18 16:29:10 +01:00
|
|
|
const roomId = this.roomId
|
2022-03-18 16:43:15 +01:00
|
|
|
let audioFile;
|
2022-03-18 16:29:10 +01:00
|
|
|
this.storage.get('recordData').then((recordData) => {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-03-18 16:43:15 +01:00
|
|
|
audioFile = recordData;
|
2022-03-31 16:48:53 +01:00
|
|
|
|
2022-04-18 15:24:01 +01:00
|
|
|
if (recordData?.value?.recordDataBase64?.includes('data:audio')) {
|
2022-03-18 16:29:10 +01:00
|
|
|
this.audioRecorded = recordData.value.recordDataBase64;
|
|
|
|
|
}
|
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 16:29:10 +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)
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-03-18 16:29:10 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(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-18 16:29:10 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
});
|
2022-03-18 16:29:10 +01:00
|
|
|
this.deleteRecording();
|
2021-09-28 15:23:51 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-06 16:00:57 +01:00
|
|
|
|
2022-03-31 16:48:53 +01:00
|
|
|
deleteMessage(msgId: string, msg: MessageService) {
|
2022-03-15 15:49:59 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(this.roomId).sendDeleteRequest(msgId)
|
2021-09-21 14:05:59 +01:00
|
|
|
}
|
|
|
|
|
|
2022-03-27 22:07:13 +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-03-31 11:56:49 +01:00
|
|
|
var begin = sliceIndex * sliceSize;
|
|
|
|
|
var end = Math.min(begin + sliceSize, bytesLength);
|
2022-03-27 22:07:13 +01:00
|
|
|
|
2022-03-31 11:56:49 +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-27 22:07:13 +01:00
|
|
|
}
|
|
|
|
|
return new Blob(byteArrays, { type: contentType });
|
2022-03-31 11:56:49 +01:00
|
|
|
}
|
2022-03-27 22:07:13 +01:00
|
|
|
|
2022-01-28 19:09:37 +01:00
|
|
|
|
2021-12-16 16:36:39 +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 = {
|
2021-12-16 16:36:39 +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-08-24 14:07:27 +01:00
|
|
|
getChatMembers() {
|
2022-04-28 09:32:27 +01:00
|
|
|
//
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2021-07-26 12:12:59 +01:00
|
|
|
//this.showLoader = true;
|
2021-12-16 16:36:39 +01:00
|
|
|
this.chatService.getMembers(this.roomId).subscribe(res => {
|
2021-08-20 11:58:28 +01:00
|
|
|
this.members = res['members'];
|
2022-04-26 14:34:52 +01:00
|
|
|
this.dmUsers = res['members'].filter(data => data.username != this.sessionStore.user.UserName)
|
2021-03-04 18:49:50 +01:00
|
|
|
this.showLoader = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async openMessagesOptions(ev: any) {
|
|
|
|
|
const popover = await this.popoverController.create({
|
|
|
|
|
component: MessagesOptionsPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
roomId: this.dm._id,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'messages-options',
|
|
|
|
|
event: ev,
|
|
|
|
|
translucent: true,
|
|
|
|
|
});
|
|
|
|
|
return await popover.present();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
async addContacts() {
|
2021-03-04 18:49:50 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ContactsPage,
|
2021-07-23 14:43:51 +01:00
|
|
|
componentProps: {},
|
2021-03-04 18:49:50 +01:00
|
|
|
cssClass: 'contacts',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
|
|
|
|
|
|
|
|
|
modal.onDidDismiss();
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
openSendMessageOptions(ev?: any) {
|
|
|
|
|
if (window.innerWidth < 701) {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2021-03-18 16:30:03 +01:00
|
|
|
this.openChatOptions(ev);
|
|
|
|
|
}
|
2021-12-16 16:36:39 +01:00
|
|
|
else {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2021-03-18 16:30:03 +01:00
|
|
|
this._openChatOptions();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-04 18:49:50 +01:00
|
|
|
async openChatOptions(ev: any) {
|
|
|
|
|
const popover = await this.popoverController.create({
|
|
|
|
|
component: ChatOptionsPopoverPage,
|
|
|
|
|
cssClass: 'chat-options-popover',
|
|
|
|
|
event: ev,
|
|
|
|
|
translucent: true
|
|
|
|
|
});
|
|
|
|
|
return await popover.present();
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-18 09:25:59 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
async _openMessagesOptions() {
|
|
|
|
|
|
|
|
|
|
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 modal = await this.modalController.create({
|
|
|
|
|
enterAnimation,
|
|
|
|
|
leaveAnimation,
|
|
|
|
|
component: MessagesOptionsPage,
|
|
|
|
|
cssClass: 'model profile-modal search-submodal',
|
|
|
|
|
componentProps: {
|
|
|
|
|
roomId: this.roomId,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return await modal.present();
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-23 14:43:51 +01:00
|
|
|
|
2022-02-09 13:59:41 +01:00
|
|
|
async takePictureMobile() {
|
2022-05-27 13:36:37 +01:00
|
|
|
|
2022-02-09 13:59:41 +01:00
|
|
|
const roomId = this.roomId
|
|
|
|
|
|
|
|
|
|
const file = await Camera.getPhoto({
|
|
|
|
|
quality: 90,
|
|
|
|
|
// allowEditing: true,
|
|
|
|
|
resultType: CameraResultType.Base64,
|
|
|
|
|
source: CameraSource.Camera
|
|
|
|
|
});
|
|
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
|
2022-02-09 13:59:41 +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 13:59:41 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(roomId).send({
|
|
|
|
|
file: {
|
|
|
|
|
"type": "application/img",
|
|
|
|
|
"guid": '',
|
|
|
|
|
},
|
|
|
|
|
temporaryData: formData,
|
|
|
|
|
attachments: [{
|
2022-03-03 08:21:22 +01:00
|
|
|
"title": file.path,
|
2022-03-03 22:57:33 +01:00
|
|
|
// "image_url": "",
|
2022-03-03 08:21:22 +01:00
|
|
|
//"image_url": 'data:image/jpeg;base64,' + file.base64String,
|
2022-02-09 13:59:41 +01:00
|
|
|
"text": "description",
|
|
|
|
|
"title_link_download": false,
|
|
|
|
|
}]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
2021-03-18 16:30:03 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
async takePicture() {
|
2021-10-07 15:30:36 +01:00
|
|
|
const roomId = this.roomId
|
2022-02-11 15:08:27 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
const image = await this.CameraService.takePicture();
|
2022-07-12 14:57:02 +01:00
|
|
|
await this.fileService.saveImage(image);
|
2022-02-04 07:42:43 +01:00
|
|
|
const lastphoto: any = await this.fileService.loadFiles();
|
2022-03-03 08:21:22 +01:00
|
|
|
const { capturedImage, capturedImageTitle } = await this.fileService.loadFileData(lastphoto);
|
2022-02-07 17:55:00 +01:00
|
|
|
const base64 = await fetch(capturedImage);
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-02-07 17:55:00 +01:00
|
|
|
const blob = await base64.blob();
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-02-07 20:18:48 +01:00
|
|
|
|
2022-02-07 17:55:00 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(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
|
|
|
},
|
2022-02-07 20:18:48 +01:00
|
|
|
temporaryData: formData,
|
2022-02-04 00:22:35 +01:00
|
|
|
attachments: [{
|
2022-03-03 08:21:22 +01:00
|
|
|
"title": capturedImageTitle,
|
2022-02-07 20:52:07 +01:00
|
|
|
"image_url": capturedImage,
|
2022-02-04 00:54:41 +01:00
|
|
|
"text": "description",
|
2022-02-04 00:22:35 +01:00
|
|
|
"title_link_download": false,
|
|
|
|
|
}]
|
|
|
|
|
})
|
|
|
|
|
|
2021-10-06 17:27:49 +01:00
|
|
|
}
|
2022-02-11 15:08:27 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
async addImage() {
|
2022-02-09 13:59:41 +01:00
|
|
|
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
|
2021-10-06 17:27:49 +01:00
|
|
|
}
|
2022-02-11 15:08:27 +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() {
|
|
|
|
|
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-03-03 08:21:22 +01:00
|
|
|
modal.onDidDismiss().then(async res => {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
const data = res.data;
|
2022-02-04 08:11:49 +01:00
|
|
|
const roomId = this.roomId
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
if (data.selected) {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-07 17:55:00 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(roomId).send({
|
2022-03-03 08:21:22 +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-04-06 16:25:47 +01:00
|
|
|
temporaryData: res,
|
2022-02-04 00:22:35 +01:00
|
|
|
attachments: [{
|
|
|
|
|
"title": res.data.selected.Assunto,
|
|
|
|
|
"description": res.data.selected.DocTypeDesc,
|
2022-02-03 21:01:53 +01:00
|
|
|
"title_link_download": true,
|
2022-02-04 08:00:10 +01:00
|
|
|
"type": "webtrix",
|
|
|
|
|
"text": res.data.selected.DocTypeDesc,
|
|
|
|
|
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
|
2022-02-07 17:55:00 +01:00
|
|
|
}],
|
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-02-03 21:01:53 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
async addFileToChatMobile(types: typeof FileType[]) {
|
2022-02-09 13:59:41 +01:00
|
|
|
const roomId = this.roomId
|
|
|
|
|
|
|
|
|
|
const file = await Camera.getPhoto({
|
|
|
|
|
quality: 90,
|
|
|
|
|
// allowEditing: true,
|
|
|
|
|
resultType: CameraResultType.Base64,
|
|
|
|
|
source: CameraSource.Photos
|
|
|
|
|
});
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-02-09 13:59:41 +01:00
|
|
|
//const imageData = await this.fileToBase64Service.convert(file)
|
2022-04-28 09:32:27 +01:00
|
|
|
//
|
2022-02-09 13:59:41 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
|
2022-02-09 13:59:41 +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 13:59:41 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(roomId).send({
|
|
|
|
|
file: {
|
|
|
|
|
"type": "application/img",
|
2022-02-09 14:39:59 +01:00
|
|
|
"guid": ''
|
2022-02-09 13:59:41 +01:00
|
|
|
},
|
|
|
|
|
temporaryData: formData,
|
|
|
|
|
attachments: [{
|
2022-03-03 08:21:22 +01:00
|
|
|
"title": file.path,
|
|
|
|
|
//"image_url": 'data:image/jpeg;base64,' + file.base64String,
|
2022-02-09 13:59:41 +01:00
|
|
|
"text": "description",
|
|
|
|
|
"title_link_download": false,
|
|
|
|
|
}]
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-04 00:22:35 +01:00
|
|
|
|
2022-03-03 08:21:22 +01:00
|
|
|
async addFileToChat(types: typeof FileType[]) {
|
2022-02-11 15:08:27 +01:00
|
|
|
|
2022-02-04 08:11:49 +01:00
|
|
|
const roomId = this.roomId
|
|
|
|
|
|
2022-02-07 13:41:27 +01:00
|
|
|
const file: any = await this.fileService.getFileFromDevice(types);
|
2022-07-06 09:59:22 +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") {
|
|
|
|
|
|
|
|
|
|
const encodedData = btoa(JSON.stringify(await this.getBase64(file)));
|
|
|
|
|
const blob = this.base64toBlob(encodedData, file.type)
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append("blobFile", blob);
|
2022-02-11 15:08:27 +01:00
|
|
|
|
2022-02-25 15:10:10 +01:00
|
|
|
this.wsChatMethodsService.getDmRoom(roomId).send({
|
|
|
|
|
file: {
|
|
|
|
|
"type": file.type,
|
|
|
|
|
"guid": '',
|
|
|
|
|
},
|
|
|
|
|
attachments: [{
|
2022-03-03 08:21:22 +01:00
|
|
|
"title": file.name,
|
|
|
|
|
"name": file.name,
|
|
|
|
|
//"image_url": res,
|
2022-02-25 15:10:10 +01:00
|
|
|
// "text": "description",
|
|
|
|
|
"title_link_download": false,
|
|
|
|
|
}],
|
|
|
|
|
temporaryData: formData
|
|
|
|
|
})
|
2022-04-05 13:22:17 +01:00
|
|
|
|
|
|
|
|
} else {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-04-05 13:22:17 +01:00
|
|
|
}
|
2022-02-04 00:22:35 +01:00
|
|
|
|
2022-02-07 20:35:52 +01:00
|
|
|
|
2021-10-06 17:27:49 +01:00
|
|
|
}
|
2022-02-11 15:08:27 +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-02-25 15:10:10 +01:00
|
|
|
return new Promise(resolve => {
|
2022-04-06 16:25:47 +01:00
|
|
|
reader.onload = function () {
|
|
|
|
|
resolve(reader.result)
|
|
|
|
|
};
|
|
|
|
|
reader.onerror = function (error) {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-02-25 15:10:10 +01:00
|
|
|
};
|
|
|
|
|
});
|
2022-04-06 16:25:47 +01:00
|
|
|
|
|
|
|
|
}
|
2022-02-25 15:10:10 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
bookMeeting() {
|
2021-10-06 17:27:49 +01:00
|
|
|
let data = {
|
|
|
|
|
roomId: this.roomId,
|
|
|
|
|
members: this.members
|
|
|
|
|
}
|
|
|
|
|
this.openNewEventPage.emit(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-02-04 00:22:35 +01:00
|
|
|
chatsend() {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-18 16:30:03 +01:00
|
|
|
async _openChatOptions() {
|
2022-02-03 21:01:53 +01:00
|
|
|
const roomId = this.roomId;
|
|
|
|
|
|
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')
|
|
|
|
|
.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 16:30:03 +01:00
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
enterAnimation,
|
|
|
|
|
leaveAnimation,
|
2021-08-18 18:58:02 +01:00
|
|
|
component: ChatOptionsFeaturesPage,
|
2021-03-18 16:30:03 +01:00
|
|
|
cssClass: 'model profile-modal search-submodal',
|
|
|
|
|
componentProps: {
|
|
|
|
|
roomId: this.roomId,
|
2021-08-20 11:58:28 +01:00
|
|
|
members: this.members,
|
2021-03-18 16:30:03 +01:00
|
|
|
}
|
|
|
|
|
});
|
2021-08-20 11:58:28 +01:00
|
|
|
await modal.present();
|
2022-03-03 08:21:22 +01:00
|
|
|
modal.onDidDismiss().then(async (res) => {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-02-11 15:08:27 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2021-12-16 16:36:39 +01:00
|
|
|
if (res['data'] == 'meeting') {
|
2021-08-20 11:58:28 +01:00
|
|
|
//this.closeAllDesktopComponents.emit();
|
|
|
|
|
let data = {
|
|
|
|
|
roomId: this.roomId,
|
|
|
|
|
members: this.members
|
|
|
|
|
}
|
|
|
|
|
this.openNewEventPage.emit(data);
|
|
|
|
|
}
|
2021-12-16 16:36:39 +01:00
|
|
|
else if (res['data'] == 'take-picture') {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2022-02-09 13:59:41 +01:00
|
|
|
this.takePictureMobile()
|
2022-02-03 21:01:53 +01:00
|
|
|
|
2021-09-23 12:13:20 +01:00
|
|
|
}
|
2021-12-16 16:36:39 +01:00
|
|
|
else if (res['data'] == 'add-picture') {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
|
|
|
|
this.addImage()
|
|
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
}
|
2021-12-16 16:36:39 +01:00
|
|
|
else if (res['data'] == 'add-document') {
|
2022-02-03 21:01:53 +01:00
|
|
|
|
|
|
|
|
this.addFile()
|
|
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
}
|
2021-12-16 16:36:39 +01:00
|
|
|
else if (res['data'] == 'documentoGestaoDocumental') {
|
2021-09-21 14:05:59 +01:00
|
|
|
|
2022-02-03 21:01:53 +01:00
|
|
|
this.addFileWebtrix()
|
2022-02-11 15:08:27 +01:00
|
|
|
|
2021-09-21 14:05:59 +01:00
|
|
|
this.showLoader = false;
|
|
|
|
|
}
|
2021-08-20 11:58:28 +01:00
|
|
|
|
|
|
|
|
});
|
2021-03-18 16:30:03 +01:00
|
|
|
}
|
|
|
|
|
|
2021-09-23 12:13:20 +01:00
|
|
|
|
|
|
|
|
|
2021-07-26 10:52:14 +01:00
|
|
|
|
2022-01-20 15:33:55 +01:00
|
|
|
downloadFileMsg(msg: MessageService) {
|
2022-04-05 13:22:17 +01:00
|
|
|
msg.downloadFileMsg()
|
2021-12-23 07:40:01 +01:00
|
|
|
}
|
|
|
|
|
|
2022-02-25 15:10:10 +01:00
|
|
|
pdfPreview() {
|
2022-02-10 19:47:16 +01:00
|
|
|
const options: DocumentViewerOptions = {
|
|
|
|
|
title: 'My App'
|
|
|
|
|
};
|
|
|
|
|
DocumentViewer.viewDocument
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-21 13:33:57 +01:00
|
|
|
async audioPreview(msg) {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-03-21 13:33:57 +01:00
|
|
|
if (!msg.attachments[0].title_link || msg.attachments[0].title_link === null || msg.attachments[0].title_link === '') {
|
|
|
|
|
this.downloadFileMsg(msg)
|
2022-03-31 16:48:53 +01:00
|
|
|
} else { }
|
2022-03-21 13:33:57 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
b64toBlob(b64Data, contentType) {
|
|
|
|
|
contentType = contentType || '';
|
|
|
|
|
var sliceSize = 512;
|
|
|
|
|
b64Data = b64Data.replace(/^[^,]+,/, '');
|
|
|
|
|
b64Data = b64Data.replace(/\s/g, '');
|
|
|
|
|
var byteCharacters = window.atob(b64Data);
|
|
|
|
|
var byteArrays = [];
|
|
|
|
|
|
|
|
|
|
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
|
|
|
var slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
|
|
|
|
|
|
|
|
var byteNumbers = new Array(slice.length);
|
|
|
|
|
for (var i = 0; i < slice.length; i++) {
|
|
|
|
|
byteNumbers[i] = slice.charCodeAt(i);
|
|
|
|
|
}
|
2022-01-20 15:33:55 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
var byteArray = new Uint8Array(byteNumbers);
|
2022-01-20 14:31:49 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
byteArrays.push(byteArray);
|
|
|
|
|
}
|
2022-03-31 11:56:49 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
var blob = new Blob(byteArrays, { type: contentType });
|
|
|
|
|
return blob;
|
|
|
|
|
}
|
2022-03-31 11:56:49 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
downloadFileFromBrowser(fileName: string, data: any): void {
|
2022-07-06 09:59:22 +01:00
|
|
|
console.log(fileName + data)
|
2022-04-06 16:25:47 +01:00
|
|
|
const linkSource = data;
|
|
|
|
|
const downloadLink = document.createElement("a");
|
|
|
|
|
downloadLink.href = linkSource;
|
|
|
|
|
downloadLink.download = fileName;
|
|
|
|
|
downloadLink.click();
|
|
|
|
|
}
|
2022-03-31 11:56:49 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
viewDocument(file: any, url?: string) {
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
if (file.type == "application/webtrix") {
|
|
|
|
|
this.openViewDocumentModal(file);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
let fullUrl = "https://www.tabularium.pt" + url;
|
|
|
|
|
this.fileService.viewDocumentByUrl(fullUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-25 15:10:10 +01:00
|
|
|
|
2022-04-06 17:35:44 +01:00
|
|
|
openFile(pdfString, filename, type) {
|
|
|
|
|
const blob = this.b64toBlob(pdfString, type)
|
|
|
|
|
let pathFile = ''
|
|
|
|
|
const fileName = filename
|
|
|
|
|
const contentFile = blob
|
|
|
|
|
if (this.platform.is('ios')) {
|
|
|
|
|
pathFile = this.file.documentsDirectory
|
|
|
|
|
} else {
|
|
|
|
|
pathFile = this.file.externalRootDirectory
|
|
|
|
|
}
|
2022-07-06 09:59:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-04-06 17:35:44 +01:00
|
|
|
this.file
|
|
|
|
|
.writeFile(pathFile, fileName, contentFile, { replace: true })
|
|
|
|
|
.then(success => {
|
|
|
|
|
this.fileOpener
|
|
|
|
|
.open(pathFile + fileName, type)
|
2022-07-06 09:59:22 +01:00
|
|
|
.then(() => { })
|
2022-04-28 09:32:27 +01:00
|
|
|
.catch(e => console.error(e))
|
2022-04-06 17:35:44 +01:00
|
|
|
})
|
2022-04-28 09:32:27 +01:00
|
|
|
.catch(e => console.error(e))
|
2022-04-06 17:35:44 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
async openPreview(msg) {
|
2022-03-31 11:56:49 +01:00
|
|
|
|
2022-07-06 09:59:22 +01:00
|
|
|
|
|
|
|
|
if (msg.file.type === "application/webtrix") {
|
2022-04-06 16:25:47 +01:00
|
|
|
this.viewDocument(msg.file, msg.attachments.image_url)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if (!msg.attachments[0].image_url || msg.attachments[0].image_url === null || msg.attachments[0].image_url === '') {
|
|
|
|
|
this.downloadFileMsg(msg)
|
2022-04-07 15:22:25 +01:00
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
} else {
|
|
|
|
|
var str = msg.attachments[0].image_url;
|
|
|
|
|
str = str.substring(1, ((str.length) - 1));
|
2022-04-07 15:22:25 +01:00
|
|
|
|
2022-04-06 17:35:44 +01:00
|
|
|
if (this.platform.is('desktop') || this.platform.is('mobileweb')) {
|
2022-04-07 15:22:25 +01:00
|
|
|
|
2022-07-06 09:59:22 +01:00
|
|
|
console.log(msg)
|
|
|
|
|
if (msg.file.type == "application/img") {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: ViewMediaPage,
|
|
|
|
|
cssClass: 'modal modal-desktop',
|
|
|
|
|
componentProps: {
|
|
|
|
|
image: msg.attachments[0].image_url,
|
|
|
|
|
type: msg.file.type,
|
|
|
|
|
username: msg.u.name,
|
|
|
|
|
_updatedAt: msg._updatedAt
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
modal.present();
|
|
|
|
|
} else {
|
|
|
|
|
this.downloadFileFromBrowser("file", str)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
2022-04-06 17:35:44 +01:00
|
|
|
this.openFile(str, msg.attachments[0].name, msg.file.type);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-07 15:22:25 +01:00
|
|
|
|
|
|
|
|
|
2022-04-06 16:25:47 +01:00
|
|
|
}
|
2021-12-23 07:40:01 +01:00
|
|
|
}
|
2022-01-05 21:27:26 +01:00
|
|
|
|
2021-11-22 13:53:37 +01:00
|
|
|
}
|
2022-02-16 15:52:59 +01:00
|
|
|
|
2022-06-29 11:42:31 +01:00
|
|
|
start(track) {
|
2022-07-06 09:59:22 +01:00
|
|
|
if (this.audioPlay) {
|
2022-06-29 11:42:31 +01:00
|
|
|
this.audioPlay.stop();
|
|
|
|
|
}
|
|
|
|
|
this.audioPlay = new Howl({
|
|
|
|
|
src: [track.changingThisBreaksApplicationSecurity],
|
|
|
|
|
onplay: () => {
|
|
|
|
|
console.log('audio play')
|
|
|
|
|
this.isPlaying = true;
|
|
|
|
|
this.updateProgress()
|
|
|
|
|
},
|
|
|
|
|
onend: () => {
|
|
|
|
|
console.log('audio end')
|
|
|
|
|
this.isPlaying = false;
|
|
|
|
|
clearTimeout(this.audioTimer)
|
|
|
|
|
this.audioProgress = 0
|
2022-07-06 09:59:22 +01:00
|
|
|
|
2022-06-29 11:42:31 +01:00
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
this.audioPlay.play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
togglePlayer(pause) {
|
|
|
|
|
this.isPlaying = !pause;
|
2022-07-06 09:59:22 +01:00
|
|
|
if (pause) {
|
2022-06-29 11:42:31 +01:00
|
|
|
this.audioPlay.pause();
|
|
|
|
|
} else {
|
|
|
|
|
this.audioPlay.play();
|
|
|
|
|
}
|
2022-07-06 09:59:22 +01:00
|
|
|
}
|
2022-06-29 11:42:31 +01:00
|
|
|
|
|
|
|
|
seek() {
|
|
|
|
|
let newValue = +this.range.value;
|
|
|
|
|
let duration = this.audioPlay.duration();
|
|
|
|
|
this.audioPlay.seek(duration * (newValue / 100));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateProgress() {
|
|
|
|
|
let seek = this.audioPlay.seek();
|
|
|
|
|
this.audioProgress = (seek / this.audioPlay.duration()) * 100 || 0;
|
|
|
|
|
console.log(this.audioDuration)
|
|
|
|
|
this.audioTimer = setTimeout(() => {
|
|
|
|
|
this.updateProgress()
|
2022-07-06 09:59:22 +01:00
|
|
|
}, 1000)
|
2022-06-29 11:42:31 +01:00
|
|
|
}
|
|
|
|
|
|
2022-07-06 17:50:42 +01:00
|
|
|
async getRoomInfo() {
|
|
|
|
|
this.wsChatMethodsService.getGroupRoom(this.roomId).loadHistory({});
|
|
|
|
|
let room = await this.chatService.getRoomInfo(this.roomId).toPromise();
|
|
|
|
|
// console.log('ROOM',room)
|
|
|
|
|
this.room = room['room'];
|
|
|
|
|
if (this.room.name) {
|
|
|
|
|
this.roomName = this.room.name.split('-').join(' ');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(SessionStore.user.ChatData.data.userId == this.room.u._id){
|
|
|
|
|
this.isAdmin = true
|
|
|
|
|
} else {
|
|
|
|
|
this.isAdmin = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.room.customFields.countDownDate) {
|
|
|
|
|
this.roomCountDownDate = this.room.customFields.countDownDate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-29 11:42:31 +01:00
|
|
|
|
2021-03-04 18:49:50 +01:00
|
|
|
}
|
2021-03-12 11:56:54 +01:00
|
|
|
|
2021-11-22 13:53:37 +01:00
|
|
|
|
|
|
|
|
|