Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Account View #24

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
26a84aa
Merge branch 'Create_Admin_Building_Classes' of https://github.com/da…
hassanmohamed2003 Nov 3, 2022
da8e4e7
Added: admin space views, controllers and necessary entities
hassanmohamed2003 Nov 3, 2022
162a1f7
Added: controllers for both meetingroom and workspace when editing ex…
hassanmohamed2003 Nov 4, 2022
d2b8945
Merge branch 'dev' of https://github.com/daymeijroos/werkplekken-fron…
hassanmohamed2003 Nov 5, 2022
3fe6e31
Added: nav bar in spaces, styling fix: return button
hassanmohamed2003 Nov 5, 2022
d8df685
Added: cancel button
hassanmohamed2003 Nov 5, 2022
6435bd1
Merge branch 'dev' of https://github.com/daymeijroos/werkplekken-fron…
hassanmohamed2003 Nov 6, 2022
ec63ed3
Change: getcurrentuser for the AccountViewController
Anisha2002 Nov 6, 2022
144c51e
Added: SpaceDao.java
hassanmohamed2003 Nov 6, 2022
d122640
added: facility model
hassanmohamed2003 Nov 6, 2022
164e7bc
Merge remote-tracking branch 'origin/dev' into Create_Admin_Space_Cla…
hassanmohamed2003 Nov 6, 2022
215a007
added: spacedao updated
hassanmohamed2003 Nov 6, 2022
0982466
Merge remote-tracking branch 'origin/Create_Admin_Space_Classes' into…
Anisha2002 Nov 6, 2022
3cb135f
Merge remote-tracking branch 'origin/Change_FloorDAO' into Create_Acc…
Anisha2002 Nov 6, 2022
572658f
Change: updated the reservationdao to the current structure
Anisha2002 Nov 6, 2022
0bb28ad
Fix: fixed error messages
Anisha2002 Nov 6, 2022
b4580b8
Removed print statements, log out button functioning now
Nov 9, 2022
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
20 changes: 15 additions & 5 deletions src/main/java/com/example/werkplekkenfrontend/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,48 @@

import com.example.werkplekkenfrontend.controllers.*;
import com.example.werkplekkenfrontend.daos.LoginDao;
import com.example.werkplekkenfrontend.daos.SpaceDao;
import com.example.werkplekkenfrontend.daos.UserDao;
import com.example.werkplekkenfrontend.models.Space;
import com.example.werkplekkenfrontend.models.User;
import com.example.werkplekkenfrontend.services.HttpService;
import com.fasterxml.jackson.databind.ObjectMapper;
import javafx.application.Application;
import javafx.stage.Stage;

import java.util.UUID;

