FIX::fixed checkstyle errors
Merge branch 'master' of gitlab.ewi.tudelft.nl:cse1105/2018-2019/oopp-group-43/template # Conflicts: # src/Client/src/main/java/greenify/client/Hints.java # src/Client/src/main/java/greenify/client/controller/DashBoardController.java # src/Server/src/main/java/greenify/server/service/CalculatorService.java
This commit is contained in:
@@ -29,4 +29,4 @@ public class Friend {
|
||||
public void setScore(Float score) {
|
||||
this.score = new SimpleFloatProperty(score);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ public class Hints {
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a random Hint.
|
||||
* @return a random hint as a string
|
||||
* This method gets a random hint from the list of hints.
|
||||
* @return the random hint.
|
||||
*/
|
||||
public String randomHint() {
|
||||
Random rand = new Random();
|
||||
|
||||
@@ -21,6 +21,7 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.stage.Stage;
|
||||
@@ -154,6 +155,8 @@ public class DashBoardController {
|
||||
@FXML
|
||||
private Label snacks;
|
||||
@FXML
|
||||
private ImageView achiev1image;
|
||||
@FXML
|
||||
private CheckBox localProduce;
|
||||
@FXML
|
||||
private CheckBox loweringTemp;
|
||||
@@ -211,6 +214,7 @@ public class DashBoardController {
|
||||
}
|
||||
friendsTable.setItems(data);
|
||||
updateLeaderboard();
|
||||
updateAchievements();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -285,6 +289,7 @@ public class DashBoardController {
|
||||
activitiesPane.setVisible(false);
|
||||
friendsPane.setVisible(false);
|
||||
updateLeaderboard();
|
||||
updateAchievements();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,13 +406,13 @@ public class DashBoardController {
|
||||
}
|
||||
|
||||
/**
|
||||
* opens the Extra activities scene.
|
||||
* @param event the click of the button
|
||||
* @throws IOException exception if it can't find the fxml file
|
||||
* Opens extra activities.
|
||||
* @param event the event (clicking the button)
|
||||
* @throws IOException if the Application doesn't load.
|
||||
*/
|
||||
public void openExtraActivities(ActionEvent event) throws IOException {
|
||||
Parent extra = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/extraActivities.fxml"));
|
||||
.getResource("fxml/extraActivities.fxml"));
|
||||
Scene scene = new Scene(extra);
|
||||
Stage extraStage = new Stage();
|
||||
extraStage.setScene(scene);
|
||||
@@ -487,6 +492,15 @@ public class DashBoardController {
|
||||
friendLeaderboard.setItems(friendLeaderData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the achievements.
|
||||
*/
|
||||
public void updateAchievements() {
|
||||
Map achievements = userService.getAchievements(userService.currentUser.getName());
|
||||
achiev1image.setVisible((Boolean)achievements.get("Starting off"));
|
||||
//achiev2image.setVisible(achievements.get("name second achievement"));
|
||||
//Add all achievements here, add updateAchievements to the achievements pane
|
||||
}
|
||||
|
||||
//class for the animations on the navigation buttons
|
||||
public class MyButtonSkin extends ButtonSkin {
|
||||
@@ -512,7 +526,6 @@ public class DashBoardController {
|
||||
scaleDown.setToX(1.0);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,6 +282,23 @@ public class UserService {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the achievements of a user.
|
||||
* @param name name of the user
|
||||
* @return Map with all achievements
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public Map getAchievements(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getAchievements")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
return this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), Map.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of all users.
|
||||
*/
|
||||
|
||||
BIN
src/Client/src/main/resources/achiev1pic.jpg
Normal file
BIN
src/Client/src/main/resources/achiev1pic.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -22,7 +22,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<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>
|
||||
<AnchorPane fx:id="menuBar" prefHeight="703.0" prefWidth="216.0" style="-fx-background-color: #5a635c;">
|
||||
<children>
|
||||
@@ -451,6 +451,12 @@
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Label fx:id="achiev1text" layoutX="579.0" layoutY="379.0" prefHeight="17.0" prefWidth="181.0" text="Achievement test label" />
|
||||
<ImageView fx:id="achiev1image" fitHeight="150.0" fitWidth="200.0" layoutX="579.0" layoutY="396.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../achiev1pic.jpg" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</children>
|
||||
</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">
|
||||
|
||||
@@ -155,6 +155,12 @@ public class UserServiceTest {
|
||||
userService.removeFriend("Eric", "Ceren");
|
||||
Mockito.verify(userService).removeFriend("Eric", "Ceren");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAchievementsTest() throws Exception {
|
||||
userService.getAchievements("mika");
|
||||
Mockito.verify(userService).getAchievements("mika");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user