From b7da5dc1431fab4e6328b61bd6748a803b870dda Mon Sep 17 00:00:00 2001 From: vicsash Date: Wed, 29 May 2024 14:32:22 +0200 Subject: [PATCH] Ajsutando css y los botones del pdf --- .../controllers/AdminController.java | 3 +- .../servicios/empresa/AlumnoService.java | 14 ++++- .../servicios/empresa/CicloService.java | 9 +-- .../servicios/empresa/OfertaService.java | 2 - src/main/resources/static/style.css | 46 ++++++++------- .../templates/admin/usuario/delete.html | 2 + .../resources/templates/buscador_admin.html | 5 ++ .../resources/templates/list/alumnos.html | 12 ++-- src/main/resources/templates/list/ciclos.html | 12 ++-- .../resources/templates/list/contactos.html | 13 ++-- .../resources/templates/list/empresas.html | 12 ++-- .../resources/templates/list/familias.html | 59 +++++++++---------- .../resources/templates/list/ofertas.html | 12 ++-- .../resources/templates/list/sectores.html | 12 ++-- src/main/resources/templates/list/skills.html | 2 +- .../resources/templates/list/sucursales.html | 2 +- 16 files changed, 117 insertions(+), 100 deletions(-) diff --git a/src/main/java/com/example/proyectofinal/controllers/AdminController.java b/src/main/java/com/example/proyectofinal/controllers/AdminController.java index 56dff02..b61f60c 100644 --- a/src/main/java/com/example/proyectofinal/controllers/AdminController.java +++ b/src/main/java/com/example/proyectofinal/controllers/AdminController.java @@ -160,11 +160,12 @@ public class AdminController { // ... if (currentUser.getId().equals(id)) { return ResponseEntity.ok("selfDelete"); + }else if(currentUser.getId() ==1){ + return ResponseEntity.ok("originalAdmin"); } Usuario user = usuarioService.findUserById(id); if(user.getRol().getId() == 2){ Alumno alumno = alumnoService.findByEmail(user.getEmail()); - System.out.println("TEST DELETING ALUMNO WITH ID: " + alumno.getId()+" AND EMAIL: "+alumno.getCorreo()+" AND NAME: "+alumno.getNombre()); alumnoService.deleteById(alumno.getId()); } usuarioService.deleteUser(id); diff --git a/src/main/java/com/example/proyectofinal/servicios/empresa/AlumnoService.java b/src/main/java/com/example/proyectofinal/servicios/empresa/AlumnoService.java index 7866fd1..00b9776 100644 --- a/src/main/java/com/example/proyectofinal/servicios/empresa/AlumnoService.java +++ b/src/main/java/com/example/proyectofinal/servicios/empresa/AlumnoService.java @@ -2,8 +2,10 @@ package com.example.proyectofinal.servicios.empresa; import com.example.proyectofinal.models.empresas.Alumno; import com.example.proyectofinal.models.empresas.Skill; +import com.example.proyectofinal.models.login.Usuario; import com.example.proyectofinal.repositories.empresas.AlumnoRepository; import com.example.proyectofinal.servicios.implemetations.empresas.IAlumno; +import com.example.proyectofinal.servicios.user.UsuarioService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.*; import org.springframework.stereotype.Service; @@ -18,6 +20,8 @@ import java.util.Set; public class AlumnoService implements IAlumno{ @Autowired private AlumnoRepository alumnoRepository; + @Autowired + private UsuarioService usuarioService; @Override public Page getPage(int pageNum, int size, String sortField, String sortDir, String query, String secondaryOption) { @@ -87,9 +91,13 @@ public class AlumnoService implements IAlumno{ List alumnos = alumnoRepository.findByCiclo(id); if(!alumnos.isEmpty()){ for(Alumno alumno : alumnos){ - System.out.println("Deleting alumno with id: " + alumno.getId()); - alumnoRepository.deleteSkillByAlumnoId(alumno.getId()); // delete associated skills - alumnoRepository.deleteById(alumno.getId()); // then delete the alumno + alumnoRepository.deleteSkillByAlumnoId(alumno.getId()); + alumnoRepository.deleteById(alumno.getId()); + String logIn = "alu." + alumno.getNombre() + alumno.getNia().substring(0, 3); + Usuario usuario = usuarioService.findByLogInName(logIn); + if(usuario != null){ + usuarioService.deleteById(usuario.getId()); + } } } } diff --git a/src/main/java/com/example/proyectofinal/servicios/empresa/CicloService.java b/src/main/java/com/example/proyectofinal/servicios/empresa/CicloService.java index 7238812..cdf764d 100644 --- a/src/main/java/com/example/proyectofinal/servicios/empresa/CicloService.java +++ b/src/main/java/com/example/proyectofinal/servicios/empresa/CicloService.java @@ -25,8 +25,7 @@ public class CicloService implements ICiclos { @Autowired private OfertaService ofertaService; - @Autowired - private UsuarioService usuarioService; + @Override @@ -53,12 +52,6 @@ public class CicloService implements ICiclos { public void deleteById(Long id) { Ciclo ciclo = cicloRepository.findById(id).orElse(null); if(ciclo != null){ - Alumno alumno = alumnoService.findById(id); - String logIn = "alu." + alumno.getNombre() + alumno.getNia().substring(0, 3); - Usuario usuario = usuarioService.findByLogInName(logIn); - if(usuario != null){ - usuarioService.deleteById(usuario.getId()); - } alumnoService.deleteByCiclo(ciclo.getId()); ofertaService.deleteByCicloId(ciclo.getId()); cicloRepository.deleteById(id); diff --git a/src/main/java/com/example/proyectofinal/servicios/empresa/OfertaService.java b/src/main/java/com/example/proyectofinal/servicios/empresa/OfertaService.java index 126bb1c..e34df26 100644 --- a/src/main/java/com/example/proyectofinal/servicios/empresa/OfertaService.java +++ b/src/main/java/com/example/proyectofinal/servicios/empresa/OfertaService.java @@ -203,8 +203,6 @@ public class OfertaService implements IOferta { sbMessage.append("Empresa: ").append(oferta.getSucursal().getEmpresa().getNombre()).append("\n"); sbMessage.append("Localidad: ").append(oferta.getSucursal().getLocalidad()).append("\n"); sbMessage.append("DescipciĆ³n: ").append(oferta.getDescripcion()).append("\n"); - System.out.println("TEST " + alumno.getNombre()); - System.out.println("TEST CORREO " + alumno.getCorreo()); mailService.sendEmail(alumno.getCorreo(), "Nueva oferta de practicas", sbMessage.toString()); if(alumno.getCorreo2() != null){ mailService.sendEmail(alumno.getCorreo2(), "Nueva oferta de practicas", sbMessage.toString()); diff --git a/src/main/resources/static/style.css b/src/main/resources/static/style.css index bd92b65..98354c2 100644 --- a/src/main/resources/static/style.css +++ b/src/main/resources/static/style.css @@ -26,12 +26,9 @@ th { h1 { text-align: center; font-family: Verdana, Geneva, Tahoma, sans-serif; - font-size: 50px; + font-size: 3vw; color: white; - margin-top: 0; - margin-left: 0; - margin-right: 0; - margin-bottom: 50px; + margin: 0 0 50px; padding-top: 0; padding-left: 0; padding-right: 0; @@ -104,23 +101,28 @@ body { align-items: center; justify-content: space-between; background-color: #007BFF; - padding: 0; + padding: 0.2vw; box-sizing: border-box; } + .pdfButton { - font-size: 10px; /* Adjust font size */ - padding: 2px 5px; /* Adjust padding */ - width: auto; /* Adjust width to auto so it expands as needed */ - white-space: normal; /* Allow text to wrap to next line */ - text-align: center; /* Center the text */ - z-index: 2; - position: relative; + font-size: 0.5em; + padding: 1em; + margin : 0.25em; + width: auto; + white-space: normal; + text-align: center; } -.header h1 { - position: absolute; - left: 50%; - transform: translateX(-50%); - margin: 0; + +i.fas.fa-arrow-left { + z-index: 1; + pointer-events: auto; /* Add this line */ +} +.button-group { + display: flex; + flex-direction: row; + align-items: center; + z-index: 1; } .header button { margin-right: auto; @@ -182,8 +184,8 @@ html, body { width: 100vw; height: 100%; overflow: auto; - background-color: rgb(0,0,0); /* Fallback color */ - background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ + background-color: rgb(0,0,0); + background-color: rgba(0,0,0,0.4); } .modal-content{ background-color: #fefefe; @@ -194,7 +196,7 @@ html, body { } .delete{ - background-color: #f8f9fa; /* Light gray background */ + background-color: #f8f9fa; color: red; float: right; font-size: 28px; @@ -202,7 +204,7 @@ html, body { padding: 10px; } .close{ - background-color: #f8f9fa; /* Light gray background */ + background-color: #f8f9fa; color: black; float: right; font-size: 28px; diff --git a/src/main/resources/templates/admin/usuario/delete.html b/src/main/resources/templates/admin/usuario/delete.html index 02d1ebf..935cbc2 100644 --- a/src/main/resources/templates/admin/usuario/delete.html +++ b/src/main/resources/templates/admin/usuario/delete.html @@ -94,6 +94,8 @@ window.location.href = "/buscador?error=selfDelete"; } else if (response === 'userDeleted') { window.location.href = "/buscador?userDeleted=true"; + } else if(response === 'originalAdmin'){ + window.location.href = "/buscador?error=originalAdmin"; } }, error: function(jqXHR, textStatus, errorThrown) { diff --git a/src/main/resources/templates/buscador_admin.html b/src/main/resources/templates/buscador_admin.html index d59957d..d0f95c1 100644 --- a/src/main/resources/templates/buscador_admin.html +++ b/src/main/resources/templates/buscador_admin.html @@ -211,6 +211,11 @@ urlParams.set('error', 'false'); window.history.replaceState({}, '', `${location.pathname}?${urlParams}`); } + if(error ==='originalAdmin'){ + alert('No puedes eliminar al administrador original'); + urlParams.set('error', 'false'); + window.history.replaceState({}, '', `${location.pathname}?${urlParams}`); + } }); function deleteUser() { diff --git a/src/main/resources/templates/list/alumnos.html b/src/main/resources/templates/list/alumnos.html index 75df5f2..c17dea0 100644 --- a/src/main/resources/templates/list/alumnos.html +++ b/src/main/resources/templates/list/alumnos.html @@ -21,10 +21,7 @@
-
- - -
+

Listado de Alumnos @@ -33,7 +30,12 @@

- + + +
+ + +
diff --git a/src/main/resources/templates/list/ciclos.html b/src/main/resources/templates/list/ciclos.html index 8e0f30f..e5e0e7a 100644 --- a/src/main/resources/templates/list/ciclos.html +++ b/src/main/resources/templates/list/ciclos.html @@ -15,10 +15,7 @@
-
- - -
+

Listado de Ciclos @@ -27,7 +24,12 @@

- + + +
+ + +
diff --git a/src/main/resources/templates/list/contactos.html b/src/main/resources/templates/list/contactos.html index 808cb53..527acdb 100644 --- a/src/main/resources/templates/list/contactos.html +++ b/src/main/resources/templates/list/contactos.html @@ -15,10 +15,7 @@
-
- - -
+

Listado de Contactos @@ -27,8 +24,12 @@

- - + + +
+ + +
diff --git a/src/main/resources/templates/list/empresas.html b/src/main/resources/templates/list/empresas.html index f4200c5..59f33a3 100644 --- a/src/main/resources/templates/list/empresas.html +++ b/src/main/resources/templates/list/empresas.html @@ -18,10 +18,7 @@
-
- - -
+

Listado de Empresas @@ -30,7 +27,12 @@

- + + +
+ + +
diff --git a/src/main/resources/templates/list/familias.html b/src/main/resources/templates/list/familias.html index fba8448..dbe4f6a 100644 --- a/src/main/resources/templates/list/familias.html +++ b/src/main/resources/templates/list/familias.html @@ -15,10 +15,6 @@
-
- - -

Listado de Familias @@ -27,8 +23,12 @@

- - + + +
+ + +
@@ -113,28 +113,29 @@ var isSearchBarUsed = false; $table.on('click', '.edit-icon', function(event) { - console.log("Edit icon clicked"); + //console.log("Edit icon clicked"); handleEdit(event); }); $table.on('click', '.delete-icon', function(event) { - console.log("Delete icon clicked"); + // console.log("Delete icon clicked"); handleDelete(event); }); function handleEdit(event) { - console.log("handleEdit function called"); + //console.log("handleEdit function called"); const row = event.target.closest('tr'); const rowId = row.dataset.id; - console.log("Row ID: " + rowId); + //console.log("Row ID: " + rowId); window.location = "/admin/familia/update/" + rowId; } - var modal = document.getElementById("modalDelete"); + function handleDelete(event) { - console.log("handleDelete function called"); - console.log("Delete icon clicked"); + //console.log("handleDelete function called"); + //console.log("Delete icon clicked"); + var modal = document.getElementById("modalDelete"); const row = event.target.closest('tr'); const rowId = row.dataset.id; modal.style.display = "block"; @@ -148,25 +149,21 @@ modal.style.display = "none"; document.body.style.pointerEvents = 'auto'; } - - setTimeout(function() { - deleteSpan.onclick = function() { - $.ajax({ - url: '/familia/delete/' + rowId, - type: 'GET', - success: function(response) { - if (response === "La familia ha sido eliminada") { - alert("Familia borrada con exito"); - modal.style.display = "none"; // Hide the modal - document.body.style.pointerEvents = 'auto'; // Enable pointer events - window.location.reload(); // Reload the page - } else { - alert("Error al borrar familia"); - } + deleteSpan.onclick = function() { + $.ajax({ + url: '/familia/delete/' + rowId, + type: 'GET', + success: function(response) { + if (response === "La familia ha sido eliminado") { + alert("Familia borrada con exito"); + modal.style.display = "none"; // Hide the modal + window.location.reload(); // Reload the page + } else { + alert("Error al borrar familia"); } - }); - } - }, 500); // Delay of 500 milliseconds + } + }); + } } $myInput.on('input', function() { diff --git a/src/main/resources/templates/list/ofertas.html b/src/main/resources/templates/list/ofertas.html index 8133e8a..9a4c802 100644 --- a/src/main/resources/templates/list/ofertas.html +++ b/src/main/resources/templates/list/ofertas.html @@ -17,10 +17,7 @@
-
- - -
+

Listado de Ofertas @@ -29,7 +26,12 @@

- + + +
+ + +
diff --git a/src/main/resources/templates/list/sectores.html b/src/main/resources/templates/list/sectores.html index ff47f74..6c52cab 100644 --- a/src/main/resources/templates/list/sectores.html +++ b/src/main/resources/templates/list/sectores.html @@ -15,10 +15,7 @@
-
- - -
+

Listado de Sectores @@ -27,7 +24,12 @@

- + + +
+ + +
diff --git a/src/main/resources/templates/list/skills.html b/src/main/resources/templates/list/skills.html index 20b430b..41e8a77 100644 --- a/src/main/resources/templates/list/skills.html +++ b/src/main/resources/templates/list/skills.html @@ -15,7 +15,7 @@
-
+
diff --git a/src/main/resources/templates/list/sucursales.html b/src/main/resources/templates/list/sucursales.html index a3e778d..9560e40 100644 --- a/src/main/resources/templates/list/sucursales.html +++ b/src/main/resources/templates/list/sucursales.html @@ -15,7 +15,7 @@
-
+