#38 MERGE | devAldrick -> develop

Спојено
AldrickChavarria споји(ла) 3 комит(е) из ITTEC/devAldrick у ITTEC/develop пре 2 недеља

+ 65 - 50
Front/src/app/modules/Administrador/pages/calendar/calendar.component.ts

@@ -161,44 +161,49 @@ export class ModalEvent implements OnInit, OnDestroy {
   public modoEdicion = !!this.data?.evento;
 
   ngOnInit(): void {
-    this.editor = new Editor();
-
-    if (this.data?.evento) {
-      const evento = this.data.evento;
-
-      this.form.patchValue({
-        titulo: evento.titulo,
-        fechaInicio: evento.fechaInicio ? evento.fechaInicio.split(' ')[0] : '',
-        fechaFin: evento.fechaFin ? evento.fechaFin.split(' ')[0] : '',
-        horaInicio: evento.fechaInicio ? evento.fechaInicio.split(' ')[1] : '',
-        horaFinal: evento.fechaFin ? evento.fechaFin.split(' ')[1] : '',
-        todoDia: evento.diaCompleto === 'Sí' || evento.diaCompleto === 'Si' || evento.diaCompleto === 'Yes',
-        categoria: evento.colorEvento,
-        contenido: evento.descripcion
-      });
+  this.editor = new Editor();
+
+  if (this.data?.evento) {
+    const evento = this.data.evento;
+
+    this.form.patchValue({
+      titulo: evento.titulo,
+      fechaInicio: evento.fechaInicio ? evento.fechaInicio.split(' ')[0] : '',
+      fechaFin: evento.fechaFin ? evento.fechaFin.split(' ')[0] : '',
+      horaInicio: evento.fechaInicio ? evento.fechaInicio.split(' ')[1] : '',
+      horaFinal: evento.fechaFin ? evento.fechaFin.split(' ')[1] : '',
+      todoDia: evento.diaCompleto === 'Sí' || evento.diaCompleto === 'Si' || evento.diaCompleto === 'Yes',
+      categoria: evento.colorEvento,
+      contenido: evento.descripcion
+    });
 
-      console.log(evento.fechaInicio.split(' ')[1]);
+    // 🔒 Deshabilitar los campos de audiencia y destino al editar
+    this.form.get('audiencia')?.disable();
+    this.form.get('destinos')?.disable();
 
-      // Si era todo el día, deshabilita campos
-      if (evento.diaCompleto === 'Si') {
-        this.form.get('fechaInicio')?.disable();
-        this.form.get('fechaFin')?.disable();
-        this.form.get('horaInicio')?.disable();
-        this.form.get('horaFinal')?.disable();
-      }
+    // Si era todo el día, deshabilita campos de fecha/hora
+    if (evento.diaCompleto === 'Si') {
+      this.form.get('fechaInicio')?.disable();
+      this.form.get('fechaFin')?.disable();
+      this.form.get('horaInicio')?.disable();
+      this.form.get('horaFinal')?.disable();
     }
+  }
 
-    // Escuchar cambios en el campo de audiencia
-    this.form.get('audiencia')?.valueChanges.subscribe((value) => {
+  // Escuchar cambios en el campo de audiencia (solo si no está deshabilitado)
+  this.form.get('audiencia')?.valueChanges.subscribe((value) => {
+    if (!this.form.get('audiencia')?.disabled) {
       if (value === 'TD') {
         this.form.get('destinos')?.disable();
-        this.form.get('destinos')?.setValue('todos'); // valor por defecto
+        this.form.get('destinos')?.setValue('todos');
       } else {
         this.form.get('destinos')?.enable();
-        this.form.get('destinos')?.setValue(''); 
+        this.form.get('destinos')?.setValue('');
       }
-    });
-  }
+    }
+  });
+}
+
 
   ngOnDestroy(): void {
     this.editor.destroy();
@@ -425,31 +430,41 @@ export class ModalEvent implements OnInit, OnDestroy {
   }
 
   actualizarEvento() {
-    const formattedFechaInicio = moment(this.form.value.fechaInicio).format("YYYY-MM-DD");
-    const formattedFechaFinal = moment(this.form.value.fechaFin).format("YYYY-MM-DD");
+  const formattedFechaInicio = moment(this.form.value.fechaInicio).format("YYYY-MM-DD");
+  const formattedFechaFinal = moment(this.form.value.fechaFin).format("YYYY-MM-DD");
 
-    const dataActualizada = {
-      idEvento: this.data.evento.idEvento,
-      ...this.form.value,
-      fechaInicio: `${formattedFechaInicio} ${this.form.value.horaInicio}`,
-      fechaFin: `${formattedFechaFinal} ${this.form.value.horaFinal}`,
-    };
-
-    Swal.fire({ title: 'Actualizando...', didOpen: () => Swal.showLoading() });
+  let horaInicio = this.form.value.horaInicio;
+  let horaFinal = this.form.value.horaFinal;
 
-    this.eventoService.actualizarEvento(dataActualizada).subscribe(
-      () => {
-        Swal.close();
-        Swal.fire('Actualizado', 'El evento se actualizó correctamente.', 'success');
-        this.dialogRef.close('refresh');
-      },
-      (error) => {
-        console.error(error);
-        Swal.fire('Error', 'No se pudo actualizar el evento.', 'error');
-      }
-    );
+  // Si es "todo el día", forzar las horas a rango completo
+  if (this.form.value.todoDia) {
+    horaInicio = '00:00:00';
+    horaFinal = '23:30:00';
   }
 
+  const dataActualizada = {
+    idEvento: this.data.evento.idEvento,
+    ...this.form.value,
+    fechaInicio: `${formattedFechaInicio} ${horaInicio}`,
+    fechaFin: `${formattedFechaFinal} ${horaFinal}`,
+  };
+
+  Swal.fire({ title: 'Actualizando...', didOpen: () => Swal.showLoading() });
+
+  this.eventoService.actualizarEvento(dataActualizada).subscribe(
+    () => {
+      Swal.close();
+      Swal.fire('Actualizado', 'El evento se actualizó correctamente.', 'success');
+      this.dialogRef.close('refresh');
+    },
+    (error) => {
+      console.error(error);
+      Swal.fire('Error', 'No se pudo actualizar el evento.', 'error');
+    }
+  );
+}
+
+
   guardarEvento(formattedData: any) {
     this.eventoService.crearEvento(formattedData).subscribe(
       (response: any) => {

+ 0 - 6
Front/src/app/modules/Administrador/pages/layout-page/layout-page.component.ts

@@ -225,14 +225,8 @@ export class LayoutPageComponent {
         confirmButtonColor: 'rgb(237,46,56)',
         confirmButtonText: 'Ok'
       }).then(() => {
-        this._authService.logout().subscribe(() => {
           localStorage.clear();
           this._router.navigate(['']); // ruta login explícita
-        }, () => {
-          // Incluso si falla el logout del backend, borra y navega
-          localStorage.clear();
-          this._router.navigate(['']);
-        });
       });
     });
     

+ 21 - 6
Front/src/app/modules/Alumno/pages/layout-page/layout-page.component.ts

@@ -7,6 +7,7 @@ import { Keepalive } from '@ng-idle/keepalive';
 import { MatDialog } from '@angular/material/dialog';
 import { Router } from '@angular/router';
 import Swal from 'sweetalert2';
+import { NavbarHomeComponent } from '../../../../shared/navbar-home/navbar-home.component';
 
 @Component({
   selector: 'app-layout-page',
@@ -35,6 +36,7 @@ export class LayoutPageComponent implements OnInit {
     private keepalive: Keepalive,
     public dialog: MatDialog,
     private _router: Router,
+    private navbarHome: NavbarHomeComponent
   ) { }
 
 
@@ -63,6 +65,25 @@ export class LayoutPageComponent implements OnInit {
 
     })
 
+    const expira = localStorage.getItem('expira');
+    if (expira) {
+      const expiraDate = new Date(parseInt(expira, 10));
+      const now = new Date();
+
+      if (now > expiraDate) {
+
+        console.log('La fecha de expiración ha pasado.');
+        Swal.fire({
+          icon: 'info',
+          title: 'Ha estado inactivo por mucho tiempo, por favor inicie sesión nuevamente.'
+        })
+        // this.navbarHome.actualizarActividad();
+        this.navbarHome.logout();
+      } else {
+        console.log('La fecha de expiración no ha pasado.');
+      }
+    }
+
     let userDataS = localStorage.getItem('userDataS');
     if (!userDataS) {
       // Configuración de idle
@@ -83,14 +104,8 @@ export class LayoutPageComponent implements OnInit {
           confirmButtonColor: 'rgb(237,46,56)',
           confirmButtonText: 'Ok'
         }).then(() => {
-          this._authService.logout().subscribe(() => {
             localStorage.clear();
             this._router.navigate(['']); // ruta login explícita
-          }, () => {
-            // Incluso si falla el logout del backend, borra y navega
-            localStorage.clear();
-            this._router.navigate(['']);
-          });
         });
       });
       

+ 21 - 6
Front/src/app/modules/Padres/pages/layout-page/layout-page.component.ts

@@ -10,6 +10,7 @@ import { ActividadService } from '../../../Administrador/services/actividad.serv
 import { ActividadUser } from '../../../Administrador/interfaces/ActividadUser.interface';
 import { format } from 'date-fns';
 import Swal from 'sweetalert2';
+import { NavbarHomeComponent } from '../../../../shared/navbar-home/navbar-home.component';
 
 @Component({
   selector: 'app-layout-page',
@@ -57,6 +58,7 @@ export class LayoutPageComponent {
     private _enviarInfo: EnviarInfoService,
     private authService: AuthService,
     private actividadService: ActividadService,
+    private navbarHome: NavbarHomeComponent
     // private navbarHome: NavbarHomeComponent
   ) {
     
@@ -189,6 +191,25 @@ export class LayoutPageComponent {
       this._enviarInfo.changeColorLinks(this.links);
     })
 
+    const expira = localStorage.getItem('expira');
+    if (expira) {
+      const expiraDate = new Date(parseInt(expira, 10));
+      const now = new Date();
+
+      if (now > expiraDate) {
+
+        console.log('La fecha de expiración ha pasado.');
+        Swal.fire({
+          icon: 'info',
+          title: 'Ha estado inactivo por mucho tiempo, por favor inicie sesión nuevamente.'
+        })
+        // this.navbarHome.actualizarActividad();
+        this.navbarHome.logout();
+      } else {
+        console.log('La fecha de expiración no ha pasado.');
+      }
+    }
+
     // const actual = new Date();
     // console.log(actual.toLocaleTimeString());
 
@@ -212,14 +233,8 @@ export class LayoutPageComponent {
           confirmButtonColor: 'rgb(237,46,56)',
           confirmButtonText: 'Ok'
         }).then(() => {
-          this._authService.logout().subscribe(() => {
             localStorage.clear();
             this._router.navigate(['']); // ruta login explícita
-          }, () => {
-            // Incluso si falla el logout del backend, borra y navega
-            localStorage.clear();
-            this._router.navigate(['']);
-          });
         });
       });
       

