Skip to content

Merge Workaround/ntnu git is suboptimal into release/v1.0.0 #55

Merged
merged 47 commits into from
Mar 20, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e5689e8
feat: made App class work with JavaFX
emilfa Mar 5, 2026
bb91d6e
feat: created a HeaderView component and made App work with JavaFX
emilfa Mar 5, 2026
a5aa3e0
feat: made a MainController and a HeaderController which make it poss…
emilfa Mar 10, 2026
1a9aef9
feat:add LoginPageView with image section
Mar 10, 2026
b312097
feat[DbWrapper]: add methods for connecting to database
Mar 10, 2026
bdaeb1c
refactor: changed the file structure for resources connected to views
emilfa Mar 10, 2026
6bf7ee7
feat: added HomePageController for HomePageView
emilfa Mar 10, 2026
df5a249
feat: created HomePageView
emilfa Mar 10, 2026
eb54636
feat: made it so that logosection when clicked sends user to Homepage
emilfa Mar 10, 2026
f2c74cc
refactor: made app and MainView work together
emilfa Mar 10, 2026
16ce552
feat: made LoginHeader for LoginPageView
Mar 10, 2026
7802896
feat: merged feat/loginpage into feat/homepage
Mar 10, 2026
1c56f3c
update[DbWrapper]: remove input for script and database paths
Mar 10, 2026
83063c9
fix: fixed placements of images
Mar 10, 2026
c1ce598
feat: add email, password fields and register navigation to LoginPage…
Mar 11, 2026
f200ee8
feat: add SignInPageView into MainView and controllers
Mar 11, 2026
73191e3
feat: merged release/v1.0.0 into feat/loginpage
Mar 11, 2026
de7e295
fix: a bug in App
Mar 11, 2026
37c7db7
feat: made SignInPageView and removed HeaderController from SignIn an…
Mar 11, 2026
bdd2284
refactor[wrapper]&feat[DbWrapper]: move wrapper classes to its own fo…
Mar 12, 2026
fe39dd0
refactor[wrapper-tests]: move wrapper tests to a wrapper subfolder
Mar 12, 2026
ea35d89
feat: created files associated with BrowsePage
emilfa Mar 12, 2026
05bb334
refactor: altered Controller structure for better coupling
emilfa Mar 12, 2026
8ee932d
feat: added showBrowsePage functionality to MainView and altered it t…
emilfa Mar 12, 2026
93e8a65
feat: created BrowsePage and a component for cards representing an or…
emilfa Mar 12, 2026
1b27911
style: minor style changes
emilfa Mar 12, 2026
a50cab8
refactor: changed spacing and stuff
emilfa Mar 12, 2026
c0556a1
update[DbWrapper]: add exception-throwing to export methods
Mar 12, 2026
73df8e6
feat: made DonationPageView
Mar 14, 2026
e6a2d09
feat: made PaymentCompletePageView and its controllers
Mar 14, 2026
24229ee
update[DbWrapper]: change excpetion handling and implement logging
Mar 15, 2026
f3a6e5a
test[DbWrapper]: add tests for both users and donations
Mar 15, 2026
06c135b
feat: made UserPageView and added connection to controllers and testd…
Mar 15, 2026
963d53f
feat: merged feat/wrapper into workaround/ntnu-git-is-suboptimal
Mar 16, 2026
74cf853
feat: created organization page
emilfa Mar 16, 2026
b356fbe
feat: merged feat/organizationpage into workaround/ntnu-git-is-subopt…
Mar 16, 2026
28eb0a1
fix&update[UserService]: change login to return a User, easier connec…
Mar 19, 2026
c650c5c
update6test[UserService]: add test to check return of correct user
Mar 19, 2026
04080ed
update[]: add session user to make it clear which user is logged in …
Mar 19, 2026
6901cd0
Update&feat[]: Connect backend to frontend by adding login, registrat…
Mar 19, 2026
44b0811
update[UserPageView]: Update Previous donations to have currency disp…
Mar 19, 2026
e746035
feat[app]: overwrite close method to export information to database o…
Mar 20, 2026
ab5ab06
fix[app]: properly call the stop super method when overriding
Mar 20, 2026
4444322
fix&test[model]: fix the repositories not only adding new rows
Mar 20, 2026
8676d9b
fix[DBWrapper]: Fix exporting of Donations to successfully export whe…
Mar 20, 2026
97be183
Merge pull request #53 from Group-5/feat/connectfrontback-2
lucych Mar 20, 2026
3acabc5
Merge pull request #54 from Group-5/feat/connectfrontback
lucych Mar 20, 2026
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
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
<artifactId>slf4j-simple</artifactId>
<version>2.0.9</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.224</version>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
Expand Down
98 changes: 94 additions & 4 deletions src/main/java/edu/group5/app/App.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,100 @@
package edu.group5.app;

