diff --git a/src/Client/src/main/java/greenify/client/Application.java b/src/Client/src/main/java/greenify/client/Application.java
index e7da5f4..a710131 100644
--- a/src/Client/src/main/java/greenify/client/Application.java
+++ b/src/Client/src/main/java/greenify/client/Application.java
@@ -31,9 +31,12 @@ public class Application extends javafx.application.Application {
@Override
public void start(Stage primaryStage) throws Exception {
fxmlLoader.setLocation(this.getClass().getClassLoader().getResource("fxml/sample.fxml"));
+
rootNode = fxmlLoader.load();
+
primaryStage.setTitle("GoGreen");
Scene scene = new Scene(rootNode);
+
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 b1c812d..b9c7419 100644
--- a/src/Client/src/main/java/greenify/client/controller/UserController.java
+++ b/src/Client/src/main/java/greenify/client/controller/UserController.java
@@ -55,6 +55,20 @@ public class UserController {
}
userService.registerUser(usernameField.getText(), passwordField.getText());
+
+ // load the dashboard stage
+ // Parent parent = FXMLLoader.load(
+ // this.getClass().getClassLoader().getResource("/fxml/dashboard.fxml")
+ // );
+ //
+ // Scene scene = new Scene(parent);
+ // Stage app_stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
+ // app_stage.setScene(scene);
+ // app_stage.setFullScreen(true);
+ // app_stage.show();
+
+ Stage current = (Stage) owner;
+ current.close();
openDashboard();
}
@@ -98,4 +112,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/sample.fxml b/src/Client/src/main/resources/fxml/sample.fxml
index 27dd987..8a4722d 100644
--- a/src/Client/src/main/resources/fxml/sample.fxml
+++ b/src/Client/src/main/resources/fxml/sample.fxml
@@ -1,5 +1,10 @@
+
+
+
+
+
@@ -10,7 +15,7 @@
-
+
@@ -21,8 +26,8 @@
-
-
+
+
diff --git a/src/Client/src/main/resources/registerBackground.png b/src/Client/src/main/resources/registerBackground.png
new file mode 100644
index 0000000..b98cca1
Binary files /dev/null and b/src/Client/src/main/resources/registerBackground.png differ
diff --git a/src/Client/src/main/resources/stylesheets/dashboardStyle.css b/src/Client/src/main/resources/stylesheets/dashboardStyle.css
index b0dabf2..3f5681e 100644
--- a/src/Client/src/main/resources/stylesheets/dashboardStyle.css
+++ b/src/Client/src/main/resources/stylesheets/dashboardStyle.css
@@ -52,4 +52,3 @@
#activitiesButton:pressed {
-fx-background-color: #b7e2c2;
}
-