mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
save merge
This commit is contained in:
@@ -69,10 +69,10 @@
|
|||||||
<div *ngIf="room.lastMessage" class="item-description" [class.item-description-active]="room.id == idSelected">
|
<div *ngIf="room.lastMessage" class="item-description" [class.item-description-active]="room.id == idSelected">
|
||||||
|
|
||||||
<ion-label *ngIf="room.lastMessage && room.otherUserType == false">{{room.lastMessage.msg}}</ion-label>
|
<ion-label *ngIf="room.lastMessage && room.otherUserType == false">{{room.lastMessage.msg}}</ion-label>
|
||||||
<ion-label *ngIf="room.otherUserType == true">A escrever ...</ion-label>
|
<ion-label *ngIf="room.otherUserType == true">A escrever...</ion-label>
|
||||||
<ion-label *ngIf="room.lastMessage.file">
|
<!-- <ion-label *ngIf="room.lastMessage.file">
|
||||||
<fa-icon *ngIf="room.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
|
<fa-icon *ngIf="room.lastMessage.file.type != 'application/meeting'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
|
||||||
</ion-label>
|
</ion-label> -->
|
||||||
|
|
||||||
<div *ngIf="room.lastMessage.file">
|
<div *ngIf="room.lastMessage.file">
|
||||||
<fa-icon *ngIf="room.lastMessage.file.type != 'application/meeting' && room.lastMessage.file.type != 'application/img'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
|
<fa-icon *ngIf="room.lastMessage.file.type != 'application/meeting' && room.lastMessage.file.type != 'application/img'" icon="file-alt" class="file-icon" [class.set-active-item-font-to-white]="room.id == idSelected"></fa-icon>
|
||||||
|
|||||||
@@ -628,8 +628,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||||
file: {
|
file: {
|
||||||
"type": "application/img",
|
"type": "application/img",
|
||||||
"guid": '',
|
"guid": ''
|
||||||
"image_url": 'data:image/jpeg;base64,' +file.base64String
|
|
||||||
},
|
},
|
||||||
temporaryData: formData,
|
temporaryData: formData,
|
||||||
attachments: [{
|
attachments: [{
|
||||||
|
|||||||
@@ -201,10 +201,8 @@ export class InactivityPage implements OnInit {
|
|||||||
|
|
||||||
storePin() {
|
storePin() {
|
||||||
|
|
||||||
const code = this.code.join('')
|
const code = this.code.join('');
|
||||||
|
SessionStore.setPin(code);
|
||||||
SessionStore.setPin(code)
|
|
||||||
|
|
||||||
this.router.navigate(['/home/events']);
|
this.router.navigate(['/home/events']);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ export class AuthService {
|
|||||||
|
|
||||||
this.loginToChatWs()
|
this.loginToChatWs()
|
||||||
|
|
||||||
console.log('Login to Rocket chat OK');
|
console.log('Login to Rocket chat OK', responseChat);
|
||||||
this.ValidatedUserChat = responseChat;
|
this.ValidatedUserChat = responseChat;
|
||||||
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
localStorage.setItem('userChat', JSON.stringify(responseChat));
|
||||||
this.storageService.store(AuthConnstants.AUTH, responseChat);
|
this.storageService.store(AuthConnstants.AUTH, responseChat);
|
||||||
|
|||||||
@@ -91,33 +91,39 @@ export class RoomService {
|
|||||||
this.id,
|
this.id,
|
||||||
"stream-room-messages",
|
"stream-room-messages",
|
||||||
(ChatMessage) => {
|
(ChatMessage) => {
|
||||||
ChatMessage = ChatMessage.fields.args[0]
|
|
||||||
|
|
||||||
ChatMessage = this.fix_updatedAt(ChatMessage)
|
setTimeout(()=>{
|
||||||
// console.log('recivemessage', ChatMessage)
|
ChatMessage = ChatMessage.fields.args[0]
|
||||||
|
|
||||||
const messageIsFound = this.messages.find((message) => {
|
ChatMessage = this.fix_updatedAt(ChatMessage)
|
||||||
message._id == ChatMessage._id
|
// console.log('recivemessage', ChatMessage)
|
||||||
})
|
|
||||||
|
|
||||||
if(!messageIsFound) {
|
|
||||||
const message = this.prepareMessage(ChatMessage)
|
|
||||||
|
|
||||||
this.lastMessage = message
|
|
||||||
if (message.t == 'r') { this.name = message.msg }
|
|
||||||
this.calDateDuration(ChatMessage._updatedAt)
|
|
||||||
|
|
||||||
setTimeout(() => {
|
const messageIsFound = this.messages.find((message) => {
|
||||||
this.scrollDown()
|
return message._id == ChatMessage._id
|
||||||
}, 100)
|
})
|
||||||
|
|
||||||
this.NativeNotificationService.sendNotificationChat({
|
if(!messageIsFound) {
|
||||||
message: message.msg,
|
console.log('messageIsFound', messageIsFound)
|
||||||
title: this.name
|
const message = this.prepareMessage(ChatMessage)
|
||||||
});
|
|
||||||
|
this.lastMessage = message
|
||||||
this.addMessageDB(ChatMessage)
|
if (message.t == 'r') { this.name = message.msg }
|
||||||
}
|
this.calDateDuration(ChatMessage._updatedAt)
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.scrollDown()
|
||||||
|
}, 100)
|
||||||
|
|
||||||
|
this.NativeNotificationService.sendNotificationChat({
|
||||||
|
message: message.msg,
|
||||||
|
title: this.name
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addMessageDB(ChatMessage)
|
||||||
|
} else {
|
||||||
|
console.log('have')
|
||||||
|
}
|
||||||
|
}, 150)
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -666,7 +666,7 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
|
|||||||
|
|
||||||
if (this.ws.connected == false || loginRequired == true && this.isLogin == false) { // save data to send when back online
|
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 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}
|
this.wsMsgQueue[requestId] = {message, requestId, loginRequired}
|
||||||
} else {
|
} else {
|
||||||
@@ -679,8 +679,6 @@ updateRoomEventss(roomId, collection:string, funx: Function, ) {
|
|||||||
onmessage: async (event: any)=> {
|
onmessage: async (event: any)=> {
|
||||||
const data = JSON.parse(event.data)
|
const data = JSON.parse(event.data)
|
||||||
|
|
||||||
console.log('data', data)
|
|
||||||
|
|
||||||
for (const [key, value] of Object.entries(this.wsCallbacks)) {
|
for (const [key, value] of Object.entries(this.wsCallbacks)) {
|
||||||
if(value.type== 'Onmessage') {
|
if(value.type== 'Onmessage') {
|
||||||
const dontRepeat = await value.funx(data)
|
const dontRepeat = await value.funx(data)
|
||||||
|
|||||||
@@ -48,11 +48,11 @@
|
|||||||
</mat-menu>
|
</mat-menu>
|
||||||
</div>
|
</div>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<ion-label>{{msg.u.name}} {{msg.offline}} {{ msg.sendAttempt }} {{ msg.uploadingFile }} errorUploadingAttachment:{{ msg.errorUploadingAttachment}}</ion-label>
|
<ion-label>{{msg.u.name}}</ion-label>
|
||||||
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
<span class="time">{{showDateDuration(msg._updatedAt)}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<ion-label>{{msg.msg}} {{msg.offline}}</ion-label>
|
<ion-label>{{msg.msg}}</ion-label>
|
||||||
{{last ? scrollToBottom() : ''}}
|
{{last ? scrollToBottom() : ''}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -67,7 +67,7 @@
|
|||||||
</mat-menu>
|
</mat-menu>
|
||||||
</div>
|
</div>
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<ion-label>{{msg.u.name}} {{msg.offline}} {{ msg.sendAttempt }} {{ msg.uploadingFile }} errorUploadingAttachment:{{ msg.errorUploadingAttachment}}</ion-label>
|
<ion-label>{{msg.u.name}} </ion-label>
|
||||||
<span class="time">{{showDateDuration(msg.duration)}}</span>
|
<span class="time">{{showDateDuration(msg.duration)}}</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import { FileType } from 'src/app/models/fileType';
|
|||||||
import { SearchPage } from 'src/app/pages/search/search.page';
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
||||||
import { ProcessesService } from 'src/app/services/processes.service';
|
import { ProcessesService } from 'src/app/services/processes.service';
|
||||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||||
|
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||||
|
|
||||||
const IMAGE_DIR = 'stored-images';
|
const IMAGE_DIR = 'stored-images';
|
||||||
@Component({
|
@Component({
|
||||||
@@ -441,6 +442,40 @@ 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": '',
|
||||||
|
},
|
||||||
|
temporaryData: formData,
|
||||||
|
attachments: [{
|
||||||
|
"title": file.path ,
|
||||||
|
"image_url": 'data:image/jpeg;base64,' +file.base64String,
|
||||||
|
"text": "description",
|
||||||
|
"title_link_download": false,
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
async takePicture() {
|
async takePicture() {
|
||||||
const roomId = this.roomId
|
const roomId = this.roomId
|
||||||
@@ -450,6 +485,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
const lastphoto: any = await this.fileService.loadFiles();
|
const lastphoto: any = await this.fileService.loadFiles();
|
||||||
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
|
const { capturedImage, capturedImageTitle} = await this.fileService.loadFileData(lastphoto);
|
||||||
const base64 = await fetch(capturedImage);
|
const base64 = await fetch(capturedImage);
|
||||||
|
console.log('imsge take picture', image)
|
||||||
const blob = await base64.blob();
|
const blob = await base64.blob();
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("blobFile", blob);
|
formData.append("blobFile", blob);
|
||||||
@@ -473,7 +509,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addImage() {
|
async addImage() {
|
||||||
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
|
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
|
||||||
}
|
}
|
||||||
|
|
||||||
async addFile() {
|
async addFile() {
|
||||||
@@ -522,14 +558,51 @@ 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": ''
|
||||||
|
},
|
||||||
|
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[] ) {
|
async addFileToChat(types: typeof FileType[] ) {
|
||||||
|
|
||||||
const roomId = this.roomId
|
const roomId = this.roomId
|
||||||
|
|
||||||
const file: any = await this.fileService.getFileFromDevice(types);
|
const file: any = await this.fileService.getFileFromDevice(types);
|
||||||
|
console.log('Add image', file)
|
||||||
const imageData = await this.fileToBase64Service.convert(file)
|
const imageData = await this.fileToBase64Service.convert(file)
|
||||||
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("blobFile", file);
|
formData.append("blobFile", file);
|
||||||
|
|
||||||
@@ -617,7 +690,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
else if (res['data'] == 'take-picture') {
|
else if (res['data'] == 'take-picture') {
|
||||||
|
|
||||||
this.takePicture()
|
this.takePictureMobile()
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (res['data'] == 'add-picture') {
|
else if (res['data'] == 'add-picture') {
|
||||||
|
|||||||
Reference in New Issue
Block a user