Merge branch 'master' into 'Add_Calculator_to_GUI'
# Conflicts: # src/Client/src/main/java/greenify/client/controller/DashBoardController.java # src/Client/src/main/resources/fxml/dashboard.fxml the conflicts were only empty lines on the master
This commit is contained in:
@@ -12,15 +12,11 @@ import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//springbootApplication is so Spring knows that this is a Spring application
|
||||
@SpringBootApplication
|
||||
public class Application extends javafx.application.Application {
|
||||
//configurable application is for spring so it knows that it can use it
|
||||
private static ConfigurableApplicationContext springContext;
|
||||
//logger to log all the things that happen to the console
|
||||
private static final Logger log = LoggerFactory.getLogger(Application.class);
|
||||
|
||||
//launch is to launch the GUI things
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
@@ -29,10 +25,8 @@ public class Application extends javafx.application.Application {
|
||||
* This method takes an url and return a parent.
|
||||
* @param url which is being loaded.
|
||||
* @return parent object.
|
||||
* @throws IOException if it can't find an FXML file
|
||||
*/
|
||||
public static Parent load(java.net.URL url) throws IOException {
|
||||
//loader to load the FXML file
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setControllerFactory(springContext::getBean);
|
||||
loader.setLocation(url);
|
||||
@@ -41,22 +35,14 @@ public class Application extends javafx.application.Application {
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
//run the application
|
||||
springContext = SpringApplication.run(Application.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
//load the fxml file
|
||||
Parent rootNode = load(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
||||
//set the title for the window
|
||||
Parent rootNode = load(this.getClass().getClassLoader().getResource("fxml/LoginWindow.fxml"));
|
||||
primaryStage.setTitle("Greenify");
|
||||
//set the scene
|
||||
Scene scene = new Scene(rootNode);
|
||||
//add the stylesheet
|
||||
scene.getStylesheets()
|
||||
.add(getClass().getClassLoader().getResource("stylesheets/LoginWindowStyle.css")
|
||||
.toExternalForm());
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
@@ -121,11 +121,7 @@ public class DashBoardController {
|
||||
* @param event the event (clicking the button)
|
||||
*/
|
||||
public void displayActivities(ActionEvent event) {
|
||||
|
||||
|
||||
addFadeTransition(activitiesPane);
|
||||
|
||||
net = userService.currentUser.getVeganMeal() + count;
|
||||
totalVeganMealCounter.setText("" + net);
|
||||
System.out.println("display activities");
|
||||
dashboardPane.setVisible(false);
|
||||
@@ -157,23 +153,6 @@ public class DashBoardController {
|
||||
friendsPane.setVisible(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* adds a vegetarian meal.
|
||||
* @param event the event (clicking the button)
|
||||
*/
|
||||
public void addVeganMeal(ActionEvent event) {
|
||||
|
||||
count++;
|
||||
net = userService.currentUser.getVeganMeal() + count;
|
||||
totalVeganMealCounter.setText("" + net);
|
||||
veganMealCounter.setText("" + count);
|
||||
System.out.println(userService);
|
||||
userService.addVeganMeal(userService.currentUser.getId(),
|
||||
userService.currentUser.getName());
|
||||
System.out.println("Vegetarian meal is added");
|
||||
}
|
||||
|
||||
//sets the slide in transition for startup
|
||||
public void addSlideTransition(Node node, Line path1) {
|
||||
PathTransition pathTrans = new PathTransition(Duration.millis(1100), path1, node);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class UserController {
|
||||
public void openDashboard() throws IOException {
|
||||
//load the fxml file
|
||||
Parent dash = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/dashboard.fxml"));
|
||||
.getResource("fxml/dashboard.fxml"));
|
||||
Scene scene = new Scene(dash);
|
||||
//add the stylesheet for the CSS
|
||||
scene.getStylesheets().add(getClass().getClassLoader()
|
||||
|
||||
@@ -80,27 +80,18 @@ public class UserService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* a user adds vegan meal.
|
||||
* @param id the id of the user
|
||||
* @param name the username of the user
|
||||
* @return a userDTO
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public UserDto addVeganMeal(Long id, String name) {
|
||||
//this method is almost the same as the registerUser one, but with a different link
|
||||
public String updateInput(String name, String inputName, String value) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/addVeganMeal")
|
||||
.queryParam("id", id)
|
||||
.queryParam("name", name);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/setInput")
|
||||
.queryParam("name", name)
|
||||
.queryParam("inputName", inputName)
|
||||
.queryParam("value",value);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
return this.restTemplate.getForObject(builder.build().encode().toUri(), UserDto.class);
|
||||
}
|
||||
|
||||
@RequestMapping("/userData")
|
||||
public int getVeganData(@RequestParam(value = "veganMeal") int veganMeal) {
|
||||
return veganMeal;
|
||||
String result = this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user