import edu.group5.app.control.MainController;
import edu.group5.app.control.wrapper.DbWrapper;
import edu.group5.app.control.wrapper.OrgApiWrapper;
import edu.group5.app.model.donation.Donation;
import edu.group5.app.model.donation.DonationRepository;
import edu.group5.app.model.donation.DonationService;
import edu.group5.app.model.organization.OrganizationRepository;
import edu.group5.app.model.organization.OrganizationService;
import edu.group5.app.model.user.User;
import edu.group5.app.model.user.UserRepository;
import edu.group5.app.model.user.UserService;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

import java.util.List;

import java.util.logging.Logger;

/**
* Hello world!
* Main entry point for the Help-Me-Help charity donation application.
* Handles database connection, data loading, and application setup.
*/
public class App {
public static void main(String[] args) throws InterruptedException {
System.out.println("Hello World!");
public class App extends Application {
DbWrapper dbWrapper;
UserRepository userRepository;
DonationRepository donationRepository;
private Logger logger;
private MainController controller;
private Scene scene;

@Override
public void init() {
this.logger = Logger.getLogger(App.class.getName());
this.logger.info("Application starting");

this.dbWrapper = new DbWrapper(false);
OrgApiWrapper orgApiWrapper = new OrgApiWrapper("https://app.innsamlingskontrollen.no/api/public/v1/all");

while (!dbWrapper.connect()) {
this.logger.warning("Failed to connect to database");
}

// Load data from database
List<Object[]> userData = dbWrapper.importUsers();
List<Object[]> donationData = dbWrapper.fetchAllDonations();
dbWrapper.disconnect();

// Load organizations from API
Object[] organizationData = new Object[0];
try {
if (orgApiWrapper.importData()) {
organizationData = orgApiWrapper.getData();
}
} catch (InterruptedException e) {
System.err.println("Failed to load organization data: " + e.getMessage());
}

// Create repositories with fetched data
this.userRepository = new UserRepository(userData);
this.donationRepository = new DonationRepository(donationData);
OrganizationRepository organizationRepository = new OrganizationRepository(organizationData);

// Create services (backend wiring)
UserService userService = new UserService(this.userRepository);
DonationService donationService = new DonationService(this.donationRepository, organizationRepository);
OrganizationService organizationService = new OrganizationService(organizationRepository);

this.controller = new MainController(userService, donationService, organizationService);

this.scene = controller.getMainView().getScene();
}

@Override
public void start(Stage stage) {
this.controller.showLoginPage();

stage.getIcons().add(new Image(getClass().getResource("/header/images/hmh-logo.png").toExternalForm()));
stage.setTitle("Help-Me-Help");
stage.setScene(this.scene);
stage.show();
}

@Override
public void stop() throws Exception {
super.stop();
this.logger.info("Application stopping");
this.dbWrapper.connect();
this.dbWrapper.exportUsers(this.userRepository.export());
this.dbWrapper.exportDonations(this.donationRepository.export());
this.dbWrapper.disconnect();
}

public static void main(String[] args) {
launch(args);
}
}
16 changes: 16 additions & 0 deletions src/main/java/edu/group5/app/control/BrowseCardController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package edu.group5.app.control;

import edu.group5.app.model.organization.Organization;

public class BrowseCardController {
private final MainController controller;

public BrowseCardController(MainController mainController) {
this.controller = mainController;
}

public void handleCardClick(Organization organization) {
controller.setCurrentOrganization(organization);
controller.showOrganizationPage();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package edu.group5.app.control;

public class BrowsePageController {
private final MainController controller;

public BrowsePageController(MainController mainController) {
this.controller = mainController;
}
}
28 changes: 28 additions & 0 deletions src/main/java/edu/group5/app/control/HeaderController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package edu.group5.app.control;

public class HeaderController {
private final MainController controller;

public HeaderController(MainController controller) {
this.controller = controller;
}

public void handleHomeBtn() {
System.out.println("Home button pressed");
controller.showHomePage();
}

public void handleCausesBtn() {
System.out.println("Causes button pressed");
controller.showBrowsePage();
}

public void handleAboutBtn() {
System.out.println("About button pressed");
}

public void handleProfileBtn() {
System.out.println("profileSection");
controller.showUserPage();
}
}
19 changes: 19 additions & 0 deletions src/main/java/edu/group5/app/control/HomePageController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package edu.group5.app.control;

public class HomePageController {
private final MainController controller;

public HomePageController(MainController controller) {
this.controller = controller;
}

public void handleDonateToACauseBtn() {
System.out.println("Donate to a cause button pressed");
controller.showBrowsePage();
}

public void handleAboutUsBtn() {
System.out.println("About us button pressed");
controller.showAboutUsPage();
}
}
44 changes: 44 additions & 0 deletions src/main/java/edu/group5/app/control/LoginPageController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package edu.group5.app.control;

import edu.group5.app.model.user.User;
import edu.group5.app.model.user.UserService;
import edu.group5.app.view.loginpage.LoginPageView;

public class LoginPageController {
private final MainController controller;
private final UserService userService;
private LoginPageView view;

public LoginPageController(MainController controller, UserService userService) {
this.controller = controller;
this.userService = userService;
}

public void setView(LoginPageView view) {
this.view = view;
}

public void handleLoginBtn() {
String email = view.getEmail();
char[] passwordChars = view.getPassword();

if (email == null || email.trim().isEmpty() || passwordChars == null || passwordChars.length == 0) {
view.showError("Email and password are required");
return;
}

User user = userService.login(email, passwordChars);

if (user != null) {
controller.setCurrentUser(user);
controller.showHomePage();
} else {
view.showError("Invalid email or password");
}
}

public void handleRegisterBtn() {
System.out.println("Sign in button pressed");
controller.showSignInPage();
}
}
121 changes: 121 additions & 0 deletions src/main/java/edu/group5/app/control/MainController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package edu.group5.app.control;

import edu.group5.app.control.donationpage.DonationPageController;
import edu.group5.app.model.donation.DonationService;
import edu.group5.app.model.organization.Organization;
import edu.group5.app.model.organization.OrganizationService;
import edu.group5.app.model.user.User;
import edu.group5.app.model.user.UserService;
import edu.group5.app.view.MainView;
import edu.group5.app.view.donationpage.DonationPageView;

import java.math.BigDecimal;

public class MainController {
private final MainView view;
private final HeaderController headerController;
private final HomePageController homePageController;
private final BrowsePageController browsePageController;
private final BrowseCardController browseCardController;
private final OrganizationPageController organizationPageController;
private final DonationPageController donationPageController;
private final UserService userService;
private final DonationService donationService;
private final OrganizationService organizationService;
private User currentUser;
private Organization currentOrganization;
private BigDecimal currentDonationAmount;

public MainController(UserService userService, DonationService donationService,
OrganizationService organizationService) {
this.userService = userService;
this.donationService = donationService;
this.organizationService = organizationService;

this.view = new MainView(this, userService);
this.headerController = new HeaderController(this);
this.homePageController = new HomePageController(this);
this.browsePageController = new BrowsePageController(this);
this.browseCardController = new BrowseCardController(this);
this.organizationPageController = new OrganizationPageController(this);
this.donationPageController = new DonationPageController(this);
}

public UserService getUserService() {
return userService;
}

public DonationService getDonationService() {
return donationService;
}

public OrganizationService getOrganizationService() {
return organizationService;
}

public void setCurrentUser(User user) {
this.currentUser = user;
}

public User getCurrentUser() {
return this.currentUser;
}

public void setCurrentOrganization(Organization organization) {
this.currentOrganization = organization;
}

public Organization getCurrentOrganization() {
return this.currentOrganization;
}

public void setCurrentDonationAmount(BigDecimal amount) {
this.currentDonationAmount = amount;
}

public BigDecimal getCurrentDonationAmount() {
return this.currentDonationAmount;
}

public void logout() {
currentUser = null;
currentOrganization = null;
currentDonationAmount = null;
showLoginPage();
}

public MainView getMainView() {
return view;
}

public void showHomePage() {
view.showHomePage(homePageController, headerController);
}

public void showLoginPage() {
view.showLoginPage();
}
public void showSignInPage() {
view.showSignInPage();
}
public void showPaymentCompletePage() {
view.showPaymentCompletePage();
}
public void showBrowsePage() {
view.showBrowsePage(browsePageController, browseCardController, headerController);
}

public void showOrganizationPage() {
view.showOrganizationPage(organizationPageController, headerController);
}

public void showDonationPage() {
view.showDonationPage();
}

public void showAboutUsPage() {}

public void showUserPage() {
view.showUserPage();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package edu.group5.app.control;

public class OrganizationPageController {
private final MainController controller;

public OrganizationPageController(MainController controller) {
this.controller = controller;
}

public void handleDonateClick() {
controller.showDonationPage();
}
}
Loading