From 7be567d258d2e1524d4e440dc8fc336d13baa2c8 Mon Sep 17 00:00:00 2001 From: "tiago.kayaya" Date: Wed, 9 Feb 2022 11:34:21 +0100 Subject: [PATCH 1/2] save --- src/app/pages/chat/chat.page.html | 6 +++--- src/app/pages/inactivity/inactivity.page.ts | 6 ++---- src/app/services/auth.service.ts | 2 +- src/app/services/chat/ws-chat.service.ts | 2 +- src/app/shared/chat/messages/messages.page.html | 6 +++--- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/app/pages/chat/chat.page.html b/src/app/pages/chat/chat.page.html index 05200b433..0c26044cf 100644 --- a/src/app/pages/chat/chat.page.html +++ b/src/app/pages/chat/chat.page.html @@ -69,10 +69,10 @@
{{room.lastMessage.msg}} - A escrever ... - + A escrever... +
diff --git a/src/app/pages/inactivity/inactivity.page.ts b/src/app/pages/inactivity/inactivity.page.ts index 4a60452d7..00dd852b0 100644 --- a/src/app/pages/inactivity/inactivity.page.ts +++ b/src/app/pages/inactivity/inactivity.page.ts @@ -201,10 +201,8 @@ export class InactivityPage implements OnInit { storePin() { - const code = this.code.join('') - - SessionStore.setPin(code) - + const code = this.code.join(''); + SessionStore.setPin(code); this.router.navigate(['/home/events']); } diff --git a/src/app/services/auth.service.ts b/src/app/services/auth.service.ts index 5698453cd..fb9659c43 100644 --- a/src/app/services/auth.service.ts +++ b/src/app/services/auth.service.ts @@ -126,7 +126,7 @@ export class AuthService { this.loginToChatWs() - console.log('Login to Rocket chat OK'); + console.log('Login to Rocket chat OK', responseChat); this.ValidatedUserChat = responseChat; localStorage.setItem('userChat', JSON.stringify(responseChat)); this.storageService.store(AuthConnstants.AUTH, responseChat); diff --git a/src/app/services/chat/ws-chat.service.ts b/src/app/services/chat/ws-chat.service.ts index d4904bf0c..ef226c27c 100644 --- a/src/app/services/chat/ws-chat.service.ts +++ b/src/app/services/chat/ws-chat.service.ts @@ -671,7 +671,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) { if (this.ws.connected == false || loginRequired == true && this.isLogin == false) { // save data to send when back online // console.log('save msgQueue this.ws.connected == false || loginRequired == true && this.isLogin == false',this.ws.connected, loginRequired, this.isLogin) - console.log('save msgQueue', requestId, message) + //console.log('save msgQueue', requestId, message) this.wsMsgQueue[requestId] = {message, requestId, loginRequired} } else { diff --git a/src/app/shared/chat/messages/messages.page.html b/src/app/shared/chat/messages/messages.page.html index 16c0804e9..52066f057 100644 --- a/src/app/shared/chat/messages/messages.page.html +++ b/src/app/shared/chat/messages/messages.page.html @@ -48,11 +48,11 @@
- {{msg.u.name}} {{msg.offline}} + {{msg.u.name}} {{showDateDuration(msg._updatedAt)}}
- {{msg.msg}} {{msg.offline}} + {{msg.msg}} {{last ? scrollToBottom() : ''}}
@@ -73,7 +73,7 @@
-
+
image
From ae1ddbddb20fcca7f8e9ae70d2d1a41efc4cece5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eudes=20In=C3=A1cio?= Date: Wed, 9 Feb 2022 13:59:41 +0100 Subject: [PATCH 2/2] bug on tablet chat add image --- src/app/shared/chat/messages/messages.page.ts | 81 ++++++++++++++++++- 1 file changed, 78 insertions(+), 3 deletions(-) diff --git a/src/app/shared/chat/messages/messages.page.ts b/src/app/shared/chat/messages/messages.page.ts index 29e55cbb0..f80738448 100644 --- a/src/app/shared/chat/messages/messages.page.ts +++ b/src/app/shared/chat/messages/messages.page.ts @@ -32,6 +32,7 @@ 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'; +import { Camera, CameraResultType, CameraSource } from '@capacitor/camera'; const IMAGE_DIR = 'stored-images'; @Component({ @@ -442,6 +443,41 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy } + 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) + + const response = await fetch('data:image/jpeg;base64,'+ file.base64String!); + const blob = await response.blob(); + + const formData = new FormData(); + formData.append("blobFile", blob); + + this.wsChatMethodsService.getDmRoom(roomId).send({ + file: { + "type": "application/img", + "guid": '', + "image_url": 'data:image/jpeg;base64,' +file.base64String + }, + temporaryData: formData, + attachments: [{ + "title": file.path , + "image_url": 'data:image/jpeg;base64,' +file.base64String, + "text": "description", + "title_link_download": false, + }] + }) + + } async takePicture() { const roomId = this.roomId @@ -451,6 +487,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy const lastphoto: any = await this.fileService.loadFiles(); const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto); const base64 = await fetch(capturedImage); + console.log('imsge take picture', image) const blob = await base64.blob(); const formData = new FormData(); formData.append("blobFile", blob); @@ -475,7 +512,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy } async addImage() { - this.addFileToChat(['image/apng', 'image/jpeg', 'image/png']) + this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png']) } async addFile() { @@ -524,14 +561,52 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy }); } + async addFileToChatMobile(types: typeof FileType[] ) { + 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) + + const response = await fetch('data:image/jpeg;base64,'+ file.base64String!); + const blob = await response.blob(); + + const formData = new FormData(); + formData.append("blobFile", blob); + + this.wsChatMethodsService.getDmRoom(roomId).send({ + file: { + "type": "application/img", + "guid": '', + "image_url": 'data:image/jpeg;base64,' +file.base64String + }, + temporaryData: formData, + attachments: [{ + "title": file.path , + "image_url": 'data:image/jpeg;base64,' +file.base64String, + "text": "description", + "title_link_download": false, + }] + }) + + } + async addFileToChat(types: typeof FileType[] ) { + const roomId = this.roomId const file: any = await this.fileService.getFileFromDevice(types); + console.log('Add image', file) const imageData = await this.fileToBase64Service.convert(file) - + const formData = new FormData(); formData.append("blobFile", file); @@ -620,7 +695,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy } else if (res['data'] == 'take-picture') { - this.takePicture() + this.takePictureMobile() } else if (res['data'] == 'add-picture') {