Skip to content

Commit

Permalink
Merge pull request #44 from IrvingCM123/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
IrvingCM123 authored May 24, 2023
2 parents 89772e0 + f1b272d commit ab0a36d
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 55 deletions.
1 change: 1 addition & 0 deletions src/app/Views/UI/inicio/Datos.Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class DatosService {
}

getNrc() {
console.log('get', this.datos_locales.obtener_DatoLocal('NRC'))
return this.datos_locales.obtener_DatoLocal('NRC');
}

Expand Down
3 changes: 1 addition & 2 deletions src/app/Views/UI/inicio/inicio.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

<h1 class="Titulo_Inicio"> Materias del docente</h1>


<article class="Contenedor_Materias row row-cols-1 row-cols-md-2 " style="column-gap: 15px; row-gap: 15px;">
<div class="card" *ngFor="let materia of Materias; let i = index ">
<div class="banner">
Expand All @@ -12,7 +11,7 @@ <h2 *ngIf="!datos?.title" class="name"> {{materia.nombre_materia}} </h2>
<div class="actions">
<div class="follow-info">
<h2><p ><span *ngIf="!datos?.title"> {{materia.grupo_materia}} </span><small>Grupo</small></p></h2>
<h2><p><span *ngIf="!datos?.title"> {{materia.alumnos_materia}} </span><small>Estudiantes</small></p></h2>
<h2><p><span *ngIf="!datos?.title"> {{cantidad_alumnos[i]}} </span><small>Estudiantes</small></p></h2>
</div>
<div class="follow-btn">
<button (click)="enviarDato(materia.nrc_materia, materia.carrera_materia)" routerLink="Listas">Lista Asistencia</button>
Expand Down
35 changes: 26 additions & 9 deletions src/app/Views/UI/inicio/inicio.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,42 @@ import { FirestoreService } from '../listas/FirestoreListas.service';
@Component({
selector: 'app-inicio',
templateUrl: './inicio.component.html',
styleUrls: ['./inicio.component.scss']
styleUrls: ['./inicio.component.scss'],
})
export class InicioComponent implements OnInit {

public Materias : Array <any> = [];
public Materias: Array<any> = [];
public cantidad_alumnos: any[] = [];

constructor( private _getMateriasCasosUso : GetMateriaUseCase, private obtenerDato: DatosService) { }
response$ :any ;
datos: any ;
dato:number = 0;
constructor(
private _getMateriasCasosUso: GetMateriaUseCase,
private obtenerDato: DatosService,
private datos_Locales: FirestoreService
) {}
response$: any;
datos: any;
dato: number = 0;

ngOnInit(): void {
async ngOnInit() {
this.response$ = this._getMateriasCasosUso.getMateriasAll();
this.response$.subscribe( (Resp: any) => { this.Materias = Resp } )

this.response$.subscribe(async (Resp: any) => {
this.Materias = Resp;
this.obtener_cantidadEstudiantes();
});
}

async obtener_cantidadEstudiantes() {
let nrc: string[] | any = this.Materias.map( (materia: any) => materia.nrc_materia );
let carrera: string[] | any = this.Materias.map( (materia: any) => materia.carrera_materia );

for (let a = 0; a <= nrc.length - 1; a++) {
this.cantidad_alumnos[a] = await this.datos_Locales.getCantidadEstudiantes(nrc[a], carrera[a]);
}
}

enviarDato(nrc: any, carrera: any) {
this.obtenerDato.setCarrera(carrera);
this.obtenerDato.setNrc(nrc);
}

}
27 changes: 27 additions & 0 deletions src/app/Views/UI/listado/listado.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="table-container">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Matricula</th>
<th>Nombre</th>
<th>Estado</th>
<th>Hora</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let alumno_recibido of listaAsistencia; let i = index">
<tr class="Datos" >
<th scope="row">{{ i + 1 }}</th>
<td>{{ alumno_recibido.Matricula }}</td>
<td>{{ alumno_recibido.Nombre }}</td>
<td>{{ alumno_recibido.Estado }}</td>
<td>{{ alumno_recibido.Hora }}</td>
</tr>
</ng-container>
</tbody>
</table>
</div>



9 changes: 9 additions & 0 deletions src/app/Views/UI/listado/listado.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ td,
th {
width: 25%;
}


.Datos td{
color: black;
font-weight: 800;
font-style: italic;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
font-size: 17px;
}
71 changes: 30 additions & 41 deletions src/app/Views/UI/listado/listado.component.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,45 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/compat/firestore';
import { Observable, Subscription } from 'rxjs';
import { Component, Inject, OnInit } from '@angular/core';
import { FirestoreService } from '../listas/FirestoreListas.service';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { DatosService } from '../inicio/Datos.Service';


interface Dato {
id?: string;
Hora: string;
export interface Estructura {
Matricula: string;
Nombre: string;
Status: string;
Estado: string;
Hora: string;
}

@Component({
selector: 'app-listado',
templateUrl: './listado.component.html',
styleUrls: ['./listado.component.scss']
styleUrls: ['./listado.component.scss'],
})
export class ListadoComponent implements OnInit, OnDestroy {
NRC: any;
datos: Dato[] = [];
datosCollection: AngularFirestoreCollection<Dato> | undefined;
subscription: Subscription = new Subscription();
datosCargados = false;
items: any[] = [];

dia: number;
mes: number;
anio: number;
fechaFormateada: string;

constructor(readonly afs: AngularFirestore, private recibirDato: DatosService,) {
const fechaActual = new Date();
this.dia = fechaActual.getDate();
this.mes = fechaActual.getMonth() + 1;
this.anio = fechaActual.getFullYear();
this.fechaFormateada = `${this.anio}-${this.mes}-${this.dia}`;
console.log(this.fechaFormateada)
export class ListadoComponent implements OnInit {
mostrarLista: Estructura[] = [];
listaAsistencia: any = [];
nrcMateria: string = '';
carrera: string = '';
datosCargados: boolean = false;
fechaCompleta: string;

constructor(
private firestoreService: FirestoreService,
private datos: DatosService
) {
this.carrera = datos.getCarrera();
this.nrcMateria = datos.getNrc();

let fecha = new Date();
let dia = fecha.getDate();
let mes = fecha.getMonth() + 1;
let año = fecha.getFullYear();
this.fechaCompleta = año + ':' + mes + ':' + dia;
}


ngOnInit(): void {
console.log(this.NRC)
const ruta = this.fechaFormateada;
this.datosCollection = this.afs.collection<Dato>('JorgeDiaz/Sistemas en red/' + ruta);
this.subscription.add(this.datosCollection.valueChanges().subscribe((datos: Dato[]) => {
this.datos = datos;
this.datosCargados = true;
}));
async ngOnInit() {
this.listaAsistencia = await this.firestoreService.getDatosLeidos(this.nrcMateria, this.fechaCompleta);
console.log('aa', this.listaAsistencia)
}

ngOnDestroy(): void {
this.subscription.unsubscribe();
}
}
30 changes: 30 additions & 0 deletions src/app/Views/UI/listas/FirestoreListas.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class FirestoreService {

private almacenar_NRC = new Subject<any>();
private almacenar_Carrera = new Subject<any>();
private almacenarDatosQRObservable = new Subject<any>();

constructor(
private firestore: AngularFirestore
Expand Down Expand Up @@ -44,4 +45,33 @@ export class FirestoreService {
}
}

async getCantidadEstudiantes(nrc: string, carrera: string) {
let url = '/' + carrera + '/Materias/' + nrc;
const lista_encontrada = await this.firestore.collection(url).get().toPromise();

if (lista_encontrada) {
const datos_lista = lista_encontrada.docs.map((alumnos) => alumnos.data());
let contador = datos_lista.length;
return contador;
} else {
console.log('No se pudo obtener la información de Firestore.');
return [];
}
}

async getDatosLeidos(nrc: string, dia:any) {
let url = '/Registro/Asistencia/' + nrc + '/' + dia + '/Alumnos'
console.log(dia)
const obtener_datos = await this.firestore.collection(url).get().toPromise();

if (obtener_datos) {
const datos_leidos = obtener_datos.docs.map((datos) => datos.data());
console.log(datos_leidos)
return datos_leidos;
} else {
console.log('No se pudo obtener la información de Firestore.');
return [];
}
}

}
5 changes: 3 additions & 2 deletions src/app/Views/UI/listas/listas.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { DatosService } from '../inicio/Datos.Service';
import { FirestoreService } from './FirestoreListas.service';
import { DatosServicel } from './DatosServiceL.Service';

interface Dato {
id?: string;
Expand All @@ -21,14 +22,14 @@ export class Listas implements OnInit {

constructor(
private firestoreService: FirestoreService,
private datos: DatosService
private datos: DatosService,
) {
this.carrera = datos.getCarrera();
this.nrcMateria = datos.getNrc();
}

async ngOnInit() {
console.log(this.nrcMateria)
console.log(this.nrcMateria, this.carrera)
this.listaAsistencia = await this.firestoreService.getListaAsistencia(
this.nrcMateria,
this.carrera
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<Main id="Contenedor">

<Article id="Navegacion">
<Article id="Navegacion" >
<app-menu> </app-menu>
</Article>

Expand Down
4 changes: 4 additions & 0 deletions src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ body {
background-attachment: fixed;
}

.imagen {
opacity: 0.5;
}

#Contenedor {
position: relative;
display: grid;
Expand Down

0 comments on commit ab0a36d

Please sign in to comment.