makes profiles public

This commit is contained in:
Christian Beutel
2024-11-16 15:13:22 +01:00
parent 2e8d7f5e82
commit dcc8da83e7
19 changed files with 364 additions and 41 deletions

View File

@@ -11,6 +11,16 @@ export async function GET(event: RequestEvent) {
sort: "+date",
filter: filter
})
for (const t of r) {
if (!t.author || !pb.authStore.model) {
continue;
}
if (!t.expand) {
t.expand = {} as any
}
t.expand.author = await pb.collection("users_anonymous").getOne(t.author);
}
return json(r)
} catch (e: any) {
throw error(e.status, e);

View File

@@ -7,6 +7,12 @@ export async function GET(event: RequestEvent) {
try {
const r = await pb.collection('summit_logs')
.getOne<SummitLog>(event.params.id as string)
if (!r.expand) {
r.expand = {} as any
}
r.expand.author = await pb.collection("users_anonymous").getOne(r.author!);
return json(r)
} catch (e: any) {
throw error(e.status, e);

View File

@@ -21,9 +21,15 @@ export async function GET(event: RequestEvent) {
r.date = r.date?.substring(0, 10) ?? ""
for (const log of r.expand?.summit_logs ?? []) {
log.date = log.date.substring(0, 10)
if (!log.expand) {
log.expand = {} as any
}
log.expand.author = await pb.collection("users_anonymous").getOne(log.author!);
}
return json(r)
} catch (e: any) {
console.error(e)
throw error(e.status || 500, e);
}
}

View File

@@ -218,7 +218,7 @@
}
async function loadSummitLogs() {
const logs = await summit_logs_index(filter);
const logs = await summit_logs_index($page.params.id, filter);
summitLogs.set(logs);
}
</script>
@@ -230,21 +230,21 @@
<div
class="grid grid-cols-1 sm:grid-cols-[272px_minmax(0,_1fr)] md:grid-cols-[356px_minmax(0,_1fr)] gap-y-4 max-w-6xl mx-auto"
>
{#if $currentUser}
{#if data.user}
<div class="flex items-center gap-x-6 h-full px-4">
<img
class="rounded-full w-16 aspect-square overflow-hidden"
src={getFileURL($currentUser, $currentUser.avatar) ||
`https://api.dicebear.com/7.x/initials/svg?seed=${$currentUser.username}&backgroundType=gradientLinear`}
src={getFileURL(data.user, data.user.avatar) ||
`https://api.dicebear.com/7.x/initials/svg?seed=${data.user.username}&backgroundType=gradientLinear`}
alt="avatar"
/>
<div>
<h4 class="text-2xl font-semibold col-start-2">
{$currentUser.username}
{data.user.username}
</h4>
<p class="text-sm">
<span class="text-gray-500">Joined:</span>
{new Date($currentUser.created ?? "").toLocaleDateString(
{new Date(data.user.created ?? "").toLocaleDateString(
undefined,
{
month: "2-digit",
@@ -420,7 +420,7 @@
<span class="text-gray-500 font-semibold text-lg"
><i class="fa fa-table mr-3"></i>{$_("all-activities")}</span
>
<div class=" overflow-x-scroll">
<div class=" overflow-x-auto">
<SummitLogTable summitLogs={$summitLogs} showCategory showTrail
></SummitLogTable>
</div>

View File

@@ -1,10 +1,15 @@
import type { SummitLogFilter } from "$lib/models/summit_log";
import { categories_index } from "$lib/stores/category_store";
import { summit_logs_index } from "$lib/stores/summit_log_store";
import { type ServerLoad } from "@sveltejs/kit";
import { users_show } from "$lib/stores/user_store";
import { error, type ServerLoad } from "@sveltejs/kit";
export const load: ServerLoad = async ({ params, locals, fetch }) => {
if(!params.id) {
error(404, "Not found")
}
const date = new Date()
date.setUTCHours(6)
const y = date.getFullYear()
@@ -19,7 +24,8 @@ export const load: ServerLoad = async ({ params, locals, fetch }) => {
endDate: lastDay.toISOString().slice(0, 10),
category: []
}
const logs = await summit_logs_index(filter, fetch);
const logs = await summit_logs_index(params.id, filter, fetch);
const user = await users_show(params.id, fetch);
return {filter}
return { filter, user }
};