Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ Let´s build and setup the system locally.
This will build booth docker images (using their individual Docker files) and start them in one container each in docker desktop. It will setup a small network so the applications can talk to eachother

3. **Verify**
- Go to http://localhost:8080 and http://localhost:8081 respectively and verify that booth the client and the hub is running.
- Try to register, unregister and set a rating and see how it updates in the HUB UI.
- Spring boot comes with swagger to describe the API. Have a look at the API documentation on the default swagger adress http://localhost:8080/swagger-ui.html
- Using the API, try to register an additional participant by klicking "Try it out" in the swagger gui. Change the default name to someting else and execute a API call. Verify that there now are two participants in the HUB UI.
- Go to http://localhost:8080 and 8081 respectively and verify that booth the client and the hub is running.

# Setup 2 - move to the cloud

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
package se.sodalabs.hub.repository;

import com.google.gson.Gson;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;

public class RegisteredParticipant {
private String id;
private String name;
private String registeredAt;
private String avatarImage;
private Map<Integer, SubmittedFeedback> submittedFeedback = new HashMap<>();
private SubmittedFeedback submittedFeedback;

public RegisteredParticipant() {
this.avatarImage = generateRandomAvatarImage();
}

public RegisteredParticipant(String id, String name, String registeredAt) {
public RegisteredParticipant(
String id, String name, String registeredAt, SubmittedFeedback submittedFeedback) {
this.id = id;
this.name = name;
this.registeredAt = registeredAt;
this.avatarImage = generateRandomAvatarImage();
this.submittedFeedback = submittedFeedback;
}

public String getId() {
Expand Down Expand Up @@ -57,20 +56,11 @@ public void setAvatarImage(String avatarImage) {
}

public SubmittedFeedback getSubmittedFeedback() {
return submittedFeedback.get(0);
}

public SubmittedFeedback getSubmittedFeedbackForExercise(int exerciseIndex) {
return submittedFeedback.get(exerciseIndex);
return submittedFeedback;
}

public void setSubmittedFeedback(SubmittedFeedback submittedFeedback) {
// Used for first exercise, where no explicit index is given
this.submittedFeedback.put(0, submittedFeedback);
}

public void addSubmittedFeedback(SubmittedFeedback submittedFeedback) {
this.submittedFeedback.put(submittedFeedback.getExerciseIndex(), submittedFeedback);
this.submittedFeedback = submittedFeedback;
}

private String generateRandomAvatarImage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@

public class SubmittedFeedback {
private String timestamp;
private int exerciseIndex;
private int happinessScore;
private String comment;

public SubmittedFeedback() {}

public SubmittedFeedback(
String timestamp, int exerciseIndex, int happinessScore, String comment) {
String timestamp,
int happinessScore) {
this.timestamp = timestamp;
this.exerciseIndex = exerciseIndex;
this.happinessScore = happinessScore;
this.comment = comment;
}

public String getTimestamp() {
Expand All @@ -34,22 +31,6 @@ public void setHappinessScore(int happinessScore) {
this.happinessScore = happinessScore;
}

public int getExerciseIndex() {
return exerciseIndex;
}

public void setExerciseIndex(int exerciseIndex) {
this.exerciseIndex = exerciseIndex;
}

public String getComment() {
return comment;
}

public void setComment(String comment) {
this.comment = comment;
}

public String toJsonString() {
Gson gson = new Gson();
return gson.toJson(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import se.sodalabs.hub.repository.RegisteredParticipant;
import se.sodalabs.hub.repository.SubmittedFeedback;

public class ParticipantCard extends VerticalLayout {

Expand Down Expand Up @@ -50,39 +49,14 @@ public ParticipantCard(RegisteredParticipant registeredParticipant) {
participantInfoPanel.add(exerciseHappiness);
}

if (registeredParticipant.getSubmittedFeedbackForExercise(1) != null) {
Span secondExerciseHappiness = getSecondExerciseHappiness(registeredParticipant);
participantInfoPanel.add(secondExerciseHappiness);
}

cardContent.add(participantInfoPanel);
this.add(cardContent);
}

private static Span getFirstExerciseFeedbackSpan(RegisteredParticipant registeredParticipant) {
return getExerciseFeedbackSpan(registeredParticipant, 0, "1️⃣");
}

private static Span getSecondExerciseHappiness(RegisteredParticipant registeredParticipant) {
return getExerciseFeedbackSpan(registeredParticipant, 1, "2️⃣");
}

private static Span getExerciseFeedbackSpan(
RegisteredParticipant registeredParticipant, int exerciseIndex, String exerciseIndicator) {
SubmittedFeedback exerciseFeedback =
registeredParticipant.getSubmittedFeedbackForExercise(exerciseIndex);

int happinessScore = exerciseFeedback.getHappinessScore();
int happinessScore = registeredParticipant.getSubmittedFeedback().getHappinessScore();
String feedbackIndicator = happinessScore > 49 ? "👍" : "👎";

String hasCommentIndicator = exerciseFeedback.getComment() == null ? "" : "💬";

return new Span(
exerciseIndicator
.concat(" ")
.concat(feedbackIndicator)
.concat(hasCommentIndicator)
.concat(String.valueOf(happinessScore))
.concat(" % exercise happiness"));
feedbackIndicator.concat(String.valueOf(happinessScore)).concat(" % exercise happiness"));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
//import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import se.sodalabs.demo.domain.FeedbackDTO;
import se.sodalabs.demo.domain.ParticipantDTO;

@Service
Expand Down Expand Up @@ -90,18 +89,7 @@ public ResponseEntity<String> sendFeedback(int happinessScore) {
String.class);
}

public ResponseEntity<String> sendFeedback(FeedbackDTO feedback) {
HttpHeaders headers = new HttpHeaders();
headers.set("Content-Type", "application/json");
HttpEntity<FeedbackDTO> request = new HttpEntity<>(feedback, headers);

return restTemplate.exchange(
hubAddress + "/api/v2/participant/" + id + "/feedback",
HttpMethod.POST,
request,
String.class);
}

/*
private static ResponseEntity<String> returnParsedHubResponse(
ResponseEntity<String> responseFromHub) {
if (responseFromHub.getStatusCode().is2xxSuccessful()) {
Expand All @@ -111,7 +99,7 @@ private static ResponseEntity<String> returnParsedHubResponse(
} else {
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}*/

public String getLastRegisteredAt() {
return lastRegisteredAt;
Expand Down
Loading