Skip to content

Commit

Permalink
Merge pull request #1113 from bounswe/main
Browse files Browse the repository at this point in the history
Deploy recent changes 25.12.2023 20.14
  • Loading branch information
canuzdrn authored Dec 25, 2023
2 parents 82f9690 + f8f92b7 commit f80ece6
Show file tree
Hide file tree
Showing 111 changed files with 31,148 additions and 13,343 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CorsConfig {
@Bean
public CorsConfigurationSource corsConfigurationSource() {
final CorsConfiguration configuration = new CorsConfiguration();
configuration.setAllowedOrigins(Arrays.asList("http://localhost:5173", "http://ec2-51-20-78-40.eu-north-1.compute.amazonaws.com/"));
configuration.setAllowedOrigins(Arrays.asList("http://localhost:5173", "http://localhost", "http://ec2-51-20-78-40.eu-north-1.compute.amazonaws.com/"));
configuration.setAllowedMethods(Arrays.asList("GET", "POST", "PUT", "DELETE", "OPTIONS"));
configuration.setAllowCredentials(true);
configuration.setAllowedHeaders(Arrays.asList("Authorization", "Content-Type", "Set-Cookie", "credentials"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ public Map<String, Object> updateAnnotation(CreateAnnotationRequestDto dto) {
Annotation updatedAnnotation = modelMapper.map(dto, Annotation.class);
List<Selector> selectorList = new ArrayList<>();
for (SelectorDto s : dto.getTarget().getSelector()) {
if (s.getType().equals("TextQuoteSelector")) {
selectorList.add(modelMapper.map(s, TextQuoteSelector.class));
} else if (s.getType().equals("TextPositionSelector")) {
selectorList.add(modelMapper.map(s, TextPositionSelector.class));
switch (s.getType()) {
case "TextQuoteSelector" -> selectorList.add(modelMapper.map(s, TextQuoteSelector.class));
case "TextPositionSelector" -> selectorList.add(modelMapper.map(s, TextPositionSelector.class));
case "FragmentSelector" -> selectorList.add(modelMapper.map(s, FragmentSelector.class));
}
//TODO add more selectors if implemented in the future
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ public List<Game> getRecommendedGames(String email){
Profile profile = findProfile.get();
List<String> followedGameIds = profile.getGames();

if(followedGameIds.isEmpty()){
return getRecommendedGames();
}

TreeSet<RecommendGameDto> recommendedGames = new TreeSet<>(Comparator.reverseOrder());

for(String gameId : followedGameIds){
Expand All @@ -435,6 +439,22 @@ public List<Game> getRecommendedGames(String email){
}
}

if(recommendations.size() < 10){
int diff = 10;
Query query = new Query(); // all games except the base game
query.addCriteria(Criteria.where("isDeleted").is(false));
query.with(Sort.by(Sort.Direction.DESC, "overallVote"));
query.limit(diff);
List<Game> extraGames = mongoTemplate.find(query, Game.class);

for(Game game : extraGames){
if(!recommendations.contains(game))
recommendations.add(game);
}

return recommendations;
}

return recommendations;
}

Expand Down
1 change: 1 addition & 0 deletions app/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@ant-design/icons": "^5.2.6",
"@recogito/recogito-js": "^1.8.2",
"@recogito/annotorious": "^2.7.13",
"@types/js-cookie": "^3.0.5",
"antd": "^5.10.2",
"axios": "^1.6.0",
Expand Down
41 changes: 28 additions & 13 deletions app/frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions app/frontend/src/Components/GameDetails/Review/Reviews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import {
SortDescendingOutlined,
} from "@ant-design/icons";
import { isEmpty } from "../../../Library/utils/isEmpty";
import { useAuth } from "../../Hooks/useAuth";

function Reviews({ gameId }: { gameId: string }) {
const [reviewedBy, setReviewedBy] = useState();
const [searchText, setSearchText] = useState("");

const { isLoggedIn } = useAuth();
const { Search } = Input;

const sortOptions = [
Expand Down Expand Up @@ -62,7 +63,7 @@ function Reviews({ gameId }: { gameId: string }) {
style={{ width: "200px" }}
/>
</div>
<ReviewInput gameId={gameId} />
{isLoggedIn && <ReviewInput gameId={gameId} />}
{!isEmpty(reviews) ? (
reviews
?.filter((review: any) => {
Expand Down
44 changes: 33 additions & 11 deletions app/frontend/src/Components/GameDetails/Summary/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import styles from "./Summary.module.scss";
import { getAchievementByGame } from "../../../Services/achievement";
import Achievement from "../../Achievement/Achievement/Achievement";
import { useQuery } from "react-query";
import {
handleAxiosError,
handleError,
} from "../../../Library/utils/handleError.ts";
import { handleAxiosError } from "../../../Library/utils/handleError.ts";
import { Recogito } from "@recogito/recogito-js";

import "@recogito/recogito-js/dist/recogito.min.css";
Expand All @@ -17,7 +14,7 @@ import {
updateAnnotation,
} from "../../../Services/annotation.ts";
import { NotificationUtil } from "../../../Library/utils/notification.ts";
import { useState } from "react";
import { useEffect, useState } from "react";
import { useAuth } from "../../Hooks/useAuth.tsx";
import { getCharacterByGame } from "../../../Services/character";
import CharacterDetails from "../../Character/CharacterDetails";
Expand All @@ -30,8 +27,26 @@ function Summary({ game }: { game: any }) {
() => getAchievementByGame({ gameId: game.id! })
);

const pageUrl = window.location.href.replace("?back=/home", "");

const isAdmin = user?.role === "ADMIN";

const hideTagField = () => {
const tagField = document.querySelector(".r6o-widget.r6o-tag");

if (tagField) {
tagField.style.display = "none";
}
};

useEffect(() => {
const textElement = document.querySelector("#textElement");

if (textElement) {
textElement.addEventListener("click", hideTagField);
}
}, [game]);

const linkAnnotation = (elem: any) => {
if (elem && isAnnotationsApplied === false) {
const r = new Recogito({
Expand All @@ -43,7 +58,7 @@ function Summary({ game }: { game: any }) {
r.loadAnnotations(
`${
import.meta.env.VITE_APP_ANNOTATION_API_URL
}/annotation/get-source-annotations?source=${game.id}`
}/annotation/get-source-annotations?source=${pageUrl}`
)
.then(function (annotations) {})
.catch((error) => {
Expand All @@ -53,10 +68,13 @@ function Summary({ game }: { game: any }) {
NotificationUtil.error("Error occurred while retrieving annotations");
});

r.on("createAnnotation", async (annotation: any, _overrideId) => {
try {
annotation.target = { ...annotation.target, source: game.id };

r.on("createAnnotation", async (annotation: any, overrideId) => {
try {
annotation.target = { ...annotation.target, source: pageUrl };
const newId = pageUrl + "/" + annotation.id.replace("#", "");
annotation.id = newId;
overrideId(newId);
await createAnnotation(annotation);
NotificationUtil.success("You successfully create the annotation");
} catch (error) {
Expand All @@ -74,9 +92,13 @@ function Summary({ game }: { game: any }) {
}
});

r.on("selectAnnotation", async function (annotation: any) {
hideTagField();
});

r.on("updateAnnotation", async function (annotation, _previous) {
try {
annotation.target = { ...annotation.target, source: game.id };
annotation.target = { ...annotation.target, source: pageUrl };
await updateAnnotation(annotation);
NotificationUtil.success("You successfully update the annotation");
} catch (error) {
Expand Down Expand Up @@ -143,7 +165,7 @@ function Summary({ game }: { game: any }) {
)}
</div>
<div className={styles.summary}>
<Typography ref={(elem) => linkAnnotation(elem)}>
<Typography ref={(elem) => linkAnnotation(elem)} id="textElement">
{game?.gameDescription}
</Typography>
</div>
Expand Down
12 changes: 1 addition & 11 deletions app/frontend/src/Components/Groups/PrivateGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@ import { Button } from "antd";
import TagRenderer from "../TagRenderer/TagRenderer";
import { formatDate } from "../../Library/utils/formatDate";
import { useNavigate } from "react-router-dom";
import { applyGroup } from "../../Services/group";
import { NotificationUtil } from "../../Library/utils/notification";


function PrivateGroup({ group }: { group: any }) {
const navigate = useNavigate();

const handleClick = async () => {
try {
const response = await applyGroup(group.id);
if (response) {
NotificationUtil.success("You successfully applied to the group");
}
} catch (error: any) {
NotificationUtil.error(error.response.data);
}
navigate(`/group/apply/${group.id}`);
};

return (
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/Components/Hooks/useAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const useAuth = (): UseAuthProps => {
isLoggedIn: !!user,
logOut,
profile,
isLoading: !user || isLoading,
isLoading: isLoading,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Link } from "react-router-dom";

function LastActivities() {
const activities = useQuery(["activites"], () => getActivities());

return (
<div className={styles.container}>
{!activities.data ? (
Expand Down
Loading

0 comments on commit f80ece6

Please sign in to comment.