Alertas modificacion usuario
This commit is contained in:
		
							parent
							
								
									07e9d80c57
								
							
						
					
					
						commit
						48a894c455
					
				| 
						 | 
				
			
			@ -180,7 +180,7 @@
 | 
			
		|||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <!-- Form -->
 | 
			
		||||
    <!-- Form de info usuario -->
 | 
			
		||||
    <form
 | 
			
		||||
      autocomplete="off"
 | 
			
		||||
      class="ds-form col-lg ml-lg-5 mr-lg-5 pr-lg-5"
 | 
			
		||||
| 
						 | 
				
			
			@ -190,6 +190,14 @@
 | 
			
		|||
      (ngSubmit)="save()"
 | 
			
		||||
      [formGroup]="editForm"
 | 
			
		||||
    >
 | 
			
		||||
      <div class="alert alert-danger" *ngIf="error" jhiTranslate="global.messages.info.authenticated.updateForm" data-cy="loginError"></div>
 | 
			
		||||
 | 
			
		||||
      <div *ngIf="success" class="alert alert-success alert-dismissible fade show" role="alert">
 | 
			
		||||
        Sus datos fueron actualizados de manera exitosa
 | 
			
		||||
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
 | 
			
		||||
          <span aria-hidden="true">×</span>
 | 
			
		||||
        </button>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="row mb-2">
 | 
			
		||||
        <div class="form-group w-100">
 | 
			
		||||
          <label class="form-control-label" for="field_email">Correo electrónico</label>
 | 
			
		||||
| 
						 | 
				
			
			@ -221,7 +229,7 @@
 | 
			
		|||
            <input
 | 
			
		||||
              id="field_fechaNacimiento"
 | 
			
		||||
              data-cy="fechaNacimiento"
 | 
			
		||||
              type="datetime-local"
 | 
			
		||||
              type="date"
 | 
			
		||||
              class="form-control"
 | 
			
		||||
              name="fechaNacimiento"
 | 
			
		||||
              formControlName="fechaNacimiento"
 | 
			
		||||
| 
						 | 
				
			
			@ -278,7 +286,7 @@
 | 
			
		|||
      </div>
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <!-- Form -->
 | 
			
		||||
    <!-- Form de password-->
 | 
			
		||||
    <form
 | 
			
		||||
      autocomplete="off"
 | 
			
		||||
      class="ds-form col-lg ml-lg-5 mr-lg-5 pr-lg-5"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,5 +1,5 @@
 | 
			
		|||
import { Component, OnInit } from '@angular/core';
 | 
			
		||||
import { HttpResponse } from '@angular/common/http';
 | 
			
		||||
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
 | 
			
		||||
import { FormBuilder, Validators } from '@angular/forms';
 | 
			
		||||
import { ActivatedRoute } from '@angular/router';
 | 
			
		||||
import { Observable } from 'rxjs';
 | 
			
		||||
| 
						 | 
				
			
			@ -15,6 +15,7 @@ import { IUsuarioExtra, UsuarioExtra } from 'app/entities/usuario-extra/usuario-
 | 
			
		|||
import { UsuarioExtraService } from 'app/entities/usuario-extra/service/usuario-extra.service';
 | 
			
		||||
import { AccountService } from 'app/core/auth/account.service';
 | 
			
		||||
import { LocalStorageService } from 'ngx-webstorage';
 | 
			
		||||
import { EMAIL_ALREADY_USED_TYPE, LOGIN_ALREADY_USED_TYPE } from '../../config/error.constants';
 | 
			
		||||
 | 
			
		||||
@Component({
 | 
			
		||||
  selector: 'jhi-settings',
 | 
			
		||||
| 
						 | 
				
			
			@ -22,7 +23,8 @@ import { LocalStorageService } from 'ngx-webstorage';
 | 
			
		|||
})
 | 
			
		||||
export class SettingsComponent implements OnInit {
 | 
			
		||||
  isSaving = false;
 | 
			
		||||
 | 
			
		||||
  success = false;
 | 
			
		||||
  error = false;
 | 
			
		||||
  usersSharedCollection: IUser[] = [];
 | 
			
