This commit is contained in:
Peter Maquiran
2022-02-07 13:41:27 +01:00
17 changed files with 1120 additions and 1107 deletions
@@ -97,7 +97,7 @@
<ion-label *ngIf="msg.file">
<span *ngIf="file.description">{{file.description}}</span>
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"></span>
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
<span *ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
</ion-label>
</div>
</div>
@@ -26,6 +26,12 @@ import { HttpEventType } from '@angular/common/http';
import { Storage } from '@ionic/storage';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service';
import { MessageService } from 'src/app/services/chat/message.service';
import { AttachmentsService } from 'src/app/services/attachments.service';
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';
/*
import * as pdfjsLib from 'pdfjs-dist';
@@ -96,6 +102,10 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
public ThemeService: ThemeService,
private changeDetectorRef: ChangeDetectorRef,
private storage: Storage,
private AttachmentsService: AttachmentsService,
private CameraService: CameraService,
private toastService: ToastService,
) {
console.log('OnCONSTRUCTOR');
@@ -129,7 +139,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
setTimeout(() => {
this.getRoomInfo();
}, 1000);
this.setStatus('online');
this.getChatMembers();
//this.getMessageDB();
@@ -216,7 +225,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
ngOnDestroy() {
this.setStatus('away');
window.removeEventListener('scroll', this.scrollChangeCallback, true);
}
@@ -297,17 +305,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}
}
loadGroupMessages(roomId) {
this.showLoader = true;
this.chatService.getPrivateGroupMessages(this.roomId).subscribe(res => {
console.log(res);
let msgOnly = res['messages'].filter(data => data.t != 'au');
this.showLoader = false;
});
}
sendMessage() {
this.wsChatMethodsService.getGroupRoom(this.roomId).send()
this.wsChatMethodsService.getGroupRoom(this.roomId).send({})
}
deleteMessage(msgId: string, room:any) {
@@ -388,10 +387,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
else {
this.roomName = res.data.name.split('-').join(' ');
console.log(this.roomName);
//this.getRoomInfo();
this.loadGroupMessages(this.roomId);
//this.modalController.dismiss();
};
});
@@ -423,7 +418,6 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
popover.onDidDismiss().then(res => {
console.log(res);
if (res.data) {
this.loadGroupMessages(this.roomId);
//this.getRoomInfo();
//this.modalController.dismiss();
};
@@ -464,89 +458,9 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
modal.onDidDismiss().then(() => {
//this.getRoomInfo();
this.loadGroupMessages(this.roomId)
});
}
loadPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
console.log(file);
const imageData = await this.fileToBase64Service.convert(file)
this.capturedImage = imageData;
this.capturedImageTitle = file.name;
let body = {
"message":
{
"rid": this.roomId,
"msg": "",
"attachments": [{
//"title": this.capturedImageTitle ,
//"text": "description",
"title_link_download": false,
"image_url": this.capturedImage,
}]
}
}
this.chatService.sendMessage(body).subscribe(res => {
console.log(res);
}, (error) => {
});
//console.log(this.capturedImage)
};
}
loadDocument() {
const input = this.fileLoaderService.createInput({
accept: ['.doc', '.docx', '.pdf']
})
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
console.log(file);
const imageData = await this.fileToBase64Service.convert(file)
this.capturedImage = imageData;
this.capturedImageTitle = file.name;
let body = {
"message":
{
"rid": this.roomId,
"msg": "",
"attachments": [{
"title": this.capturedImageTitle,
"text": "",
"title_link": this.capturedImage,
"title_link_download": true,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
"message_link": this.capturedImage,
}],
"file": {
"name": this.capturedImageTitle,
"type": "application/pdf",
}
}
}
this.chatService.sendMessage(body).subscribe(res => {
//console.log(res);
}, (error) => {
});
//console.log(this.capturedImage)
};
}
async addDocGestaoDocumental() {
const modal = await this.modalController.create({
@@ -563,36 +477,8 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
if (res) {
const data = res.data;
this.documents.push(data.selected);
console.log(res.data.selected);
console.log(res.data.selected.Id);
console.log(res.data.selected.ApplicationType);
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer", "webTRIX.Viewer.Branch1");
console.log(url_no_options);
//console.log('Oie');
let body = {
"message":
{
"rid": this.roomId,
"msg": "",
"attachments": [{
"title": res.data.selected.Assunto,
"text": res.data.selected.DocTypeDesc,
"title_link": url_no_options,
"title_link_download": true,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
"message_link": url_no_options,
}]
}
}
this.chatService.sendMessage(body).subscribe(res => {
console.log(res);
}, (error) => {
});
this.addFileWebtrix()
}
});
}
@@ -656,18 +542,183 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
await modal.present();
}
takePicture() {
this.fileService.addCameraPictureToChat(this.roomId);
async takePicture() {
const roomId = this.roomId
const image = await this.CameraService.takePicture();
await this.fileService.saveImage(image)
const lastphoto: any = await this.fileService.loadFiles();
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": capturedImage
},
attachments: [{
"title": capturedImageTitle ,
"text": "description",
"title_link_download": false,
}]
})
const base64 = await fetch(capturedImage);
const blob = await base64.blob();
const formData = new FormData();
formData.append("blobFile", blob);
console.log('ALL IMAGE', formData)
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
updateMessage({
file: {
type: "application/img",
guid: guid.path,
image_url: capturedImage
}
})
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
if (event.type === HttpEventType.DownloadProgress) {
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
//console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) {
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('add picture to chat', capturedImage);
await this.storage.set(guid.path, capturedImage).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
});
}
});
}
addImage() {
this.fileService.addPictureToChat(this.roomId);
async addImage() {
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
}
addFile() {
this.fileService.addDocumentToChat(this.roomId);
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
}
addFileWebtrix() {
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
async addFileWebtrix() {
const roomId = this.roomId
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();
modal.onDidDismiss().then(async res=>{
const data = res.data;
if(data.selected) {
const loader = this.toastService.loading();
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
file:{
"name": res.data.selected.Assunto,
"type": "application/webtrix",
"ApplicationId": res.data.selected.ApplicationType,
"DocId": res.data.selected.Id,
"Assunto": res.data.selected.Assunto,
},
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,
"type": "webtrix"
}]
})
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
console.log(url_no_options);
updateMessage({
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,
"type": "webtrix",
"text": res.data.selected.DocTypeDesc,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
}]
})
loader.remove();
}
});
}
async addFileToChat(types: typeof FileType[] ) {
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
const imageData = await this.fileToBase64Service.convert(file)
const formData = new FormData();
formData.append("blobFile", file);
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": imageData
},
attachments: [{
"title": file.name ,
"text": "description",
"title_link_download": false,
}]
})
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
updateMessage({
file: {
type: "application/img",
guid: guid.path,
image_url: imageData
}
})
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
if (event.type === HttpEventType.DownloadProgress) {
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
//console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) {
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('add picture to chat',fileImage);
await this.storage.set(guid.path, fileImage).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
});
}
});
}
bookMeeting() {
let data = {
roomId: this.roomId,
@@ -693,7 +744,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
return this.animationController.create()
.addElement(baseEl)
.easing('ease-out')
.duration(5000)
.duration(500)
.addAnimation([backdropAnimation, wrapperAnimation]);
}
@@ -711,10 +762,11 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
members: this.members,
}
});
await modal.present();
modal.onDidDismiss().then((res) => {
//console.log(res['data']);
modal.onDidDismiss().then( async (res) => {
console.log(res['data']);
const roomId = this.roomId;
if (res['data'] == 'meeting') {
//this.closeAllDesktopComponents.emit();
let data = {
@@ -724,73 +776,36 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
this.openNewEventPage.emit(data);
}
else if (res['data'] == 'take-picture') {
this.fileService.addCameraPictureToChat(this.roomId);
//this.loadPicture();
this.takePicture()
}
else if (res['data'] == 'add-picture') {
this.fileService.addPictureToChat(this.roomId);
//this.loadPicture();
this.addImage()
}
else if (res['data'] == 'add-document') {
this.loadDocument();
this.addFile()
}
else if (res['data'] == 'documentoGestaoDocumental') {
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
//this.addDocGestaoDocumental();
this.addFileWebtrix()
this.showLoader = false;
}
this.loadGroupMessages(this.roomId);
});
}
sliderOpts = {
zoom: false,
slidesPerView: 1.5,
spaceBetween: 20,
centeredSlides: true
};
zoomActive = false;
zoomScale = 1;
sliderZoomOpts = {
allowSlidePrev: false,
allowSlideNext: false,
zoom: {
maxRatio: 5
},
on: {
zoomChange: (scale, imageEl, slideEl) => {
this.zoomActive = true;
this.zoomScale = scale / 5;
this.changeDetectorRef.detectChanges();
}
}
}
async touchEnd(zoomslides: IonSlides, card) {
// Zoom back to normal
const slider = await zoomslides.getSwiper();
const zoom = slider.zoom;
zoom.out();
// Card back to normal
card.el.style['z-index'] = 9;
this.zoomActive = false;
this.changeDetectorRef.detectChanges();
}
touchStart(card) {
// Make card appear above backdrop
card.el.style['z-index'] = 11;
}
downloadFileMsg(msg: MessageService) {
console.log('FILE TYPE', msg.file.type)
this.downloadFile = "";
if (msg.file.type == "application/img") {
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
console.log('FILE TYPE 22', msg.file.guid)
var name = msg.file.guid;
@@ -97,7 +97,7 @@
<span *ngIf="file.description">{{file.description}}</span>
<span *ngIf="file.description && msg.file.type != 'application/webtrix'"></span>
<span
*ngIf="msg.file.type != 'application/webtrix'">{{msg.file.type.replace('application/','').toUpperCase()}}</span>
*ngIf="msg.file.type != 'application/webtrix'">{{msg.displayType}}</span>
</ion-label>
</div>
</div>
+216 -116
View File
@@ -13,10 +13,9 @@ import { ChatMessageStore } from 'src/app/store/chat/chat-message.service';
import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
import { TimeService } from 'src/app/services/functions/time.service';
import { FileService } from 'src/app/services/functions/file.service';
import { HttpClient, HttpEventType, HttpHeaders } from '@angular/common/http';
import { HttpClient, HttpEventType } from '@angular/common/http';
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
import { ThemeService } from 'src/app/services/theme.service'
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
import { SqliteService } from 'src/app/services/sqlite.service';
import { StorageService } from 'src/app/services/storage.service';
@@ -26,7 +25,13 @@ import { Storage } from '@ionic/storage';
import { WsChatMethodsService } from 'src/app/services/chat/ws-chat-methods.service'
import { WsChatService } from 'src/app/services/chat/ws-chat.service'
import { MessageService } from 'src/app/services/chat/message.service';
import { element } from 'protractor';
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';
import { ProcessesService } from 'src/app/services/processes.service';
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
const IMAGE_DIR = 'stored-images';
@Component({
@@ -92,7 +97,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
private router: Router,
private storage: Storage,
public wsChatMethodsService: WsChatMethodsService,
public WsChatService: WsChatService
public WsChatService: WsChatService,
private AttachmentsService: AttachmentsService,
private CameraService: CameraService,
private processesService: ProcessesService,
private fileToBase64Service: FileToBase64Service,
) {
this.loggedUser = authService.ValidatedUserChat['data'];
@@ -104,6 +114,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
this.wsChatMethodsService.openRoom(this.roomId)
this.wsChatMethodsService.getDmRoom(this.roomId).uploadAttachment = async (formData) => {
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
}
setTimeout(() => {
this.scrollToBottomClicked()
}, 150)
@@ -113,7 +128,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
ngOnInit() {
this.scrollToBottom();
this.setStatus('online');
this.getChatMembers();
}
@@ -134,15 +149,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
});
}
setStatus(status: string) {
let body = {
message: '',
status: status,
}
this.chatService.setUserStatus(body).subscribe(res => {
console.log(res);
})
}
notImplemented() {
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
@@ -150,7 +156,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
load = () => {
this.checktimeOut = true;
this.serverLongPull();
this.getChatMembers();
}
@@ -205,7 +210,6 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
ngOnDestroy() {
this.checktimeOut = false;
this.setStatus('away');
window.removeEventListener('scroll', this.scrollChangeCallback, true);
}
@@ -242,7 +246,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
sendMessage() {
this.wsChatMethodsService.getDmRoom(this.roomId).send()
this.wsChatMethodsService.getDmRoom(this.roomId).send({})
}
deleteMessage(msgId: string, room:any) {
@@ -251,7 +255,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async viewDocument(msg: any, url?: string) {
if (msg.file.type == "application/img") {
let response: any = await this.fileService.getFile(msg.file.guid).toPromise();
let response: any = await this.AttachmentsService.getFile(msg.file.guid).toPromise();
console.log(response);
alert(response);
@@ -267,7 +271,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
//fullUrl = "http://www.africau.edu/images/default/sample.pdf";
this.frameUrl = fullUrl;
//this.fileService.viewDocumentByUrl(fullUrl);
this.chatService.getDocumentDetails(fullUrl);
}
}
@@ -439,22 +443,183 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
takePicture() {
async takePicture() {
const roomId = this.roomId
this.fileService.addCameraPictureToChat(roomId);
const image = await this.CameraService.takePicture();
await this.fileService.saveImage(image)
const lastphoto: any = await this.fileService.loadFiles();
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": capturedImage
},
attachments: [{
"title": capturedImageTitle ,
"text": "description",
"title_link_download": false,
}]
})
const base64 = await fetch(capturedImage);
const blob = await base64.blob();
const formData = new FormData();
formData.append("blobFile", blob);
console.log('ALL IMAGE', formData)
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
updateMessage({
file: {
type: "application/img",
guid: guid.path,
image_url: capturedImage
}
})
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
if (event.type === HttpEventType.DownloadProgress) {
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
//console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) {
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('add picture to chat', capturedImage);
await this.storage.set(guid.path, capturedImage).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
});
}
});
}
addImage() {
const roomId = this.roomId;
this.fileService.addPictureToChat(roomId);
//this.fileService.loadPicture();
//this.fileService.addPictureToChat(roomId);
async addImage() {
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
}
addFile() {
this.fileService.addDocumentToChat(this.roomId);
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
}
addFileWebtrix() {
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
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();
modal.onDidDismiss().then(async res=>{
const data = res.data;
const roomId = this.roomId
if(data.selected) {
const loader = this.toastService.loading();
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
file:{
"name": res.data.selected.Assunto,
"type": "application/webtrix",
"ApplicationId": res.data.selected.ApplicationType,
"DocId": res.data.selected.Id,
"Assunto": res.data.selected.Assunto,
},
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,
"type": "webtrix"
}]
})
let url = await this.processesService.GetDocumentUrl(res.data.selected.Id, res.data.selected.ApplicationType).toPromise();
let url_no_options: string = url.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
console.log(url_no_options);
updateMessage({
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,
"type": "webtrix",
"text": res.data.selected.DocTypeDesc,
"thumb_url": "https://static.ichimura.ed.jp/uploads/2017/10/pdf-icon.png",
}]
})
loader.remove();
}
});
}
async addFileToChat(types: typeof FileType[] ) {
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
const imageData = await this.fileToBase64Service.convert(file)
const formData = new FormData();
formData.append("blobFile", file);
const { message, updateMessage} = this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
"guid": '',
"image_url": imageData
},
attachments: [{
"title": file.name ,
"text": "description",
"title_link_download": false,
}]
})
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
updateMessage({
file: {
type: "application/img",
guid: guid.path,
image_url: imageData
}
})
this.AttachmentsService.downloadFile(guid.path).subscribe(async (event) => {
if (event.type === HttpEventType.DownloadProgress) {
//this.downloadProgess = Math.round((100 * event.loaded) / event.total);
//console.log('FILE TYPE 33', msg.file.type)
} else if (event.type === HttpEventType.Response) {
var fileImage = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
console.log('add picture to chat',fileImage);
await this.storage.set(guid.path, fileImage).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
});
}
});
}
bookMeeting() {
let data = {
roomId: this.roomId,
@@ -464,7 +629,13 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
chatsend() {
}
async _openChatOptions() {
const roomId = this.roomId;
const enterAnimation = (baseEl: any) => {
const backdropAnimation = this.animationController.create()
@@ -500,8 +671,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
});
await modal.present();
modal.onDidDismiss().then((res) => {
modal.onDidDismiss().then( async (res) => {
console.log(res['data']);
if (res['data'] == 'meeting') {
//this.closeAllDesktopComponents.emit();
let data = {
@@ -511,111 +684,38 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
this.openNewEventPage.emit(data);
}
else if (res['data'] == 'take-picture') {
this.fileService.addCameraPictureToChat(this.roomId);
//this.loadPicture();
this.takePicture()
}
else if (res['data'] == 'add-picture') {
this.fileService.addPictureToChat(this.roomId);
//this.loadPicture();
this.addImage()
}
else if (res['data'] == 'add-document') {
this.fileService.addDocumentToChat(this.roomId);
//this.loadDocument();
this.addFile()
}
else if (res['data'] == 'documentoGestaoDocumental') {
this.fileService.addDocGestaoDocumentalToChat(this.roomId);
this.addFileWebtrix()
this.showLoader = false;
//this.addDocGestaoDocumental();
}
});
}
async serverLongPull() {
const roomId = this.roomId;
this.chatService.getRoomMessages(this.roomId).subscribe(async res => {
console.log('serverLongPull', res['success']);
if (res['success'] == true) {
// Show Error
//showMessage(response.statusText);
/* this.messages = res['messages'].reverse();
this.chatMessageStore.add(roomId, this.messages) */
console.log('MSG FROM ROCKET ', res['messages'].reverse())
/* this.transformData(res['messages'].reverse());
this.getMessageDB(); */
//console.log(this.messages);
// Reconnect in one second
if (this.route.url != "/home/chat") {
console.log("Timer message stop")
}
else {
if (document.querySelector('app-messages')) {
await new Promise(resolve => setTimeout(resolve, 5000));
// await this.serverLongPull();
this.getDirectMessages.emit();
console.log('Timer message running')
}
}
}
}, (error) => {
console.log(error);
});
}
sliderOpts = {
zoom: false,
slidesPerView: 1.5,
spaceBetween: 20,
centeredSlides: true
};
zoomActive = false;
zoomScale = 1;
sliderZoomOpts = {
allowSlidePrev: false,
allowSlideNext: false,
zoom: {
maxRatio: 5
},
on: {
zoomChange: (scale, imageEl, slideEl) => {
this.zoomActive = true;
this.zoomScale = scale / 5;
this.changeDetectorRef.detectChanges();
}
}
}
async touchEnd(zoomslides: IonSlides, card) {
// Zoom back to normal
const slider = await zoomslides.getSwiper();
const zoom = slider.zoom;
zoom.out();
// Card back to normal
card.el.style['z-index'] = 9;
this.zoomActive = false;
this.changeDetectorRef.detectChanges();
}
touchStart(card) {
// Make card appear above backdrop
card.el.style['z-index'] = 11;
}
downloadFileMsg(msg: MessageService) {
console.log('FILE TYPE', msg.file.type)
this.downloadFile = "";
if (msg.file.type == "application/img") {
this.fileService.downloadFile(msg.file.guid).subscribe(async (event) => {
this.AttachmentsService.downloadFile(msg.file.guid).subscribe(async (event) => {
console.log('FILE TYPE 22', msg.file.guid)
var name = msg.file.guid;