From e99953a7a25038cdf5c4e004b5e03a00b321d537 Mon Sep 17 00:00:00 2001 From: meenakshijay1005-netizen Date: Thu, 9 Apr 2026 09:14:49 +0200 Subject: [PATCH] profile for user and otganization fxml created, loginSite fxml created, aboutPage fxml updated --- .../AvailableOrganizationController.java | 25 +- .../controller/CharityPageController.java | 1 + .../controller/DonationPageController.java | 1 + .../team6/controller/FrontpageController.java | 371 +++++---- .../src/main/resources/fxml/aboutPage.fxml | 776 +++++++++--------- .../fxml/available_organizations.fxml | 0 .../resources/fxml/creater_user_site.fxml | 0 .../src/main/resources/fxml/dashboard.fxml | 0 .../src/main/resources/fxml/loginSite.fxml | 281 +++++++ .../resources/fxml/profile_org_Inbox.fxml | 467 ++++++----- .../resources/fxml/profile_org_Payments.fxml | 452 +++++----- .../resources/fxml/profile_org_Settings.fxml | 233 +++--- .../main/resources/fxml/profile_org_edit.fxml | 249 +++--- .../resources/fxml/profile_user_history.fxml | 300 +++++++ .../resources/fxml/profile_user_inbox.fxml | 313 +++++++ .../fxml/profile_user_interests.fxml | 356 ++++++++ .../resources/fxml/profile_user_settings.fxml | 295 +++++++ .../src/main/resources/fxml/test.fxml | 0 18 files changed, 2913 insertions(+), 1207 deletions(-) create mode 100644 helpmehelpapplication/src/main/resources/fxml/available_organizations.fxml create mode 100644 helpmehelpapplication/src/main/resources/fxml/creater_user_site.fxml create mode 100644 helpmehelpapplication/src/main/resources/fxml/dashboard.fxml create mode 100644 helpmehelpapplication/src/main/resources/fxml/loginSite.fxml create mode 100644 helpmehelpapplication/src/main/resources/fxml/profile_user_history.fxml create mode 100644 helpmehelpapplication/src/main/resources/fxml/profile_user_inbox.fxml create mode 100644 helpmehelpapplication/src/main/resources/fxml/profile_user_interests.fxml create mode 100644 helpmehelpapplication/src/main/resources/fxml/profile_user_settings.fxml create mode 100644 helpmehelpapplication/src/main/resources/fxml/test.fxml diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/AvailableOrganizationController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/AvailableOrganizationController.java index 5f7a569..e2c7abd 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/AvailableOrganizationController.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/AvailableOrganizationController.java @@ -15,12 +15,11 @@ /** * This controller represents the available organization page, where the user can search for a - * charity and choose to donate to it. It also has a button to return to the front page. - * The user can search for a charity by typing in the search field, - * and the charities that match the search query will be displayed. - * The user can click on a charity to see more details about it, - * or click on the featured charity to see more details about it. - * The user can also switch to the charity page or donation page for the selected charity. + * charity and choose to donate to it. It also has a button to return to the front page. The user + * can search for a charity by typing in the search field, and the charities that match the search + * query will be displayed. The user can click on a charity to see more details about it, or click + * on the featured charity to see more details about it. The user can also switch to the charity + * page or donation page for the selected charity. */ public class AvailableOrganizationController { @@ -31,12 +30,11 @@ public class AvailableOrganizationController { private List allCharities; /** - * This method is used to initialize the available organization page. - * It retrieves all charities from the database and sets up a listener on the search field - * to filter the charities based on the user's input. - * It also clears the cards container to prepare for displaying the filtered charities. - * The method is called automatically when the page is loaded, - * and it sets up the initial state of the page. + * This method is used to initialize the available organization page. It retrieves all charities + * from the database and sets up a listener on the search field to filter the charities based on + * the user's input. It also clears the cards container to prepare for displaying the filtered + * charities. The method is called automatically when the page is loaded, and it sets up the + * initial state of the page. */ @FXML public void initialize() { @@ -54,6 +52,7 @@ public void initialize() { /** * This method filters the charities based on the user's input in the search field. + * * @param query is the user's input in the search field, which is used to filter the charities. * @return a list of charities that match the search query. */ @@ -79,6 +78,7 @@ private List filterCharities(String query) { /** * This method displays the charities in the cards container. + * * @param charities is a list of charities to be displayed. */ private void displayCharities(List charities) { @@ -101,6 +101,7 @@ private void displayCharities(List charities) { /** * This method is used to set the initial search query in the search field. + * * @param query is the initial search query. */ @FXML diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java index de2e43e..b52064f 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/CharityPageController.java @@ -64,6 +64,7 @@ public void switchToDonationPage(ActionEvent event) { /** * This method is used to search for charities based on the input in the search field. + * * @param event is the event that triggered the search. */ @FXML diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/DonationPageController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/DonationPageController.java index dc7e0d8..0ce757f 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/DonationPageController.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/DonationPageController.java @@ -135,6 +135,7 @@ private void showAlert(Alert.AlertType type, String title, String message) { /** * This method is used to handle the search action when the user clicks the search button. + * * @param event is the event that triggered the search. */ @FXML diff --git a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/FrontpageController.java b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/FrontpageController.java index 2abff0b..f91877c 100644 --- a/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/FrontpageController.java +++ b/helpmehelpapplication/src/main/java/ntnu/systemutvikling/team6/controller/FrontpageController.java @@ -4,7 +4,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; - import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; @@ -27,198 +26,194 @@ * to the charity page and the donation page for the featured charity */ public class FrontpageController { - @FXML - private Charity featuredCharity; - @FXML - private FlowPane cardsContainer; - @FXML - private Label Carosel_Organisasjon; - @FXML - private Label Carosel_Beskrivelse; - @FXML - private Label Total_Orgnisasjon; - @FXML - private Label Total_Donations; - @FXML - private Label PreApproved_Percentage; - @FXML - private TextField frontSearchField; - @FXML - private CheckBox verifiedFilter; - @FXML - private CheckBox childrenFilter; - @FXML - private CheckBox healthFilter; - @FXML - private CheckBox emergencyAidFilter; - - private List allCharities = new ArrayList<>(); - - /** - * Initialize method for the front page. This method is called when the front page is loaded. It - * retrieves the list of charities and donations from the database. The list of charities is - * displayed as a list of cards, where each card represents a charity from the - * Innsamlingskontrollen. A random charity is selected to be featured on the page, and its name - * and description are displayed in the carousel section. The total number of charities, total - * amount of donations, and percentage of pre-approved charities are also displayed on the page. - */ - @FXML - public void initialize() { - try { - DatabaseManager db = new DatabaseManager(); - CharityRegistry charities = db.getCharitiesFromDB(); - DonationRegistry donations = db.getDonationFromDB(); - - allCharities = new ArrayList<>(charities.getAllCharities()); - displayCharities(allCharities); - - int charitiesSize = charities.getAllCharities().size(); - Random random = new Random(); - int randomIndex = random.nextInt(charitiesSize); - Charity randomCharity = charities.getAllCharities().get(randomIndex); - - this.featuredCharity = randomCharity; - Carosel_Organisasjon.setText(randomCharity.getName()); - Carosel_Beskrivelse.setText(randomCharity.getDescription()); - - Total_Orgnisasjon.setText(Integer.toString(charitiesSize)); - Total_Donations.setText( - Double.toString( - donations.getAllDonations().stream().mapToDouble(Donation::getAmount).sum())); - PreApproved_Percentage.setText( - String.format( - "%.2f", - charities.getAllCharities().stream().filter(Charity::getPreApproved).count() - * 100.0 - / charitiesSize) - + "%"); - } catch (Exception e) { - e.printStackTrace(); - } - } - - - /** - * This method is used to switch to the charity page for the selected charity - * - * @param event - */ - public void switchToCharityPage(ActionEvent event) { - LoaderScene.LoadScene("CharityPage", event, featuredCharity, null); - } - - /** - * This method is used to switch to the donation page for the selected charity. - * - * @param event - */ - public void switchToDonationPage(ActionEvent event) { - LoaderScene.LoadScene("DonationPage", event, featuredCharity, null); - } - - /** - * This method is used to filter the charities based on the selected filters. - * @param event is the event that triggered the filter. - */ - @FXML - public void handleCategoryFilterChange(ActionEvent event) { - displayCharities(getFilteredCharities()); + @FXML private Charity featuredCharity; + @FXML private FlowPane cardsContainer; + @FXML private Label Carosel_Organisasjon; + @FXML private Label Carosel_Beskrivelse; + @FXML private Label Total_Orgnisasjon; + @FXML private Label Total_Donations; + @FXML private Label PreApproved_Percentage; + @FXML private TextField frontSearchField; + @FXML private CheckBox verifiedFilter; + @FXML private CheckBox childrenFilter; + @FXML private CheckBox healthFilter; + @FXML private CheckBox emergencyAidFilter; + + private List allCharities = new ArrayList<>(); + + /** + * Initialize method for the front page. This method is called when the front page is loaded. It + * retrieves the list of charities and donations from the database. The list of charities is + * displayed as a list of cards, where each card represents a charity from the + * Innsamlingskontrollen. A random charity is selected to be featured on the page, and its name + * and description are displayed in the carousel section. The total number of charities, total + * amount of donations, and percentage of pre-approved charities are also displayed on the page. + */ + @FXML + public void initialize() { + try { + DatabaseManager db = new DatabaseManager(); + CharityRegistry charities = db.getCharitiesFromDB(); + DonationRegistry donations = db.getDonationFromDB(); + + allCharities = new ArrayList<>(charities.getAllCharities()); + displayCharities(allCharities); + + int charitiesSize = charities.getAllCharities().size(); + Random random = new Random(); + int randomIndex = random.nextInt(charitiesSize); + Charity randomCharity = charities.getAllCharities().get(randomIndex); + + this.featuredCharity = randomCharity; + Carosel_Organisasjon.setText(randomCharity.getName()); + Carosel_Beskrivelse.setText(randomCharity.getDescription()); + + Total_Orgnisasjon.setText(Integer.toString(charitiesSize)); + Total_Donations.setText( + Double.toString( + donations.getAllDonations().stream().mapToDouble(Donation::getAmount).sum())); + PreApproved_Percentage.setText( + String.format( + "%.2f", + charities.getAllCharities().stream().filter(Charity::getPreApproved).count() + * 100.0 + / charitiesSize) + + "%"); + } catch (Exception e) { + e.printStackTrace(); } - - /** - * This method is used to search for charities based on the input in the search field. - * @param event is the event that triggered the search. - */ - @FXML - public void handleFrontSearch(ActionEvent event) { - String query = frontSearchField.getText().trim(); - - if (query.isEmpty()) { - return; - } - - LoaderScene.LoadScene("availableOrganization", event, null, query); + } + + /** + * This method is used to switch to the charity page for the selected charity + * + * @param event + */ + public void switchToCharityPage(ActionEvent event) { + LoaderScene.LoadScene("CharityPage", event, featuredCharity, null); + } + + /** + * This method is used to switch to the donation page for the selected charity. + * + * @param event + */ + public void switchToDonationPage(ActionEvent event) { + LoaderScene.LoadScene("DonationPage", event, featuredCharity, null); + } + + /** + * This method is used to filter the charities based on the selected filters. + * + * @param event is the event that triggered the filter. + */ + @FXML + public void handleCategoryFilterChange(ActionEvent event) { + displayCharities(getFilteredCharities()); + } + + /** + * This method is used to search for charities based on the input in the search field. + * + * @param event is the event that triggered the search. + */ + @FXML + public void handleFrontSearch(ActionEvent event) { + String query = frontSearchField.getText().trim(); + + if (query.isEmpty()) { + return; } - /** - * This method is used to filter the charities based on the selected filters. - * @return a list of filtered charities. - */ - private List getFilteredCharities() { - if (!verifiedFilter.isSelected() - && !childrenFilter.isSelected() - && !healthFilter.isSelected() - && !emergencyAidFilter.isSelected()) { - return allCharities; - } - - List filteredCharities = new ArrayList<>(); - for (Charity charity : allCharities) { - if (matchesSelectedFilters(charity)) { - filteredCharities.add(charity); - } - } - return filteredCharities; + LoaderScene.LoadScene("availableOrganization", event, null, query); + } + + /** + * This method is used to filter the charities based on the selected filters. + * + * @return a list of filtered charities. + */ + private List getFilteredCharities() { + if (!verifiedFilter.isSelected() + && !childrenFilter.isSelected() + && !healthFilter.isSelected() + && !emergencyAidFilter.isSelected()) { + return allCharities; } - /** - * This method is used to check if a charity matches the selected filters. - * @param charity is the charity to be checked. - * @return true if the charity matches the selected filters, false otherwise. - */ - private boolean matchesSelectedFilters(Charity charity) { - return (verifiedFilter.isSelected() && charity.getPreApproved()) - || (childrenFilter.isSelected() && matchesKeywordCategory(charity, "children")) - || (healthFilter.isSelected() && matchesKeywordCategory(charity, "health")) - || (emergencyAidFilter.isSelected() && matchesKeywordCategory(charity, "emergency")); + List filteredCharities = new ArrayList<>(); + for (Charity charity : allCharities) { + if (matchesSelectedFilters(charity)) { + filteredCharities.add(charity); + } } - - /** - * This method is used to check if a charity matches a specific category. - * @param charity is the charity to be checked. - * @param category is the category to check against. - * @return true if the charity matches the category, false otherwise. - */ - private boolean matchesKeywordCategory(Charity charity, String category) { - String text = (charity.getName() + " " + charity.getDescription()).toLowerCase(); - - return switch (category) { - case "children" -> text.contains("child") - || text.contains("children") - || text.contains("barn") - || text.contains("youth") - || text.contains("young"); - case "health" -> text.contains("health") - || text.contains("medical") - || text.contains("helse") - || text.contains("hospital") - || text.contains("care"); - case "emergency" -> text.contains("emergency") - || text.contains("relief") - || text.contains("crisis") - || text.contains("aid") - || text.contains("disaster"); - default -> false; - }; - } - - /** - * This method is used to display the charities in the cards container. - * @param charities is the list of charities to be displayed. - */ - private void displayCharities(List charities) { - cardsContainer.getChildren().clear(); - - for (Charity charity : charities) { - try { - FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/organizationCard.fxml")); - Parent card = loader.load(); - OrganizationCardController cardController = loader.getController(); - cardController.setOrganization(charity); - cardsContainer.getChildren().add(card); - } catch (IOException e) { - throw new RuntimeException("Could not load organization card.", e); - } - } + return filteredCharities; + } + + /** + * This method is used to check if a charity matches the selected filters. + * + * @param charity is the charity to be checked. + * @return true if the charity matches the selected filters, false otherwise. + */ + private boolean matchesSelectedFilters(Charity charity) { + return (verifiedFilter.isSelected() && charity.getPreApproved()) + || (childrenFilter.isSelected() && matchesKeywordCategory(charity, "children")) + || (healthFilter.isSelected() && matchesKeywordCategory(charity, "health")) + || (emergencyAidFilter.isSelected() && matchesKeywordCategory(charity, "emergency")); + } + + /** + * This method is used to check if a charity matches a specific category. + * + * @param charity is the charity to be checked. + * @param category is the category to check against. + * @return true if the charity matches the category, false otherwise. + */ + private boolean matchesKeywordCategory(Charity charity, String category) { + String text = (charity.getName() + " " + charity.getDescription()).toLowerCase(); + + return switch (category) { + case "children" -> + text.contains("child") + || text.contains("children") + || text.contains("barn") + || text.contains("youth") + || text.contains("young"); + case "health" -> + text.contains("health") + || text.contains("medical") + || text.contains("helse") + || text.contains("hospital") + || text.contains("care"); + case "emergency" -> + text.contains("emergency") + || text.contains("relief") + || text.contains("crisis") + || text.contains("aid") + || text.contains("disaster"); + default -> false; + }; + } + + /** + * This method is used to display the charities in the cards container. + * + * @param charities is the list of charities to be displayed. + */ + private void displayCharities(List charities) { + cardsContainer.getChildren().clear(); + + for (Charity charity : charities) { + try { + FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/organizationCard.fxml")); + Parent card = loader.load(); + OrganizationCardController cardController = loader.getController(); + cardController.setOrganization(charity); + cardsContainer.getChildren().add(card); + } catch (IOException e) { + throw new RuntimeException("Could not load organization card.", e); + } } + } } diff --git a/helpmehelpapplication/src/main/resources/fxml/aboutPage.fxml b/helpmehelpapplication/src/main/resources/fxml/aboutPage.fxml index 7a0918d..8e99542 100644 --- a/helpmehelpapplication/src/main/resources/fxml/aboutPage.fxml +++ b/helpmehelpapplication/src/main/resources/fxml/aboutPage.fxml @@ -1,10 +1,8 @@ - - @@ -12,8 +10,6 @@ - - @@ -22,577 +18,557 @@ - + - + - + - + - + + + + + + + - + + + - + - - - - - - - - + - - - - - - - - - - + - + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/helpmehelpapplication/src/main/resources/fxml/profile_org_Inbox.fxml b/helpmehelpapplication/src/main/resources/fxml/profile_org_Inbox.fxml index adff16f..e369d53 100644 --- a/helpmehelpapplication/src/main/resources/fxml/profile_org_Inbox.fxml +++ b/helpmehelpapplication/src/main/resources/fxml/profile_org_Inbox.fxml @@ -6,258 +6,303 @@ + + + + - - + - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - + - - + - + - - - + + + + + + + - + - + + - - + + - + - + - + - - - + - + + - + - + + - - + + - + - + - + - - - + - + + + + + + + + + + + + + + + + + + - + - + - - - + + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +