mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
merge with developer_prod
This commit is contained in:
@@ -30,7 +30,7 @@ import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||
import { FileOpener } from '@awesome-cordova-plugins/file-opener/ngx';
|
||||
import { SessionStore } from 'src/app/store/session.service';
|
||||
import { ViewMediaPage } from 'src/app/modals/view-media/view-media.page';
|
||||
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
@Component({
|
||||
selector: 'app-group-messages',
|
||||
templateUrl: './group-messages.page.html',
|
||||
@@ -474,14 +474,14 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
if (recordData?.value?.recordDataBase64.includes('data:audio')) {
|
||||
this.audioRecorded = recordData?.value?.recordDataBase64;
|
||||
}
|
||||
else if(recordData?.value?.mimeType && recordData?.value?.recordDataBase64){
|
||||
else if (recordData?.value?.mimeType && recordData?.value?.recordDataBase64) {
|
||||
this.audioRecorded = `data:${recordData.value.mimeType};base64,${recordData?.value?.recordDataBase64}`;
|
||||
}
|
||||
|
||||
//Converting base64 to blob
|
||||
const encodedData = btoa(this.audioRecorded);
|
||||
const blob = this.fileService.base64toBlob(encodedData, recordData.value.mimeType)
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
@@ -498,7 +498,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
fileBase64: encodedData,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -640,12 +640,18 @@ export class GroupMessagesPage 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 file = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
// allowEditing: true,
|
||||
resultType: CameraResultType.Base64,
|
||||
source: CameraSource.Camera
|
||||
});
|
||||
|
||||
const imageBase64 = 'data:image/jpeg;base64,' + file.base64String
|
||||
const blob = this.dataURItoBlob(imageBase64)
|
||||
|
||||
console.log(imageBase64)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
@@ -654,14 +660,14 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"type": "application/img",
|
||||
"guid": ''
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": capturedImageTitle,
|
||||
"title": "file.jpg",
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
fileBase64: imageBase64,
|
||||
}
|
||||
})
|
||||
|
||||
@@ -675,6 +681,51 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.addFileToChat(['.doc', '.docx', '.pdf'])
|
||||
}
|
||||
|
||||
async addImageMobile() {
|
||||
this.addFileToChatMobile(['image/apng', 'image/jpeg', 'image/png'])
|
||||
}
|
||||
|
||||
|
||||
async addFileToChatMobile(types: typeof FileType[]) {
|
||||
const roomId = this.roomId
|
||||
|
||||
const file = await Camera.getPhoto({
|
||||
quality: 90,
|
||||
// allowEditing: true,
|
||||
resultType: CameraResultType.Base64,
|
||||
source: CameraSource.Photos
|
||||
});
|
||||
|
||||
//const imageData = await this.fileToBase64Service.convert(file)
|
||||
//
|
||||
|
||||
const imageBase64 = 'data:image/jpeg;base64,' + file.base64String
|
||||
const response = await fetch(imageBase64);
|
||||
const blob = await response.blob();
|
||||
|
||||
console.log(imageBase64)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
|
||||
this.ChatSystemService.getGroupRoom(roomId).send({
|
||||
file: {
|
||||
"type": "application/img",
|
||||
"guid": ''
|
||||
},
|
||||
temporaryData: formData,
|
||||
attachments: [{
|
||||
"title": file.path,
|
||||
"text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
attachmentsModelData: {
|
||||
fileBase64: imageBase64,
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async addFileWebtrix() {
|
||||
const modal = await this.modalController.create({
|
||||
component: SearchPage,
|
||||
@@ -719,6 +770,19 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
|
||||
_getBase64(file) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
var reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = function () {
|
||||
resolve(reader.result)
|
||||
};
|
||||
reader.onerror = function (error) {
|
||||
console.log('Error: ', error);
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
async addFileToChat(types: typeof FileType[]) {
|
||||
|
||||
const roomId = this.roomId
|
||||
@@ -734,6 +798,9 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
})));
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
|
||||
const fileBase64 = await this._getBase64(file)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
|
||||
@@ -751,7 +818,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
fileBase64: fileBase64
|
||||
}
|
||||
});
|
||||
|
||||
@@ -806,7 +873,7 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.takePicture()
|
||||
}
|
||||
else if (res['data'] == 'add-picture') {
|
||||
this.addImage()
|
||||
this.addImageMobile()
|
||||
|
||||
}
|
||||
else if (res['data'] == 'add-document') {
|
||||
@@ -1090,5 +1157,31 @@ export class GroupMessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
this.downloadFileMsg(msg)
|
||||
} else { }
|
||||
}
|
||||
|
||||
|
||||
dataURItoBlob(dataURI) {
|
||||
// convert base64 to raw binary data held in a string
|
||||
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
|
||||
var byteString = atob(dataURI.split(',')[1]);
|
||||
|
||||
// separate out the mime component
|
||||
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
|
||||
|
||||
// write the bytes of the string to an ArrayBuffer
|
||||
var ab = new ArrayBuffer(byteString.length);
|
||||
|
||||
// create a view into the buffer
|
||||
var ia = new Uint8Array(ab);
|
||||
|
||||
// set the bytes of the buffer to the correct values
|
||||
for (var i = 0; i < byteString.length; i++) {
|
||||
ia[i] = byteString.charCodeAt(i);
|
||||
}
|
||||
|
||||
// write the ArrayBuffer to a blob, and you're done
|
||||
var blob = new Blob([ab], {type: mimeString});
|
||||
return blob;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -781,6 +781,20 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
return zoneOriginalInstance || fileReader;
|
||||
}
|
||||
|
||||
|
||||
_getBase64(file) {
|
||||
return new Promise((resolve, reject)=>{
|
||||
var reader = new FileReader();
|
||||
reader.readAsDataURL(file);
|
||||
reader.onload = function () {
|
||||
resolve(reader.result)
|
||||
};
|
||||
reader.onerror = function (error) {
|
||||
console.log('Error: ', error);
|
||||
};
|
||||
})
|
||||
}
|
||||
|
||||
async addFileToChat(types: typeof FileType[]) {
|
||||
|
||||
const roomId = this.roomId
|
||||
@@ -796,11 +810,11 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
})));
|
||||
const blob = this.fileService.base64toBlob(encodedData, file.type)
|
||||
|
||||
const fileBase64 = await this._getBase64(file)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', blob);
|
||||
|
||||
|
||||
this.ChatSystemService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
"type": file.type,
|
||||
@@ -814,7 +828,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
}],
|
||||
temporaryData: formData,
|
||||
attachmentsModelData: {
|
||||
fileBase64: await this.fileService.blobToBase64(blob),
|
||||
fileBase64: fileBase64,
|
||||
}
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
export let versionData = {
|
||||
"shortSHA": "fc83f1dd5",
|
||||
"SHA": "fc83f1dd5cb04722615efe6a93480b83142920f1",
|
||||
"shortSHA": "471d05653",
|
||||
"SHA": "471d05653d40a9c316a6bdcbdce15d9e552d25c0",
|
||||
"branch": "developer",
|
||||
"lastCommitAuthor": "'Eudes Inácio'",
|
||||
"lastCommitTime": "'Fri Aug 18 12:48:54 2023 +0100'",
|
||||
"lastCommitMessage": "remove save racunho button and cancelar",
|
||||
"lastCommitNumber": "5170",
|
||||
"lastCommitTime": "'Fri Aug 18 20:27:37 2023 +0100'",
|
||||
"lastCommitMessage": "users picture added",
|
||||
"lastCommitNumber": "5171",
|
||||
"change": "",
|
||||
"changeStatus": "On branch developer\nYour branch is ahead of 'origin/developer' by 1 commit.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tnew file: src/assets/images/md.webp\n\tnew file: src/assets/images/presidente.jpeg\n\tnew file: src/assets/images/sg.jpeg",
|
||||
"changeStatus": "On branch developer\nYour branch and 'origin/developer' have diverged,\nand have 2 and 5 different commits each, respectively.\n (use \"git pull\" to merge the remote branch into yours)\n\nAll conflicts fixed but you are still merging.\n (use \"git commit\" to conclude merge)\n\nChanges to be committed:\n\tmodified: src/app/pages/chat/group-messages/group-messages.page.ts\n\tmodified: src/app/pages/chat/messages/messages.page.ts",
|
||||
"changeAuthor": "eudes.inacio"
|
||||
}
|
||||
Reference in New Issue
Block a user