Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
</properties>

<dependencies>

<!-- JavaFX -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
Expand All @@ -31,7 +29,6 @@
<version>${javafx.version}</version>
</dependency>

<!-- JUnit -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand All @@ -42,7 +39,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.0</version>
<version>2.18.3</version>
</dependency>

<dependency>
Expand All @@ -61,37 +58,24 @@

<build>
<plugins>

<!-- JavaFX Plugin -->
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>app.Main</mainClass>
<options>
<option>-Dfile.encoding=UTF-8</option>
<option>-Dstdout.encoding=UTF-8</option>
</options>
</configuration>
</plugin>

<!-- Surefire for JUnit -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.4</version>
</plugin>

<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>app.Main</mainClass>
<options>
<option>-Dfile.encoding=UTF-8</option>
<option>-Dstdout.encoding=UTF-8</option>
</options>
</configuration>
</plugin>

</plugins>
</build>
</project>
43 changes: 42 additions & 1 deletion src/main/java/domain/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class User {
private String userName;
private String phoneNumber;
private final String eMail;
private String eMail;
private String password;
private Long id;

Expand Down Expand Up @@ -87,6 +87,47 @@ public String getPassword() {
*/
public long getID() { return id; }

/**
* Sets the username of this user.
* @param userName the new username; must not be null or blank
*/
public void setUsername(String userName) {
if (userName == null || userName.isBlank()) {
throw new IllegalArgumentException("Username has to be filled in");
}
this.userName = userName;
}

/**
* Sets the phone number of this user.
* @param phoneNumber the new phone number; must be exactly 8 digits
*/
public void setPhoneNumber(String phoneNumber) {
if (phoneNumber == null || phoneNumber.isBlank() || phoneNumber.length() != 8) {
throw new IllegalArgumentException("Fill in a phonenumber with 8 digits");
}
this.phoneNumber = phoneNumber;
}

/**
* Sets the email address of this user.
* @param eMail the new email address; must be a valid email format
*/
public void setEmail(String eMail) {
if (!isValidEmail(eMail)) {
throw new IllegalArgumentException("Invalid email address: " + eMail);
}
this.eMail = eMail.trim();
}

/**
* Sets the password hash of this user.
* @param password the new hashed password
*/
public void setPassword(String password) {
this.password = password;
}

/**
* Sets the ID for this user.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/persistence/dao/DonationDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,6 @@ private String mapRowSimple(ResultSet rs) throws SQLException {
*/
private String mapRowFavorite(ResultSet rs) throws SQLException {
return rs.getString("name")
+ " (" + rs.getInt("donation_count") + " donasjoner)";
+ " (" + rs.getInt("donation_count") + " donations)";
}
}
15 changes: 15 additions & 0 deletions src/main/java/ui/controller/NavbarController.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import ui.Page;
import util.SessionManager;
Expand All @@ -23,6 +24,8 @@ public class NavbarController {
private Button orgBtn;
@FXML
private Button signInBtn;
@FXML
private Label logoLabel;

/**
* Sets the navigation callback.
Expand Down Expand Up @@ -56,13 +59,15 @@ public void setActivePage(Page page) {
/**
* Navigates to the home page.
*/
@FXML
public void goHome() {
onNavigate.accept(Page.HOME);
}

/**
* Navigates to the sign in page or profile page depending on authentication state.
*/
@FXML
public void goToSignIn() {
if (SessionManager.isSignedIn()) {
onNavigate.accept(Page.PROFILE);
Expand All @@ -74,10 +79,12 @@ public void goToSignIn() {
/**
* Navigates to the organizations page.
*/
@FXML
public void goToOrganizations() {
onNavigate.accept(Page.ORGANIZATIONS);
}


/**
* Updates the sign in button text based on the user's authentication state.
* Shows "My Profile" if signed in, "Sign In" otherwise.
Expand All @@ -90,6 +97,14 @@ public void updateAuthButton() {
}
}

/**
* Navigates to the home page.
*/
@FXML
private void handleLogoClick() {
onNavigate.accept(Page.HOME);
}

/**
* Hides the navbar.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ui/controller/OrganizationDetailController.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public void setOrganization(Organization org, OrganizationDetails details) {
} else {
logoImageView.setVisible(false);
}
System.out.println("Beskrivelse: " + details.getDescription());
System.out.println("Lengde: " + details.getDescription().length());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/css/Global.css
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
}

.logo-label {
-fx-font-size: 22px;
-fx-font-size: 32px;
-fx-font-family: "Times New Roman";
-fx-text-fill: white;
-fx-font-weight: bold;
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/view/Home.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>

<BorderPane xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/25" fx:controller="ui.controller.HomeController">
<BorderPane xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ui.controller.HomeController">
<center>
<ScrollPane fitToWidth="true" BorderPane.alignment="CENTER">
<content>
Expand All @@ -25,7 +25,6 @@
<HBox spacing="12.0">
<children>
<Button mnemonicParsing="false" onAction="#handleBrowseOrganizations" styleClass="hero-button-primary" text="Explore Organizations" />
<Button mnemonicParsing="false" styleClass="hero-button-secondary" text="Learn More" />
</children>
</HBox>
</children>
Expand Down
114 changes: 103 additions & 11 deletions src/main/resources/view/MyProfile.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,123 @@
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.PasswordField?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>

<BorderPane xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ui.controller.MyProfileController">
<center>
<ScrollPane fitToWidth="true" hbarPolicy="NEVER" BorderPane.alignment="CENTER">
<ScrollPane fx:id="scrollPane" fitToWidth="true" hbarPolicy="NEVER" BorderPane.alignment="CENTER">
<content>
<VBox prefHeight="800.0" spacing="25.0">
<children>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0">
<children>
<Label styleClass="section-title" text="My Profile" />
<VBox fx:id="MyProfile" prefHeight="100.0" prefWidth="187.0" spacing="10.0" styleClass="org-card">
<VBox fx:id="myProfile" prefHeight="100.0" prefWidth="187.0" spacing="10.0" styleClass="org-card">
<children>
<Label fx:id="nameLabel" styleClass="profile-label" text="Name: " />
<Label fx:id="emailLabel" styleClass="profile-label" text="Email:" />
<Label fx:id="phoneLabel" styleClass="profile-label" text="Phone:" />
<Button mnemonicParsing="false" styleClass="page-button" text="Edit Profile" />
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label styleClass="field-label" text="Name:" />
<Label fx:id="nameLabel" styleClass="profile-label" />
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label styleClass="field-label" text="Email:" />
<Label fx:id="emailLabel" styleClass="profile-label" />
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label styleClass="field-label" text="Phone number:" />
<Label fx:id="phoneLabel" styleClass="profile-label" />
</children>
</VBox>
<Button mnemonicParsing="false" styleClass="secondary-button" text="Edit Profile" />
</children>
<padding>
<Insets bottom="15.0" left="15.0" right="15.0" top="15.0" />
</padding>
</VBox>
<VBox fx:id="editProfilePane" managed="false" styleClass="org-card" visible="false">
<children>
<HBox prefHeight="100.0" prefWidth="200.0">
<children>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" HBox.hgrow="ALWAYS">
<children>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label styleClass="field-label" text="Name" />
<TextField fx:id="editNameField" styleClass="input-field">
<VBox.margin>
<Insets />
</VBox.margin>
</TextField>
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label styleClass="field-label" text="Email" />
<TextField fx:id="editEmailField" styleClass="input-field" />
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label styleClass="field-label" text="Phone number" />
<TextField fx:id="editPhoneField" styleClass="input-field" />
</children>
</VBox>
</children>
<padding>
<Insets bottom="15.0" right="15.0" top="15.0" />
</padding>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0" HBox.hgrow="ALWAYS">
<children>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label styleClass="field-label" text="New passsword" />
<PasswordField fx:id="newPasswordField" styleClass="input-field" />
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0">
<children>
<Label styleClass="field-label" text="Confirm password" />
<PasswordField fx:id="confirmPasswordField" styleClass="input-field" />
</children>
</VBox>
<Region prefHeight="200.0" prefWidth="200.0" />
</children>
<padding>
<Insets bottom="15.0" left="15.0" top="15.0" />
</padding>
</VBox>
</children>
</HBox>
<VBox alignment="TOP_RIGHT">
<children>
<HBox alignment="TOP_RIGHT" prefHeight="42.0" prefWidth="211.0" spacing="10.0">
<children>
<Button mnemonicParsing="false" styleClass="secondary-button" text="Cancel" />
<Button mnemonicParsing="false" styleClass="confirm-button" text="Save Profile" />
</children>
<padding>
<Insets left="15.0" right="15.0" />
</padding>
</HBox>
<Label fx:id="errorLabel" alignment="CENTER" styleClass="error-label" />
</children>
</VBox>
</children>
</VBox>
</children>
</VBox>
<VBox fx:id="Statistics" prefHeight="100.0" prefWidth="173.0">
Expand Down Expand Up @@ -64,22 +153,25 @@
</HBox>
</children>
</VBox>
<VBox prefHeight="200.0" prefWidth="100.0" spacing="10.0">
<VBox spacing="10.0">
<children>
<Label styleClass="section-title" text="Donation history" />
<TableView fx:id="donationTable" prefHeight="200.0" prefWidth="200.0">
<TableView fx:id="donationTable" minHeight="200.0" prefHeight="200.0" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="orgColumn" prefWidth="250.00003564357758" text="Organizations" />
<TableColumn fx:id="orgColumn" prefWidth="250.00003564357758" text="Organizations" />
<TableColumn fx:id="amountColumn" minWidth="0.0" prefWidth="131.99998474121094" text="Amount" />
<TableColumn fx:id="dateColumn" prefWidth="116.0" text="Date" />
<TableColumn fx:id="dateColumn" prefWidth="116.0" text="Date" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
</TableView>
</children>
</VBox>
<VBox fx:id="MyOrganizations" prefHeight="100.0" prefWidth="184.0">
<children>
<Label styleClass="section-title" text="Saved Organizations" />
<FlowPane fx:id="savedOrgsPane" prefHeight="200.0" prefWidth="200.0" />
<FlowPane fx:id="savedOrgsPane" hgap="15.0" prefHeight="200.0" prefWidth="200.0" vgap="15.0" />
</children>
</VBox>
<Button mnemonicParsing="false" onAction="#handleSignOut" styleClass="page-button" text="Log out">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/Navbar.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<?import javafx.scene.layout.Region?>

<HBox fx:id="navBar" alignment="CENTER_LEFT" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="89.0" prefWidth="595.0" spacing="15.0" styleClass="navbar" stylesheets="@../css/Global.css" xmlns="http://javafx.com/javafx/25" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ui.controller.NavbarController">
<Label styleClass="logo-label" text="Give Hope" />
<Label fx:id="logoLabel" onMouseClicked="#handleLogoClick" style="-fx-cursor: hand;" styleClass="logo-label" text="Give Hope" />
<Region maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS" />

<Button fx:id="homeBtn" onAction="#goHome" styleClass="nav-button" text="Home" />
Expand Down
Loading