From 12b13293643a92a453fe736e203359a31f7c1c8f Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Tue, 22 Aug 2023 18:56:17 -0700 Subject: [PATCH] feat: add sticky table header --- src/routes/modlog/+page.svelte | 72 ++++++++++++++++++++--------- src/routes/modlog/+page.ts | 11 +++-- src/routes/modlog/ModlogItem.svelte | 49 ++++++++++++++++++-- 3 files changed, 99 insertions(+), 33 deletions(-) diff --git a/src/routes/modlog/+page.svelte b/src/routes/modlog/+page.svelte index 62114617..51a4fe56 100644 --- a/src/routes/modlog/+page.svelte +++ b/src/routes/modlog/+page.svelte @@ -1,39 +1,65 @@ + + Modlog + +

Modlog

{#if data.modlog} - - - - - - - - - - - - - - - - - - {#each data.modlog as modlog} - - {/each} -
ActionModeratorModerateeCommunityLink
+
+ + + + + + + + + + + + + + + + + + + + + + + + + {#each data.modlog as modlog} + + {/each} + +
TimeModeratorActionUserCommunityContentReasonLink
+
{/if} + searchParam($page.url, 'page', e.detail.toString())} + />
diff --git a/src/routes/modlog/+page.ts b/src/routes/modlog/+page.ts index d5449ac3..4f7c74ff 100644 --- a/src/routes/modlog/+page.ts +++ b/src/routes/modlog/+page.ts @@ -34,13 +34,13 @@ export const _toModLog = (item: ModAction): ModLog => { moderator: item.moderator, moderatee: item.banned_person, community: item.community, - actionName: 'Ban', + actionName: 'ban', reason: item.mod_ban_from_community.reason, timestamp: Date.parse(`${item.mod_ban_from_community.when_}Z`), } } else if ('mod_remove_comment' in item) { return { - actionName: 'Comment Removal', + actionName: 'commentRemoval', community: item.community, content: item.comment.content, timestamp: Date.parse(`${item.mod_remove_comment.when_}Z`), @@ -51,7 +51,7 @@ export const _toModLog = (item: ModAction): ModLog => { } } else if ('mod_remove_post' in item) { return { - actionName: 'Post Removal', + actionName: 'postRemoval', community: item.community, content: item.post.name, timestamp: Date.parse(`${item.mod_remove_post.when_}Z`), @@ -68,9 +68,9 @@ export const _toModLog = (item: ModAction): ModLog => { } export async function load({ url }) { - if (!get(profile)) return + if (!get(profile)) return { page: 1 } const { jwt } = get(profile)! - if (!jwt) return + if (!jwt) return { page: 1 } let community = Number(url.searchParams.get('community')) || undefined let modId = Number(url.searchParams.get('mod_id')) || undefined @@ -96,6 +96,7 @@ export async function load({ url }) { .sort((b, a) => b.timestamp - a.timestamp) return { + page: page, modlog: moderationActions, } } diff --git a/src/routes/modlog/ModlogItem.svelte b/src/routes/modlog/ModlogItem.svelte index 381b7601..6523724e 100644 --- a/src/routes/modlog/ModlogItem.svelte +++ b/src/routes/modlog/ModlogItem.svelte @@ -4,28 +4,67 @@ import UserLink from '$lib/components/lemmy/user/UserLink.svelte' import Card from '$lib/components/ui/Card.svelte' import SectionTitle from '$lib/components/ui/SectionTitle.svelte' + import RelativeDate from '$lib/components/util/RelativeDate.svelte' + import { Icon, Trash, XCircle } from 'svelte-hero-icons' import type { ModLog } from './+page.js' export let item: ModLog - + - {item.actionName} + + + {#if item.moderator} - + {/if} + + + {#if item.actionName == 'ban'} + + Ban + + {:else if item.actionName == 'postRemoval' || item.actionName == 'commentRemoval'} + + Removal + + {:else} + {item.actionName} + {/if} + + {#if item.moderatee} - + {/if} {#if item.community} - + + {/if} + + + {#if item.content} +

{item.content}

+ {/if} + + + {#if item.reason} +

{item.reason}

{/if}