profile picture done

This commit is contained in:
Eudes Inácio
2023-08-29 16:05:32 +01:00
64 changed files with 519 additions and 289 deletions
@@ -9,6 +9,7 @@ import { ThemeService } from 'src/app/services/theme.service';
import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';
import { Filesystem, Directory } from '@capacitor/filesystem';
import { File } from '@awesome-cordova-plugins/file/ngx';
import { StorageService } from 'src/app/services/storage.service';
@Component({
@@ -23,6 +24,7 @@ export class EditProfilePage implements OnInit {
environment = environment
capturedImage = '';
capturedImageTitle = '';
profilePicture = "";
constructor(private modalController: ModalController,
private animationController: AnimationController,
@@ -30,9 +32,21 @@ export class EditProfilePage implements OnInit {
private BackgroundService: BackgroundService,
public ThemeService: ThemeService,
private file: File,
private storageService: StorageService,
) { }
ngOnInit() { }
ngOnInit() {
this.getProfilpicture()
}
getProfilpicture() {
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
console.log(picture)
this.profilePicture = picture
}).catch((error ) => {
this.profilePicture = "";
})
}
close() {
this.modalController.dismiss();
@@ -132,6 +146,8 @@ export class EditProfilePage implements OnInit {
async takePicture() {
const capturedImage = await Camera.getPhoto({
width: 188,
height: 188,
quality: 50,
// allowEditing: true,
resultType: CameraResultType.Base64,
@@ -139,12 +155,19 @@ export class EditProfilePage implements OnInit {
});
this.capturedImage = 'data:image/jpeg;base64,' + capturedImage.base64String;
console.log(this.SessionStore.user.RoleID.toString())
this.storageService.store(this.SessionStore.user.RoleID.toString(),this.capturedImage).then((value) => {
console.log('picture saved')
}).catch((error) => {
console.log('picture not saved')
})
this.getProfilpicture()
this.capturedImageTitle = SessionStore.user.Profile;
this.saveFile(this.capturedImage,this.capturedImageTitle,'application/img');
/* this.saveFile(this.capturedImage,this.capturedImageTitle,'application/img'); */
}
async saveFile(pdfString, filename, type) {
/* async saveFile(pdfString, filename, type) {
const blob = this.b64toBlob(pdfString, type)
console.log(blob)
let pathFile = ''
@@ -165,11 +188,8 @@ export class EditProfilePage implements OnInit {
}).then((dir) => {
console.log('DIR ', dir)
});
}
} */
getImagem() {
}
b64toBlob(b64Data, contentType) {
contentType = contentType || '';