Skip to content

Commit

Permalink
Administracion concluida
Browse files Browse the repository at this point in the history
  • Loading branch information
jorge1301 committed Jan 23, 2020
1 parent 6d77b4d commit 11c76cb
Show file tree
Hide file tree
Showing 41 changed files with 1,106 additions and 135 deletions.
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"ag-grid-angular": "^22.1.1",
"ag-grid-community": "^22.1.1",
"ng2-pdf-viewer": "^6.0.2",
"ngx-bootstrap": "^5.3.2",
"ngx-editor": "^4.1.0",
Expand Down
14 changes: 11 additions & 3 deletions src/app/administracion/administracion.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ import { PortafolioFormularioComponent } from './portafolio/portafolio-formulari
import { PortafolioCursosFormularioComponent } from './portafolio-cursos/portafolio-cursos-formulario.component';
import { NgxEditorModule } from 'ngx-editor';
import { PdfViewerModule } from 'ng2-pdf-viewer';
import { AgGridModule } from 'ag-grid-angular';
import { ProgramacionComponent } from './programacion/programacion.component';
import { EstiloCeldaAgridComponent } from './estilo-celda-agrid/estilo-celda-agrid.component';

@NgModule({
declarations: [
Expand All @@ -46,7 +49,9 @@ import { PdfViewerModule } from 'ng2-pdf-viewer';
GaleriaFormularioComponent,
InternacionalFormularioComponent,
PortafolioFormularioComponent,
PortafolioCursosFormularioComponent
PortafolioCursosFormularioComponent,
ProgramacionComponent,
EstiloCeldaAgridComponent
],
imports: [
SharedModule,
Expand All @@ -56,7 +61,8 @@ import { PdfViewerModule } from 'ng2-pdf-viewer';
CommonModule,
ReactiveFormsModule,
NgxEditorModule,
PdfViewerModule
PdfViewerModule,
AgGridModule.withComponents([EstiloCeldaAgridComponent])
],
exports: [
PortafolioComponent,
Expand All @@ -66,7 +72,9 @@ import { PdfViewerModule } from 'ng2-pdf-viewer';
InternacionalComponent,
CertificadosComponent,
AccountSettingsComponent,
PortafolioCursosComponent
PortafolioCursosComponent,
ProgramacionComponent,
EstiloCeldaAgridComponent
]
})

Expand Down
4 changes: 3 additions & 1 deletion src/app/administracion/administracion.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { InternacionalFormularioComponent } from './internacional/internacional-
import { PortafolioFormularioComponent } from './portafolio/portafolio-formulario.component';
import { CertificadoFormularioComponent } from './certificados/certificado-formulario.component';
import { PortafolioCursosFormularioComponent } from './portafolio-cursos/portafolio-cursos-formulario.component';
import { ProgramacionComponent } from './programacion/programacion.component';


