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 {useState} from "react";
import GameDto from "Frontend/generated/de/grimsi/gameyfin/games/dto/GameDto";
import {GameOverviewCard} from "Frontend/components/games/GameOverviewCard";
export default function TestView() {
const [gameTitle, setGameTitle] = useState("");
@@ -54,6 +55,7 @@ export default function TestView() {
<Input label="Game title" onValueChange={setGameTitle}/>
<Button onPress={getGame} size="lg">Match</Button>
</div>
{game && <GameOverviewCard game={game}></GameOverviewCard>}
{game && <>{JSON.stringify(game, null, 2)}</>}
</div>
</div>
@@ -89,7 +89,7 @@ class GameService(
return GameDto(
id = gameId,
title = game.title,
coverImageUrl = game.coverImage.contentId,
coverId = game.coverImage.id,
comment = game.comment,
summary = game.summary,
release = game.release,
@@ -100,7 +100,7 @@ class GameService(
keywords = game.keywords.toList(),
features = game.features.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() },
source = game.source.pluginId
)
@@ -137,7 +137,7 @@ class GameService(
val image = Image(originalUrl = imageUrl, type = type)
imageUrl.openStream().use { input ->
image.mimeType = URLConnection.guessContentTypeFromStream(input)
image.mimeType = URLConnection.guessContentTypeFromName(imageUrl.file)
imageContentStore.setContent(image, input)
}
return imageRepository.save(image)
@@ -5,7 +5,7 @@ import java.time.Instant
class GameDto(
val id: Long,
val title: String,
val coverImageUrl: String?,
val coverId: Long?,
val comment: String?,
val summary: String?,
val release: Instant?,
@@ -16,7 +16,7 @@ class GameDto(
val keywords: List<String>?,
val features: List<String>?,
val perspectives: List<String>?,
val images: List<Long>?,
val imageIds: List<Long>?,
val videoUrls: List<String>?,
val source: String?
)
@@ -76,8 +76,8 @@ class ImageEndpoint(
val inputStreamResource = InputStreamResource(file)
val headers = HttpHeaders()
headers.contentLength = image.contentLength!!
headers.contentType = MediaType.parseMediaType(image.mimeType!!)
image.contentLength?.let { headers.contentLength = it }
image.mimeType?.let { headers.contentType = MediaType.parseMediaType(it) }
return ResponseEntity.ok()
.headers(headers)