Fix client errors
This commit is contained in:
@@ -12,15 +12,11 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
//springbootApplication is so Spring knows that this is a Spring application
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class Application extends javafx.application.Application {
|
public class Application extends javafx.application.Application {
|
||||||
//configurable application is for spring so it knows that it can use it
|
|
||||||
private static ConfigurableApplicationContext springContext;
|
private static ConfigurableApplicationContext springContext;
|
||||||
//logger to log all the things that happen to the console
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(Application.class);
|
private static final Logger log = LoggerFactory.getLogger(Application.class);
|
||||||
|
|
||||||
//launch is to launch the GUI things
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
@@ -29,10 +25,8 @@ public class Application extends javafx.application.Application {
|
|||||||
* This method takes an url and return a parent.
|
* This method takes an url and return a parent.
|
||||||
* @param url which is being loaded.
|
* @param url which is being loaded.
|
||||||
* @return parent object.
|
* @return parent object.
|
||||||
* @throws IOException if it can't find an FXML file
|
|
||||||
*/
|
*/
|
||||||
public static Parent load(java.net.URL url) throws IOException {
|
public static Parent load(java.net.URL url) throws IOException {
|
||||||
//loader to load the FXML file
|
|
||||||
FXMLLoader loader = new FXMLLoader();
|
FXMLLoader loader = new FXMLLoader();
|
||||||
loader.setControllerFactory(springContext::getBean);
|
loader.setControllerFactory(springContext::getBean);
|
||||||
loader.setLocation(url);
|
loader.setLocation(url);
|
||||||
@@ -41,22 +35,14 @@ public class Application extends javafx.application.Application {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
//run the application
|
|
||||||
springContext = SpringApplication.run(Application.class);
|
springContext = SpringApplication.run(Application.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
//load the fxml file
|
Parent rootNode = load(this.getClass().getClassLoader().getResource("fxml/LoginWindow.fxml"));
|
||||||
Parent rootNode = load(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
|
|
||||||
//set the title for the window
|
|
||||||
primaryStage.setTitle("Greenify");
|
primaryStage.setTitle("Greenify");
|
||||||
//set the scene
|
|
||||||
Scene scene = new Scene(rootNode);
|
Scene scene = new Scene(rootNode);
|
||||||
//add the stylesheet
|
|
||||||
scene.getStylesheets()
|
|
||||||
.add(getClass().getClassLoader().getResource("stylesheets/LoginWindowStyle.css")
|
|
||||||
.toExternalForm());
|
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package greenify.client.controller;
|
package greenify.client.controller;
|
||||||
|
|
||||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
|
||||||
import greenify.client.rest.UserService;
|
import greenify.client.rest.UserService;
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
import javafx.animation.PathTransition;
|
import javafx.animation.PathTransition;
|
||||||
@@ -10,6 +9,7 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.skin.ButtonSkin;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.shape.Line;
|
import javafx.scene.shape.Line;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
@@ -72,9 +72,6 @@ public class DashBoardController {
|
|||||||
activitiesButton.setSkin(new MyButtonSkin(activitiesButton));
|
activitiesButton.setSkin(new MyButtonSkin(activitiesButton));
|
||||||
userButton.setSkin(new MyButtonSkin(userButton));
|
userButton.setSkin(new MyButtonSkin(userButton));
|
||||||
friendsButton.setSkin(new MyButtonSkin(friendsButton));
|
friendsButton.setSkin(new MyButtonSkin(friendsButton));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -109,11 +106,7 @@ public class DashBoardController {
|
|||||||
* @param event the event (clicking the button)
|
* @param event the event (clicking the button)
|
||||||
*/
|
*/
|
||||||
public void displayActivities(ActionEvent event) {
|
public void displayActivities(ActionEvent event) {
|
||||||
|
|
||||||
|
|
||||||
addFadeTransition(activitiesPane);
|
addFadeTransition(activitiesPane);
|
||||||
|
|
||||||
net = userService.currentUser.getVeganMeal() + count;
|
|
||||||
totalVeganMealCounter.setText("" + net);
|
totalVeganMealCounter.setText("" + net);
|
||||||
System.out.println("display activities");
|
System.out.println("display activities");
|
||||||
dashboardPane.setVisible(false);
|
dashboardPane.setVisible(false);
|
||||||
@@ -146,23 +139,6 @@ public class DashBoardController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
//sets the slide in transition for startup
|
||||||
public void addSlideTransition(Node node, Line path1) {
|
public void addSlideTransition(Node node, Line path1) {
|
||||||
PathTransition pathTrans = new PathTransition(Duration.millis(1100), path1, node);
|
PathTransition pathTrans = new PathTransition(Duration.millis(1100), path1, node);
|
||||||
@@ -194,4 +170,4 @@ public class DashBoardController {
|
|||||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class UserController {
|
|||||||
public void openDashboard() throws IOException {
|
public void openDashboard() throws IOException {
|
||||||
//load the fxml file
|
//load the fxml file
|
||||||
Parent dash = Application.load(this.getClass().getClassLoader()
|
Parent dash = Application.load(this.getClass().getClassLoader()
|
||||||
.getResource("fxml/dashboard.fxml"));
|
.getResource("fxml/dashboard.fxml"));
|
||||||
Scene scene = new Scene(dash);
|
Scene scene = new Scene(dash);
|
||||||
//add the stylesheet for the CSS
|
//add the stylesheet for the CSS
|
||||||
scene.getStylesheets().add(getClass().getClassLoader()
|
scene.getStylesheets().add(getClass().getClassLoader()
|
||||||
|
|||||||
@@ -80,27 +80,18 @@ public class UserService {
|
|||||||
return result;
|
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")
|
@SuppressWarnings("Duplicates")
|
||||||
public UserDto addVeganMeal(Long id, String name) {
|
public String updateInput(String name, String inputName, String value) {
|
||||||
//this method is almost the same as the registerUser one, but with a different link
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/addVeganMeal")
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/setInput")
|
||||||
.queryParam("id", id)
|
.queryParam("name", name)
|
||||||
.queryParam("name", name);
|
.queryParam("inputName", inputName)
|
||||||
|
.queryParam("value",value);
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
return this.restTemplate.getForObject(builder.build().encode().toUri(), UserDto.class);
|
String result = this.restTemplate.getForObject(builder.build()
|
||||||
}
|
.encode().toUri(), String.class);
|
||||||
|
return result;
|
||||||
@RequestMapping("/userData")
|
|
||||||
public int getVeganData(@RequestParam(value = "veganMeal") int veganMeal) {
|
|
||||||
return veganMeal;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.image.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.image.Image?>
|
<?import javafx.scene.image.Image?>
|
||||||
<?import javafx.scene.image.ImageView?>
|
<?import javafx.scene.image.ImageView?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
|
|
||||||
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="602.0" prefWidth="934.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.UserController">
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="602.0" prefWidth="934.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.UserController">
|
||||||
<children>
|
<children>
|
||||||
<ImageView fitHeight="600.0" fitWidth="943.0" layoutX="-1.0" pickOnBounds="true">
|
<ImageView fitHeight="600.0" fitWidth="943.0" layoutX="-1.0" pickOnBounds="true">
|
||||||
@@ -36,3 +32,4 @@
|
|||||||
<TextField fx:id="usernameField" layoutX="319.0" layoutY="154.0" prefHeight="42.0" prefWidth="303.0" promptText="Username" />
|
<TextField fx:id="usernameField" layoutX="319.0" layoutY="154.0" prefHeight="42.0" prefWidth="303.0" promptText="Username" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|
||||||
@@ -1,21 +1,14 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.image.*?>
|
<?import javafx.scene.image.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.shape.*?>
|
<?import javafx.scene.shape.*?>
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.PasswordField?>
|
|
||||||
<?import javafx.scene.control.TextField?>
|
|
||||||
<?import javafx.scene.image.Image?>
|
|
||||||
<?import javafx.scene.image.ImageView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
|
|
||||||
<AnchorPane prefHeight="300.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.RegisterWindowController">
|
<AnchorPane prefHeight="300.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.RegisterWindowController">
|
||||||
<children>
|
<children>
|
||||||
<Line fx:id="uNamePathLine" endX="100.0" layoutX="2.0" layoutY="109.0" startX="-100.0" />
|
<Line fx:id="uNamePathLine" endX="100.0" layoutX="2.0" layoutY="109.0" startX="-100.0" />
|
||||||
<ImageView fitHeight="312.0" fitWidth="300.0" pickOnBounds="true" preserveRatio="true">
|
<ImageView fitHeight="312.0" fitWidth="300.0" pickOnBounds="true" preserveRatio="true">
|
||||||
<image>
|
<image>
|
||||||
<Image url="@../registerBackground.png" />
|
<Image url="@../registerBackground.png" />
|
||||||
|
|||||||
@@ -1,22 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.image.*?>
|
<?import javafx.scene.image.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<?import javafx.scene.shape.*?>
|
<?import javafx.scene.shape.*?>
|
||||||
<?import javafx.scene.text.*?>
|
<?import javafx.scene.text.*?>
|
||||||
<?import javafx.scene.control.Button?>
|
|
||||||
<?import javafx.scene.control.Label?>
|
|
||||||
<?import javafx.scene.image.Image?>
|
|
||||||
<?import javafx.scene.image.ImageView?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
<?import javafx.scene.layout.Pane?>
|
|
||||||
<?import javafx.scene.layout.VBox?>
|
|
||||||
<?import javafx.scene.shape.Line?>
|
|
||||||
<?import javafx.scene.text.Font?>
|
|
||||||
<?import javafx.scene.text.Text?>
|
|
||||||
|
|
||||||
<AnchorPane prefHeight="602.0" prefWidth="934.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
|
<AnchorPane prefHeight="602.0" prefWidth="934.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
|
||||||
<children>
|
<children>
|
||||||
@@ -229,10 +217,10 @@
|
|||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
<TableView fx:id="friendsTable" layoutX="60.0" layoutY="130.0" prefHeight="426.0" prefWidth="216.0" style="-fx-background-color: #e1fcd9;">
|
<TableView fx:id="friendsTable" layoutX="60.0" layoutY="130.0" prefHeight="426.0" prefWidth="216.0" style="-fx-background-color: #e1fcd9;">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn fx:id="friendsColumn" prefWidth="107.0" text="Friend" />
|
<TableColumn fx:id="friendsColumn" prefWidth="107.0" text="Friend" />
|
||||||
<TableColumn fx:id="scoreColumn" prefWidth="108.0" text="Score" />
|
<TableColumn fx:id="scoreColumn" prefWidth="108.0" text="Score" />
|
||||||
</columns>
|
</columns>
|
||||||
</TableView>
|
</TableView>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
|||||||
Reference in New Issue
Block a user