mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
upload profile picture
This commit is contained in:
@@ -188,5 +188,6 @@
|
|||||||
<button class="btn-cancel" shape="round" (click)="cancelTask()">Cancelar</button>
|
<button class="btn-cancel" shape="round" (click)="cancelTask()">Cancelar</button>
|
||||||
<button *ngIf="taskType == '0'" class="btn-ok" shape="round" (click)="saveTask()">Concluir</button>
|
<button *ngIf="taskType == '0'" class="btn-ok" shape="round" (click)="saveTask()">Concluir</button>
|
||||||
<button *ngIf="taskType == '1'" class="btn-ok" shape="round" (click)="saveTask()">Solicitar</button>
|
<button *ngIf="taskType == '1'" class="btn-ok" shape="round" (click)="saveTask()">Solicitar</button>
|
||||||
|
<button *ngIf="taskType == '2'" class="btn-ok" shape="round" (click)="saveTask()">Solicitar</button>
|
||||||
</div>
|
</div>
|
||||||
</ion-footer>
|
</ion-footer>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera
|
|||||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||||
import { File } from '@awesome-cordova-plugins/file/ngx';
|
import { File } from '@awesome-cordova-plugins/file/ngx';
|
||||||
import { StorageService } from 'src/app/services/storage.service';
|
import { StorageService } from 'src/app/services/storage.service';
|
||||||
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -33,20 +34,42 @@ export class EditProfilePage implements OnInit {
|
|||||||
public ThemeService: ThemeService,
|
public ThemeService: ThemeService,
|
||||||
private file: File,
|
private file: File,
|
||||||
private storageService: StorageService,
|
private storageService: StorageService,
|
||||||
|
private attachmentService: AttachmentsService
|
||||||
|
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.getProfilpicture()
|
this.getProfilpictureFromStorage()
|
||||||
}
|
}
|
||||||
getProfilpicture() {
|
getProfilpictureFromStorage() {
|
||||||
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
|
||||||
console.log(picture)
|
console.log(picture)
|
||||||
this.profilePicture = picture
|
this.profilePicture = picture
|
||||||
}).catch((error ) => {
|
}).catch((error) => {
|
||||||
this.profilePicture = "";
|
this.profilePicture = "";
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
getProfilpicture(guid) {
|
||||||
|
console.log('Get picture ', guid.path)
|
||||||
|
this.attachmentService.downloadFile(guid.path).subscribe(async (picture: any) => {
|
||||||
|
|
||||||
|
|
||||||
|
let downloadFile = 'data:image/jpeg;base64,' + btoa(new Uint8Array(picture.body).reduce((data, byte) => data + String.fromCharCode(byte), ''));
|
||||||
|
console.log('Get picture ', downloadFile)
|
||||||
|
this.storageService.store(this.SessionStore.user.RoleID.toString()+"guid", guid.path)
|
||||||
|
this.storageService.store(this.SessionStore.user.RoleID.toString(), downloadFile).then((value) => {
|
||||||
|
|
||||||
|
|
||||||
|
console.log('picture saved')
|
||||||
|
}).catch((error) => {
|
||||||
|
console.log('picture not saved')
|
||||||
|
});
|
||||||
|
|
||||||
|
}, ((error) => {
|
||||||
|
console.log('Error get profile picture: ', error)
|
||||||
|
}))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
this.modalController.dismiss();
|
this.modalController.dismiss();
|
||||||
@@ -146,50 +169,32 @@ export class EditProfilePage implements OnInit {
|
|||||||
|
|
||||||
async takePicture() {
|
async takePicture() {
|
||||||
const capturedImage = await Camera.getPhoto({
|
const capturedImage = await Camera.getPhoto({
|
||||||
width: 188,
|
width: 250,
|
||||||
height: 188,
|
height: 250,
|
||||||
quality: 100,
|
quality: 100,
|
||||||
// allowEditing: true,
|
// allowEditing: true,
|
||||||
resultType: CameraResultType.Base64,
|
resultType: CameraResultType.Base64,
|
||||||
source: CameraSource.Camera
|
source: CameraSource.Camera
|
||||||
});
|
});
|
||||||
|
|
||||||
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.capturedImageTitle = SessionStore.user.Profile;
|
||||||
/* this.saveFile(this.capturedImage,this.capturedImageTitle,'application/img'); */
|
this.capturedImage = 'data:image/jpeg;base64,' + capturedImage.base64String;
|
||||||
|
|
||||||
|
const blob = this.dataURItoBlob(this.capturedImage)
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append("blobFile", blob);
|
||||||
|
|
||||||
|
this.attachmentService.uploadFile(formData).subscribe((guid) => {
|
||||||
|
console.log('GUID ', guid)
|
||||||
|
console.log(this.SessionStore.user.RoleID.toString())
|
||||||
|
this.getProfilpicture(guid);
|
||||||
|
}, ((error) => {
|
||||||
|
console.log('Erro Upload profile picture ',error)
|
||||||
|
}))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* async saveFile(pdfString, filename, type) {
|
|
||||||
const blob = this.b64toBlob(pdfString, type)
|
|
||||||
console.log(blob)
|
|
||||||
let pathFile = ''
|
|
||||||
const fileName = filename
|
|
||||||
const contentFile = blob
|
|
||||||
if (this.platform.is('ios')) {
|
|
||||||
pathFile = this.file.documentsDirectory
|
|
||||||
} else {
|
|
||||||
pathFile = this.file.externalRootDirectory
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(pathFile)
|
|
||||||
|
|
||||||
await Filesystem.writeFile({
|
|
||||||
path: fileName,
|
|
||||||
data: pdfString,
|
|
||||||
directory: Directory.Documents,
|
|
||||||
}).then((dir) => {
|
|
||||||
console.log('DIR ', dir)
|
|
||||||
});
|
|
||||||
} */
|
|
||||||
|
|
||||||
|
|
||||||
b64toBlob(b64Data, contentType) {
|
b64toBlob(b64Data, contentType) {
|
||||||
contentType = contentType || '';
|
contentType = contentType || '';
|
||||||
@@ -216,5 +221,30 @@ export class EditProfilePage implements OnInit {
|
|||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -253,6 +253,19 @@ export class ProfilePage implements OnInit {
|
|||||||
else if (Service === "gabinete-digital" && Object === "despachos-pr") {
|
else if (Service === "gabinete-digital" && Object === "despachos-pr") {
|
||||||
|
|
||||||
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', IdObject, 'gabinete-digital']));
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/despachos-pr', IdObject, 'gabinete-digital']));
|
||||||
|
}else if (Service === "gabinete-digital" && Object === "diplomas") {
|
||||||
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital']));
|
||||||
|
}
|
||||||
|
else if (Service === "gabinete-digital" && Object === "diplomas-assinar") {
|
||||||
|
|
||||||
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas-assinar', IdObject, 'gabinete-digital']));
|
||||||
|
}
|
||||||
|
else if (Service === "gabinete-digital" && Object === "diploma-revisao") {
|
||||||
|
|
||||||
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/diplomas', IdObject, 'gabinete-digital']));
|
||||||
|
}
|
||||||
|
else if (Service === "gabinete-digital" && Object === "expedientes-pr") {
|
||||||
|
this.zone.run(() => this.router.navigate(['/home/gabinete-digital/expedientes-pr', IdObject, 'gabinete-digital']));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deleteNotification(index);
|
this.deleteNotification(index);
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ export class HeaderPage implements OnInit {
|
|||||||
this.eventTriger.getObservable().subscribe((event) => {
|
this.eventTriger.getObservable().subscribe((event) => {
|
||||||
if (event.notification == "recive") {
|
if (event.notification == "recive") {
|
||||||
console.log('header', event.notification)
|
console.log('header', event.notification)
|
||||||
this.notificationLength++
|
this.notificationLengthData()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -105,21 +105,24 @@ export class HeaderPage implements OnInit {
|
|||||||
this.eventTriger.getObservable().subscribe((event) => {
|
this.eventTriger.getObservable().subscribe((event) => {
|
||||||
if (event.notification == "deleted") {
|
if (event.notification == "deleted") {
|
||||||
console.log('header', event.notification)
|
console.log('header', event.notification)
|
||||||
this.notificationLength--
|
this.notificationLengthData()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async notificationLengthData() {
|
async notificationLengthData() {
|
||||||
|
console.log('Call notification data')
|
||||||
await this.storageservice.get("Notifications").then((value) => {
|
await this.storageservice.get("Notifications").then((value) => {
|
||||||
|
|
||||||
|
console.log('Get notification data', )
|
||||||
|
|
||||||
this.notificationLength = value.length;
|
this.notificationLength = value.length;
|
||||||
|
console.log('Call notification data',this.notificationLength)
|
||||||
|
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
|
console.error('header storage get notification', error)
|
||||||
this.notificationLength = 0;
|
this.notificationLength = 0;
|
||||||
} else {
|
} else {
|
||||||
console.error('header storage get notification', error)
|
console.error('header storage get notification', error)
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
export let versionData = {
|
export let versionData = {
|
||||||
"shortSHA": "9de301944",
|
"shortSHA": "fb1bd07ad",
|
||||||
"SHA": "9de30194464b9511a9aa14a85b5b60894aeb860b",
|
"SHA": "fb1bd07ad0a5ba460b84408f87a08f72604cb41f",
|
||||||
"branch": "developer-prod",
|
"branch": "developer-prod",
|
||||||
"lastCommitAuthor": "'Eudes Inácio'",
|
"lastCommitAuthor": "'Eudes Inácio'",
|
||||||
"lastCommitTime": "'Thu Aug 31 17:35:39 2023 +0100'",
|
"lastCommitTime": "'Wed Sep 6 21:23:21 2023 +0100'",
|
||||||
"lastCommitMessage": "new erro hendle",
|
"lastCommitMessage": "a lot of changes",
|
||||||
"lastCommitNumber": "5256",
|
"lastCommitNumber": "5257",
|
||||||
"change": "",
|
"change": "",
|
||||||
"changeStatus": "On branch developer-prod\nYour branch is ahead of 'origin/developer-prod' by 2 commits.\n (use \"git push\" to publish your local commits)\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/Rules/despacho.service.ts\n\tmodified: src/app/modals/create-process/create-process.page.html\n\tmodified: src/app/modals/create-process/create-process.page.ts\n\tnew file: src/app/models/eventToAprove.model.ts\n\tmodified: src/app/models/user.model.ts\n\tmodified: src/app/pages/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/pages/agenda/new-event/new-event.page.ts\n\tmodified: src/app/pages/events/events.page.html\n\tmodified: src/app/pages/gabinete-digital/diplomas-assinar/diploma-assinar/diploma-assinar.page.html\n\tmodified: src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.html\n\tmodified: src/app/pages/gabinete-digital/event-list/approve-event-modal/approve-event-modal.page.ts\n\tmodified: src/app/pages/gabinete-digital/expediente/expediente-detail/expediente-detail.page.ts\n\tmodified: src/app/services/auth.service.ts\n\tmodified: src/app/services/http-error-handle.service.ts\n\tmodified: src/app/services/processes.service.ts\n\tmodified: src/app/shared/agenda/approve-event/approve-event.page.ts\n\tmodified: src/app/shared/agenda/edit-event/edit-event.page.ts\n\tmodified: src/app/shared/agenda/new-event/new-event.page.ts\n\tmodified: src/app/shared/chat/group-messages/group-messages.page.ts\n\tmodified: src/app/shared/chat/messages/messages.page.ts\n\tmodified: src/app/shared/header/header.page.html\n\tmodified: src/app/shared/header/header.page.scss\n\tmodified: src/app/shared/popover/deploma-options/deploma-options.page.html\n\tmodified: src/app/shared/popover/deploma-options/deploma-options.page.ts",
|
"changeStatus": "On branch developer-prod\nYour branch is up to date with 'origin/developer-prod'.\n\nChanges to be committed:\n (use \"git restore --staged <file>...\" to unstage)\n\tmodified: src/app/modals/create-process/create-process.page.html\n\tmodified: src/app/modals/profile/edit-profile/edit-profile.page.ts\n\tmodified: src/app/modals/profile/profile.page.ts\n\tmodified: src/app/shared/header/header.page.ts",
|
||||||
"changeAuthor": "eudes.inacio"
|
"changeAuthor": "eudes.inacio"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user