		||||
  plantillasSharedCollection: IPlantilla[] = [];
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -120,14 +122,15 @@ export class SettingsComponent implements OnInit {
 | 
			
		|||
    window.history.back();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  //Se manda la info a guardar
 | 
			
		||||
  save(): void {
 | 
			
		||||
    this.isSaving = true;
 | 
			
		||||
    const usuarioExtra = this.createFromForm();
 | 
			
		||||
    if (usuarioExtra.id !== undefined) {
 | 
			
		||||
      this.subscribeToSaveResponse(this.usuarioExtraService.update(usuarioExtra));
 | 
			
		||||
    } else {
 | 
			
		||||
      this.subscribeToSaveResponse(this.usuarioExtraService.create(usuarioExtra));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    console.log(usuarioExtra.iconoPerfil);
 | 
			
		||||
    console.log(usuarioExtra.fechaNacimiento);
 | 
			
		||||
 | 
			
		||||
    this.subscribeToSaveResponse(this.usuarioExtraService.update(usuarioExtra));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  trackUserById(index: number, item: IUser): number {
 | 
			
		||||
| 
						 | 
				
			
			@ -151,10 +154,15 @@ export class SettingsComponent implements OnInit {
 | 
			
		|||
 | 
			
		||||
  protected subscribeToSaveResponse(result: Observable<HttpResponse<IUsuarioExtra>>): void {
 | 
			
		||||
    result.pipe(finalize(() => this.onSaveFinalize())).subscribe(
 | 
			
		||||
      () => this.onSaveSuccess(),
 | 
			
		||||
      () => this.onSaveError()
 | 
			
		||||
      () => (this.success = true),
 | 
			
		||||
      response => this.processError(response)
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
  processError(response: HttpErrorResponse): void {
 | 
			
		||||
    if (response.status === 400) {
 | 
			
		||||
      this.error = true;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  protected onSaveSuccess(): void {
 | 
			
		||||
    this.previousState();
 | 
			
		||||
| 
						 | 
				
			
			@ -182,7 +190,7 @@ export class SettingsComponent implements OnInit {
 | 
			
		|||
    });
 | 
			
		||||
 | 
			
		||||
    // Update swiper
 | 
			
		||||
    this.profileIcon = parseInt(usuarioExtra.iconoPerfil!);
 | 
			
		||||
    this.profileIcon = usuarioExtra.iconoPerfil!;
 | 
			
		||||
    this.profileIcons.forEach(icon => {
 | 
			
		||||
      if (parseInt(icon.name.split('C')[1]) === this.profileIcon) {
 | 
			
		||||
        icon.class = 'active';
 | 
			
		||||
| 
						 | 
				
			
			@ -219,7 +227,7 @@ export class SettingsComponent implements OnInit {
 | 
			
		|||
      ...new UsuarioExtra(),
 | 
			
		||||
      id: this.editForm.get(['id'])!.value,
 | 
			
		||||
      nombre: this.editForm.get(['nombre'])!.value,
 | 
			
		||||
      iconoPerfil: this.editForm.get(['iconoPerfil'])!.value,
 | 
			
		||||
      iconoPerfil: this.profileIcon,
 | 
			
		||||
      fechaNacimiento: this.editForm.get(['fechaNacimiento'])!.value
 | 
			
		||||
        ? dayjs(this.editForm.get(['fechaNacimiento'])!.value, DATE_TIME_FORMAT)
 | 
			
		||||
        : undefined,
 | 
			
		||||
| 
						 | 
				
			
			@ -234,6 +242,8 @@ export class SettingsComponent implements OnInit {
 | 
			
		|||
      document.querySelectorAll('.active').forEach(e => e.classList.remove('active'));
 | 
			
		||||
      event.target.classList.add('active');
 | 
			
		||||
      this.profileIcon = +event.target.getAttribute('id')! + 1;
 | 
			
		||||
 | 
			
		||||
      console.log(this.profileIcon);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -8,7 +8,7 @@ import { EstadoUsuario } from 'app/entities/enumerations/estado-usuario.model';
 | 
			
		|||
export interface IUsuarioExtra {
 | 
			
		||||
  id?: number;
 | 
			
		||||
  nombre?: string;
 | 
			
		||||
  iconoPerfil?: string | null;
 | 
			
		||||
  iconoPerfil?: number | null;
 | 
			
		||||
  fechaNacimiento?: dayjs.Dayjs | null;
 | 
			
		||||
  estado?: EstadoUsuario;
 | 
			
		||||
  user?: IUser | null;
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +21,7 @@ export class UsuarioExtra implements IUsuarioExtra {
 | 
			
		|||
  constructor(
 | 
			
		||||
    public id?: number,
 | 
			
		||||
    public nombre?: string,
 | 
			
		||||
    public iconoPerfil?: string | null,
 | 
			
		||||
    public iconoPerfil?: number | null,
 | 
			
		||||
    public fechaNacimiento?: dayjs.Dayjs | null,
 | 
			
		||||
    public estado?: EstadoUsuario,
 | 
			
		||||
    public user?: IUser | null,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -65,7 +65,8 @@
 | 
			
		|||
        "authenticated": {
 | 
			
		||||
          "prefix": "Si desea ",
 | 
			
		||||
          "link": "iniciar sesión",
 | 
			
		||||
          "suffix": ", puede intentar con las cuentas predeterminadas:<br/>- Administrador (usuario=\"admin\" y contraseña=\"admin\") <br/>- Usuario (usuario=\"user\" y contraseña=\"user\")."
 | 
			
		||||
          "suffix": ", puede intentar con las cuentas predeterminadas:<br/>- Administrador (usuario=\"admin\" y contraseña=\"admin\") <br/>- Usuario (usuario=\"user\" y contraseña=\"user\").",
 | 
			
		||||
          "updateForm": "Ocurrió un error al actualizar su información, favor revisar los campos e intentar de nuevo"
 | 
			
		||||
        },
 | 
			
		||||
        "register": {
 | 
			
		||||
          "noaccount": "¿Aún no tienes una cuenta?",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue