fix add pic and attach pic in actions

This commit is contained in:
tiago.kayaya
2022-02-11 15:08:27 +01:00
parent 79bbb9b03d
commit 500349ab97
7 changed files with 39 additions and 78 deletions
@@ -820,7 +820,7 @@ downloadFileMsg(msg) {
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -828,7 +828,7 @@ async openPreview(msg) {
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
+10 -10
View File
@@ -108,7 +108,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
private sqlservice: SqliteService,
public wsChatMethodsService: WsChatMethodsService,
private AttachmentsService: AttachmentsService,
private CameraService: CameraService,
private processesService: ProcessesService,
private storage: Storage,
@@ -127,7 +127,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
this.wsChatMethodsService.getDmRoom(this.roomId).loadHistory({})
this.wsChatMethodsService.getDmRoom(this.roomId).scrollDown = this.scrollToBottomClicked
this.wsChatMethodsService.openRoom(this.roomId)
setTimeout(()=>{
this.scrollToBottomClicked()
}, 150)
@@ -518,13 +518,13 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
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 base64 = await fetch(capturedImage);
const blob = await base64.blob();
const formData = new FormData();
@@ -550,11 +550,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
async addImageMobile() {
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
}
async addImage() {
this.addFileToChat(['image/apng', 'image/jpeg', 'image/png'])
}
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
}
@@ -618,7 +618,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
@@ -647,7 +647,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
const formData = new FormData();
formData.append("blobFile", file);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
@@ -809,7 +809,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -817,7 +817,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
-1
View File
@@ -165,7 +165,6 @@ export class AuthService {
try {
let guid: any = await this.AttachmentsService.uploadFile(formData).toPromise()
message.file.guid = guid.path
alert('uploaded')
await this.storage.set(guid.path, message.file.image_url).then(() => {
console.log('add picture to chat IMAGE SAVED')
message.getFileFromDb()
@@ -559,7 +559,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getGroupRoom(roomId).send({
file: {
"type": "application/img",
@@ -676,7 +676,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getGroupRoom(roomId).send({
file: {
"type": "application/img",
@@ -833,7 +833,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
async openPreview(msg) {
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -841,7 +841,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
+15 -14
View File
@@ -101,7 +101,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
public wsChatMethodsService: WsChatMethodsService,
public WsChatService: WsChatService,
private AttachmentsService: AttachmentsService,
private CameraService: CameraService,
private processesService: ProcessesService,
private fileToBase64Service: FileToBase64Service,
@@ -458,7 +458,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
@@ -477,7 +477,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async takePicture() {
const roomId = this.roomId
const image = await this.CameraService.takePicture();
await this.fileService.saveImage(image)
const lastphoto: any = await this.fileService.loadFiles();
@@ -505,11 +505,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
})
}
async addImage() {
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
}
async addFile() {
this.addFileToChat(['.doc', '.docx', '.pdf'])
}
@@ -572,7 +572,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": "application/img",
@@ -592,7 +592,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
async addFileToChat(types: typeof FileType[] ) {
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
@@ -602,10 +602,10 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}) */
const blob = new Blob([file],{type: file.type})
console.log('Add file', blob)
const formData = new FormData();
formData.append("blobFile", blob);
this.wsChatMethodsService.getDmRoom(roomId).send({
file: {
"type": file.type,
@@ -623,7 +623,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
bookMeeting() {
let data = {
@@ -678,7 +678,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
await modal.present();
modal.onDidDismiss().then( async (res) => {
console.log(res['data']);
if (res['data'] == 'meeting') {
//this.closeAllDesktopComponents.emit();
@@ -706,7 +706,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
else if (res['data'] == 'documentoGestaoDocumental') {
this.addFileWebtrix()
this.showLoader = false;
}
@@ -755,8 +755,9 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}
async openPreview(msg) {
console.log(msg);
if (msg.file.image_url === null || msg.file.image_url === '' ) {
if (msg.attachments[0].image_url === null || msg.attachments[0].image_url === '' ) {
this.downloadFileMsg(msg)
} else {
@@ -764,7 +765,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
component: ViewMediaPage,
cssClass: 'modal modal-desktop',
componentProps: {
image: msg.file.image_url,
image: msg.attachments[0].image_url,
username: msg.u.name,
_updatedAt: msg._updatedAt
}
@@ -94,65 +94,26 @@ export class NewPublicationPage implements OnInit {
const capturedImage = await Camera.getPhoto({
quality: 90,
// allowEditing: true,
resultType: CameraResultType.Uri,
resultType: CameraResultType.Base64,
source: CameraSource.Camera
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
this.capturedImageTitle = capturedImage.path;
//console.log(this.capturedImage);
}
convertBlobToBase64 = (blob: Blob) => new Promise((resolve, reject) => {
const reader = new FileReader;
reader.onerror = reject;
reader.onload = () => {
resolve(reader.result);
};
reader.readAsDataURL(blob);
});
async laodPicture() {
const capturedImage = await Camera.getPhoto({
resultType: CameraResultType.Uri,
source: CameraSource.Photos,
quality: 90,
width: 1080,
height: 720,
resultType: CameraResultType.Base64,
source: CameraSource.Photos
});
const response = await fetch(capturedImage.webPath!);
const blob = await response.blob();
this.photos.unshift({
filepath: "soon...",
webviewPath: capturedImage.webPath
});
this.capturedImage = await this.convertBlobToBase64(blob);
this.capturedImageTitle = new Date().getTime() + '.jpeg';
this.capturedImage = 'data:image/jpeg;base64,' +capturedImage.base64String;
this.capturedImageTitle = capturedImage.path;
}
/* laodPicture() {
const input = this.fileLoaderService.createInput({
accept: ['image/apng', 'image/jpeg', 'image/png']
})
input.onchange = async () => {
const file = this.fileLoaderService.getFirstFile(input)
const imageData = await this.fileToBase64Service.convert(file)
this.capturedImage = imageData;
this.capturedImageTitle = file.name
};
} */
runValidation() {
this.validateFrom = true
+1 -1
View File
@@ -6,5 +6,5 @@ export const environment = {
domain: 'gabinetedigital.local',
defaultuser: '',//paulo.pinto paulo.pinto@gabinetedigital.local
defaultuserpwd: '', //tabteste@006,
chatOffline: true
chatOffline: false
};