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
@@ -60,15 +60,24 @@
<div>
<div class="d-flex align-center flex-column" (click)="takePicture()">
<ion-icon *ngIf="SessionStore.user.RoleDescription != 'Presidente da República' && SessionStore.user.RoleDescription != 'Ministro e Director do Gabinete do PR' && SessionStore.user.RoleDescription != 'Secretário Geral' " class="profile-pic"
src="assets/images/theme/gov/icons-profile.svg"></ion-icon>
<div *ngIf="profilePicture == '' ">
<ion-icon
*ngIf="SessionStore.user.RoleDescription != 'Presidente da República' && SessionStore.user.RoleDescription != 'Ministro e Director do Gabinete do PR' && SessionStore.user.RoleDescription != 'Secretário Geral' "
class="profile-pic" src="assets/images/theme/gov/icons-profile.svg"></ion-icon>
<img *ngIf="SessionStore.user.RoleDescription == 'Presidente da República' " class="profile-pic"
src='assets/images/presidente.png'>
<img *ngIf="SessionStore.user.RoleDescription == 'Ministro e Director do Gabinete do PR' "
class="profile-pic" src='assets/images/ministro.png'>
<img *ngIf="SessionStore.user.RoleDescription == 'Secretário Geral' " class="profile-pic"
src='assets/images/secretaria_geral.png'>
</div>
<div *ngIf="profilePicture != '' ">
<img class="profile-pic" src={{profilePicture}}>
</div>
<img *ngIf="SessionStore.user.RoleDescription == 'Presidente da República' " class="profile-pic"
src='assets/images/presidente.png'>
<img *ngIf="SessionStore.user.RoleDescription == 'Ministro e Director do Gabinete do PR' " class="profile-pic"
src='assets/images/ministro.png'>
<img *ngIf="SessionStore.user.RoleDescription == 'Secretário Geral' " class="profile-pic"
src='assets/images/secretaria_geral.png'>
<!-- <ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="profile-pic"
src="assets/images/icons-default-profile.svg"></ion-icon>
@@ -76,11 +85,12 @@
src="assets/images/theme/gov/icons-profile.svg"></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="profile-pic"
src="assets/images/theme/{{ThemeService.currentTheme}}/icons-profile.svg"></ion-icon> -->
<div style="background: black;width: 50px;height: 50px;position: relative;top: -33px;left: 38px;border-radius: 55px;overflow: hidden;border: 5px solid white;">
<img src="assets/images/camera.png">
</div>
<div
style="background: black;width: 50px;height: 50px;position: relative;top: -33px;left: 38px;border-radius: 55px;overflow: hidden;border: 5px solid white;">
<img src="assets/images/camera.png">
</div>
</div>
</div>
<div class="profile-info">
@@ -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 || '';