First version of GameOverviewCard

This commit is contained in:
grimsi
2024-12-22 22:43:38 +01:00
parent c1012c7e96
commit 1c85d4dcaa
5 changed files with 24 additions and 7 deletions
@@ -0,0 +1,15 @@
import GameDto from "Frontend/generated/de/grimsi/gameyfin/games/dto/GameDto";
import {Card, Image} from "@nextui-org/react";
export function GameOverviewCard({game}: { game: GameDto }) {
return (
<Card className="h-80 aspect-[12/17]">
<Image
removeWrapper
alt={game.title}
className="z-0 w-full h-full object-cover"
src={`images/cover/${game.coverId}`}
/>
</Card>
);
}
@@ -4,6 +4,7 @@ import {toast} from "sonner";
import {LibraryEndpoint, SystemEndpoint} from "Frontend/generated/endpoints"; import {LibraryEndpoint, SystemEndpoint} from "Frontend/generated/endpoints";
import {useState} from "react"; import {useState} from "react";
import GameDto from "Frontend/generated/de/grimsi/gameyfin/games/dto/GameDto"; import GameDto from "Frontend/generated/de/grimsi/gameyfin/games/dto/GameDto";
import {GameOverviewCard} from "Frontend/components/games/GameOverviewCard";
export default function TestView() { export default function TestView() {
const [gameTitle, setGameTitle] = useState(""); const [gameTitle, setGameTitle] = useState("");
@@ -54,6 +55,7 @@ export default function TestView() {
<Input label="Game title" onValueChange={setGameTitle}/> <Input label="Game title" onValueChange={setGameTitle}/>
<Button onPress={getGame} size="lg">Match</Button> <Button onPress={getGame} size="lg">Match</Button>
</div> </div>
{game && <GameOverviewCard game={game}></GameOverviewCard>}
{game && <>{JSON.stringify(game, null, 2)}</>} {game && <>{JSON.stringify(game, null, 2)}</>}
</div> </div>
</div> </div>
@@ -89,7 +89,7 @@ class GameService(
return GameDto( return GameDto(
id = gameId, id = gameId,
title = game.title, title = game.title,
coverImageUrl = game.coverImage.contentId, coverId = game.coverImage.id,
comment = game.comment, comment = game.comment,
summary = game.summary, summary = game.summary,
release = game.release, release = game.release,
@@ -100,7 +100,7 @@ class GameService(
keywords = game.keywords.toList(), keywords = game.keywords.toList(),
features = game.features.map { it.name }, features = game.features.map { it.name },
perspectives = game.perspectives.map { it.name }, perspectives = game.perspectives.map { it.name },
images = game.images.mapNotNull { it.id }, imageIds = game.images.mapNotNull { it.id },
videoUrls = game.videoUrls.map { it.toString() }, videoUrls = game.videoUrls.map { it.toString() },
source = game.source.pluginId source = game.source.pluginId
) )
@@ -137,7 +137,7 @@ class GameService(
val image = Image(originalUrl = imageUrl, type = type) val image = Image(originalUrl = imageUrl, type = type)
imageUrl.openStream().use { input -> imageUrl.openStream().use { input ->
image.mimeType = URLConnection.guessContentTypeFromStream(input) image.mimeType = URLConnection.guessContentTypeFromName(imageUrl.file)
imageContentStore.setContent(image, input) imageContentStore.setContent(image, input)
} }
return imageRepository.save(image) return imageRepository.save(image)
@@ -5,7 +5,7 @@ import java.time.Instant
class GameDto( class GameDto(
val id: Long, val id: Long,
val title: String, val title: String,
val coverImageUrl: String?, val coverId: Long?,
val comment: String?, val comment: String?,
val summary: String?, val summary: String?,
val release: Instant?, val release: Instant?,
@@ -16,7 +16,7 @@ class GameDto(
val keywords: List<String>?, val keywords: List<String>?,
val features: List<String>?, val features: List<String>?,
val perspectives: List<String>?, val perspectives: List<String>?,
val images: List<Long>?, val imageIds: List<Long>?,
val videoUrls: List<String>?, val videoUrls: List<String>?,
val source: String? val source: String?
) )
@@ -76,8 +76,8 @@ class ImageEndpoint(
val inputStreamResource = InputStreamResource(file) val inputStreamResource = InputStreamResource(file)
val headers = HttpHeaders() val headers = HttpHeaders()
headers.contentLength = image.contentLength!! image.contentLength?.let { headers.contentLength = it }
headers.contentType = MediaType.parseMediaType(image.mimeType!!) image.mimeType?.let { headers.contentType = MediaType.parseMediaType(it) }
return ResponseEntity.ok() return ResponseEntity.ok()
.headers(headers) .headers(headers)