diff --git a/README.md b/README.md index 052cc92..ed0c5ab 100644 --- a/README.md +++ b/README.md @@ -53,8 +53,7 @@ action plan: ## Personal Development Plan: - -- This is my core quadrant: + My strong points: - I am an ambitious person in order to achieve my goal I can study a lot diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index 40cb60a..54f51de 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -11,11 +11,11 @@ import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; import javafx.scene.control.Slider; import javafx.scene.control.TextField; -import javafx.scene.control.CheckBox; import javafx.scene.layout.AnchorPane; import javafx.scene.text.Text; import javafx.stage.Stage; @@ -472,6 +472,18 @@ public class CalculatorController { servicesLabel.getText().replace("€ / month", "")); } Float footprint = userService.saveFootprint(userService.currentUser.getName()); + if(localProduceCheckbox.isSelected()) { + controller.localProduce.setSelected(true); + } + if(bikeCheckbox.isSelected()) { + controller.bike.setSelected(true); + } + if(temperatureCheckbox.isSelected()) { + controller.loweringTemp.setSelected(true); + } + if(solarPanelsCheckbox.isSelected()) { + controller.solarPanels.setSelected(true); + } Window owner = saveButton.getScene().getWindow(); Stage current = (Stage) owner; current.close(); diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java index ff9a565..edf21e0 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -15,10 +15,7 @@ import javafx.scene.Node; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.chart.PieChart; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; +import javafx.scene.control.*; import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.AnchorPane; import javafx.scene.shape.Line; @@ -29,6 +26,7 @@ import org.springframework.stereotype.Controller; import java.io.IOException; import java.util.List; +import java.util.Map; /** * Class that controls the dashboard fxml file (the GUI Screen). @@ -96,6 +94,60 @@ public class DashBoardController { private PieChart pieChart; @FXML private Label usernameLabel; + @FXML + private TextField peopleNumber; + @FXML + private TextField income; + @FXML + private TextField electricityUsage; + @FXML + private TextField cleanEnergy; + @FXML + private TextField naturalGasUsage; + @FXML + private TextField heatingOilUsage; + @FXML + private TextField waterUsage; + @FXML + private TextField livingSpace; + @FXML + private TextField gasolineMiles; + @FXML + private TextField gasolineMpg; + @FXML + private TextField dieselMiles; + @FXML + private TextField dieselMpg; + @FXML + private TextField electricMiles; + @FXML + private TextField electricMpg; + @FXML + private TextField publicTransportation; + @FXML + private TextField airPlane; + @FXML + private TextField goodShopping; + @FXML + private TextField serviceShopping; + @FXML + private TextField meat; + @FXML + private TextField grains; + @FXML + private TextField dairy; + @FXML + private TextField fruits; + @FXML + private TextField snacks; + @FXML + public CheckBox localProduce; + @FXML + public CheckBox loweringTemp; + @FXML + public CheckBox bike; + @FXML + public CheckBox solarPanels; /** * Loads the the necessary things before anything else. @@ -200,6 +252,30 @@ public class DashBoardController { userPane.setVisible(false); activitiesPane.setVisible(true); friendsPane.setVisible(false); + Map inputMap = userService.getInputs(userService.currentUser.getName()); + peopleNumber.setText(inputMap.get("input_size")); + income.setText(inputMap.get("input_income")); + electricityUsage.setText(inputMap.get("input_footprint_housing_electricity_dollars")); + cleanEnergy.setText(inputMap.get("input_footprint_housing_gco2_per_kwh")); + naturalGasUsage.setText(inputMap.get("input_footprint_housing_naturalgas_dollars")); + heatingOilUsage.setText(inputMap.get("input_footprint_housing_heatingoil_dollars")); + waterUsage.setText(inputMap.get("input_footprint_housing_watersewage")); + livingSpace.setText(inputMap.get("input_footprint_housing_squarefeet")); + gasolineMiles.setText(inputMap.get("input_footprint_transportation_miles1")); + gasolineMpg.setText(inputMap.get("input_footprint_transportation_mpg1")); + dieselMiles.setText(inputMap.get("input_footprint_transportation_miles2")); + dieselMpg.setText(inputMap.get("input_footprint_transportation_mpg2")); + electricMiles.setText(inputMap.get("input_footprint_transportation_miles3")); + electricMpg.setText(inputMap.get("input_footprint_transportation_mpg3")); + publicTransportation.setText(inputMap.get("input_footprint_transportation_publictrans")); + airPlane.setText(inputMap.get("input_footprint_transportation_airtotal")); + goodShopping.setText(inputMap.get("input_footprint_shopping_goods_total")); + serviceShopping.setText(inputMap.get("input_footprint_shopping_services_total")); + meat.setText(inputMap.get("input_footprint_shopping_food_meatfisheggs")); + grains.setText(inputMap.get("input_footprint_shopping_food_cereals")); + dairy.setText(inputMap.get("input_footprint_shopping_food_dairy")); + fruits.setText(inputMap.get("input_footprint_shopping_food_fruitvegetables")); + snacks.setText(inputMap.get("input_footprint_shopping_food_otherfood")); } /** @@ -209,8 +285,7 @@ public class DashBoardController { public void displayUser(ActionEvent event) { System.out.println(userService.currentUser.getName()); System.out.println(userService.getFootprint(userService.currentUser.getName())); - footprintLabel.setText("" + userService.getFootprint(userService.currentUser.getName()) - + "\n tons CO2/year"); + footprintLabel.setText("" + userService.getFootprint(userService.currentUser.getName())); usernameLabel.setText("" + userService.currentUser.getName()); addFadeTransition(userPane); System.out.println("display user"); diff --git a/src/Client/src/main/java/greenify/client/rest/UserService.java b/src/Client/src/main/java/greenify/client/rest/UserService.java index f07534f..9cdd50f 100644 --- a/src/Client/src/main/java/greenify/client/rest/UserService.java +++ b/src/Client/src/main/java/greenify/client/rest/UserService.java @@ -1,5 +1,6 @@ package greenify.client.rest; +import com.sun.javafx.collections.MappingChange; import greenify.common.UserDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.client.RestTemplateBuilder; @@ -12,7 +13,10 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; +import java.awt.*; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class UserService { @@ -173,6 +177,23 @@ public class UserService { .encode().toUri(), String.class); } + /** + * Gets the footprint inputs of the user. + * @param name the username of the current user. + */ + @SuppressWarnings("Duplicates") + public Map getInputs(String name) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getInputs") + .queryParam("name", name); + HttpEntity entity = new HttpEntity<>(headers); + System.out.println(builder.build().encode().toUri()); + Map result = this.restTemplate.getForObject(builder.build() + .encode().toUri(), Map.class); + return result; + } + /** * Gets the list of all users. */ diff --git a/src/Client/src/main/resources/fxml/dashboard.fxml b/src/Client/src/main/resources/fxml/dashboard.fxml index 5ac6f85..af55c2e 100644 --- a/src/Client/src/main/resources/fxml/dashboard.fxml +++ b/src/Client/src/main/resources/fxml/dashboard.fxml @@ -1,17 +1,12 @@ - - - - - - - + + @@ -57,121 +52,225 @@ - + - + + - - - - - - - - - - - - - - - - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -275,16 +374,16 @@ - - - - + + + + - - - - + + + +