-
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
1 parent
cbb3407
commit c8c4ad3
Showing
16 changed files
with
439 additions
and
21 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
<div class="fondo-negro animated fadeIn fast" [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</h5> | ||
<button type="button" class="close" aria-label="Close" (click)="cerrarModal()"> | ||
<span aria-hidden>×</span> | ||
</button> | ||
|
||
</div> | ||
|
||
<div class="modal-body text-center"> | ||
<div> | ||
<img *ngIf="!imagenTemp" [src]="'xxx' | imagen" class="w150"> | ||
<img *ngIf="imagenTemp" [src]="imagenTemp" class="w150"> | ||
</div> | ||
<br> | ||
|
||
<input type="file" | ||
(change)="seleccionImagen($event.target.files[0])"> | ||
</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,66 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Usuario } from '../../models/usuario.model'; | ||
import swal from 'sweetalert'; | ||
import { SubirArchivoService } from '../../services/subir-archivo/subir-archivo.service'; | ||
import { ModalUploadService } from './modal-upload.service'; | ||
|
||
@Component({ | ||
selector: 'app-modal-upload', | ||
templateUrl: './modal-upload.component.html', | ||
styles: [ | ||
] | ||
}) | ||
export class ModalUploadComponent implements OnInit { | ||
|
||
|
||
imagenTemp: any; | ||
public usuario: Usuario; | ||
imagenSubir: File; | ||
|
||
constructor(public _subirArchivoService: SubirArchivoService, | ||
public _modalUploadService: ModalUploadService) { } | ||
|
||
ngOnInit(): void { | ||
} | ||
|
||
cerrarModal(){ | ||
this.imagenTemp = null; | ||
this.imagenSubir = null; | ||
this._modalUploadService.ocultarModal(); | ||
} | ||
|
||
subirImagen(){ | ||
this._subirArchivoService.subirArchivo(this.imagenSubir, this._modalUploadService.tipo, this._modalUploadService.id) | ||
.then( resp => { | ||
//console.log(resp); | ||
this._modalUploadService.notificacion.emit(resp); | ||
this.cerrarModal(); | ||
swal('Excelente','Imagen subida exitosamente', 'success'); | ||
}) | ||
.catch( err => { | ||
console.log('Error en la carga...'); | ||
}); | ||
} | ||
|
||
seleccionImagen(archivo: File){ | ||
|
||
if (!archivo) { | ||
this.imagenSubir = null; | ||
return; | ||
} | ||
|
||
if (archivo.type.indexOf('image') < 0) { | ||
swal('Sólo imágenes', 'El archivo seleccionado no es una imagen', 'error'); | ||
this.imagenSubir = null; | ||
return; | ||
} | ||
|
||
this.imagenSubir = archivo; | ||
|
||
let reader = new FileReader(); | ||
let urlImagenTemp = reader.readAsDataURL(archivo); | ||
reader.onloadend = () => this.imagenTemp = reader.result; | ||
|
||
} | ||
|
||
} |
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,27 @@ | ||
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() { } | ||
|
||
ocultarModal(){ | ||
this.oculto = 'oculto'; | ||
this.id = null; | ||
this.tipo = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,9 @@ | |
|
||
</div> | ||
|
||
<!-- Modal Uplod--> | ||
<app-modal-upload></app-modal-upload> | ||
|
||
|
||
|
||
|
||
|
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,94 @@ | ||
<div class="row animated fadeIn fast"> | ||
<div class="col-12"> | ||
<div class="card"> | ||
<div class="card-body"> | ||
|
||
<input type="text" | ||
class="form-control" | ||
placeholder="Buscar usuario..." | ||
(keyup)="buscarUsuario(txtTermino.value)" | ||
#txtTermino/> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="row animated fadeIn fast" *ngIf="cargando"> | ||
<div class="col-sm-12"> | ||
|
||
<div class="alert alert-warning text-center"> | ||
<strong>Cargando</strong> | ||
<br> | ||
<i class="fa fa-spin fa-refresh fa-2x"></i> | ||
<br> | ||
<p class="">Por favor espere</p> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
|
||
<div class="row animated fadeIn fast" *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 class="text-center">Imagen</th> | ||
<th class="text-center">Correo</th> | ||
<th class="text-center">Nombre</th> | ||
<th class="text-center">Role</th> | ||
<!--<th>Auth</th>--> | ||
<th class="text-center">Opciones</th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<tr *ngFor="let usuario of usuarios"> | ||
<th class="w70"> | ||
<img (click)="mostarModal(usuario._id)" [src]="usuario.img | imagen" class="img-50 img-circle pointer"> | ||
</th> | ||
<th class="text-center">{{usuario.email}}</th> | ||
<th class="text-center">{{usuario.nombre}}</th> | ||
<!--<th class="text-center">{{usuario.role}}</th>--> | ||
<th> | ||
<select class="form-control" [(ngModel)]="usuario.role"> | ||
<option value="ADMIN_ROLE">ADMIN_ROLE</option> | ||
<option value="USER_ROLE">USER_ROLE</option> | ||
</select> | ||
</th> | ||
<!--<th> | ||
<label class="label label-danger">Google</label> | ||
<label class="label label-primary">Normal</label> | ||
</th>--> | ||
<th class="text-center"> | ||
<button class="btn btn-primary" (click)="modRoleUsuario(usuario)"> | ||
<i class="fa fa-save"></i> | ||
</button> | ||
|
||
<button (click)="borrarUsuario(usuario)" style="margin-left: 5px" class="btn btn-danger"> | ||
<i class="fa fa-trash-o"></i> | ||
</button> | ||
|
||
</th> | ||
</tr> | ||
</tbody> | ||
|
||
</table> | ||
|
||
<div class="btn btn-success" (click)="cambiarDesde(-5)"> | ||
Anteriores | ||
</div> | ||
|
||
<div class="btn btn-success" (click)="cambiarDesde(5)" style="margin-left: 5px"> | ||
Siguientes | ||
</div> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.