mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
multipfilepicker added
This commit is contained in:
@@ -18,6 +18,6 @@
|
||||
}
|
||||
},
|
||||
"server": {
|
||||
"url": "http://192.168.1.5:8100"
|
||||
"url": "http://192.168.137.1:8100"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,10 @@
|
||||
<param name="onload" value="true"/>
|
||||
</feature>
|
||||
|
||||
<feature name="MultipleDocumentsPicker">
|
||||
<param name="android-package" value="com.akeo.cordova.plugin.MultipleDocumentsPicker"/>
|
||||
</feature>
|
||||
|
||||
<feature name="OkHttpPlugin">
|
||||
<param name="android-package" value="com.google.cordova.OkHttpPlugin"/>
|
||||
<param name="onload" value="true"/>
|
||||
|
||||
Generated
+58
@@ -799,6 +799,36 @@
|
||||
"integrity": "sha512-H71nDOOL8Y7kWRLqf6Sums+01Q5msqBW2KhDUTemh1tvY04eSkSXrK0uj/4mmY0Xr16/3zyZmsrxN7CKuRbNRg==",
|
||||
"dev": true
|
||||
},
|
||||
"@awesome-cordova-plugins/core": {
|
||||
"version": "5.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/core/-/core-5.40.0.tgz",
|
||||
"integrity": "sha512-tk5QlnXfSE2Zu3mJVC3f11Guu5iqnLtNkvvClNHjz/e4FsJEmprfXWCv/QImWs5fLsismHcn31LKYBfWIhOv9g==",
|
||||
"requires": {
|
||||
"@types/cordova": "^0.0.34"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/cordova": {
|
||||
"version": "0.0.34",
|
||||
"resolved": "https://registry.npmjs.org/@types/cordova/-/cordova-0.0.34.tgz",
|
||||
"integrity": "sha1-6nrd907Ow9dimCegw54smt3HPQQ="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@awesome-cordova-plugins/multiple-document-picker": {
|
||||
"version": "5.40.0",
|
||||
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/multiple-document-picker/-/multiple-document-picker-5.40.0.tgz",
|
||||
"integrity": "sha512-7mYRo2yulfgStK0XsPaTUJigFbYwlQy/qWjLRbNHMbEUOk372a/HnjTUwFBFT+oWX8k0Rn9hjX50Xsqoz46hyQ==",
|
||||
"requires": {
|
||||
"@types/cordova": "^0.0.34"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/cordova": {
|
||||
"version": "0.0.34",
|
||||
"resolved": "https://registry.npmjs.org/@types/cordova/-/cordova-0.0.34.tgz",
|
||||
"integrity": "sha1-6nrd907Ow9dimCegw54smt3HPQQ="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@babel/code-frame": {
|
||||
"version": "7.14.5",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.14.5.tgz",
|
||||
@@ -6892,6 +6922,29 @@
|
||||
"get-blob-duration": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"capacitor2-file-picker": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/capacitor2-file-picker/-/capacitor2-file-picker-1.0.0.tgz",
|
||||
"integrity": "sha512-mumuW44Bx6mMK0V5KEifu6EgBGPsWQ/kXKWMIaHGFYYUtmZTVpDl2DWiQe6VYFbaemhT+0C1EvKbP681RpLOpQ==",
|
||||
"requires": {
|
||||
"@capacitor/core": "^2.4.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@capacitor/core": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@capacitor/core/-/core-2.5.0.tgz",
|
||||
"integrity": "sha512-WUkUnqqLtlEYn6tly8t6VR0ABlSVbXdlD/gBbYxx0P+gEqMF9b46uYb2YqyH+8HBDANzTweEySpLfhiSUvYS7w==",
|
||||
"requires": {
|
||||
"tslib": "^1.9.0"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.14.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
|
||||
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"capture-exit": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/capture-exit/-/capture-exit-2.0.0.tgz",
|
||||
@@ -8110,6 +8163,11 @@
|
||||
"integrity": "sha512-pVQOrNM7VAuVUMXibAlMGIArrftHPrRs4dUCoE+e2HEFUp3LmN3Yj539LjdUxcWmz/A/cHC65m9E3DS56YJhcg==",
|
||||
"dev": true
|
||||
},
|
||||
"cordova-plugin-multiple-documents-picker": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-multiple-documents-picker/-/cordova-plugin-multiple-documents-picker-1.0.0.tgz",
|
||||
"integrity": "sha512-MXc1A6bP8/gOSxRRijj5Tp61Sm4zd+yxz5s5ssWD/VQV+MWK88THPZyDuQ2efUbFVs6i2T255mkboLsEEY8EXQ=="
|
||||
},
|
||||
"cordova-plugin-network-information": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-network-information/-/cordova-plugin-network-information-3.0.0.tgz",
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
"@angular/platform-browser": "~12.1.2",
|
||||
"@angular/platform-browser-dynamic": "~12.1.2",
|
||||
"@angular/router": "~12.1.2",
|
||||
"@awesome-cordova-plugins/core": "^5.40.0",
|
||||
"@awesome-cordova-plugins/multiple-document-picker": "^5.40.0",
|
||||
"@byteowls/capacitor-filesharer": "^3.0.0",
|
||||
"@capacitor-community/camera-preview": "^1.2.1",
|
||||
"@capacitor/android": "3.3.3",
|
||||
@@ -101,11 +103,13 @@
|
||||
"bootstrap": "^4.5.0",
|
||||
"build": "0.1.4",
|
||||
"capacitor-voice-recorder": "^2.0.0",
|
||||
"capacitor2-file-picker": "^1.0.0",
|
||||
"ci": "^2.1.1",
|
||||
"cordova": "^10.0.0",
|
||||
"cordova-plugin-crop": "^0.4.0",
|
||||
"cordova-plugin-dbcopy": "git+https://github.com/an-rahulpandey/cordova-plugin-dbcopy.git",
|
||||
"cordova-plugin-filepath": "^1.5.8",
|
||||
"cordova-plugin-multiple-documents-picker": "^1.0.0",
|
||||
"cordova-plugin-okhttp": "^2.0.0",
|
||||
"cordova-plugin-screen-orientation": "^3.0.2",
|
||||
"cordova-res": "^0.15.3",
|
||||
|
||||
@@ -36,6 +36,7 @@ import {MAT_DATE_FORMATS, MAT_DATE_LOCALE} from '@angular/material/core';
|
||||
import { NgxMatDateFormats, NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
|
||||
import { Network } from '@ionic-native/network/ngx';
|
||||
import { File } from '@ionic-native/file/ngx';
|
||||
import { MultipleDocumentsPicker } from '@awesome-cordova-plugins/multiple-document-picker/ngx';
|
||||
|
||||
|
||||
|
||||
@@ -144,6 +145,8 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||
StreamingMedia,
|
||||
PhotoViewer,
|
||||
NgxImageCompressService,
|
||||
MultipleDocumentsPicker,
|
||||
|
||||
],
|
||||
bootstrap: [AppComponent],
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
|
||||
@@ -20,7 +20,7 @@ import { ChatUserStorage } from 'src/app/store/chat/chat-user.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { ThemeService } from 'src/app/services/theme.service'
|
||||
|
||||
import { Directory, Encoding, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
import { Directory, Encoding , Filesystem, FilesystemDirectory, } from '@capacitor/filesystem';
|
||||
import { VoiceRecorder, VoiceRecorderPlugin, RecordingData, GenericResponse, CurrentRecordingStatus } from 'capacitor-voice-recorder';
|
||||
import { Haptics, ImpactStyle } from '@capacitor/haptics';
|
||||
import { PreviewCameraPage } from 'src/app/modals/preview-camera/preview-camera.page';
|
||||
@@ -40,10 +40,9 @@ import { SearchPage } from 'src/app/pages/search/search.page';
|
||||
import { Storage } from '@ionic/storage';
|
||||
import { FileToBase64Service } from 'src/app/services/file/file-to-base64.service';
|
||||
import { Camera, CameraResultType, CameraSource } from '@capacitor/camera';
|
||||
import { Plugins } from '@capacitor/core';
|
||||
import { fromByteArray } from 'base64-js';
|
||||
import { Plugins, Capacitor } from '@capacitor/core';
|
||||
import { MultipleDocumentsPicker } from '@awesome-cordova-plugins/multiple-document-picker/ngx';
|
||||
|
||||
const { Filesystem } = Plugins;
|
||||
|
||||
|
||||
const IMAGE_DIR = 'stored-images';
|
||||
@@ -94,6 +93,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
myAudio: any;
|
||||
downloadfile: any;
|
||||
downloadFile: any;
|
||||
files:any[] = [];
|
||||
|
||||
constructor(
|
||||
public popoverController: PopoverController,
|
||||
@@ -119,6 +119,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
private processesService: ProcessesService,
|
||||
private storage: Storage,
|
||||
private fileToBase64Service: FileToBase64Service,
|
||||
private multipleDocumentsPicker: MultipleDocumentsPicker
|
||||
) {
|
||||
this.loggedUser = authService.ValidatedUserChat['data'];
|
||||
this.roomId = this.navParams.get('roomId');
|
||||
@@ -673,21 +674,65 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
async addFileToChat(types: typeof FileType[]) {
|
||||
|
||||
const roomId = this.roomId
|
||||
this.multipleDocumentsPicker.pick(2)
|
||||
.then(async (res: any) => {
|
||||
this.files = JSON.parse(res)
|
||||
console.log('1 Add file', this.files[0].uri)
|
||||
|
||||
const file: any = await this.fileService.getFileFromDevice(types);
|
||||
console.log('Add file', file)
|
||||
/* const imageData = await this.fileToBase64Service.convert(file).then((filee) => {
|
||||
console.log('Add file', filee)
|
||||
}) */
|
||||
const response = await fetch(file);
|
||||
const blob = await response.blob();
|
||||
const blob2 = new Blob([blob])
|
||||
console.log('Add file base64', file)
|
||||
console.log('Add file blob', blob)
|
||||
|
||||
|
||||
// Here's an example of reading a file with a full file path. Use this to
|
||||
// read binary data (base64 encoded) from plugins that return File URIs, such as
|
||||
// the Camera.
|
||||
const contents = await Filesystem.readFile({
|
||||
path: this.files[0].uri
|
||||
});
|
||||
|
||||
console.log('data:', contents);
|
||||
|
||||
|
||||
/* const response = await fetch(this.files[0].uri);
|
||||
const blob = await response.blob(); */
|
||||
|
||||
|
||||
const blob = new Blob([res])
|
||||
console.log('Add Blob file', blob)
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("blobFile", blob);
|
||||
console.log(formData)
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(this.roomId).send({
|
||||
file: {
|
||||
"type": 'application/pdf',
|
||||
"guid": '',
|
||||
},
|
||||
attachments: [{
|
||||
"title": 'pdf1',
|
||||
"name": 'pdf1',
|
||||
// "text": "description",
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
})
|
||||
.catch((error: any) => console.error(error));
|
||||
|
||||
/* const roomId = this.roomId
|
||||
|
||||
const file: any = await this.fileService.getFileFromDevice(types);
|
||||
|
||||
|
||||
console.log('Add file', file)
|
||||
const blob = new Blob([file], { type: file.type });
|
||||
//const blob = new Blob([file.size], {type: file.type });
|
||||
console.log('Add Blob file', blob)
|
||||
this.blobToBase64(file)
|
||||
.then(base64String => console.log(base64String));
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('blobFile', file);
|
||||
console.log(formData)
|
||||
|
||||
this.wsChatMethodsService.getDmRoom(roomId).send({
|
||||
file: {
|
||||
@@ -701,11 +746,22 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
"title_link_download": false,
|
||||
}],
|
||||
temporaryData: formData
|
||||
})
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
blobToBase64 = blob => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsDataURL(blob);
|
||||
return new Promise(resolve => {
|
||||
reader.onloadend = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
async openChatOptions(ev?: any) {
|
||||
const roomId = this.roomId
|
||||
console.log('MOBILE CHAT OPTION', this.members);
|
||||
@@ -838,6 +894,7 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
} else {
|
||||
//console.log('TRY THIS LIBRARY ',fromByteArray(event.body));
|
||||
this.downloadFile = event.body;
|
||||
console.log(this._arrayBufferToBase64(event.body))
|
||||
}
|
||||
|
||||
msg.attachments[0] = {
|
||||
@@ -856,6 +913,16 @@ export class MessagesPage implements OnInit, AfterViewInit, OnDestroy {
|
||||
|
||||
}
|
||||
|
||||
_arrayBufferToBase64(buffer) {
|
||||
var binary = '';
|
||||
var bytes = new Uint8Array(buffer);
|
||||
var len = bytes.byteLength;
|
||||
for (var i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
}
|
||||
return window.btoa(binary);
|
||||
}
|
||||
|
||||
async openPreview(msg) {
|
||||
console.log(msg);
|
||||
|
||||
|
||||
@@ -750,7 +750,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
|
||||
this.downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||
} else if (msg.file.type === 'application/pdf') {
|
||||
|
||||
this.downloadFile = event.body;
|
||||
this.downloadFile = 'data:application/pdf;base64,' + btoa(new Uint8Array(event.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));;
|
||||
console.log(this._arrayBufferToBase64(event.body))
|
||||
}
|
||||
|
||||
msg.attachments[0] = {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
export const environment = {
|
||||
production: false,
|
||||
apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/',
|
||||
// apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/',
|
||||
//apiURL: 'https://gabinetedigital.dyndns.info/GabineteDigital.Services/V5/api/',
|
||||
apiURL: 'http://gpr-dev-01.gabinetedigital.local/GabineteDigital.Services/V5/api/',
|
||||
apiChatUrl: 'https://gabinetedigitalchat.dyndns.info/api/v1/',
|
||||
apiWsChatUrl: 'wss://gabinetedigitalchat.dyndns.info/websocket',
|
||||
//apiChatUrl: 'https://www.tabularium.pt/api/v1/',
|
||||
|
||||
Reference in New Issue
Block a user