Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ROMM-1433] Rework columns in table view #1455

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions backend/endpoints/responses/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class RomSchema(BaseModel):
# Metadata fields
first_release_date: int | None
youtube_video_id: str | None
average_rating: float
alternative_names: list[str]
genres: list[str]
franchises: list[str]
Expand Down
18 changes: 17 additions & 1 deletion backend/models/rom.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,25 @@ def alternative_names(self) -> list[str]:
@property
def first_release_date(self) -> int:
if self.igdb_metadata:
return self.igdb_metadata.get("first_release_date", 0)
return self.igdb_metadata.get("first_release_date", 0) * 1000
return 0

@property
def average_rating(self) -> float:
igdb_rating = (
float(self.igdb_metadata.get("total_rating", 0))
if self.igdb_metadata
else 0.0
)
moby_rating = (
float(self.moby_metadata.get("moby_score", 0))
if self.moby_metadata
else 0.0
)
ratings = [igdb_rating, moby_rating * 10] # Moby rating is out of 10

return sum(ratings) / len([r for r in ratings if r]) if any(ratings) else 0.0

@property
def genres(self) -> list[str]:
return (
Expand Down
1 change: 1 addition & 0 deletions frontend/src/__generated__/models/DetailedRomSchema.ts

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

1 change: 1 addition & 0 deletions frontend/src/__generated__/models/RomSchema.ts

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

1 change: 1 addition & 0 deletions frontend/src/__generated__/models/SimpleRomSchema.ts

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

2 changes: 1 addition & 1 deletion frontend/src/components/Details/Title.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useDisplay } from "vuetify";
const props = defineProps<{ rom: DetailedRom }>();
const { smAndDown } = useDisplay();
const releaseDate = new Date(
Number(props.rom.first_release_date) * 1000,
Number(props.rom.first_release_date),
).toLocaleDateString("en-US", {
day: "2-digit",
month: "short",
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/common/Game/FavBtn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ async function switchFromFavourites() {
@click.stop="switchFromFavourites"
class="translucent text-shadow"
rouded="0"
size="x-small"
size="small"
variant="text"
icon
><v-icon color="romm-accent-1">{{
collectionsStore.isFav(rom) ? "mdi-star" : "mdi-star-outline"
}}</v-icon></v-btn
Expand Down
141 changes: 106 additions & 35 deletions frontend/src/components/common/Game/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,47 @@ const HEADERS = [
key: "name",
},
{
title: "",
title: "Size",
align: "start",
sortable: false,
key: "is_fav",
sortable: true,
key: "file_size_bytes",
},
{
title: "Size",
title: "Added",
align: "start",
sortable: true,
key: "file_size_bytes",
key: "created_at",
},
{
title: "Reg",
title: "Released",
align: "start",
sortable: true,
key: "regions",
key: "first_release_date",
},
{
title: "Lang",
title: "Rating",
align: "start",
sortable: true,
key: "average_rating",
},
{
title: "Languages",
align: "start",
sortable: false,
key: "languages",
},
{
title: "Rev",
title: "Regions",
align: "start",
sortable: true,
key: "revision",
sortable: false,
key: "regions",
},
{
title: "",
align: "center",
key: "actions",
sortable: false,
},
{ title: "", align: "end", key: "actions", sortable: false },
] as const;

const selectedRomIDs = computed(() => selectedRoms.value.map((rom) => rom.id));
Expand Down Expand Up @@ -170,26 +181,26 @@ onMounted(() => {
</template>
<template #item.name="{ item }">
<td>
<v-list-item :min-width="400" class="px-0">
<v-list-item class="px-0">
<template #prepend>
<r-avatar-rom :rom="item" />
</template>
<v-row no-gutters>
<v-col>{{ item.name }}</v-col></v-row
>
<v-row no-gutters
><v-col class="text-romm-accent-1">{{
item.file_name
}}</v-col></v-row
>
<v-col>{{ item.name }}</v-col>
</v-row>
<v-row no-gutters>
<v-col class="text-romm-accent-1">
{{ item.file_name }}
</v-col>
</v-row>
<template #append>
<v-chip
v-if="
item.sibling_roms &&
item.sibling_roms.length > 0 &&
showSiblings
"
class="translucent-dark ml-2"
class="translucent-dark ml-4"
size="x-small"
>
<span class="text-caption">+{{ item.sibling_roms.length }}</span>
Expand All @@ -198,26 +209,78 @@ onMounted(() => {
</v-list-item>
</td>
</template>
<template #item.is_fav="{ item }">
<fav-btn :rom="item" />
</template>
<template #item.file_size_bytes="{ item }">
<v-chip size="x-small" label>{{
formatBytes(item.file_size_bytes)
}}</v-chip>
<span class="text-no-wrap">{{ formatBytes(item.file_size_bytes) }}</span>
</template>
<template #item.regions="{ item }">
<span class="px-1" v-for="region in item.regions">
{{ regionToEmoji(region) }}
</span>
<template #item.created_at="{ item }">
<span v-if="item.created_at" class="text-no-wrap">{{
new Date(item.created_at).toLocaleDateString("en-US", {
day: "2-digit",
month: "short",
year: "numeric",
})
}}</span>
<span v-else>-</span>
</template>
<template #item.first_release_date="{ item }">
<span v-if="item.first_release_date" class="text-no-wrap">{{
new Date(item.first_release_date).toLocaleDateString("en-US", {
day: "2-digit",
month: "short",
year: "numeric",
})
}}</span>
<span v-else>-</span>
</template>
<template #item.average_rating="{ item }">
<span v-if="item.average_rating" class="text-no-wrap">{{
Intl.NumberFormat("en-US", {
maximumSignificantDigits: 3,
}).format(item.average_rating)
}}</span>
<span v-else>-</span>
</template>
<template #item.languages="{ item }">
<span class="px-1" v-for="language in item.languages">
{{ languageToEmoji(language) }}
</span>
<div class="text-no-wrap" v-if="item.languages.length > 0">
<span
class="emoji"
v-for="language in item.languages.slice(0, 3)"
:title="`Languages: ${item.languages.join(', ')}`"
:class="{ 'emoji-collection': item.regions.length > 3 }"
>
{{ languageToEmoji(language) }}
</span>
<spa class="reglang-super">
{{
item.languages.length > 3
? `&nbsp;+${item.languages.length - 3}`
: ""
}}
</spa>
</div>
<span v-else>-</span>
</template>
<template #item.regions="{ item }">
<div class="text-no-wrap" v-if="item.regions.length > 0">
<span
class="emoji"
v-for="region in item.regions.slice(0, 3)"
:title="`Regions: ${item.regions.join(', ')}`"
:class="{ 'emoji-collection': item.regions.length > 3 }"
>
{{ regionToEmoji(region) }}
</span>
<spa class="reglang-super">
{{
item.regions.length > 3 ? `&nbsp;+${item.regions.length - 3}` : ""
}}
</spa>
</div>
<span v-else>-</span>
</template>
<template #item.actions="{ item }">
<v-btn-group divided density="compact">
<v-btn-group density="compact">
<fav-btn :rom="item" />
<v-btn
:disabled="downloadStore.value.includes(item.id)"
download
Expand Down Expand Up @@ -291,3 +354,11 @@ onMounted(() => {
</template>
</v-data-table>
</template>

<style scoped>
.reglang-super {
vertical-align: super;
font-size: 75%;
opacity: 75%;
}
</style>
Loading