+ 22 - 0
Front/src/app/modules/Profesor/pages/layout-page/layout-page.component.ts

@@ -7,6 +7,7 @@ import { Keepalive } from '@ng-idle/keepalive';
 import { MatDialog } from '@angular/material/dialog';
 import { Router } from '@angular/router';
 import Swal from 'sweetalert2';
+import { NavbarHomeComponent } from '../../../../shared/navbar-home/navbar-home.component';
 
 @Component({
   selector: 'app-layout-page',
@@ -35,6 +36,7 @@ export class LayoutPageComponent {
     private keepalive: Keepalive,
     public dialog: MatDialog,
     private _router: Router,
+    private navbarHome: NavbarHomeComponent
   ) { }
 
 
@@ -59,6 +61,26 @@ export class LayoutPageComponent {
       this._enviarInfo.changeTextColor(this.fontColorBar);
       this._enviarInfo.changeColorLinks(this.links);
     })
+
+    const expira = localStorage.getItem('expira');
+    if (expira) {
+      const expiraDate = new Date(parseInt(expira, 10));
+      const now = new Date();
+
+      if (now > expiraDate) {
+
+        console.log('La fecha de expiración ha pasado.');
+        Swal.fire({
+          icon: 'info',
+          title: 'Ha estado inactivo por mucho tiempo, por favor inicie sesión nuevamente.'
+        })
+        // this.navbarHome.actualizarActividad();
+        this.navbarHome.logout();
+      } else {
+        console.log('La fecha de expiración no ha pasado.');
+      }
+    }
+
     let userDataS = localStorage.getItem('userDataS');
     if (!userDataS) {
       // Configuración de idle

+ 2 - 7
Front/src/app/shared/navbar-home/navbar-home.component.ts

@@ -195,13 +195,8 @@ export class NavbarHomeComponent implements OnInit {
 
 
   logout() {
-    this.authService.logout().subscribe((response) => {
-      localStorage.clear();
-      this._router.navigate(['']);
-    },
-      (err) => {
-      }
-    );
+    localStorage.clear();
+    this._router.navigate(['']);
   }
 
   checkUrl() {