Skip to content
This repository has been archived by the owner on Feb 4, 2025. It is now read-only.

Commit

Permalink
Al cambia
Browse files Browse the repository at this point in the history
  • Loading branch information
rosema2012 committed Jan 21, 2025
1 parent a967835 commit 45b7fac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ throw new Error('Method not implemented.');
protected service: OntimizeService;
avatar: any

defaultImage: string = 'assets/images/no-image.png'; // Ruta de la imagen por defecto


constructor(protected injector: Injector,private router: Router, private mainService: MainService,protected dialogService: DialogService,private oUserInfoService: OUserInfoService) {
this.service= this.injector.get(OntimizeService);
this.configureService();
Expand Down Expand Up @@ -75,6 +78,10 @@ throw new Error('Method not implemented.');
}
onImageChange(event: any) {
if (!event || !this.UsrPhoto.currentFileName) {
this.oUserInfoService.setUserInfo({
...this.oUserInfoService.getUserInfo(),
avatar:this.defaultImage
})
return;
}

Expand All @@ -89,8 +96,8 @@ throw new Error('Method not implemented.');
const fileExtension = currentFileName.split('.').pop()?.toLowerCase();

if (!fileExtension || !validExtensions.includes(fileExtension)) {
this.showAlert();
this.UsrPhoto.setValue('');
//this.showAlert();
//this.UsrPhoto.setValue('');
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export class PersonalTutorInfoComponent {
mainInfo: any = {};
protected service: OntimizeService;

defaultImage: string = 'assets/images/no-image.png'; // Ruta de la imagen por defecto


constructor(protected injector: Injector, private mainService: MainService,private router: Router,protected dialogService: DialogService,private oUserInfoService:OUserInfoService) {
this.service= this.injector.get(OntimizeService);
this.configureService();
Expand Down Expand Up @@ -66,9 +69,17 @@ export class PersonalTutorInfoComponent {
}
onImageChange(event: any) {
if (!event || !this.tutorsPhoto.currentFileName) {
this.oUserInfoService.setUserInfo({
...this.oUserInfoService.getUserInfo(),
avatar:this.defaultImage
})
return;
}

if(!this.tutorsPhoto.currentFileName){

}

if (this.isUpdatingImage) {
return;
}
Expand All @@ -81,7 +92,7 @@ export class PersonalTutorInfoComponent {

// Validar si el nombre del archivo o la extensión son inválidos
if (!fileExtension || !validExtensions.includes(fileExtension)) {
this.tutorsPhoto.setValue(''); // Limpia el valor del archivo
//this.tutorsPhoto.setValue(''); // Limpia el valor del archivo
return;
}

Expand All @@ -107,22 +118,22 @@ export class PersonalTutorInfoComponent {
avatar:modifiedImageBase64
})
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
};
}}


img.onerror = () => {
console.error('Error al cargar la imagen.');
};
}

}}


}



showAlert() {
if (this.dialogService) {
this.dialogService.error('Error de tipo de archivo', 'Por favor, sube una imagen con extensión .jpg, .jpeg .png o .gif');
}
}

}

0 comments on commit 45b7fac

Please sign in to comment.