const routes: Routes = [{
Expand All @@ -39,7 +40,8 @@ const routes: Routes = [{
{ path: 'account-settings', component: AccountSettingsComponent, data: { titulo: 'Ajustes del Tema' }},
{ path: 'perfil', component: ProfileComponent, data: { titulo: 'Perfil de usuario' } },
{ path: 'portafolio-cursos', component: PortafolioCursosComponent, data: { titulo: 'Cursos del Portafolio' } },
{ path: 'portafolio-cursos/:id', component: PortafolioCursosFormularioComponent, data: { titulo: 'Cursos del Portafolio' } }
{ path: 'portafolio-cursos/:id', component: PortafolioCursosFormularioComponent, data: { titulo: 'Cursos del Portafolio' } },
{ path: 'programacion', component: ProgramacionComponent, data: { titulo: 'Programacion de cursos' } }
]
}];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h4 class="card-title">Crear Agencia</h4>
<div class="col-lg-5 col-md-5">
<div class="card">
<div class="card-body" align="center">
<h4 class="card-title">Fotografía del usuario</h4>
<h4 class="card-title">Imagen de la agencia</h4>
<img *ngIf="!imagenTemporal" [src]="agencia.imagen| imagen:'agencias'" class="w150">
<img *ngIf="imagenTemporal" [src]="imagenTemporal" class="w150">
<input (change)="seleccionarImagen($event.target.files[0])" type="file" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,80 @@
<p>avanzado-formulario works!</p>
<div class="row">
<div class="col-lg-7">
<div class="card">
<div class="card-body">
<h4 class="card-title">Crear Agencia</h4>
<form ngNativeValidate #formulario="ngForm" (ngSubmit)="crearCursoAvanzado(formulario)"
class="form p-t-20">
<div class="form-group">
<label for="exampleInputuname">Titulo</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="titulo"
[(ngModel)]="avanzado.titulo" [placeholder]="'Ingrese el titulo aqui....'"
[spellcheck]="true" required></app-ngx-editor>
</div>
<div class="form-group">
<label for="exampleInputuname">Direccion</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="direccion"
[(ngModel)]="avanzado.direccion" [placeholder]="'Ingrese la dirección aqui....'"
[spellcheck]="true" required></app-ngx-editor>
</div>
<div class="form-group">
<label for="exampleInputuname">Fecha</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="fecha"
[(ngModel)]="avanzado.fecha" [placeholder]="'Ingrese la fecha aqui....'"
[spellcheck]="true" required></app-ngx-editor>
</div>
<div class="form-group">
<label for="exampleInputuname">Descripción</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="descripcion"
[(ngModel)]="avanzado.descripcion" [placeholder]="'Ingrese la descripción aqui....'"
[spellcheck]="true" required></app-ngx-editor>
</div>
<div class="form-group">
<label for="exampleInputuname">Requisitos</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="requisitos"
[(ngModel)]="avanzado.requisitos" [placeholder]="'Ingrese los requisitos aqui....'"
[spellcheck]="true" required></app-ngx-editor>
</div>
<div class="form-group">
<label for="exampleInputuname">Proposito</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="proposito"
[(ngModel)]="avanzado.proposito" [placeholder]="'Ingrese el proposito aqui....'"
[spellcheck]="true" required></app-ngx-editor>
</div>
<div class="form-group">
<label for="exampleInputuname">Metodología</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="metodologia" [(ngModel)]="avanzado.metodologia"
[placeholder]="'Ingrese la metodología aqui....'" [spellcheck]="true" required></app-ngx-editor>
</div>
<div class="form-group">
<label for="exampleInputuname">Valor</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="valor" [(ngModel)]="avanzado.valor"
[placeholder]="'Ingrese el valor aqui....'" [spellcheck]="true" required></app-ngx-editor>
</div>
<div class="form-group">
<label for="exampleInputuname">Incluye</label>
<app-ngx-editor ngNativeValidate [config]="configuraciones" name="incluye" [(ngModel)]="avanzado.incluye"
[placeholder]="'Ingrese lo que se incluye aqui....'" [spellcheck]="true" required></app-ngx-editor>
</div>
<button type="submit" class="btn btn-success waves-effect waves-light m-r-10">
<i class="fa fa-save"></i>
Guardar</button>
<a routerLink="/avanzado" class="btn btn-inverse waves-effect waves-light m-r-10">
<i class="fa fa-times"></i>
Cancelar</a>
</form>
</div>
</div>
</div>
<div class="col-lg-5 col-md-5">
<div class="card">
<div class="card-body" align="center">
<h4 class="card-title">Imagen del curso avanzado</h4>
<img *ngIf="!imagenTemporal" [src]="avanzado.imagen| imagen:'avanzados'" class="w150">
<img *ngIf="imagenTemporal" [src]="imagenTemporal" class="w150">
<input style="font-family: 'Times New Roman', Times, serif;"
(change)="seleccionarImagen($event.target.files[0])" type="file" />
</div>
</div>
</div>
</div>
66 changes: 65 additions & 1 deletion src/app/administracion/avanzado/avanzado-formulario.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,79 @@
import { Component, OnInit } from '@angular/core';
import { CursoAvanzado } from '../../models/cursoAvanzado.model';
import { CursoAvanzadoService } from '../../services/service.index';
import Swal from 'sweetalert2';
import { NgForm } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
import { configuracion } from '../../config/editor';

@Component({
selector: 'app-avanzado-formulario',
templateUrl: './avanzado-formulario.component.html',
styles: []
})
export class AvanzadoFormularioComponent implements OnInit {
avanzado: CursoAvanzado = new CursoAvanzado();
imagenSubir: File;
imagenTemporal: string | ArrayBuffer;
configuraciones = configuracion;
id: string;

constructor() { }
constructor(
public avanzadoService: CursoAvanzadoService,
public router: Router,
public activatedRoute: ActivatedRoute
) {
activatedRoute.params.subscribe(params => {
this.id = params.id;
if (this.id !== 'nuevo') {
this.buscarInformacion(this.id);
}
});
}

ngOnInit() {
}

seleccionarImagen(archivo: File) {
if (!archivo) {
this.imagenSubir = null;
return;
}
if (archivo.type.indexOf('image') < 0) {
Swal.fire('Solo imagenes', 'El archivo seleccionado no es una imagen', 'error');
this.imagenSubir = null;
return;
}
this.imagenSubir = archivo;
const reader = new FileReader();
const urlImagenTemp = reader.readAsDataURL(archivo);
reader.onloadend = () => this.imagenTemporal = reader.result;
}

crearCursoAvanzado(formulario: NgForm) {
if (formulario.invalid) {
return;
}
const programacion = this.avanzado.programacion;
this.avanzado = formulario.value;
this.avanzado._id = this.id;
this.avanzado.programacion = programacion;
const formData = new FormData();
if (this.imagenSubir) {
formData.append('imagen', this.imagenSubir, this.imagenSubir.name);
}
this.avanzadoService.crearCursosAvanzados(formData, this.avanzado)
.subscribe(() => {
this.router.navigate(['/avanzado']);
}
);
}

buscarInformacion(id) {
this.avanzadoService.buscarCursoAvanzadoId(id)
.subscribe((avanzado) => {
this.avanzado = avanzado;
});
}

}
18 changes: 12 additions & 6 deletions src/app/administracion/avanzado/avanzado.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<div class="card">
<div class="card-body">
<div class="text-right">
<button type="button" class="btn waves-effect waves-light btn-rounded btn-primary"> <i class="fa fa-plus"></i>
<button [routerLink]="['/avanzado','nuevo']" type="button" class="btn waves-effect waves-light btn-rounded btn-primary"> <i class="fa fa-plus"></i>
Crear Curso Avanzado
</button>
</div>
Expand All @@ -42,15 +42,21 @@ <h3 class="card-title"> Cursos avanzados registrados (<small>{{totalRegistros}}<
<td class="w70">
<img [src]="avanzado.imagen | imagen: 'avanzados'" class="img-50 img-circle">
</td>
<td>{{avanzado.titulo}}</td>
<td>{{avanzado.direccion}}</td>
<td>{{avanzado.fecha}}</td>
<td>
<div [innerHTML]="avanzado.titulo | domSeguro"></div>
</td>
<td>
<div [innerHTML]="avanzado.direccion | domSeguro"></div>
</td>
<td>
<div [innerHTML]="avanzado.fecha | domSeguro"></div>
</td>
<td>
<div class="d-flex justify-content-sm-end">
<button class="btn btn-primary mr-1">
<button [routerLink]="['/avanzado', avanzado._id]" class="btn btn-primary mr-1">
<i class="fa fa-edit"></i>
</button>
<button (click)="eliminarCurso()" class="btn btn-danger mr-1">
<button (click)="eliminarCurso(avanzado)" class="btn btn-danger mr-1">
<i class="fa fa-trash-o"></i>
</button>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/app/administracion/avanzado/avanzado.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export class AvanzadoComponent implements OnInit {
this.avanzadoService.eliminarCursoAvanzado(avanzado._id)
.subscribe((resp: any) => {
Swal.fire('Curso eliminado', 'El curso avanzado a sido eliminado correctamente', 'success');
this.totalRegistros--;
if (this.desde === this.totalRegistros) {
this.desde -= 5;
}
this.cargarCursos();
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div [innerHTML]="cellValue | domSeguro"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component, OnInit } from '@angular/core';
import { ICellRendererAngularComp } from 'ag-grid-angular';

@Component({
selector: 'app-estilo-celda-agrid',
templateUrl: './estilo-celda-agrid.component.html',
styles: []
})
export class EstiloCeldaAgridComponent implements OnInit, ICellRendererAngularComp {
public cellValue: any;
constructor() { }

ngOnInit() {
}

agInit(params: any) {
this.cellValue = params.value;
}

refresh(params: any): boolean {
this.cellValue = params.value;
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h4 class="card-title">Crear Agencia</h4>
<div class="col-lg-5 col-md-5">
<div class="card">
<div class="card-body" align="center">
<h4 class="card-title">Fotografía del usuario</h4>
<h4 class="card-title">Imagen de la galeria</h4>
<img *ngIf="!imagenTemporal" [src]="galeria.imagen| imagen:'galerias'" class="w150">
<img *ngIf="imagenTemporal" [src]="imagenTemporal" class="w150">
<input (change)="seleccionarImagen($event.target.files[0])" type="file" />
Expand Down
Loading

0 comments on commit 11c76cb

Please sign in to comment.