From 2c13620d8dbf7fe3f53bc986c5ea77fc0065b288 Mon Sep 17 00:00:00 2001
From: Gerard
Date: Tue, 23 Mar 2021 18:24:00 +0100
Subject: [PATCH 1/2] Center Columns info
---
.../resources/static/custom_bootstrap.min.css | 7 ++-
src/main/resources/static/index.css | 2 +-
src/main/resources/static/index.js | 47 +++++++++----------
src/main/resources/templates/index.html | 10 +++-
4 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/src/main/resources/static/custom_bootstrap.min.css b/src/main/resources/static/custom_bootstrap.min.css
index d3f35ee..d3c7201 100644
--- a/src/main/resources/static/custom_bootstrap.min.css
+++ b/src/main/resources/static/custom_bootstrap.min.css
@@ -554,6 +554,7 @@ pre code {
.table thead th {
vertical-align: bottom;
+ background-color: white;
border-bottom: 2px solid #dee2e6;
}
@@ -588,9 +589,13 @@ pre code {
}
.table-striped tbody tr:nth-of-type(odd) {
- background-color: rgba(0, 0, 0, 0.05);
+ background-color: rgba(0, 0, 0, 0.10);
}
+.table-striped tbody tr:nth-of-type(even) {
+ background-color: rgb(255, 255, 255);
+
+}
.table-hover tbody tr:hover {
color: #212529;
background-color: rgba(0, 0, 0, 0.075);
diff --git a/src/main/resources/static/index.css b/src/main/resources/static/index.css
index dcac151..4a5ab5f 100644
--- a/src/main/resources/static/index.css
+++ b/src/main/resources/static/index.css
@@ -1,7 +1,7 @@
body::after {
content: "";
background: url(background.jpeg);
- opacity: 0.6;
+ opacity: 0.5;
top: 0;
left: 0;
bottom: 0;
diff --git a/src/main/resources/static/index.js b/src/main/resources/static/index.js
index bdf2d63..79d23ad 100644
--- a/src/main/resources/static/index.js
+++ b/src/main/resources/static/index.js
@@ -2,11 +2,10 @@ $(document).ready(function () {
updateTable();
});
-var table=$('#employeeTable').DataTable({
- columnDefs: [
- {targets: '_all',classname: 'dt-center' }
- ]
- });
+var table = $('#employeeTable').DataTable({
+ columnDefs: [
+ { targets: '_all', className: 'text-center' }]
+});
//Read employee List & Update the table
function updateTable() {
@@ -16,19 +15,19 @@ function updateTable() {
table.row.add(createRow(employee)).draw();
});
});
-};
+}
//create Row for DataTables Format
-function createRow(employee){
+function createRow(employee) {
return [
employee.id,
employee.name,
employee.job,
employee.salary,
- "" +
- ""
- ];
-};
+ "" +
+ ""
+ ];
+}
//Create & update
function sendEmployee() {
@@ -43,7 +42,7 @@ function sendEmployee() {
"job": $('#job').val()
}),
success: function (data, textStatus, jQxhr) {
- table.row.add(createRow(data)).order( [ 0, 'asc' ] ).page('last').draw(false);
+ table.row.add(createRow(data)).order([0, 'asc']).page('last').draw(false);
},
error: function (xhr, textStatus, errorThrown) {
console.log(textStatus);
@@ -72,7 +71,7 @@ function sendEmployee() {
$('#EmployeeForm').trigger('reset');
$('#action').val('Afegir');
$('#formType').html('Afegir nou');
-};
+}
//Delete employee
function deleteEmployee(id) {
@@ -91,18 +90,18 @@ function deleteEmployee(id) {
}
},
callback: function (result) {
- if (result == true) {
+ if (result === true) {
$.ajax({
type: "DELETE",
url: "/EmployeeList/" + id,
success: function (data, textStatus, jQxhr) {
var indexes = table
- .rows()
- .indexes()
- .filter( function ( value, index ) {
- return id === table.row(value).data()[0];
- } );
- table.rows(indexes).remove().draw(false);
+ .rows()
+ .indexes()
+ .filter(function (value, index) {
+ return id === table.row(value).data()[0];
+ });
+ table.rows(indexes).remove().draw(false);
},
error: function (xhr, textStatus, errorThrown) {
console.log(textStatus);
@@ -110,8 +109,8 @@ function deleteEmployee(id) {
});
}
}
- })
-};
+ });
+}
//Read one employee info and put in the modifier form.
function editEmployee(id) {
@@ -122,7 +121,7 @@ function editEmployee(id) {
});
$('#action').val('Actualitzar');
$('#formType').html('Actualizar');
-};
+}
//Set Form in New Employee Mode
function newEmployee() {
@@ -146,4 +145,4 @@ function getJobCode(job) {
} else {
return "Default";
}
-}
\ No newline at end of file
+}
diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html
index 0387c89..b0c84f9 100644
--- a/src/main/resources/templates/index.html
+++ b/src/main/resources/templates/index.html
@@ -59,7 +59,15 @@ Exercici realitzat utilitzant: Spring Api Rest, Javascript, jquery i Bootstr
Accions |
-
+
+ id |
+ nom |
+ carreg |
+ sou |
+ |
+
+
From a819f269fe8cb1948355034fe7c392fa9f12ed0f Mon Sep 17 00:00:00 2001
From: Gerard
Date: Tue, 23 Mar 2021 18:24:15 +0100
Subject: [PATCH 2/2] Java minor Corrections
---
.../controller/ControllerWeb.java | 23 -------------------
.../CrudEmpleats/exceptions/IdNotFound.java | 2 ++
2 files changed, 2 insertions(+), 23 deletions(-)
delete mode 100644 src/main/java/com/itacademy/CrudEmpleats/controller/ControllerWeb.java
diff --git a/src/main/java/com/itacademy/CrudEmpleats/controller/ControllerWeb.java b/src/main/java/com/itacademy/CrudEmpleats/controller/ControllerWeb.java
deleted file mode 100644
index 261ba7d..0000000
--- a/src/main/java/com/itacademy/CrudEmpleats/controller/ControllerWeb.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.itacademy.CrudEmpleats.controller;
-
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-
-@Controller
-public class ControllerWeb {
- /*
- * Controlador d'accés html
- */
-
-
- @GetMapping("/index")
- public String goIndex() {
- return "index";
- }
-
- @GetMapping("/ModificarEmpleat")
- public String bodyHeader() {
- return "ModificarEmpleat";
- }
-
-}
diff --git a/src/main/java/com/itacademy/CrudEmpleats/exceptions/IdNotFound.java b/src/main/java/com/itacademy/CrudEmpleats/exceptions/IdNotFound.java
index 16a5532..6c08e0a 100644
--- a/src/main/java/com/itacademy/CrudEmpleats/exceptions/IdNotFound.java
+++ b/src/main/java/com/itacademy/CrudEmpleats/exceptions/IdNotFound.java
@@ -2,6 +2,8 @@
public class IdNotFound extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
private int id;
public IdNotFound(int id) {