diff --git a/react-frontend/src/App.css b/react-frontend/src/App.css index 3bd6851..b04c54c 100644 --- a/react-frontend/src/App.css +++ b/react-frontend/src/App.css @@ -45,4 +45,10 @@ background-color: black; text-align: center; color: white; +} + +.btnQuote{ + float: right; + margin-top: 30px; + background-color: white; } \ No newline at end of file diff --git a/react-frontend/src/App.js b/react-frontend/src/App.js index ae2c723..99192e3 100644 --- a/react-frontend/src/App.js +++ b/react-frontend/src/App.js @@ -8,6 +8,7 @@ import FooterComponent from './components/FooterComponent'; import CreateEmployeeComponent from './components/CreateEmployeeComponent'; import UpdateEmployeeComponent from './components/UpdateEmployeeComponent'; import ViewEmployeeComponent from './components/ViewEmployeeComponent'; +import getAQuote from './components/getAQuote'; function App() { return ( @@ -20,6 +21,7 @@ function App() { + {/* */} diff --git a/react-frontend/src/components/ListEmployeeComponent.jsx b/react-frontend/src/components/ListEmployeeComponent.jsx index 7617b4b..be09086 100644 --- a/react-frontend/src/components/ListEmployeeComponent.jsx +++ b/react-frontend/src/components/ListEmployeeComponent.jsx @@ -11,6 +11,7 @@ class ListEmployeeComponent extends Component { this.addEmployee = this.addEmployee.bind(this); this.editEmployee = this.editEmployee.bind(this); this.deleteEmployee = this.deleteEmployee.bind(this); + this.getQuote = this.getQuote.bind(this); } deleteEmployee(id){ @@ -35,9 +36,16 @@ class ListEmployeeComponent extends Component { this.props.history.push('/add-employee/_add'); } + getQuote(){ + this.props.history.push('/get-a-quote'); + } + render() { return ( + +
+

Employees List

@@ -45,7 +53,7 @@ class ListEmployeeComponent extends Component {

- + @@ -55,7 +63,8 @@ class ListEmployeeComponent extends Component { - { + + { this.state.employees.map( employee => diff --git a/react-frontend/src/components/getAQuote.js b/react-frontend/src/components/getAQuote.js new file mode 100644 index 0000000..a6ed754 --- /dev/null +++ b/react-frontend/src/components/getAQuote.js @@ -0,0 +1,34 @@ + + +import React, { Component } from 'react'; +import EmployeeService from '../services/EmployeeService'; + +class getAQuote extends Component { + + constructor(props) { + super(props) + this.state = { + QuoteMessage : '' + } + } + + componentDidMount(){ + EmployeeService.getQuote().then(res => { + this.setState({ + QuoteMessage: res.data + }) + }) + } + + render(props) { + return ( +
+

Here is a Quote for you :

+

{this.state.QuoteMessage}

+
+
+ ); + } +} + +export default getAQuote; \ No newline at end of file diff --git a/react-frontend/src/services/EmployeeService.js b/react-frontend/src/services/EmployeeService.js index 35a45d4..d2cf64e 100644 --- a/react-frontend/src/services/EmployeeService.js +++ b/react-frontend/src/services/EmployeeService.js @@ -1,6 +1,8 @@ import axios from 'axios'; const EMPLOYEE_API_BASE_URL = "http://localhost:8080/api/v1/employees"; +const GET_A_QUOTE_BASE_URL = "http://localhost:8081/api/v1/get-a-quote" + class EmployeeService { @@ -23,6 +25,10 @@ class EmployeeService { deleteEmployee(employeeId){ return axios.delete(EMPLOYEE_API_BASE_URL + '/' + employeeId); } + + getQuote(){ + return axios.get(GET_A_QUOTE_BASE_URL); + } } export default new EmployeeService() \ No newline at end of file diff --git a/springboot-backend/src/main/java/net/javaguides/springboot/controller/EmployeeController.java b/springboot-backend/src/main/java/net/javaguides/springboot/controller/EmployeeController.java index 2c7a91d..a3e29de 100644 --- a/springboot-backend/src/main/java/net/javaguides/springboot/controller/EmployeeController.java +++ b/springboot-backend/src/main/java/net/javaguides/springboot/controller/EmployeeController.java @@ -74,6 +74,13 @@ public ResponseEntity> deleteEmployee(@PathVariable Long id response.put("deleted", Boolean.TRUE); return ResponseEntity.ok(response); } + + + @GetMapping("/get-a-quote") + public String returnAQuote() { + int randomQuoteNumber = (int) Math.floor(Math.random() * (quotes.size() - 0) + 0); + return quotes.get(randomQuoteNumber); + } } diff --git a/springboot-backend/src/main/java/utility/Util.java b/springboot-backend/src/main/java/utility/Util.java new file mode 100644 index 0000000..2ca6d01 --- /dev/null +++ b/springboot-backend/src/main/java/utility/Util.java @@ -0,0 +1,18 @@ +package utility; + +import java.util.*; + +public class Util { + + public List quotes(){ + List quotes = new ArrayList(Arrays.asList( + "“That which does not kill us makes us stronger.”", + "“Be who you are and say what you feel, because those who mind don’t matter and those who matter don’t mind.”", + "“We must not allow other people’s limited perceptions to define us.”", + "“Be yourself; everyone else is already taken.”", + "“This above all: to thine own self be true.”" + )); + return quotes; + } + +} diff --git a/springboot-backend/src/main/resources/application.properties b/springboot-backend/src/main/resources/application.properties index d219091..7ee1fc4 100644 --- a/springboot-backend/src/main/resources/application.properties +++ b/springboot-backend/src/main/resources/application.properties @@ -1,7 +1,17 @@ -spring.datasource.url=jdbc:mysql://localhost:3306/employee_management_system?useSSL=false -spring.datasource.username=root -spring.datasource.password=root +#spring.datasource.url=jdbc:mysql://localhost:3306/employee_management_system?useSSL=false +#spring.datasource.username=root +#spring.datasource.password=root +# +#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect +# +#spring.jpa.hibernate.ddl-auto = update -spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect -spring.jpa.hibernate.ddl-auto = update + +server.port = 8081 +spring.jpa.show-sql=true + +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console +spring.datasource.url=jdbc:h2:mem:testdb +spring.devtools.livereload.enabled = true \ No newline at end of file
Employee First Name