Reorganizando el proyecto y quitando el menu para operaciones crud. Sale muy raro la configuracion sale mejor tener botones en las tablas que indican si el usuario qiere crear/editar/borar el usuario. Ajustes adicionales a la tabla para que sale x entradas y aparecen paginas. Cambios a las ojas del estilo. Pero este preparado el formulario y controlador para crear una nueva familia que va aservir despues de reorganizar las tablas
parent
626a595c23
commit
bfe2ce00ab
@ -0,0 +1,44 @@
|
||||
package com.example.proyectofinal.controllers.modelControllers;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Ciclo;
|
||||
import com.example.proyectofinal.repositories.empresas.CicloRepository;
|
||||
import com.example.proyectofinal.servicios.FamiliaService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/familia")
|
||||
public class FamiliaController {
|
||||
@Autowired
|
||||
private CicloRepository cicloRepository;
|
||||
|
||||
@Autowired
|
||||
private FamiliaService familiaService;
|
||||
|
||||
@PostMapping("/crearFamilia")
|
||||
@ResponseBody
|
||||
public String editFamilia(@RequestParam String name) {
|
||||
String result = familiaService.createFamilia(name);
|
||||
System.out.println(name);
|
||||
if (result.equals("Familia creada")) {
|
||||
return "redirect:/editMain";
|
||||
}else if (result.equals("Familia ya existe")){
|
||||
return result;
|
||||
} else {
|
||||
return "redirect:/error";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public String getFamiliaById(@PathVariable Long id, Model model) {
|
||||
Set<Ciclo> cicloSet = new HashSet<>(cicloRepository.findCicloByFamiliaId(id));
|
||||
model.addAttribute("ciclos", cicloSet);
|
||||
return "/list/list_ciclo";
|
||||
}
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package com.example.proyectofinal.controllers.modelControllers;
|
||||
|
||||
//@RestController
|
||||
public class LogInController {
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
package com.example.proyectofinal.controllers.searchController;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Ciclo;
|
||||
import com.example.proyectofinal.repositories.empresas.CicloRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/familia")
|
||||
public class FamiliaController {
|
||||
@Autowired
|
||||
private CicloRepository cicloRepository;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public String getFamiliaById(@PathVariable Long id, Model model) {
|
||||
Set<Ciclo> cicloSet = new HashSet<>(cicloRepository.findCicloByFamiliaId(id));
|
||||
model.addAttribute("ciclos", cicloSet);
|
||||
return "/list/specific/list_familia_ciclo";
|
||||
}
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.example.proyectofinal.controllers.searchController;
|
||||
|
||||
//@RestController
|
||||
public class LogInController {
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.example.proyectofinal.servicios;
|
||||
|
||||
import com.example.proyectofinal.models.empresas.Familia;
|
||||
import com.example.proyectofinal.repositories.empresas.FamiliaRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class FamiliaService {
|
||||
@Autowired
|
||||
private FamiliaRepository familiaRepository;
|
||||
|
||||
public String createFamilia(String name) {
|
||||
if (familiaRepository.findByName(name).isPresent()) {
|
||||
return "Familia ya existe";
|
||||
} else {
|
||||
Familia newFamilia = new Familia();
|
||||
newFamilia.setNombre(name);
|
||||
familiaRepository.save(newFamilia);
|
||||
return "Familia creada";
|
||||
}
|
||||
}
|
||||
|
||||
public String updateFamilia(Long id, String name) {
|
||||
if (familiaRepository.findById(id).isPresent()) {
|
||||
Familia familia = familiaRepository.findById(id).get();
|
||||
familia.setNombre(name);
|
||||
familiaRepository.save(familia);
|
||||
return "Familia actualizada";
|
||||
} else {
|
||||
return "Familia no encontrada";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
.back-button {
|
||||
display: flex;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 200px !important;
|
||||
height: 50px !important;
|
||||
font-size: 25px !important;
|
||||
margin-top: 100px;
|
||||
background-color: #007BFF;
|
||||
color: white;
|
||||
font-weight: bolder;
|
||||
border-radius: 5px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 50%;
|
||||
}
|
||||
.search-container {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
}
|
||||
input[type="text"] {
|
||||
flex-grow: 1;
|
||||
padding: 15px;
|
||||
margin-right: 10px;
|
||||
font-size: 18px;
|
||||
}
|
||||
select {
|
||||
width: 100%;
|
||||
padding: 15px;
|
||||
font-size: 18px;
|
||||
margin-top: 20px;
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/style.css}">
|
||||
<meta charset="UTF-8">
|
||||
<title>EDITOR DE INFORMACIÓN</title>
|
||||
<style>
|
||||
.grid-container {
|
||||
margin-top: 125px;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3,1fr);
|
||||
grid-gap: 2px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 50vh;
|
||||
}
|
||||
a {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
font-size: 40px;
|
||||
background-color: #f0f0f0;
|
||||
text-decoration: none;
|
||||
width: 80%;
|
||||
height: 80%;
|
||||
margin: auto;
|
||||
}
|
||||
body, h1 {
|
||||
margin-left: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ZONA ADMINISTRADOR <a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
|
||||
<div class="grid-container">
|
||||
<a>Empresa</a>
|
||||
<a>Alumno</a>
|
||||
<a>Oferta</a>
|
||||
<a>Sector</a>
|
||||
<a>Sucursal</a>
|
||||
<a>Skill</a>
|
||||
<a>Contactos</a>
|
||||
<a>Ciclo</a>
|
||||
<a href="/editMain/FamiliaEdit?text=Familia">Familia</a>
|
||||
</div>
|
||||
|
||||
<a href="/buscador" class="back-button">Atras</a>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,18 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top_and_back.css}">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1 th:text="${text}"><a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
<div>
|
||||
<a th:href="@{'/editMain/crear/' + ${text}}" class="opt_butn">Crear</a>
|
||||
<a th:href="@{'/editMain/editar/' + ${text}}" class="opt_butn">Editar</a>
|
||||
<a th:href="@{'/editMain/borrar/' + ${text}}" class="opt_butn">Borrar</a>
|
||||
</div>
|
||||
<a href="/buscador" class="back-button">Atras</a>
|
||||
</body>
|
||||
</html>
|
@ -1,16 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CREAR FAMILIA</h1>
|
||||
<form action="/yourActionURL" method="post">
|
||||
<label for="name">Name:</label><br>
|
||||
<input type="text" id="name" name="name"><br>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
<a href="/edit/editMain" class="back-button">Atras a Menu Administrador</a>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Creacion: Familia</title>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/top.css}">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/back_button.css}">
|
||||
<style>
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
margin: auto;
|
||||
padding: 25px;
|
||||
margin-top: 100px;
|
||||
}
|
||||
|
||||
form input[type="text"], form input[type="submit"] {
|
||||
font-size: 20px;
|
||||
padding: 10px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
form input[type="text"]{
|
||||
width: 40%;
|
||||
}
|
||||
form label{
|
||||
font-size: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-family: Verdana, Geneva, Tahoma, sans-serif;
|
||||
}
|
||||
|
||||
body, h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>CREAR FAMILIA<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
<!--<form action="/familia/crearFamilia" method="post">-->
|
||||
<!--TODO: Ask why this doesnt work and if it has to do with the jumping from editcontroler to familia controler-->
|
||||
<form th:action="@{/familia/crearFamilia}" method="post">
|
||||
<label for="name">Nombre de Familia de Ciclos:</label><br>
|
||||
<input type="text" id="name" name="name"><br>
|
||||
<input type="submit" value="Crear">
|
||||
</form>
|
||||
<button onclick="location.href='/editMain'" class="back-button">Atras</button>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$("form").on("submit", function(event){
|
||||
event.preventDefault();
|
||||
$.ajax({
|
||||
url: '/familia/crearFamilia',
|
||||
type: 'post',
|
||||
data: $(this).serialize(),
|
||||
success: function(response){
|
||||
if (response.startsWith('redirect:')) {
|
||||
alert("Familia creada con exito");
|
||||
window.location.href = response.substring(9);
|
||||
} else {
|
||||
alert(response);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/style.css}">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
|
||||
<h1>Listado de Contactos<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
<div class="table">
|
||||
<table class ="table table-hover table-responsive-xl">
|
||||
<thead class="thread-light">
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Nombre</th>
|
||||
<th>Apellido 1</th>
|
||||
<th>Apellido 2</th>
|
||||
<th>Correo</th>
|
||||
<th>Telefono</th>
|
||||
<th>Empressa</th>
|
||||
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="cell" th:each="contacto :${contactos}">
|
||||
<td>[[${contacto.id}]]</td>
|
||||
<td>[[${contacto.nombre}]]</td>
|
||||
<td>[[${contacto.apellido}]]</td>
|
||||
<td>[[${contacto.apellido2}]]</td>
|
||||
<td>[[${contacto.correo}]]</td>
|
||||
<td>[[${contacto.telefono}]]</td>
|
||||
<td>[[${contacto.empresa.nombre}]]</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<a th:href="@{/buscador/search(query=${session.query}, searchOption=${session.searchOption})}" class="back-button">Atras</a>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,38 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/style.css}">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
|
||||
<h1>Listado de Ciclos<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
<div class="table">
|
||||
<table class ="table table-hover table-responsive-xl">
|
||||
<thead class="thread-light">
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Nombre</th>
|
||||
<th>Familia</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="cell" th:each="ciclo :${ciclos}">
|
||||
<td>[[${ciclo.id}]]</td>
|
||||
<td>[[${ciclo.nombre}]]</td>
|
||||
<td>[[${ciclo.familia.nombre}]]</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<a th:href="@{/buscador/search(query=${session.query}, searchOption=${session.searchOption})}" class="back-button">Atras</a>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,48 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.4/css/all.css">
|
||||
<link rel="stylesheet" type="text/css" th:href="@{/style.css}">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
|
||||
<h1>Listado de Empresas<a href="/logout" class="logout-button"><i class="fas fa-door-open"></i></a></h1>
|
||||
<div class="table">
|
||||
<table class ="table table-hover table-responsive-xl">
|
||||
<thead class="thread-light">
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Nombre</th>
|
||||
<th>Cif</th>
|
||||
<th>Correo</th>
|
||||
<th>Telefono</th>
|
||||
<th class="keywords-cell">Keywords</th>
|
||||
<th>Sector</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="cell" th:each="empresa :${empresas}">
|
||||
<td>[[${empresa.id}]]</td>
|
||||
<td>[[${empresa.nombre}]]</td>
|
||||
<td>[[${empresa.cif}]]</td>
|
||||
<td>[[${empresa.correo}]]</td>
|
||||
<td>[[${empresa.telefono}]]</td>
|
||||
<td class="keywords-cell">
|
||||
<div th:each="keyword : ${#strings.arraySplit(empresa.keywords, ',')}">[[${keyword}]]</div>
|
||||
</td>
|
||||
<td>[[${empresa.sector.nombre}]]</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<a th:href="@{/buscador/search(query=${session.query}, searchOption=${session.searchOption})}" class="back-button">Atras</a>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue