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
@@ -196,33 +196,26 @@ export class ApproveEventPage implements OnInit {
if(res.data.option == 'save') {
if(res.data.note !== '') {
let body = { "serialNumber": serialNumber,
"action": "Emendar",
"dataFields": {
"ReviewUserComment": res.data,
}
}
const loader = this.toastService.loading();
try {
await this.processes.PostTaskAction(body).toPromise();
this.httpErroHandle.httpsSucessMessagge('Rever')
this.TaskService.loadEventosParaAprovacao();
this.close();
} catch (error) {
this.httpErroHandle.httpStatusHandle(error)
} finally {
loader.remove()
}
}
else {
if(res.data.option == 'save') {
this.toastService._badRequest('É necessário adicionar uma nota');
let body = { "serialNumber": serialNumber,
"action": "Emendar",
"dataFields": {
"ReviewUserComment": res.data,
}
}
const loader = this.toastService.loading();
try {
await this.processes.PostTaskAction(body).toPromise();
this.httpErroHandle.httpsSucessMessagge('Rever')
this.TaskService.loadEventosParaAprovacao();
this.close();
} catch (error) {
this.httpErroHandle.httpStatusHandle(error)
} finally {
loader.remove()
}
} else {
@@ -435,15 +435,14 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
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);
@@ -460,7 +459,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}],
temporaryData: formData,
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: encodedData,
}
})
@@ -748,22 +747,39 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
"title_link_download": false,
}],
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: base64,
}
})
}
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 formData = new FormData();
// formData.append("blobFile", blob);
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 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 base64 = await fetch(capturedImage);
const blob = await base64.blob();
const formData = new FormData();
formData.append("blobFile", blob);
@@ -773,13 +789,13 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
"guid": ''
},
attachments: [{
"title": capturedImageTitle,
"title": 'file.jpg',
"text": "description",
"title_link_download": false,
}],
temporaryData: formData,
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: imageBase64,
}
})
@@ -847,14 +863,13 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
quality: 90,
// allowEditing: true,
resultType: CameraResultType.Base64,
source: CameraSource.Photos
source: CameraSource.Camera
});
//const imageData = await this.fileToBase64Service.convert(file)
//
const response = await fetch('data:image/jpeg;base64,' + file.base64String!);
const blob = await response.blob();
const imageBase64 = 'data:image/jpeg;base64,' + file.base64String
const blob = this.dataURItoBlob(imageBase64)
console.log(imageBase64)
const formData = new FormData();
formData.append("blobFile", blob);
@@ -872,7 +887,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
"title_link_download": false,
}],
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: imageBase64,
}
})
@@ -884,6 +899,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
const roomId = this.roomId
const file: any = await this.fileService.getFileFromDevice(types);
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
@@ -894,8 +910,10 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
const blob = this.fileService.base64toBlob(encodedData, file.type)
const fileBase64 = await this._getBase64(file)
const formData = new FormData();
formData.append("blobFile", blob);
formData.append('blobFile', blob);
this.ChatSystemService.getGroupRoom(roomId).send({
file: {
@@ -911,7 +929,7 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
}],
temporaryData: formData,
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: fileBase64,
}
})
@@ -1170,5 +1188,45 @@ export class GroupMessagesPage implements OnInit, OnChanges, AfterViewInit, OnDe
});
}
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;
}
_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);
};
})
}
}
+34 -13
View File
@@ -676,7 +676,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
"title_link_download": false,
}],
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: base64,
}
})
@@ -686,13 +686,18 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
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 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 blob = await base64.blob();
const formData = new FormData();
formData.append("blobFile", blob);
@@ -704,13 +709,12 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
},
temporaryData: formData,
attachments: [{
"title": capturedImageTitle,
"image_url": capturedImage,
"title": "file.jpg",
"text": "description",
"title_link_download": false,
}],
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: imageBase64,
}
})
@@ -795,6 +799,8 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const response = await fetch(base64);
const blob = await response.blob();
console.log(base64)
const formData = new FormData();
formData.append("blobFile", blob);
@@ -811,7 +817,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
"title_link_download": false,
}],
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: base64,
}
})
@@ -826,6 +832,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
const file: any = await this.fileService.getFileFromDevice(types);
if (file.type != "application/img" && file.type != "image/png" && file.type != "image/jpeg" && file.type != "image/gif") {
const encodedData = btoa(JSON.stringify(await this.getBase64(file).catch ((error) => {
@@ -833,9 +840,11 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
})));
const blob = this.fileService.base64toBlob(encodedData, file.type)
const fileBase64 = await this._getBase64(file)
const formData = new FormData();
formData.append("blobFile", blob);
formData.append('blobFile', blob);
this.ChatSystemService.getDmRoom(roomId).send({
file: {
@@ -851,7 +860,7 @@ export class MessagesPage implements OnInit, OnChanges, AfterViewInit, OnDestroy
}],
temporaryData: formData,
attachmentsModelData: {
fileBase64: await this.fileService.blobToBase64(blob),
fileBase64: fileBase64,
}
})
@@ -862,6 +871,18 @@ export class MessagesPage implements OnInit, OnChanges, 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);
};
})
}
getFileReader(): FileReader {
const fileReader = new FileReader();
const zoneOriginalInstance = (fileReader as any)["__zone_symbol__originalInstance"];
@@ -179,7 +179,7 @@ ion-item{
/* font-size: rem(12); */
float: right;
padding: 2.5px 13.5px 2.5px 13.5px;
color: #fff;
color: black;
}
}
.exp-date{
@@ -181,7 +181,7 @@ ion-item{
/* font-size: rem(12); */
float: right;
padding: 2.5px 13.5px 2.5px 13.5px;
color: #fff;
color: black;
}
}
.exp-date{
@@ -166,7 +166,7 @@
/* font-size: 12px; */
float: right;
padding: 2.5px 13.5px 2.5px 13.5px;
color: #fff;
color: black;
}
}
.exp-date{
@@ -102,7 +102,7 @@ ion-item{
//font-size: 12px;
float: right;
padding: 2.5px 13.5px 2.5px 13.5px;
color: #fff;
color: black;
}
}
.exp-date{
@@ -102,7 +102,7 @@ ion-item{
//font-size: 12px;
float: right;
padding: 2.5px 13.5px 2.5px 13.5px;
color: #fff;
color: black;
}
}
.exp-date{
@@ -72,7 +72,7 @@ ion-button{
background: var(--label-bg-color);
float: right;
padding: 5px 13.5px 5px 13.5px;
color: #fff;
color: black;
font-size: rem(14);
}
@@ -72,7 +72,7 @@ ion-button{
background: var(--label-bg-color);
float: right;
padding: 5px 13.5px 5px 13.5px;
color: #fff;
color: black;
font-size: rem(14);
}
@@ -77,7 +77,7 @@ ion-button{
background: var(--label-bg-color);
float: right;
padding: 5px 13.5px 5px 13.5px;
color: #fff;
color: black;
font-size: rem(14);
}
@@ -169,7 +169,7 @@ ion-item{
/* font-size: 12px; */
float: right;
padding: 2.5px 13.5px 2.5px 13.5px;
color: #fff;
color: black;
}
}
.exp-date{
@@ -164,7 +164,7 @@ ion-item{
/* font-size: 12px; */
float: right;
padding: 2.5px 13.5px 2.5px 13.5px;
color: #fff;
color: black;
}
}
.exp-date{
+32 -14
View File
@@ -47,14 +47,25 @@
<ion-icon *ngIf="ThemeService.currentTheme == 'default' " class="icon font-45-em" src='assets/images/icons-profile.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon font-45-em" src='assets/images/theme/gov/icons-profile.svg'></ion-icon> -->
<img *ngIf="loggeduser.RoleDescription == 'Presidente da República' " class="icon font-45-em"
src='assets/images/presidente.png'>
<img *ngIf="loggeduser.RoleDescription == 'Ministro e Director do Gabinete do PR' " class="icon font-45-em"
src='assets/images/ministro.png'>
<img *ngIf="loggeduser.RoleDescription == 'Secretário Geral' " class="icon font-45-em"
src='assets/images/secretaria_geral.png'>
<div *ngIf="profilePicture == ''" class="profile-image">
<img *ngIf="loggeduser.RoleDescription == 'Presidente da República' " class="profile-image"
src='assets/images/presidente.png'>
<img *ngIf="loggeduser.RoleDescription == 'Ministro e Director do Gabinete do PR' " class="profile-image"
src='assets/images/ministro.png'>
<img *ngIf="loggeduser.RoleDescription == 'Secretário Geral' " class="profile-image"
src='assets/images/secretaria_geral.png'>
<ion-icon
*ngIf="loggeduser.RoleDescription != 'Presidente da República'&& loggeduser.RoleDescription != 'Ministro e Director do Gabinete do PR' && loggeduser.RoleDescription != 'Secretário Geral' "
class="icon font-45-em" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
</div>
<div *ngIf="profilePicture != ''" class="profile-image">
<img class="profile-image" src={{profilePicture}}>
</div>
<ion-icon *ngIf="loggeduser.RoleDescription != 'Presidente da República'&& loggeduser.RoleDescription != 'Ministro e Director do Gabinete do PR' && loggeduser.RoleDescription != 'Secretário Geral' " class="icon font-45-em" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
<div class="profile-text">
<div *ngIf="notificationLength > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
@@ -200,16 +211,23 @@
<ion-icon *ngIf="ThemeService.currentTheme == 'doneIt' " class="icon" src='assets/images/theme/doneIt/icons-profile.svg'></ion-icon>
<ion-icon *ngIf="ThemeService.currentTheme == 'gov' " class="icon" src='assets/images/theme/gov/icons-profile.svg'></ion-icon> -->
<div *ngIf="profilePicture == ''" class="profile-image">
<img *ngIf="loggeduser.RoleDescription == 'Presidente da República' " class="profile-image"
src='assets/images/presidente.png'>
<img *ngIf="loggeduser.RoleDescription == 'Ministro e Director do Gabinete do PR' " class="profile-image"
src='assets/images/ministro.png'>
<img *ngIf="loggeduser.RoleDescription == 'Secretário Geral' " class="profile-image"
src='assets/images/secretaria_geral.png'>
<img *ngIf="loggeduser.RoleDescription == 'Presidente da República' " class="profile-image"
src='assets/images/presidente.png'>
<img *ngIf="loggeduser.RoleDescription == 'Ministro e Director do Gabinete do PR' " class="profile-image"
src='assets/images/ministro.png'>
<img *ngIf="loggeduser.RoleDescription == 'Secretário Geral' " class="profile-image"
src='assets/images/secretaria_geral.png'>
<ion-icon
*ngIf="loggeduser.RoleDescription != 'Presidente da República'&& loggeduser.RoleDescription != 'Ministro e Director do Gabinete do PR' && loggeduser.RoleDescription != 'Secretário Geral' "
class="icon" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
</div>
<ion-icon *ngIf="loggeduser.RoleDescription != 'Presidente da República'&& loggeduser.RoleDescription != 'Ministro e Director do Gabinete do PR' && loggeduser.RoleDescription != 'Secretário Geral' " class="icon" src='assets/images/theme/gov/icons-profile.svg'></ion-icon>
<div *ngIf="profilePicture != ''" class="profile-image">
<img class="profile-image" src={{profilePicture}}>
</div>
<div class="profile-text">
<div *ngIf="notificationLength > 0" class="icon-badge" style="right: -6px;top: 38px;top: -6px;">
+13 -1
View File
@@ -38,6 +38,7 @@ export class HeaderPage implements OnInit {
showProfileModal = false
permissionList = new PermissionList();
notificationCount: number = 0;
profilePicture = "";
constructor(
@@ -52,7 +53,8 @@ export class HeaderPage implements OnInit {
private eventTriger: EventTrigger,
public ActiveTabService: ActiveTabService,
private notificationService: NotificationsService,
private cdRef: ChangeDetectorRef
private cdRef: ChangeDetectorRef,
private storageService: StorageService,
) {
this.loggeduser = SessionStore.user;
router.events.subscribe((val) => {
@@ -76,9 +78,19 @@ export class HeaderPage implements OnInit {
async ngOnInit() {
this.hideSearch();
this.notificationLengthData();
this.getProfilpicture();
}
getProfilpicture() {
this.storageService.get(this.SessionStore.user.RoleID.toString()).then((picture) => {
console.log(picture)
this.profilePicture = picture
}).catch((error ) => {
this.profilePicture = "";
})
}
updateReciveNotification() {
this.eventTriger.getObservable().subscribe((event) => {
if (event.notification == "recive") {
@@ -12,6 +12,7 @@
<ion-content>
<div class="content-container">
<ion-progress-bar type="indeterminate" *ngIf="showLoader"></ion-progress-bar>
<div *ngIf="publicationType!='1'" class="ion-item-container" [class.input-error]="Form?.get('Subject')?.invalid && validateFrom ">
<ion-input autocomplete="on" autocorrect="on" spellcheck="true" [(ngModel)]="pub.Title" name="title" placeholder="Título*" ></ion-input>
@@ -29,6 +30,11 @@
</div>
<!-- <div *ngIf="publication">
OriginalFileName: {{ publication.OriginalFileName }}
</div> -->
<!-- Captured -->
<div class="ion-item-container-no-border" *ngIf="capturedImage">
<ion-label class="attached-title pb-10">Fotografia Anexada</ion-label>
@@ -32,6 +32,7 @@ export class NewPublicationPage implements OnInit {
@Input() publication!: Publication;
@Input() publicationType: string;
@Input() folderId:string;
@Input() documentId:string;
@Output() closeDesktopComponent = new EventEmitter<any>();
@Output() openPublicationDetails = new EventEmitter<any>();
@@ -64,16 +65,45 @@ export class NewPublicationPage implements OnInit {
setData() {
if(!this.publication) {
if(!this.publicationType) {
setTimeout(() => {
this.setData()
}, 500)
} else {
this.pub = this.publication
// this.pub = this.publication
// this.publication = null
this.getPublicationDetail()
}
}
getPublicationDetail() {
if(this.publicationType != '2') {
this.showLoader = true;
this.publications.GetPublicationById(this.documentId).subscribe( res => {
this.publication = {
DateIndex: res.DateIndex,
DocumentId: res.DocumentId,
ProcessId:res.ProcessId,
Title:res.Title,
Message: res.Message,
DatePublication: res.DatePublication,
FileBase64: "data:image/jpg;base64," + res.FileBase64,
OriginalFileName: res.OriginalFileName,
FileExtension: res.FileExtension,
}
this.pub = this.publication;
this.showLoader = false;
}, () => {
this.showLoader = false;
this.goBack()
});
}
}
async takePicture() {
const capturedImage = await Camera.getPhoto({
quality: 50,
@@ -150,6 +180,16 @@ export class NewPublicationPage implements OnInit {
}
if(this.publicationType == '3') {
if(!this.publication?.OriginalFileName || !this.pub.OriginalFileName) {
if(this.pub?.OriginalFileName) {
console.log('this.pub',this.pub)
}
throw('no this.publication.OriginalFileName')
}
const loader = this.toastService.loading()
if(this.capturedImage != '') {
@@ -10,6 +10,7 @@
<p class="post-data">{{publication.DatePublication | date: 'dd-MM-yyyy | h:mm'}}</p>
</div>
</div>
<!-- OriginalFileName: {{ publication.OriginalFileName }} -->
<div *ngIf="publication.Title == ''" class="title-contentd-flex pl-20 pt-25">
<div class="back-icon cursor-pointer">
<ion-icon (click)="goBack()" slot="end" src='assets/images/assets/images/theme/gov/icons-calendar-arrow-left.svg'></ion-icon>
@@ -70,10 +70,13 @@ export class PublicationDetailPage implements OnInit {
const localPublication = this.publicationFolderService.getLocalPublication(folderId, this.publicationId);
if(localPublication?.ProcessId) {
console.log('console.log local storage')
this.publication = localPublication
} else {
console.log('API res')
this.showLoader = true;
this.publications.GetPublicationById(this.publicationId).subscribe(res => {
@@ -43,7 +43,7 @@
<div class="post-img">
<img [lazyLoad]="publication.FileBase64">
</div>
<div class="post-content px-20">
<div class="post-content">
<div class="post-title-time">
<div class="post-title">
<ion-label>{{publication.Title}}</ion-label>