Fix client errors
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();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.PathTransition;
|
||||
@@ -10,6 +9,7 @@ import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.skin.ButtonSkin;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.util.Duration;
|
||||
@@ -72,9 +72,6 @@ public class DashBoardController {
|
||||
activitiesButton.setSkin(new MyButtonSkin(activitiesButton));
|
||||
userButton.setSkin(new MyButtonSkin(userButton));
|
||||
friendsButton.setSkin(new MyButtonSkin(friendsButton));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,11 +106,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);
|
||||
@@ -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
|
||||
public void addSlideTransition(Node node, Line path1) {
|
||||
PathTransition pathTrans = new PathTransition(Duration.millis(1100), path1, node);
|
||||
@@ -194,4 +170,4 @@ public class DashBoardController {
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
<?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.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?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">
|
||||
<children>
|
||||
<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" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
@@ -1,21 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?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.*?>
|
||||
|
||||
<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>
|
||||
<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">
|
||||
<image>
|
||||
<Image url="@../registerBackground.png" />
|
||||
|
||||
@@ -1,22 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.*?>
|
||||
<?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">
|
||||
<children>
|
||||
@@ -229,10 +217,10 @@
|
||||
</font>
|
||||
</Text>
|
||||
<TableView fx:id="friendsTable" layoutX="60.0" layoutY="130.0" prefHeight="426.0" prefWidth="216.0" style="-fx-background-color: #e1fcd9;">
|
||||
<columns>
|
||||
<TableColumn fx:id="friendsColumn" prefWidth="107.0" text="Friend" />
|
||||
<TableColumn fx:id="scoreColumn" prefWidth="108.0" text="Score" />
|
||||
</columns>
|
||||
<columns>
|
||||
<TableColumn fx:id="friendsColumn" prefWidth="107.0" text="Friend" />
|
||||
<TableColumn fx:id="scoreColumn" prefWidth="108.0" text="Score" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
|
||||
Reference in New Issue
Block a user