ADD::added button to display/hide explanation
Merge branch 'master' of gitlab.ewi.tudelft.nl:cse1105/2018-2019/oopp-group-43/template
This commit is contained in:
@@ -46,7 +46,6 @@ dependencies {
|
|||||||
testCompile("junit:junit")
|
testCompile("junit:junit")
|
||||||
compileOnly 'org.projectlombok:lombok:1.18.6'
|
compileOnly 'org.projectlombok:lombok:1.18.6'
|
||||||
compile("org.springframework.boot:spring-boot-starter-data-jpa")
|
compile("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||||
compile("com.h2database:h2")
|
|
||||||
annotationProcessor 'org.projectlombok:lombok:1.18.6'
|
annotationProcessor 'org.projectlombok:lombok:1.18.6'
|
||||||
testCompile(
|
testCompile(
|
||||||
'junit:junit:4.12',
|
'junit:junit:4.12',
|
||||||
|
|||||||
43
doc/meetings/week9/20190408_agenda.md
Normal file
43
doc/meetings/week9/20190408_agenda.md
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# Meeting 8
|
||||||
|
|
||||||
|
## Opening
|
||||||
|
> Check if everyone is present:
|
||||||
|
- ~~Nivard Jansen~~
|
||||||
|
- ~~Kristin Peneva~~
|
||||||
|
- ~~Daan Sneep~~
|
||||||
|
- [x] Merel SteenBergen
|
||||||
|
- [x] Ceren Ugurlu
|
||||||
|
- [x] Mika Wauben
|
||||||
|
- [x] Sem van der Hoeven
|
||||||
|
|
||||||
|
- Chair: Merel Steenbergen
|
||||||
|
- Secretary: Sem van der Hoeven
|
||||||
|
|
||||||
|
## Points of action
|
||||||
|
|
||||||
|
- First of all, discuss problems we have faced and if somebody is halted because of a problem
|
||||||
|
- if so, try to work out the problem
|
||||||
|
|
||||||
|
### pre/during meeting
|
||||||
|
- Discuss what we did last week (see scrumboard)
|
||||||
|
- Does anyone have blocking issues?
|
||||||
|
- Coverage reports
|
||||||
|
- Checkstyle reports
|
||||||
|
- Show demo to the TA, since Mitchell isn't here, a different TA will visit us, so we'll show him the entire application.
|
||||||
|
- Discuss about the presentation
|
||||||
|
- Discuss about final things that need to be done
|
||||||
|
|
||||||
|
### post meeting
|
||||||
|
- Focus on the presentation
|
||||||
|
- Focus on the final report
|
||||||
|
- Focus on things we get points for according to the rubric
|
||||||
|
|
||||||
|
## Any other business
|
||||||
|
> If anybody has something that should be discussed but came up with that after the agenda was finalized, he/she should bring that up now so that it can be discussed after all.
|
||||||
|
|
||||||
|
## Question round
|
||||||
|
- Questions for the TA
|
||||||
|
- How to get the code coverage badge, since we use Gradle and we've got the Maven code.
|
||||||
|
|
||||||
|
## Closing
|
||||||
|
> We're almost finished!
|
||||||
BIN
doc/reports/checkstyle/20190415_checkstyle.jpg
Normal file
BIN
doc/reports/checkstyle/20190415_checkstyle.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 793 KiB |
BIN
doc/reports/coverage/20190415_coverage.jpg
Normal file
BIN
doc/reports/coverage/20190415_coverage.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 173 KiB |
BIN
doc/reports/final-report/20190411_final_report.pdf
Normal file
BIN
doc/reports/final-report/20190411_final_report.pdf
Normal file
Binary file not shown.
13
doc/reports/sprint-reviews/20190415_sprint_review.md
Normal file
13
doc/reports/sprint-reviews/20190415_sprint_review.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
# Sprint Review
|
||||||
|
|
||||||
|
## Main problems Encountered
|
||||||
|
|
||||||
|
### Problem 1:
|
||||||
|
|
||||||
|
## Adjustments from previous sprints
|
||||||
|
Our project is completely finished and we're very happy with the result.
|
||||||
|
|
||||||
|
## Adjustments for next sprint
|
||||||
|
This is the last sprint for this project!
|
||||||
|
|
||||||
BIN
doc/sprints/sprint7/20190415_scrumboard.png
Normal file
BIN
doc/sprints/sprint7/20190415_scrumboard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
BIN
doc/sprints/sprint7/retrospective_sprint7.pdf
Normal file
BIN
doc/sprints/sprint7/retrospective_sprint7.pdf
Normal file
Binary file not shown.
@@ -39,8 +39,8 @@ test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bootJar {
|
bootJar {
|
||||||
baseName = 'gs-consuming-rest'
|
baseName = 'greenify'
|
||||||
version = '0.1.0'
|
version = '1.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
@@ -48,6 +48,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
compile "org.bouncycastle:bcprov-jdk16:1.46", "org.bouncycastle:bcpg-jdk16:1.46", "org.bouncycastle:bcmail-jdk16:1.46", "org.bouncycastle:bctsp-jdk16:1.46"
|
||||||
compile("org.springframework.boot:spring-boot-starter")
|
compile("org.springframework.boot:spring-boot-starter")
|
||||||
compile("org.springframework:spring-web")
|
compile("org.springframework:spring-web")
|
||||||
compile("com.fasterxml.jackson.core:jackson-databind")
|
compile("com.fasterxml.jackson.core:jackson-databind")
|
||||||
|
|||||||
@@ -1,18 +1,34 @@
|
|||||||
package greenify.client;
|
package greenify.client;
|
||||||
|
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
|
import javafx.beans.property.SimpleIntegerProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
public class Friend {
|
public class Friend {
|
||||||
|
|
||||||
|
private SimpleIntegerProperty place;
|
||||||
private SimpleStringProperty friend;
|
private SimpleStringProperty friend;
|
||||||
private SimpleDoubleProperty score;
|
private SimpleDoubleProperty score;
|
||||||
|
|
||||||
public Friend(String friend, Double friendScore) {
|
/**
|
||||||
|
* Constructor for a friend.
|
||||||
|
* @param place place in the leaderboard
|
||||||
|
* @param friend name of the user
|
||||||
|
* @param friendScore score of the user
|
||||||
|
*/
|
||||||
|
public Friend(Integer place, String friend, Double friendScore) {
|
||||||
|
this.place = new SimpleIntegerProperty(place);
|
||||||
this.friend = new SimpleStringProperty(friend);
|
this.friend = new SimpleStringProperty(friend);
|
||||||
this.score = new SimpleDoubleProperty(friendScore);
|
this.score = new SimpleDoubleProperty(friendScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getPlace() {
|
||||||
|
return place.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlace(Integer place) {
|
||||||
|
this.place = new SimpleIntegerProperty(place);
|
||||||
|
}
|
||||||
|
|
||||||
public String getFriend() {
|
public String getFriend() {
|
||||||
return friend.get();
|
return friend.get();
|
||||||
|
|||||||
@@ -93,6 +93,10 @@ public class DashBoardController {
|
|||||||
@FXML
|
@FXML
|
||||||
private Button addFriendButton;
|
private Button addFriendButton;
|
||||||
@FXML
|
@FXML
|
||||||
|
private Button addFriend;
|
||||||
|
@FXML
|
||||||
|
private Button removeFriend;
|
||||||
|
@FXML
|
||||||
private Button addExtraActivityButton;
|
private Button addExtraActivityButton;
|
||||||
@FXML
|
@FXML
|
||||||
private Button addExtraActivityButton2;
|
private Button addExtraActivityButton2;
|
||||||
@@ -105,18 +109,24 @@ public class DashBoardController {
|
|||||||
@FXML
|
@FXML
|
||||||
private TableView<Friend> globalLeaderboard;
|
private TableView<Friend> globalLeaderboard;
|
||||||
@FXML
|
@FXML
|
||||||
|
private TableColumn<Friend, Integer> globalPlace;
|
||||||
|
@FXML
|
||||||
private TableColumn<Friend, String> globalUser;
|
private TableColumn<Friend, String> globalUser;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Friend, Float> globalScore;
|
private TableColumn<Friend, Float> globalScore;
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<Friend> developmentLeaderboard;
|
private TableView<Friend> developmentLeaderboard;
|
||||||
@FXML
|
@FXML
|
||||||
|
private TableColumn<Friend, Integer> developmentPlace;
|
||||||
|
@FXML
|
||||||
private TableColumn<Friend, String> developmentUser;
|
private TableColumn<Friend, String> developmentUser;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Friend, Float> developmentScore;
|
private TableColumn<Friend, Float> developmentScore;
|
||||||
@FXML
|
@FXML
|
||||||
private TableView<Friend> friendLeaderboard;
|
private TableView<Friend> friendLeaderboard;
|
||||||
@FXML
|
@FXML
|
||||||
|
private TableColumn<Friend, Integer> friendPlace;
|
||||||
|
@FXML
|
||||||
private TableColumn<Friend, String> friendUser;
|
private TableColumn<Friend, String> friendUser;
|
||||||
@FXML
|
@FXML
|
||||||
private TableColumn<Friend, Float> friendScore;
|
private TableColumn<Friend, Float> friendScore;
|
||||||
@@ -235,15 +245,18 @@ public class DashBoardController {
|
|||||||
logOutButton.setSkin(new MyButtonSkin(logOutButton));
|
logOutButton.setSkin(new MyButtonSkin(logOutButton));
|
||||||
friendsColumn.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
friendsColumn.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||||
scoreColumn.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
scoreColumn.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||||
|
globalPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||||
globalUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
globalUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||||
globalScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
globalScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||||
developmentUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
developmentUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||||
|
developmentPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||||
developmentScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
developmentScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||||
|
friendPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||||
friendUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
friendUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||||
friendScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
friendScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||||
List<String> friendList = userService.getFriendNames(userService.currentUser.getName());
|
List<String> friendList = userService.getFriendNames(userService.currentUser.getName());
|
||||||
for (int i = 0; i < friendList.size(); i++) {
|
for (int i = 0; i < friendList.size(); i++) {
|
||||||
Friend friend = new Friend(friendList.get(i),
|
Friend friend = new Friend(i, friendList.get(i),
|
||||||
userService.getFootprint(friendList.get(i)));
|
userService.getFootprint(friendList.get(i)));
|
||||||
data.add(friend);
|
data.add(friend);
|
||||||
}
|
}
|
||||||
@@ -466,6 +479,7 @@ public class DashBoardController {
|
|||||||
updateFriends();
|
updateFriends();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out the user.
|
* Logs out the user.
|
||||||
* @param event the event (clicking the button)
|
* @param event the event (clicking the button)
|
||||||
@@ -485,6 +499,9 @@ public class DashBoardController {
|
|||||||
//development leaderboard
|
//development leaderboard
|
||||||
developmentLeaderboard.getItems().clear();
|
developmentLeaderboard.getItems().clear();
|
||||||
developmentData.removeAll();
|
developmentData.removeAll();
|
||||||
|
//friends leaderboard
|
||||||
|
friendLeaderboard.getItems().clear();
|
||||||
|
friendLeaderData.removeAll();
|
||||||
|
|
||||||
//load the fxml file
|
//load the fxml file
|
||||||
Parent dash = Application.load(this.getClass().getClassLoader()
|
Parent dash = Application.load(this.getClass().getClassLoader()
|
||||||
@@ -570,6 +587,20 @@ public class DashBoardController {
|
|||||||
calcStage.show();
|
calcStage.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* method opens removeFriend scene.
|
||||||
|
* @throws IOException when file is not found
|
||||||
|
*/
|
||||||
|
public void openRemoveFriend() throws IOException {
|
||||||
|
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||||
|
.getResource("fxml/RemoveFriend.fxml"));
|
||||||
|
Scene scene = new Scene(calc);
|
||||||
|
Stage calcStage = new Stage();
|
||||||
|
calcStage.setScene(scene);
|
||||||
|
calcStage.setTitle("Remove your friend - " + userService.currentUser.getName());
|
||||||
|
calcStage.show();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Leaderboard is updating.
|
* Leaderboard is updating.
|
||||||
* @throws InterruptedException throws exception
|
* @throws InterruptedException throws exception
|
||||||
@@ -585,14 +616,15 @@ public class DashBoardController {
|
|||||||
List<String> userList = userService.getAllUsers();
|
List<String> userList = userService.getAllUsers();
|
||||||
sortScores(userList);
|
sortScores(userList);
|
||||||
for (int i = userList.size() - 1; i >= 0; i--) {
|
for (int i = userList.size() - 1; i >= 0; i--) {
|
||||||
Friend user = new Friend(userList.get(i), userService.getFootprint(userList.get(i)));
|
Friend user = new Friend(userList.size() - i, userList.get(i),
|
||||||
|
userService.getFootprint(userList.get(i)));
|
||||||
globalLeaderData.add(user);
|
globalLeaderData.add(user);
|
||||||
}
|
}
|
||||||
List<String> secondList = sortDiffScores(userList);
|
List<String> secondList = sortDiffScores(userList);
|
||||||
for (int j = 0; j < userList.size(); j++) {
|
for (int j = 0; j < userList.size(); j++) {
|
||||||
double diff = Math.round((userService.getFirstFootprint(secondList.get(j))
|
double diff = Math.round((userService.getFirstFootprint(secondList.get(j))
|
||||||
- userService.getFootprint(secondList.get(j))) * 10) / 10.0;
|
- userService.getFootprint(secondList.get(j))) * 10) / 10.0;
|
||||||
Friend diffUser = new Friend(secondList.get(j), diff);
|
Friend diffUser = new Friend(j + 1, secondList.get(j), diff);
|
||||||
developmentData.add(diffUser);
|
developmentData.add(diffUser);
|
||||||
}
|
}
|
||||||
globalLeaderboard.setItems(globalLeaderData);
|
globalLeaderboard.setItems(globalLeaderData);
|
||||||
@@ -643,14 +675,14 @@ public class DashBoardController {
|
|||||||
friendLeaderData.removeAll();
|
friendLeaderData.removeAll();
|
||||||
sortDiffScores(wholeList);
|
sortDiffScores(wholeList);
|
||||||
for (int i = friendList.size() - 1; i >= 0 ; i--) {
|
for (int i = friendList.size() - 1; i >= 0 ; i--) {
|
||||||
Friend user = new Friend(friendList.get(i), userService
|
Friend user = new Friend(i, friendList.get(i), userService
|
||||||
.getFootprint(friendList.get(i)));
|
.getFootprint(friendList.get(i)));
|
||||||
data.add(user);
|
data.add(user);
|
||||||
}
|
}
|
||||||
for (int j = 0; j < wholeList.size(); j++) {
|
for (int j = 0; j < wholeList.size(); j++) {
|
||||||
double diff = Math.round((userService.getFirstFootprint(wholeList.get(j))
|
double diff = Math.round((userService.getFirstFootprint(wholeList.get(j))
|
||||||
- userService.getFootprint(wholeList.get(j))) * 10) / 10.0;
|
- userService.getFootprint(wholeList.get(j))) * 10) / 10.0;
|
||||||
Friend diffUser = new Friend(wholeList.get(j), diff);
|
Friend diffUser = new Friend(j + 1, wholeList.get(j), diff);
|
||||||
friendLeaderData.add(diffUser);
|
friendLeaderData.add(diffUser);
|
||||||
}
|
}
|
||||||
friendsTable.setItems(data);
|
friendsTable.setItems(data);
|
||||||
|
|||||||
@@ -132,6 +132,10 @@ public class ExtraActivityController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add transition animation.
|
||||||
|
* @param node adding animation
|
||||||
|
*/
|
||||||
public void addFadeTransAnimation(Node node) {
|
public void addFadeTransAnimation(Node node) {
|
||||||
FadeTransition fade = new FadeTransition(Duration.millis(350), node);
|
FadeTransition fade = new FadeTransition(Duration.millis(350), node);
|
||||||
fade.setFromValue(0);
|
fade.setFromValue(0);
|
||||||
|
|||||||
@@ -23,9 +23,13 @@ public class FriendController {
|
|||||||
private Button addButton;
|
private Button addButton;
|
||||||
@FXML
|
@FXML
|
||||||
private TextField userNameText;
|
private TextField userNameText;
|
||||||
|
@FXML
|
||||||
|
private Button removeButton;
|
||||||
|
@FXML
|
||||||
|
private TextField removeUserNameText;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signs up the user.
|
* Add a new friend.
|
||||||
* @param event the click of the sign up button
|
* @param event the click of the sign up button
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
@@ -58,8 +62,48 @@ public class FriendController {
|
|||||||
String friendName = userNameText.getText();
|
String friendName = userNameText.getText();
|
||||||
Stage current = (Stage) owner;
|
Stage current = (Stage) owner;
|
||||||
dashBoardController.updateAchievements();
|
dashBoardController.updateAchievements();
|
||||||
|
dashBoardController.updateFriends();
|
||||||
current.close();
|
current.close();
|
||||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Friend added!",
|
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Friend added!",
|
||||||
userNameText.getText() + " is now your friend!");
|
userNameText.getText() + " is now your friend!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes one of the friends of the user.
|
||||||
|
* @param event the click of the sign up button
|
||||||
|
*/
|
||||||
|
@FXML
|
||||||
|
public void removeFriend(ActionEvent event) throws InterruptedException {
|
||||||
|
//set the window to the current window (for displaying the alerts)
|
||||||
|
Window owner = removeButton.getScene().getWindow();
|
||||||
|
//check if the username field is empty
|
||||||
|
if (removeUserNameText.getText().isEmpty()) {
|
||||||
|
//if so, display an alert
|
||||||
|
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||||
|
"Please enter a username!");
|
||||||
|
return;
|
||||||
|
} else if (removeUserNameText.getText().equals(userService.currentUser.getName())) {
|
||||||
|
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||||
|
"You are not your friend!");
|
||||||
|
return;
|
||||||
|
} else if (!userService.getFriendNames(userService.currentUser.getName())
|
||||||
|
.contains(removeUserNameText.getText())) {
|
||||||
|
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||||
|
"You do not have a friend with this username!");
|
||||||
|
return;
|
||||||
|
} else if (!userService.getAllUsers().contains(removeUserNameText.getText())) {
|
||||||
|
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||||
|
"The user does not exist!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//add friend to the current user
|
||||||
|
userService.removeFriend(userService.currentUser.getName(), removeUserNameText.getText());
|
||||||
|
//close the register window after the user has entered all the credentials
|
||||||
|
Stage current = (Stage) owner;
|
||||||
|
dashBoardController.updateFriends();
|
||||||
|
dashBoardController.updateAchievements();
|
||||||
|
current.close();
|
||||||
|
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Friend removed!",
|
||||||
|
removeUserNameText.getText() + " is not your friend anymore!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -180,7 +181,7 @@ public class RegisterWindowController {
|
|||||||
TimeUnit.MILLISECONDS.sleep(300);
|
TimeUnit.MILLISECONDS.sleep(300);
|
||||||
addSlideAnimation(1100, passwordField2, -420);
|
addSlideAnimation(1100, passwordField2, -420);
|
||||||
|
|
||||||
signUpButton.setSkin(new registerButtonSkin(signUpButton));
|
signUpButton.setSkin(new RegisterButtonSkin(signUpButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,7 +210,7 @@ public class RegisterWindowController {
|
|||||||
* @param event the click of the sign up button
|
* @param event the click of the sign up button
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
public void handleSignUpButton(ActionEvent event) throws IOException {
|
public void handleSignUpButton(ActionEvent event) throws IOException, NoSuchAlgorithmException {
|
||||||
//set the window to the current window (for displaying the alerts)
|
//set the window to the current window (for displaying the alerts)
|
||||||
Window owner = signUpButton.getScene().getWindow();
|
Window owner = signUpButton.getScene().getWindow();
|
||||||
//check if the username field is empty
|
//check if the username field is empty
|
||||||
@@ -632,8 +633,12 @@ public class RegisterWindowController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
public class registerButtonSkin extends ButtonSkin {
|
public class RegisterButtonSkin extends ButtonSkin {
|
||||||
public registerButtonSkin(Button button) {
|
/**
|
||||||
|
* registers button skins.
|
||||||
|
* @param button clicking
|
||||||
|
*/
|
||||||
|
public RegisterButtonSkin(Button button) {
|
||||||
super(button);
|
super(button);
|
||||||
|
|
||||||
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
import org.springframework.web.client.HttpClientErrorException;
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +44,7 @@ public class UserController {
|
|||||||
loginButton.setSkin(new LoginButtonSkin(loginButton));
|
loginButton.setSkin(new LoginButtonSkin(loginButton));
|
||||||
signUpButton.setSkin(new LoginButtonSkin(signUpButton));
|
signUpButton.setSkin(new LoginButtonSkin(signUpButton));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles when the user clicks on the login button.
|
* Handles when the user clicks on the login button.
|
||||||
* it checks if the username and password fields are filled
|
* it checks if the username and password fields are filled
|
||||||
@@ -51,8 +53,8 @@ public class UserController {
|
|||||||
* @throws IOException an exception for logging in the user
|
* @throws IOException an exception for logging in the user
|
||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
protected void handleLoginButtonAction(ActionEvent event) throws IOException {
|
protected void handleLoginButtonAction(ActionEvent event)
|
||||||
|
throws IOException, NoSuchAlgorithmException {
|
||||||
Window owner = loginButton.getScene().getWindow(); //get the current window
|
Window owner = loginButton.getScene().getWindow(); //get the current window
|
||||||
if (usernameField.getText().isEmpty()) {
|
if (usernameField.getText().isEmpty()) {
|
||||||
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
|
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
|
||||||
@@ -153,6 +155,10 @@ public class UserController {
|
|||||||
|
|
||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
public class LoginButtonSkin extends ButtonSkin {
|
public class LoginButtonSkin extends ButtonSkin {
|
||||||
|
/**
|
||||||
|
* method for the skin of login button.
|
||||||
|
* @param button clicking
|
||||||
|
*/
|
||||||
public LoginButtonSkin(Button button) {
|
public LoginButtonSkin(Button button) {
|
||||||
super(button);
|
super(button);
|
||||||
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package greenify.client.rest;
|
|||||||
|
|
||||||
import greenify.common.UserDto;
|
import greenify.common.UserDto;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
@@ -12,6 +13,9 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.util.UriComponentsBuilder;
|
import org.springframework.web.util.UriComponentsBuilder;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.security.MessageDigest;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -19,6 +23,9 @@ import java.util.Map;
|
|||||||
public class UserService {
|
public class UserService {
|
||||||
public UserDto currentUser;
|
public UserDto currentUser;
|
||||||
|
|
||||||
|
@Value( "${server.address:http://localhost:8080}" )
|
||||||
|
String serverAddress = "http://localhost:8080";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RestTemplate restTemplate;
|
RestTemplate restTemplate;
|
||||||
|
|
||||||
@@ -36,16 +43,17 @@ public class UserService {
|
|||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
//this suppressWarnings is to get rid of the errors of duplicate code
|
//this suppressWarnings is to get rid of the errors of duplicate code
|
||||||
//because the methods are very similar
|
//because the methods are very similar
|
||||||
public UserDto registerUser(String name, String password) {
|
public UserDto registerUser(String name, String password) throws NoSuchAlgorithmException {
|
||||||
//headers for http
|
//headers for http
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
//set the accept header in JSON value
|
//set the accept header in JSON value
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
//connect to the server with the needed url
|
//connect to the server with the needed url
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/registerUser")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/registerUser")
|
||||||
.queryParam("name", name)
|
.queryParam("name", name)
|
||||||
//getting the name from the database
|
//getting the name from the database
|
||||||
.queryParam("password", password);
|
.queryParam("password", hashPassword(password));
|
||||||
//getting the password from the database
|
//getting the password from the database
|
||||||
|
|
||||||
//create a http entity to be sent
|
//create a http entity to be sent
|
||||||
@@ -67,13 +75,14 @@ public class UserService {
|
|||||||
* @return a userDTO
|
* @return a userDTO
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("Duplicates")
|
@SuppressWarnings("Duplicates")
|
||||||
public UserDto loginUser(String name, String password) {
|
public UserDto loginUser(String name, String password) throws NoSuchAlgorithmException {
|
||||||
//this method is almost the same as the registerUser one, but with a different link
|
//this method is almost the same as the registerUser one, but with a different link
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/loginUser")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/loginUser")
|
||||||
.queryParam("name", name)
|
.queryParam("name", name)
|
||||||
.queryParam("password", password);
|
.queryParam("password", hashPassword(password));
|
||||||
new HttpEntity<>(headers);
|
new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
UserDto result = this.restTemplate.getForObject(builder.build()
|
UserDto result = this.restTemplate.getForObject(builder.build()
|
||||||
@@ -92,7 +101,7 @@ public class UserService {
|
|||||||
public void updateInput(String name, String inputName, String value) {
|
public void updateInput(String name, String inputName, String value) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/setInput")
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(serverAddress + "/setInput")
|
||||||
.queryParam("name", name)
|
.queryParam("name", name)
|
||||||
.queryParam("inputName", inputName)
|
.queryParam("inputName", inputName)
|
||||||
.queryParam("value",value);
|
.queryParam("value",value);
|
||||||
@@ -112,7 +121,8 @@ public class UserService {
|
|||||||
public void updateExtraInput(String name, String inputName, String value) {
|
public void updateExtraInput(String name, String inputName, String value) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/setExtraInput")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/setExtraInput")
|
||||||
.queryParam("name", name)
|
.queryParam("name", name)
|
||||||
.queryParam("inputName", inputName)
|
.queryParam("inputName", inputName)
|
||||||
.queryParam("value", value);
|
.queryParam("value", value);
|
||||||
@@ -131,7 +141,8 @@ public class UserService {
|
|||||||
public double getFootprint(String name) {
|
public double getFootprint(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFootprint")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/getFootprint")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
new HttpEntity<>(headers);
|
new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -149,7 +160,7 @@ public class UserService {
|
|||||||
public double getFirstFootprint(String name) {
|
public double getFirstFootprint(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFirst")
|
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(serverAddress + "/getFirst")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
new HttpEntity<>(headers);
|
new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -168,7 +179,8 @@ public class UserService {
|
|||||||
public Float saveFootprint(String name) {
|
public Float saveFootprint(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/saveFootprint")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/saveFootprint")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
new HttpEntity<>(headers);
|
new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -187,7 +199,8 @@ public class UserService {
|
|||||||
public Float saveFirstFootprint(String name) {
|
public Float saveFirstFootprint(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/saveFirstFootprint")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/saveFirstFootprint")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
new HttpEntity<>(headers);
|
new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -205,7 +218,8 @@ public class UserService {
|
|||||||
public List<String> getFriendNames(String name) {
|
public List<String> getFriendNames(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFriends")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/getFriends")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
new HttpEntity<>(headers);
|
new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -223,7 +237,8 @@ public class UserService {
|
|||||||
public void addFriend(String name, String friend) {
|
public void addFriend(String name, String friend) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/addFriend")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/addFriend")
|
||||||
.queryParam("name", name)
|
.queryParam("name", name)
|
||||||
.queryParam("friend",friend);
|
.queryParam("friend",friend);
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
@@ -241,7 +256,8 @@ public class UserService {
|
|||||||
public void removeFriend(String name, String friend) {
|
public void removeFriend(String name, String friend) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/removeFriend")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/removeFriend")
|
||||||
.queryParam("name", name)
|
.queryParam("name", name)
|
||||||
.queryParam("friend",friend);
|
.queryParam("friend",friend);
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
@@ -258,7 +274,8 @@ public class UserService {
|
|||||||
public Map<String, String> getInputs(String name) {
|
public Map<String, String> getInputs(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getInputs")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/getInputs")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -275,7 +292,8 @@ public class UserService {
|
|||||||
public Map<String, String> getExtraInputs(String name) {
|
public Map<String, String> getExtraInputs(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getExtraInputs")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/getExtraInputs")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -293,7 +311,8 @@ public class UserService {
|
|||||||
public Map getAchievements(String name) {
|
public Map getAchievements(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getAchievements")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/getAchievements")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -310,7 +329,8 @@ public class UserService {
|
|||||||
public Map<String, String> getResults(String name) {
|
public Map<String, String> getResults(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getResults")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/getResults")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
@@ -325,7 +345,8 @@ public class UserService {
|
|||||||
public List<String> getAllUsers() {
|
public List<String> getAllUsers() {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getAllUsers");
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/getAllUsers");
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
List<String> result = this.restTemplate.getForObject(builder
|
List<String> result = this.restTemplate.getForObject(builder
|
||||||
@@ -341,11 +362,33 @@ public class UserService {
|
|||||||
public void deleteAccount(String name) {
|
public void deleteAccount(String name) {
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/deleteAccount")
|
UriComponentsBuilder builder = UriComponentsBuilder
|
||||||
|
.fromHttpUrl(serverAddress + "/deleteAccount")
|
||||||
.queryParam("name", name);
|
.queryParam("name", name);
|
||||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
System.out.println(builder.build().encode().toUri());
|
System.out.println(builder.build().encode().toUri());
|
||||||
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
||||||
.encode().toUri(), String.class);
|
.encode().toUri(), String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hashes the password of a user.
|
||||||
|
* @param password password of the user
|
||||||
|
* @return hashed password
|
||||||
|
* @throws NoSuchAlgorithmException when there is no such algorithm
|
||||||
|
*/
|
||||||
|
public String hashPassword(String password)
|
||||||
|
throws NoSuchAlgorithmException {
|
||||||
|
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||||
|
byte[] encodedHash = digest.digest(password.getBytes(StandardCharsets.UTF_8));
|
||||||
|
StringBuffer hexString = new StringBuffer();
|
||||||
|
for (int i = 0; i < encodedHash.length; i++) {
|
||||||
|
String hex = Integer.toHexString(0xff & encodedHash[i]);
|
||||||
|
if (hex.length() == 1) {
|
||||||
|
hexString.append('0');
|
||||||
|
}
|
||||||
|
hexString.append(hex);
|
||||||
|
}
|
||||||
|
return hexString.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
39
src/Client/src/main/resources/fxml/RemoveFriend.fxml
Normal file
39
src/Client/src/main/resources/fxml/RemoveFriend.fxml
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.image.Image?>
|
||||||
|
<?import javafx.scene.image.ImageView?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
<?import javafx.scene.text.Font?>
|
||||||
|
<?import javafx.scene.text.Text?>
|
||||||
|
|
||||||
|
<AnchorPane prefHeight="287.0" prefWidth="187.0" style="-fx-background-color: #e2f0c8;" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.FriendController">
|
||||||
|
<children>
|
||||||
|
<Text fill="#00650d" layoutX="114.0" layoutY="64.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Remove Friend" textAlignment="CENTER" wrappingWidth="234.96600341796875">
|
||||||
|
<font>
|
||||||
|
<Font size="30.0" />
|
||||||
|
</font>
|
||||||
|
</Text>
|
||||||
|
<TextField fx:id="removeUserNameText" layoutX="140.0" layoutY="100.0" prefHeight="35.0" prefWidth="183.0" promptText="Username">
|
||||||
|
<font>
|
||||||
|
<Font size="13.0" />
|
||||||
|
</font>
|
||||||
|
</TextField>
|
||||||
|
<Button fx:id="removeButton" layoutX="206.0" layoutY="154.0" mnemonicParsing="false" onAction="#removeFriend" style="-fx-background-color: #005e07;" text="Remove!" textFill="#c4eec9">
|
||||||
|
<font>
|
||||||
|
<Font name="Corbel Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
</Button>
|
||||||
|
<ImageView fitHeight="80.0" fitWidth="349.0" layoutY="211.0" pickOnBounds="true" preserveRatio="true">
|
||||||
|
<image>
|
||||||
|
<Image url="@../icons/grass.png"/>
|
||||||
|
</image>
|
||||||
|
</ImageView>
|
||||||
|
<ImageView fitHeight="150.0" fitWidth="200.0" layoutY="43.0" pickOnBounds="true" preserveRatio="true">
|
||||||
|
<image>
|
||||||
|
<Image url="@../icons/friends.png" />
|
||||||
|
</image>
|
||||||
|
</ImageView>
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
@@ -1,12 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.chart.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.image.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
<?import javafx.scene.shape.*?>
|
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
<?import javafx.scene.chart.PieChart?>
|
<?import javafx.scene.chart.PieChart?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
<?import javafx.scene.control.Label?>
|
<?import javafx.scene.control.Label?>
|
||||||
@@ -23,9 +16,8 @@
|
|||||||
<?import javafx.scene.shape.Line?>
|
<?import javafx.scene.shape.Line?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import javafx.scene.text.Text?>
|
<?import javafx.scene.text.Text?>
|
||||||
<?import javafx.scene.control.Tooltip?>
|
|
||||||
|
|
||||||
<AnchorPane prefHeight="702.0" prefWidth="1032.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
|
<AnchorPane prefHeight="702.0" prefWidth="1032.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
|
||||||
<children>
|
<children>
|
||||||
<AnchorPane fx:id="menuBar" prefHeight="703.0" prefWidth="216.0" style="-fx-background-color: #5a635c;">
|
<AnchorPane fx:id="menuBar" prefHeight="703.0" prefWidth="216.0" style="-fx-background-color: #5a635c;">
|
||||||
<children>
|
<children>
|
||||||
@@ -459,16 +451,11 @@
|
|||||||
</ImageView>
|
</ImageView>
|
||||||
</graphic>
|
</graphic>
|
||||||
</Button>
|
</Button>
|
||||||
<TableView fx:id="globalLeaderboard" layoutX="56.0" layoutY="220.0" prefHeight="333.0" prefWidth="200.0">
|
<TableView fx:id="globalLeaderboard" layoutX="53.0" layoutY="220.0" prefHeight="334.0" prefWidth="207.0">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn fx:id="globalUser" prefWidth="121.0" text="User" />
|
<TableColumn fx:id="globalPlace" prefWidth="30.0" text="#" />
|
||||||
<TableColumn fx:id="globalScore" prefWidth="78.0" text="Score" />
|
<TableColumn fx:id="globalUser" prefWidth="75.0" text="User" />
|
||||||
</columns>
|
<TableColumn fx:id="globalScore" prefWidth="100.0" text="Score" />
|
||||||
</TableView>
|
|
||||||
<TableView fx:id="developmentLeaderboard" layoutX="302.0" layoutY="220.0" prefHeight="333.0" prefWidth="200.0">
|
|
||||||
<columns>
|
|
||||||
<TableColumn fx:id="developmentUser" prefWidth="126.0" text="User" />
|
|
||||||
<TableColumn fx:id="developmentScore" prefWidth="73.0" text="Score" />
|
|
||||||
</columns>
|
</columns>
|
||||||
</TableView>
|
</TableView>
|
||||||
<Label layoutX="69.0" layoutY="177.0" prefHeight="46.0" prefWidth="187.0" text="Global Leaderboard" textAlignment="CENTER" textFill="#5f1616">
|
<Label layoutX="69.0" layoutY="177.0" prefHeight="46.0" prefWidth="187.0" text="Global Leaderboard" textAlignment="CENTER" textFill="#5f1616">
|
||||||
@@ -570,6 +557,13 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
|
<TableView fx:id="developmentLeaderboard" layoutX="292.0" layoutY="220.0" prefHeight="334.0" prefWidth="207.0">
|
||||||
|
<columns>
|
||||||
|
<TableColumn fx:id="developmentPlace" prefWidth="30.0" text="#" />
|
||||||
|
<TableColumn fx:id="developmentUser" prefWidth="75.0" text="User" />
|
||||||
|
<TableColumn fx:id="developmentScore" prefWidth="100.0" text="Score" />
|
||||||
|
</columns>
|
||||||
|
</TableView>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
<AnchorPane fx:id="friendsPane" layoutX="216.0" prefHeight="703.0" prefWidth="820.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="214.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<AnchorPane fx:id="friendsPane" layoutX="216.0" prefHeight="703.0" prefWidth="820.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="214.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
@@ -584,7 +578,7 @@
|
|||||||
<Font size="20.0" />
|
<Font size="20.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
<TableView fx:id="friendsTable" layoutX="60.0" layoutY="170.0" prefHeight="426.0" prefWidth="216.0" style="-fx-background-color: #e1fcd9;">
|
<TableView fx:id="friendsTable" layoutX="60.0" layoutY="170.0" prefHeight="426.0" prefWidth="214.0" style="-fx-background-color: #e1fcd9;">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn fx:id="friendsColumn" prefWidth="107.0" text="Friend" />
|
<TableColumn fx:id="friendsColumn" prefWidth="107.0" text="Friend" />
|
||||||
<TableColumn fx:id="scoreColumn" prefWidth="108.0" text="Score" />
|
<TableColumn fx:id="scoreColumn" prefWidth="108.0" text="Score" />
|
||||||
@@ -598,15 +592,40 @@
|
|||||||
<Font size="20.0" />
|
<Font size="20.0" />
|
||||||
</font>
|
</font>
|
||||||
</Text>
|
</Text>
|
||||||
<TableView fx:id="friendLeaderboard" layoutX="300.0" layoutY="170.0" prefHeight="426.0" prefWidth="216.0" style="-fx-background-color: #e1fcd9;">
|
<TableView fx:id="friendLeaderboard" layoutX="300.0" layoutY="170.0" prefHeight="426.0" prefWidth="232.0" style="-fx-background-color: #e1fcd9;">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn fx:id="friendUser" prefWidth="107.0" text="Friend" />
|
<TableColumn fx:id="friendPlace" prefWidth="30.0" resizable="false" text="#" />
|
||||||
<TableColumn fx:id="friendScore" prefWidth="108.0" text="Score" />
|
<TableColumn fx:id="friendUser" minWidth="30.0" prefWidth="100.0" resizable="false" text="Friend" />
|
||||||
|
<TableColumn fx:id="friendScore" minWidth="30.0" prefWidth="100.0" resizable="false" text="Score" />
|
||||||
</columns>
|
</columns>
|
||||||
<columnResizePolicy>
|
<columnResizePolicy>
|
||||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||||
</columnResizePolicy>
|
</columnResizePolicy>
|
||||||
</TableView>
|
</TableView>
|
||||||
|
<Button fx:id="addFriend" contentDisplay="RIGHT" layoutX="575.0" layoutY="75.0" mnemonicParsing="false" onAction="#openAddFriend" prefHeight="74.0" prefWidth="200.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Add friend" textFill="#29721a">
|
||||||
|
<font>
|
||||||
|
<Font name="Corbel Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
<graphic>
|
||||||
|
<ImageView fitHeight="74.0" fitWidth="64.0" pickOnBounds="true" preserveRatio="true">
|
||||||
|
<image>
|
||||||
|
<Image url="@../icons/friend2.png" />
|
||||||
|
</image>
|
||||||
|
</ImageView>
|
||||||
|
</graphic>
|
||||||
|
</Button>
|
||||||
|
<Button fx:id="removeFriend" contentDisplay="RIGHT" layoutX="560.0" layoutY="150.0" mnemonicParsing="false" onAction="#openRemoveFriend" prefHeight="74.0" prefWidth="200.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Remove friend" textFill="#29721a">
|
||||||
|
<font>
|
||||||
|
<Font name="Corbel Bold" size="14.0" />
|
||||||
|
</font>
|
||||||
|
<graphic>
|
||||||
|
<ImageView fitHeight="70.0" fitWidth="60.0" pickOnBounds="true" preserveRatio="true">
|
||||||
|
<image>
|
||||||
|
<Image url="@../icons/remove_friend.png" />
|
||||||
|
</image>
|
||||||
|
</ImageView>
|
||||||
|
</graphic>
|
||||||
|
</Button>
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
BIN
src/Client/src/main/resources/icons/remove_friend.png
Normal file
BIN
src/Client/src/main/resources/icons/remove_friend.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
@@ -7,9 +7,11 @@ import org.junit.jupiter.api.Assertions;
|
|||||||
public class FriendTest {
|
public class FriendTest {
|
||||||
@Test
|
@Test
|
||||||
public void setAndGetTest() {
|
public void setAndGetTest() {
|
||||||
Friend test = new Friend("ceren", 10.0);
|
Friend test = new Friend(1,"ceren", 10.0);
|
||||||
|
test.setPlace(1);
|
||||||
test.setFriend("greenify");
|
test.setFriend("greenify");
|
||||||
test.setScore(15.0);
|
test.setScore(15.0);
|
||||||
|
Assertions.assertEquals(test.getPlace(), 1);
|
||||||
assertEquals(test.getFriend(), "greenify");
|
assertEquals(test.getFriend(), "greenify");
|
||||||
Assertions.assertEquals(test.getScore(), 15.0);
|
Assertions.assertEquals(test.getScore(), 15.0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class UserServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void userRegisterTest() throws Exception {
|
public void userRegisterTest() throws Exception {
|
||||||
UserDto testUser = new UserDto(1L, "Eric");
|
UserDto testUser = new UserDto(1L, "Eric");
|
||||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/registerUser?name=Eric&password=password"),
|
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/registerUser?name=Eric&password=5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"),
|
||||||
UserDto.class))
|
UserDto.class))
|
||||||
.thenReturn(testUser);
|
.thenReturn(testUser);
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ public class UserServiceTest {
|
|||||||
@Test
|
@Test
|
||||||
public void userLoginTest() throws Exception {
|
public void userLoginTest() throws Exception {
|
||||||
UserDto testUser = new UserDto(1L, "Eric");
|
UserDto testUser = new UserDto(1L, "Eric");
|
||||||
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/loginUser?name=Eric&password=password"),
|
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/loginUser?name=Eric&password=5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"),
|
||||||
UserDto.class))
|
UserDto.class))
|
||||||
.thenReturn(testUser);
|
.thenReturn(testUser);
|
||||||
UserDto user = userService.loginUser("Eric", "password");
|
UserDto user = userService.loginUser("Eric", "password");
|
||||||
|
|||||||
@@ -7,6 +7,19 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id "com.heroku.sdk.heroku-gradle" version "1.0.4"
|
||||||
|
}
|
||||||
|
|
||||||
|
heroku {
|
||||||
|
appName = "greenify43"
|
||||||
|
includes = ["${buildDir}/libs/greenify-server-1.0.0.jar"]
|
||||||
|
includeBuildDir = false
|
||||||
|
processTypes(
|
||||||
|
web: "java -Dserver.port=\$PORT -jar src/Server/build/libs/greenify-server-1.0.0.jar"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
@@ -16,8 +29,8 @@ apply plugin: 'jacoco'
|
|||||||
apply plugin: 'checkstyle'
|
apply plugin: 'checkstyle'
|
||||||
|
|
||||||
bootJar {
|
bootJar {
|
||||||
baseName = 'gs-rest-service'
|
baseName = 'greenify-server'
|
||||||
version = '0.1.0'
|
version = '1.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|||||||
@@ -209,7 +209,6 @@ public class User {
|
|||||||
throw new ApplicationException("Cannot add yourself as a friend");
|
throw new ApplicationException("Cannot add yourself as a friend");
|
||||||
} else {
|
} else {
|
||||||
friends.add(user);
|
friends.add(user);
|
||||||
System.out.print("Friend added!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,7 +221,6 @@ public class User {
|
|||||||
throw new ApplicationException("This user is not your friend!");
|
throw new ApplicationException("This user is not your friend!");
|
||||||
} else {
|
} else {
|
||||||
friends.remove(user);
|
friends.remove(user);
|
||||||
System.out.print("Friend removed");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ public class UserController {
|
|||||||
*/
|
*/
|
||||||
@RequestMapping("/getFirst")
|
@RequestMapping("/getFirst")
|
||||||
public Float getFirstFootprint(@RequestParam(value = "name") String name) {
|
public Float getFirstFootprint(@RequestParam(value = "name") String name) {
|
||||||
System.out.println("hello");
|
|
||||||
Float footprint = userService.getFirstFootprint(name);
|
Float footprint = userService.getFirstFootprint(name);
|
||||||
return footprint;
|
return footprint;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ public class AchievementService {
|
|||||||
public void achieveSocialButterfly(User user) {
|
public void achieveSocialButterfly(User user) {
|
||||||
if (user.getFriends().size() >= 3) {
|
if (user.getFriends().size() >= 3) {
|
||||||
userService.setAchievement(user.getName(), "Social butterfly", true);
|
userService.setAchievement(user.getName(), "Social butterfly", true);
|
||||||
|
} else {
|
||||||
|
userService.setAchievement(user.getName(), "Social butterfly", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,6 +50,8 @@ public class AchievementService {
|
|||||||
public void achieveGreenSaver(User user) {
|
public void achieveGreenSaver(User user) {
|
||||||
if (20 > user.getFootPrint()) {
|
if (20 > user.getFootPrint()) {
|
||||||
userService.setAchievement(user.getName(), "Green saver", true);
|
userService.setAchievement(user.getName(), "Green saver", true);
|
||||||
|
} else {
|
||||||
|
userService.setAchievement(user.getName(), "Green saver", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +63,8 @@ public class AchievementService {
|
|||||||
int vegan = Integer.parseInt(user.getExtraInputs().get("vegan"));
|
int vegan = Integer.parseInt(user.getExtraInputs().get("vegan"));
|
||||||
if (vegan > 10) {
|
if (vegan > 10) {
|
||||||
userService.setAchievement(user.getName(), "Animal friend", true);
|
userService.setAchievement(user.getName(), "Animal friend", true);
|
||||||
|
} else {
|
||||||
|
userService.setAchievement(user.getName(), "Animal friend", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +76,8 @@ public class AchievementService {
|
|||||||
int bike = Integer.parseInt(user.getExtraInputs().get("bike"));
|
int bike = Integer.parseInt(user.getExtraInputs().get("bike"));
|
||||||
if (bike > 15) {
|
if (bike > 15) {
|
||||||
userService.setAchievement(user.getName(), "Tom Dumoulin", true);
|
userService.setAchievement(user.getName(), "Tom Dumoulin", true);
|
||||||
|
} else {
|
||||||
|
userService.setAchievement(user.getName(), "Tom Dumoulin", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +89,8 @@ public class AchievementService {
|
|||||||
int solarPanels = Integer.parseInt(user.getExtraInputs().get("solar_panels"));
|
int solarPanels = Integer.parseInt(user.getExtraInputs().get("solar_panels"));
|
||||||
if (solarPanels >= 2) {
|
if (solarPanels >= 2) {
|
||||||
userService.setAchievement(user.getName(), "Let it shine", true);
|
userService.setAchievement(user.getName(), "Let it shine", true);
|
||||||
|
} else {
|
||||||
|
userService.setAchievement(user.getName(), "Let it shine", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ public class CalculatorService {
|
|||||||
.indexOf("<result_grand_total>")
|
.indexOf("<result_grand_total>")
|
||||||
+ 20, response.getBody().indexOf("</result_grand_total>"));
|
+ 20, response.getBody().indexOf("</result_grand_total>"));
|
||||||
// to do: in not HTTP 200 or exception case throws exception
|
// to do: in not HTTP 200 or exception case throws exception
|
||||||
System.out.println(Float.parseFloat(result));
|
|
||||||
return Float.parseFloat(result);
|
return Float.parseFloat(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user