public class Main extends Application {
public static SceneController sceneController = new SceneController();
public static Stage publicStage;

public static LoginController loginController = new LoginController(new LoginDao(new HttpService(), new ObjectMapper()), new UserDao(new HttpService(), new ObjectMapper()));


@Override
public void start(Stage stage) {
loginController.register("day", "meijroos", "[email protected]", "DumbShit");
SpaceDao spaceDao = new SpaceDao(new HttpService(), new ObjectMapper());
loginController.register("day", "meijroos", "[email protected]", "DumbShit");
spaceDao.post(new Space(2));
publicStage = stage;
Main.sceneController.setStage(stage);
ViewController controller = sceneController.showView("admin-view.fxml");
ViewController controller = sceneController.showView("admin-workspace-view.fxml");
controller.updateView();
// testAdminBuildingsViewController();
// testAdminEditBuildingViewController();
}

private void testAdminBuildingsViewController(){
/*private void testAdminBuildingsViewController(){
AdminBuildingsViewController controller = (AdminBuildingsViewController)Main.sceneController.showView("admin-buildings-view.fxml");
controller.updateView();
}

private void testAdminEditBuildingViewController(){
*/

/*private void testAdminEditBuildingViewController(){
AdminEditBuildingViewController controller = (AdminEditBuildingViewController)Main.sceneController.showView("admin-edit-building-view.fxml");
controller.updateView();
}
*/

public static void main(String[] args) {
Main.sceneController = new SceneController();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.example.werkplekkenfrontend.controllers;

import com.example.werkplekkenfrontend.Main;
import com.example.werkplekkenfrontend.daos.UserDao;
import com.example.werkplekkenfrontend.elements.NavBarElement;
import com.example.werkplekkenfrontend.models.DaoReplicator;
import com.example.werkplekkenfrontend.models.User;
import com.example.werkplekkenfrontend.services.HttpService;
import com.fasterxml.jackson.databind.ObjectMapper;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
Expand All @@ -17,21 +21,24 @@ public class AccountViewController implements ViewController{
public Label firstName;
public Label lastName;
public Label email;
private User currentUser = null;

//private void displayUserInfo(String id){
// User user = DaoReplicator.getUserInfoFromID(id);
// firstName.setText(user.getName());
// lastName.setText(user.getLastName());
// email.setText(user.getEmail());
//}
private void displayUserInfo(String id){
UserDao dao = new UserDao(new HttpService(), new ObjectMapper());
currentUser = dao.getCurrent();

public void onLogOutClick() {
firstName.setText(currentUser.getName());
lastName.setText(currentUser.getLastName());
email.setText(currentUser.getEmail());
}

public void onLogOutClick() {
Main.sceneController.showView("login-view.fxml");
}

@Override
public void updateView() {
//displayUserInfo(UUID.randomUUID().toString());
displayUserInfo(UUID.randomUUID().toString());
main_container.getChildren().add(new NavBarElement().getBuildingBox());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.example.werkplekkenfrontend.controllers;

import com.example.werkplekkenfrontend.Main;
import com.example.werkplekkenfrontend.daos.SpaceDao;
import com.example.werkplekkenfrontend.models.Space;
import com.example.werkplekkenfrontend.services.HttpService;
import com.fasterxml.jackson.databind.ObjectMapper;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;

import java.util.List;
import java.util.Objects;
import java.util.UUID;

public class AdminEditMeetingroomViewController implements ViewController{

private SpaceDao spaceDao = new SpaceDao(new HttpService(), new ObjectMapper());
public UUID spaceID = null;


@FXML
public TextArea facility;

@FXML
public TextArea floor;
@FXML
public TextArea capacity;

@FXML
public TextArea name;


private void updateMeetingroomDetails(Space space){
capacity.setText(String.valueOf(space.getCapacity()));
facility.setText(space.getFloorId());
}


@FXML
void onApplyClick(ActionEvent event) {

if(spaceID != null){
Space updatedSpace = new Space(Integer.valueOf(capacity.getText()));
System.out.println("Patch request response: " + spaceDao.patch(updatedSpace));
}
else{
Space newSpace = new Space(Integer.valueOf(capacity.getText())); // the
if (!uniqueCheckFromDao()) return;
System.out.println("Post request response: " + spaceDao.post(newSpace));

}
ViewController controller = Main.sceneController.showView("admin-meetingroom-view.fxml");
controller.updateView();
}

private boolean uniqueCheckFromDao(){
List<Space> spaceList = spaceDao.getAll();
for(Space space : spaceList){
if (space.getId() == spaceID) continue;
if (Objects.equals(space.getCapacity(), capacity.getText())) return false;
if (Objects.equals(space.getCapacity(), capacity.getText())) return false;
}
return true;
}

private boolean validityCheck(){
if (name.getText() == null || capacity.getText() == null) return false;
return true;
}
@FXML
void onCancelClick(ActionEvent event) {
ViewController controller = Main.sceneController.showView("admin-meetingroom-view.fxml");
controller.updateView();

}

@Override
public void updateView() {
if(spaceID != null) {
Space spaceFromDao = spaceDao.get(spaceID);
updateMeetingroomDetails(spaceFromDao);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package com.example.werkplekkenfrontend.controllers;

import com.example.werkplekkenfrontend.Main;
import com.example.werkplekkenfrontend.daos.SpaceDao;
import com.example.werkplekkenfrontend.models.Space;
import com.example.werkplekkenfrontend.services.HttpService;
import com.fasterxml.jackson.databind.ObjectMapper;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;

import java.util.List;
import java.util.Objects;
import java.util.UUID;

public class AdminEditWorkspaceViewController implements ViewController{

@FXML
private TextArea capacity;

@FXML
private TextArea name;


public UUID spaceID = null;

private SpaceDao spaceDao = new SpaceDao(new HttpService(), new ObjectMapper());

private void updateWorkspaceDetails(Space space){
capacity.setText(String.valueOf(space.getCapacity()));

}
@FXML
void onApplyClick(ActionEvent event) {
if(spaceID != null){
Space updatedSpace = new Space(Integer.valueOf(capacity.getText()));
System.out.println("Patch request response: " + spaceDao.patch(updatedSpace));
}
else{
if (!uniqueCheckFromDao()) return;
Space newSpace = new Space(Integer.valueOf(capacity.getText())); // there is a chance this generates a duplicate UUID
System.out.println("Post request response: " + spaceDao.post(newSpace));

}
ViewController controller = Main.sceneController.showView("admin-workspace-view.fxml");
controller.updateView();

if (spaceID == null){
Space newSpace = new Space((Integer.valueOf(capacity.getText()))); // there is a chance this generates a duplicate UUID
System.out.println("Post request response: " + spaceDao);
}

}

private boolean uniqueCheckFromDao(){
List<Space> spaceList = spaceDao.getAll();
for(Space space : spaceList){
if (space.getId() == spaceID) continue;
if (Objects.equals(space.getCapacity(), capacity.getText())) return false;
if (Objects.equals(space.getCapacity(), capacity.getText())) return false;
}
return true;
}
private boolean validityCheck(){
if (capacity.getText() == null) return false;
return true;
}


@FXML
void onCancelClick(ActionEvent event) {
ViewController controller = Main.sceneController.showView("admin-workspace-view.fxml");
controller.updateView();
}

@Override
public void updateView() {
//Space spaceFromDao = DaoReplicator.getWorkSpaceFromID(UUID.randomUUID());
//updateWorkspaceDetails(spaceFromDao);
if(spaceID != null) {
Space spaceFromDao = spaceDao.get(spaceID);
updateWorkspaceDetails(spaceFromDao);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package com.example.werkplekkenfrontend.controllers;

import com.example.werkplekkenfrontend.Main;
import com.example.werkplekkenfrontend.daos.BuildingDao;
import com.example.werkplekkenfrontend.daos.SpaceDao;
import com.example.werkplekkenfrontend.elements.AdminMeetingroomElement;
import com.example.werkplekkenfrontend.elements.NavBarElement;
import com.example.werkplekkenfrontend.models.Building;
import com.example.werkplekkenfrontend.models.Space;
import com.example.werkplekkenfrontend.services.HttpService;
import com.fasterxml.jackson.databind.ObjectMapper;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.layout.VBox;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class AdminMeetingroomViewController implements ViewController{

@FXML
public VBox main_container;
@FXML
public VBox meetingrooms_container;


private SpaceDao spaceDao = new SpaceDao(new HttpService(), new ObjectMapper());

@FXML
void OnNewMeetingroomButtonClick(ActionEvent event) {
ViewController controller = Main.sceneController.showView("space-view-new-meetingroom.fxml");
controller.updateView();
}



private void showSpacesOnView(){
List<Space> spacesFromDao = spaceDao.getAll();
for(Space space : spacesFromDao){
AdminMeetingroomElement element = new AdminMeetingroomElement(this, space);
meetingrooms_container.getChildren().add(element.getMeetingroomBox());
}
}
@FXML
public void onEditMeetingRoomButtonClick(Space space) {
AdminEditMeetingroomViewController controller = (AdminEditMeetingroomViewController)Main.sceneController.showView("space-edit-meetingroom.fxml");
controller.spaceID = space.getId();
controller.updateView();

}


@Override
public void updateView() {
main_container.getChildren().add(new NavBarElement().getBuildingBox());
showSpacesOnView();

}

public void onEditWorkspaceButtonClick(Space space) {
AdminEditMeetingroomViewController controller = (AdminEditMeetingroomViewController) Main.sceneController.showView("space-edit-meetingroom.fxml");
controller.spaceID = space.getId();
controller.updateView();
}

@FXML
void onApplyClick(ActionEvent event) {
ViewController controller = Main.sceneController.showView("admin-space-view.fxml");
controller.updateView();

}

@FXML
void onCancelClick(ActionEvent event) {
ViewController controller = Main.sceneController.showView("admin-space-view.fxml");
controller.updateView();

}

}
Loading