-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
482 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/app/components/modal-upload/modal-upload.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<div class="fondo-negro animated fadeIn" [ngClass]="_modalUploadService.oculto" > | ||
|
||
<div class="modal" style="display: block" tabindex="-1" role="dialog"> | ||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content"> | ||
<div class="modal-header"> | ||
<h5 class="modal-title">Modal title</h5> | ||
<button | ||
(click)="cerrarModal()" | ||
type="button" | ||
class="close" | ||
aria-label="Close" | ||
> | ||
<span aria-hidden="true">×</span> | ||
</button> | ||
</div> | ||
<div class="modal-body text-center"> | ||
|
||
|
||
<img *ngIf="!imagenTemp" [src]=" 'xxx' | imagen" class="w150"> | ||
<img *ngIf="imagenTemp" [src]="imagenTemp" class="w150"> | ||
|
||
<input (change)="seleccionImage( $event.target.files[0] )" type="file"> | ||
|
||
|
||
|
||
</div> | ||
<div class="modal-footer"> | ||
<button (click)="subirImagen()" [disabled]="!imagenTemp" type="button" class="btn btn-primary">Subir imagen</button> | ||
<button (click)="cerrarModal()" type="button" class="btn btn-secondary" >Cerrar</button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { SubirArchivoService } from 'src/app/services/service.index'; | ||
|
||
import { ModalUploadService } from './modal-upload.service'; | ||
|
||
import Swal from 'sweetalert2' | ||
|
||
@Component({ | ||
selector: 'app-modal-upload', | ||
templateUrl: './modal-upload.component.html', | ||
styles: [] | ||
}) | ||
export class ModalUploadComponent implements OnInit { | ||
|
||
imagenSubir: File; | ||
imagenTemp: any; | ||
|
||
constructor( | ||
public _subirArchivoService: SubirArchivoService, | ||
public _modalUploadService: ModalUploadService | ||
) { | ||
// console.log('Modal Listo'); | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
|
||
|
||
cerrarModal() { | ||
this.imagenTemp = null; | ||
this.imagenSubir = null; | ||
|
||
this._modalUploadService.ocultarModal(); | ||
} | ||
|
||
|
||
seleccionImage(archivo: File) { | ||
|
||
if (!archivo) { | ||
this.imagenSubir = null; | ||
return; | ||
} | ||
// console.log( event ); | ||
|
||
if (archivo.type.indexOf('image') < 0) { | ||
Swal.fire({ | ||
title: 'Sólo imágenes!', | ||
text: 'El archivo seleccionado no es una imagen', | ||
type: 'error', | ||
confirmButtonText: 'Ok' | ||
}); | ||
this.imagenSubir = null; | ||
return; | ||
} | ||
|
||
this.imagenSubir = archivo; | ||
|
||
let reader = new FileReader(); | ||
let urlImagenTemp = reader.readAsDataURL(archivo); | ||
|
||
reader.onloadend = () => this.imagenTemp = reader.result; | ||
|
||
} | ||
|
||
subirImagen() { | ||
|
||
this._subirArchivoService.subirArchivo( this.imagenSubir, this._modalUploadService.tipo, this._modalUploadService.id ) | ||
.then( resp => { | ||
|
||
// console.log( resp ); | ||
this._modalUploadService.notificacion.emit( resp ); | ||
// this._modalUploadService.ocultarModal(); | ||
this.cerrarModal(); | ||
} ) | ||
.catch( err => { | ||
console.log('Error en la carga...'); | ||
} ); | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Injectable, EventEmitter } from '@angular/core'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ModalUploadService { | ||
|
||
public tipo: string; | ||
public id: string; | ||
|
||
public oculto: string = 'oculto'; | ||
|
||
public notificacion = new EventEmitter<any>(); | ||
|
||
constructor() { | ||
console.log('Modal upload listo!'); | ||
} | ||
|
||
|
||
ocultarModal() { | ||
this.oculto = 'oculto'; | ||
this.tipo = null; | ||
this.id = null; | ||
} | ||
|
||
mostrarModal( tipo:string, id: string ) { | ||
this.oculto = ''; | ||
this.id = id; | ||
this.tipo = tipo; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<div class="row animated fadeIn"> | ||
<div class="col-12"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
<input | ||
#input | ||
(keyup)="buscarUsuario( input.value )" | ||
type="text" | ||
class="form-control" | ||
placeholder="Buscar Usuario..." | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row animated fadeIn" *ngIf="cargando"> | ||
<div class="col-sm-12"> | ||
<div class="alert alert-warning text-center"> | ||
<strong>Cargando</strong> | ||
<br /> | ||
<i class="fa fa-refresh fa-spin fa-2x"></i> | ||
<br /> | ||
<span>Espere por favor</span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
<div class="row animated fadeIn" *ngIf="!cargando"> | ||
<div class="col-12"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
|
||
<h3 class="card-title"> Usuarios registrados ( <small> {{ totalRegistros }} </small> ) </h3> | ||
|
||
<table class="table table-hover"> | ||
<thead> | ||
<tr> | ||
<th>Imagen</th> | ||
<th>Correo</th> | ||
<th>Nombre</th> | ||
<th>Role</th> | ||
<th>Auth</th> | ||
<th></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<tr *ngFor="let usuario of usuarios" > | ||
<td class="w70"> | ||
<img (click)="mostrarModal( usuario._id )" [src]="usuario.img | imagen" class ="img-50 img-circle pointer"> | ||
</td> | ||
<td> | ||
{{ usuario.email }} | ||
</td> | ||
<td> | ||
{{ usuario.nombre }} | ||
</td> | ||
<td> | ||
|
||
<select [(ngModel)]="usuario.role" name="role" class="form-control" > <!-- {{ usuario.role }} --> | ||
<option value="ADMIN_ROLE">ADMIN_ROLE</option> | ||
<option value="USER_ROLE">USER_ROLE</option> | ||
|
||
</select> | ||
</td> | ||
<td> | ||
<label *ngIf="usuario.google" class="label label-danger">Google</label> | ||
<label *ngIf="!usuario.google" class="label label-info">Normal</label> | ||
</td> | ||
<td> | ||
<button (click)="guardarUsuario( usuario )" class="btn btn-primary"> | ||
<i class="fa fa-save"></i> | ||
</button> | ||
|
||
<button (click)="borrarUsuario( usuario )" class="btn btn-danger"> | ||
<i class="fa fa-trash-o"></i> | ||
</button> | ||
|
||
</td> | ||
</tr> | ||
</tbody> | ||
|
||
</table> | ||
|
||
<button (click)="cambiarDesde(-5)" class="btn btn-secondary"> | ||
Anteriores | ||
</button> | ||
|
||
<button (click)="cambiarDesde(5)" class="btn btn-secondary"> | ||
Siguientes | ||
</button> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.