diff --git a/src/Client/src/main/java/greenify/client/Application.java b/src/Client/src/main/java/greenify/client/Application.java
index dca6ad1..def73e6 100644
--- a/src/Client/src/main/java/greenify/client/Application.java
+++ b/src/Client/src/main/java/greenify/client/Application.java
@@ -37,24 +37,11 @@ public class Application extends javafx.application.Application {
public void start(Stage primaryStage) throws Exception {
fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
- // fxmlLoader.setLocation(
- // this.getClass().getClassLoader().getResource("fxml/dashboard.fxml")
- // );
-
-
rootNode = fxmlLoader.load();
- // rootNode = FXMLLoader.load(
- // this.getClass().getClassLoader().getResource("fxml/sample.fxml")
- // );
-
primaryStage.setTitle("GoGreen");
Scene scene = new Scene(rootNode);
- // scene.getStylesheets().add(
- // getClass().getResource("stylesheets/dashboardStyle.css").toExternalForm()
- // );
-
primaryStage.setScene(scene);
primaryStage.show();
}
diff --git a/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java
new file mode 100644
index 0000000..59e6aa1
--- /dev/null
+++ b/src/Client/src/main/java/greenify/client/controller/RegisterWindowController.java
@@ -0,0 +1,81 @@
+package greenify.client.controller;
+
+import greenify.client.rest.UserService;
+import javafx.event.ActionEvent;
+import javafx.fxml.FXML;
+import javafx.scene.control.Alert;
+import javafx.scene.control.Button;
+import javafx.scene.control.PasswordField;
+import javafx.scene.control.TextField;
+import javafx.stage.Stage;
+import javafx.stage.Window;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+
+@Controller
+public class RegisterWindowController {
+
+ @Autowired
+ UserService userService;
+
+ @FXML
+ private TextField userNameText;
+ @FXML
+ private PasswordField passwordField;
+ @FXML
+ private PasswordField passwordField2;
+ @FXML
+ private Button signupButton;
+
+ /**
+ * signs the user up.
+ * @param event the click of the signup button
+ */
+ @FXML
+ public void handleSignUpButton(ActionEvent event) {
+ // System.out.println("pressed sign up button!");
+
+ //set the window to the current window (for displaying the alerts)
+ Window owner = signupButton.getScene().getWindow();
+ //check if the username field is empty
+ if (userNameText.getText().isEmpty()) {
+ //if so, display an alert
+ UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
+ "Please enter a username!");
+ return;
+ }
+ // else {
+ // System.out.println("username is " + userNameText.getText());
+ // }
+
+ //check if the password field is empty
+ if (passwordField.getText().isEmpty()) {
+ //if so, display an alert
+ UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Password Error!",
+ "Please enter a password!");
+ return;
+ }
+ // else {
+ // System.out.println("password is " + passwordField.getText());
+ // }
+
+ //check if the two password fields are equal
+ if (!passwordField.getText().equals(passwordField2.getText())) {
+ //if not, display an alert
+ UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Password Error!",
+ "Please make sure the passwords entered are the same!");
+ return;
+ }
+ // else {
+ // System.out.println("registered user with username:"
+ // + userNameText.getText()
+ // + ", and password:" + passwordField.getText());
+ // }
+
+ userService.registerUser(userNameText.getText(), passwordField.getText());
+
+ //close the register window after the user has entered all the credentials
+ Stage current = (Stage) owner;
+ current.close();
+ }
+}
diff --git a/src/Client/src/main/java/greenify/client/controller/UserController.java b/src/Client/src/main/java/greenify/client/controller/UserController.java
index 72e9be2..2d2a956 100644
--- a/src/Client/src/main/java/greenify/client/controller/UserController.java
+++ b/src/Client/src/main/java/greenify/client/controller/UserController.java
@@ -81,6 +81,9 @@ public class UserController {
// app_stage.setScene(scene);
// app_stage.setFullScreen(true);
// app_stage.show();
+
+ Stage current = (Stage) owner;
+ current.close();
openDashboard();
}
@@ -128,4 +131,19 @@ public class UserController {
}
}
+ //method to open the register window
+ public void handleRegisterButtonAction(ActionEvent event) throws Exception{
+ //load the fxml file
+ Parent registerWindow = FXMLLoader.load (
+ this.getClass().getClassLoader().getResource("fxml/RegisterWindow.fxml")
+ );
+ //make the window use the scene
+ Scene registerscene = new Scene(registerWindow);
+ Stage registerStage = new Stage();
+ //open the window
+ registerStage.setScene(registerscene);
+ registerStage.setTitle("Enter register credentials");
+ registerStage.show();
+ }
+
}
diff --git a/src/Client/src/main/resources/fxml/RegisterWindow.fxml b/src/Client/src/main/resources/fxml/RegisterWindow.fxml
new file mode 100644
index 0000000..85e1d4d
--- /dev/null
+++ b/src/Client/src/main/resources/fxml/RegisterWindow.fxml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Client/src/main/resources/fxml/dashboard.fxml b/src/Client/src/main/resources/fxml/dashboard.fxml
index c82eaae..fa5d290 100644
--- a/src/Client/src/main/resources/fxml/dashboard.fxml
+++ b/src/Client/src/main/resources/fxml/dashboard.fxml
@@ -34,7 +34,7 @@
-
+
@@ -55,7 +55,7 @@
-
+