From 903ca2989e264c711387b32566535884d661e95b Mon Sep 17 00:00:00 2001 From: jesussmariscal Date: Sat, 28 Dec 2024 20:08:36 +0100 Subject: [PATCH] moodle files updated --- .../example/controller/TeacherController.java | 7 +++-- .../java/com/example/model/Attendance.java | 6 ++--- .../example/services/AttendanceService.java | 6 ++++- .../controller/TeacherController.class | Bin 7153 -> 7245 bytes .../com/example/model/Attendance.class | Bin 2651 -> 2572 bytes .../example/services/AttendanceService.class | Bin 3786 -> 3986 bytes Docker/Moodle/Dockerfile | 14 ++++++---- Docker/Moodle/entrypoint.sh | 8 ++++++ Docker/commands.sh | 9 ++++++- Frontend/capacitor.config.ts | 2 +- .../bluetooth-page/asistencia.component.ts | 15 ++++++++--- .../components/carnet/carnet.component.html | 5 ++-- .../components/carnet/carnet.component.ts | 24 +++++++++++------- .../TeacherService/teacher.service.ts | 4 +-- Moodle/.DS_Store | Bin 16388 -> 6148 bytes Moodle/lib/.DS_Store | Bin 6148 -> 0 bytes README.md | 7 ++--- 17 files changed, 73 insertions(+), 34 deletions(-) create mode 100644 Docker/Moodle/entrypoint.sh delete mode 100644 Moodle/lib/.DS_Store diff --git a/Backend/src/main/java/com/example/controller/TeacherController.java b/Backend/src/main/java/com/example/controller/TeacherController.java index 42316aa60..f49951128 100644 --- a/Backend/src/main/java/com/example/controller/TeacherController.java +++ b/Backend/src/main/java/com/example/controller/TeacherController.java @@ -124,7 +124,7 @@ public ResponseEntity> getAllAttendances(HttpServletRequest req @ApiResponse(responseCode = "500", description = "Error interno del servidor", content = @Content) }) @PutMapping("/attendances/{id}/add-time") - public ResponseEntity addTimeToAttendance(@PathVariable Long id, HttpServletRequest request) { + public ResponseEntity addTimeToAttendance(@PathVariable Long id, HttpServletRequest request) { Principal principal = request.getUserPrincipal(); if (principal == null) { return ResponseEntity.status(HttpStatus.FORBIDDEN).build(); @@ -143,12 +143,15 @@ public ResponseEntity addTimeToAttendance(@PathVariable Long id, HttpServl } if (attendanceService.addTime(id)) { - return ResponseEntity.ok().build(); + return ResponseEntity.ok().body(true); } else { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } } catch (Exception e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); } + + + } } \ No newline at end of file diff --git a/Backend/src/main/java/com/example/model/Attendance.java b/Backend/src/main/java/com/example/model/Attendance.java index 9e1b50c07..cd6a39702 100644 --- a/Backend/src/main/java/com/example/model/Attendance.java +++ b/Backend/src/main/java/com/example/model/Attendance.java @@ -68,10 +68,6 @@ public void setDateTime(LocalDateTime dateTime) { this.dateTime = dateTime; } - public void moreTime() { - dateTime = LocalDateTime.now(); - } - public User getCreator() { return creator; } @@ -80,4 +76,6 @@ public long getId() { return id; } + + } diff --git a/Backend/src/main/java/com/example/services/AttendanceService.java b/Backend/src/main/java/com/example/services/AttendanceService.java index 3b56fe659..3b471658d 100644 --- a/Backend/src/main/java/com/example/services/AttendanceService.java +++ b/Backend/src/main/java/com/example/services/AttendanceService.java @@ -1,6 +1,7 @@ package com.example.services; import java.security.SecureRandom; +import java.time.LocalDateTime; import java.util.List; import java.util.Random; @@ -54,7 +55,10 @@ public boolean isCodeUsed(String code) { } public boolean addTime(Long id) { - this.attendanceRepository.findById(id).get().moreTime(); + Attendance attendance = this.attendanceRepository.findById(id).get(); + attendance.setDateTime(LocalDateTime.now().plusHours(1)); + attendanceRepository.save(attendance); + return true; } diff --git a/Backend/target/classes/com/example/controller/TeacherController.class b/Backend/target/classes/com/example/controller/TeacherController.class index 812ee9cc44ee0dbe7990860a7ef4f9fc2ec7e3e3..1596e6d77ff7d40f925c9f745b5079e0b8c82997 100644 GIT binary patch delta 516 zcmZXR%S)7D6vlt==Qr~@SVLMp0ZeiwG*(M$zIcHHdLW85G0;ZBN4AfF&&P@BF#=T*7gSh&Uah$$_JhKo`>v{O8uV#Z=(lGzkjrs!2n z)Vuy=Xt_mKZk5T-x{0KUGf&f9OS@ar%%ArAq#DZo( zW`Oh~@=e$- R>EGf9zt|)H(amqS=MRwNh`9g& delta 443 zcmYk0%S)7D7{!0@_ixOm=k4)1f$d1h-)s#9m;pT7XNIQx)#mZ7>$ zJfp*E=xA$+c4dC_`20L!A;6+}8q8PA(f7f2<=tjS^T*^m74~1nM5!5Ya?L|$Fn`O( zo+3q6DMg?@9B%Er8+zort*++K#GP{MSW#e9PC@j3PLbu0;K3{1FHG09@a@1fbD!u} zOinRB&GQRhYhPBRaEE4wS)zrWBt{rYpefF)?u+nJ_-jTOCn&-9(201maRd`=1%pbm zQO2ZR^GrOiB)5c+ILEPgz)dE2gDp7$R{1LIt#~T2V_ebH#wgR&#kipf1@%^?RfWMrAD4;n4s|?V~sn`D>NJDRd diff --git a/Backend/target/classes/com/example/model/Attendance.class b/Backend/target/classes/com/example/model/Attendance.class index c72e30f82583fd3cc82e53fa9cf1df4908d815d0..0de81b2dbc2b688ff2a7e3cde6e4a7fb33ea4185 100644 GIT binary patch delta 200 zcmcaD(j&rk>ff$?3=9mm3@IDA+F2*hVYO0;=3!uEVB=zlWr$~Ih+|~n%StRu)Xz!G zOV{_w&r9cFNMMMZ{EPJ-BiH7eY#W#u!zXX#5U$eR05paPXb=Mf8v`Sd^kA?9l00BG zD}z0Q1CYna5Wx@$B$a?{BcN)KIu5NZ3{l${V%7rL$ohSd^m9Pff$?3=9mm45=Hr+F3a{a`TH)Lo#zyC-<}3sKoFvurjc5F~l(>urtIn zGVo<3mL=-vB<7{-`{d`P^DrbbL`{CrdXJHN^EtK+Os=X7j0{RZ)65u{fGh?E4y_#w z`db++Hv-vAKsy*1xPUYRg9igUgC~O>ki`R0$6(Lk0OT<;gfm1;uIE%?^qCyUAsQUX s5Ct{S2yWsQhUje!v1@^o84af83ZmH)tndP_l9xViVe`_4J{-20YXvu=6m*ZWTZ+VJ$H z{L`9E;oMI?TM~v0BdET0>)IQ-T)uglJT1?v%4NF=O^*f+8mYJ*<(R}2LrEf{M~xT_rl=tqS1@hG)m3=Lh$jLE zG<_gB$Z-wV8LWC_)ClQDL7xZ{nB@?-K}!AWV_K?x<*6g@r=7nPOmgaDW<1X&K zK4NQQ%q8aKAgdPN}a8NwW0yLP)C)zf*|U#nQkPF(>Mc0xDAACC3YKCiy4(sLiI6Z#aQ`v)*)V$JHiF* zKLo+O@KJOS=_|D?rriDkxx>!4IM-9uEIotMUuAy3I%B+rK$L+ZB0`oY9a|C#)zp#7fK{1Msgz!)U+3^w}7JH z179dU7@vt7S8m++$TheyuKPc@Vly4#G-npByx=;WfpNafQfOs2UK;Ig9StUY1p zO13kaJMLDB&Zxx9%0r7sJpS+_*r!yd?rrQ*t-9Pe z7);Q@CSr8yTH|~;iOF`_Nzp-?ZDe%8np9c+%^FfW^+Hod4>x7iZaM85K7vmcv}Zn& z+p)xm50A00Bt0DCtq?vE63tc7UfSrDiy*RQVl!I=iJkLQP%>tyQvwih0ap)%x|99? zSi*lT;r}f9Rj4CZJsJDN~M`9zy$5shE+T|AL!@KoB}Aej|H c)CExTM^qI=*WWWE0w2#-<8vXQUW&eeUy50C00000 diff --git a/Docker/Moodle/Dockerfile b/Docker/Moodle/Dockerfile index ff1bb9afd..c5ef15f4a 100644 --- a/Docker/Moodle/Dockerfile +++ b/Docker/Moodle/Dockerfile @@ -33,12 +33,9 @@ RUN apt-get update && apt-get install -y \ # Copy Moodle files from the Moodle directory COPY ./../Moodle /var/www/html/ -# Create moodledata directory and set permissions -RUN mkdir -p /var/www/moodledata && \ - chown -R www-data:www-data /var/www/moodledata && \ - chmod -R 0770 /var/www/moodledata +# ELIMINA la creación de moodledata aquí -# Adjust permissions for Moodle +# Adjust permissions for Moodle (Esto se puede mantener o mover al entrypoint) RUN chown -R www-data:www-data /var/www/html \ && chmod -R 755 /var/www/html @@ -53,8 +50,15 @@ RUN a2enmod rewrite COPY ./../Moodle/moodle.conf /etc/apache2/sites-available/moodle.conf RUN a2ensite moodle.conf +# Create entrypoint script +COPY ./entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + # Expose port 80 for web traffic EXPOSE 80 +# Use entrypoint script +ENTRYPOINT ["/entrypoint.sh"] + # Default command to start Apache CMD ["apache2-foreground"] \ No newline at end of file diff --git a/Docker/Moodle/entrypoint.sh b/Docker/Moodle/entrypoint.sh new file mode 100644 index 000000000..2ef092bbb --- /dev/null +++ b/Docker/Moodle/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Ajusta los permisos de moodledata DESPUÉS de que el volumen se monte +chown -R www-data:www-data /var/www/html/moodledata +chmod -R 0770 /var/www/html/moodledata + +# Ejecuta el comando principal (en este caso, Apache) +exec "$@" \ No newline at end of file diff --git a/Docker/commands.sh b/Docker/commands.sh index 2f280582c..659535961 100644 --- a/Docker/commands.sh +++ b/Docker/commands.sh @@ -1,4 +1,4 @@ - +ionic build npx cap sync npx cap copy android ionic capacitor run android -l --external @@ -20,5 +20,12 @@ Construirla: cd Docker/App docker-compose -p myurjc up -d + Si moodle deja de responder: + + docker exec -it moodle bash +chown -R www-data:www-data /var/www/html/moodledata +chmod -R 0770 /var/www/html/moodledata + + diff --git a/Frontend/capacitor.config.ts b/Frontend/capacitor.config.ts index 44da4c4c0..afb6bfb10 100644 --- a/Frontend/capacitor.config.ts +++ b/Frontend/capacitor.config.ts @@ -5,7 +5,7 @@ const config: CapacitorConfig = { appName: 'MyURJC', webDir: 'www', server: { - url: 'https://192.168.1.14:443', + url: 'http://192.168.1.14:8080', cleartext: true }, plugins: { diff --git a/Frontend/src/app/homePage/bluetooth-page/asistencia.component.ts b/Frontend/src/app/homePage/bluetooth-page/asistencia.component.ts index 52bec608e..296ffee10 100644 --- a/Frontend/src/app/homePage/bluetooth-page/asistencia.component.ts +++ b/Frontend/src/app/homePage/bluetooth-page/asistencia.component.ts @@ -102,9 +102,17 @@ export class AsistenciaComponent implements OnInit { addTimeToAttendance(attendanceId: number) { this.teacherService.addTimeToAttendance(attendanceId).subscribe({ - next: () => { - this.presentToast('Tiempo añadido correctamente', 'success'); - this.getAsisttances(); // Actualizar la lista de asistencias + next: (success: boolean) => { + if (success) { + this.presentToast('Tiempo añadido correctamente', 'success'); + const attendanceIndex = this.attendances.findIndex(a => a.id === attendanceId); + if (attendanceIndex > -1) { + // No necesitas usar 'response.newDateTime', ya que ahora solo estás trabajando con un booleano + this.getAsisttances(); // Actualiza las asistencias para refrescar la vista + } + } else { + this.presentToast('Error al añadir tiempo', 'danger'); + } }, error: (error) => { console.error('Error al añadir tiempo:', error); @@ -112,6 +120,7 @@ export class AsistenciaComponent implements OnInit { } }); } + getTimeRemaining(dateTime: Date): number { const FIVE_MINUTES_IN_MS = 5 * 60 * 1000; // 5 minutos en milisegundos diff --git a/Frontend/src/app/homePage/components/carnet/carnet.component.html b/Frontend/src/app/homePage/components/carnet/carnet.component.html index 080d17603..b60e47c21 100644 --- a/Frontend/src/app/homePage/components/carnet/carnet.component.html +++ b/Frontend/src/app/homePage/components/carnet/carnet.component.html @@ -32,9 +32,8 @@

Inicia sesión para ver tu carnet.

-Click Me - diff --git a/Frontend/src/app/homePage/components/carnet/carnet.component.ts b/Frontend/src/app/homePage/components/carnet/carnet.component.ts index 8f32d7ca8..4effbea68 100644 --- a/Frontend/src/app/homePage/components/carnet/carnet.component.ts +++ b/Frontend/src/app/homePage/components/carnet/carnet.component.ts @@ -15,14 +15,15 @@ export class CarnetComponent implements OnInit { isNfcSupported: boolean = false; isNfcEnabled: boolean = false; showMenu = false; - presentAlert = false; countdown: number = 10; + + private countdownInterval: any; // Variable para almacenar el ID del intervalo + public alertButtons = [ { - text: 'Cabcelar', + text: 'Cancelar', role: 'cancel', handler: () => { - this.presentAlert = false; }, }, @@ -31,7 +32,6 @@ export class CarnetComponent implements OnInit { role: 'confirm', handler: async () => { await Nfc.openSettings(); - this.presentAlert = false; }, }, @@ -67,15 +67,20 @@ export class CarnetComponent implements OnInit { } startCountdown() { - const interval = setInterval(() => { + clearInterval(this.countdownInterval); + this.countdown = 10; + + this.countdownInterval = setInterval(() => { if (this.countdown > 0) { this.countdown--; } else { - clearInterval(interval); + clearInterval(this.countdownInterval); this.closeModal(); + this.countdown = 10; } }, 1000); } + closeModal() { this.showMenu = false; // Cierra el modal al terminar el contador } @@ -92,6 +97,9 @@ export class CarnetComponent implements OnInit { async checkNfcEnabled() { const { isEnabled } = await Nfc.isEnabled(); this.isNfcEnabled = isEnabled; + if (!isEnabled) { + } else { + } } createNdefTextRecord() { @@ -106,11 +114,9 @@ export class CarnetComponent implements OnInit { return record; } - async writeNfcTag() { await this.checkNfcEnabled(); if (this.isNfcSupported && !this.isNfcEnabled) { - this.presentAlert = true; return; } // Crear el registro NFC @@ -142,4 +148,4 @@ export class CarnetComponent implements OnInit { } }, 10000); // 10000 milisegundos = 10 segundos } -} +} \ No newline at end of file diff --git a/Frontend/src/app/services/TeacherService/teacher.service.ts b/Frontend/src/app/services/TeacherService/teacher.service.ts index bcb5795b9..f00231b84 100644 --- a/Frontend/src/app/services/TeacherService/teacher.service.ts +++ b/Frontend/src/app/services/TeacherService/teacher.service.ts @@ -20,7 +20,7 @@ export class TeacherService { return this.http.get(`${this.API_BASE_URL}/attendances`, { withCredentials: true }); } - addTimeToAttendance(attendanceId: number): Observable { - return this.http.put(`${this.API_BASE_URL}/attendances/${attendanceId}/add-time`, null, { withCredentials: true }); + addTimeToAttendance(attendanceId: number): Observable { + return this.http.put(`${this.API_BASE_URL}/attendances/${attendanceId}/add-time`, null, { withCredentials: true }); } } \ No newline at end of file diff --git a/Moodle/.DS_Store b/Moodle/.DS_Store index 981a753974d70111b805c20fa8440de1992bbecc..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 100644 GIT binary patch delta 129 zcmZo^U~DmvU|?WibSh0TWMB{gGC6=4L^G&PEEJolCpp=`hJ^>j2LVQ)+-5_G4eX2A zIXDEFA%X(jK-v|ERW}PVerKM{Z=)y(RLGD3#2^4-H%xZ4k>+877!R_MVRJms9A*Ge C!VpOS literal 16388 zcmeI3ZEPGz8OLYu{mx0`yqKg(+Fa9Cm6{ScxP>T9(@SvEP$(~o1fqx%J2uWGKHv3X z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AiZPY)Nz(uuY@cKT1(bTD>&6j zrOyr43BXanhR;rV|NrjfzyH&s^efFknt`h`172?U;P5`Q%}Zz>y=z~^b_kpKK&$2W z(y!uUuUA#EFBuK(@&8(|@A!Kh!RNpJ2LR5e`f&K}a`&e?e+G3|%KL3UH8p+yzti19)sGQ2+n{ diff --git a/Moodle/lib/.DS_Store b/Moodle/lib/.DS_Store deleted file mode 100644 index 07799f22214c50a3a268955a00469fe41146a639..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK!AiqG5S@voR#YhH!DD_vX#XIV2;xn8@u;z)#g-InDdHtwyb9vQn|SjFJoo{A zho9n`owZF&3m!y7W?=Shc4l^8UP3lYMBEy6nnZOXs=)<=B{VZk;^HL>{KyKB-5f*e z&{^-K**;23**5SO6_97QNQX40A#K7Z&#ylaxR;!J|tTl+wArO&aIjo%^rxJeQl-hfgkrIr{08$-JCA4<0`% zk4qYXM-QG9c)VP#Iv%-ro=4-F*S#iHD&$Og%*)C12>4xin3)2mfGP0P3SiF`t1T;9 zYYLbGroco2`96ej!N_B#=sq22+z|j+!LT#*`x6Sg)iHnQ(upHQYfS-Dps2utUe;y*-=2T|FBaLADPRixD+Ra` zx8oLW$?vVDo0GjZgdf1gBrj8(l%V6bV&uwJya9KH@lZOz$YZ965t#i5I2o)l1%6e5 E4