feat: add sticky table header
This commit is contained in:
1 parent
114856a052
commit
12b1329364
3 files changed
+99
-33
No files matched your search
@@ -1,39 +1,65 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import Card from '$lib/components/ui/Card.svelte'
|
||||||
|
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
||||||
import ModlogItem from './ModlogItem.svelte'
|
import ModlogItem from './ModlogItem.svelte'
|
||||||
|
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||||
|
import { searchParam } from '$lib/util.js'
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>Modlog</title>
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
<h1 class="font-bold text-2xl">Modlog</h1>
|
<h1 class="font-bold text-2xl">Modlog</h1>
|
||||||
{#if data.modlog}
|
{#if data.modlog}
|
||||||
<table class="table border-collapse">
|
<div class="">
|
||||||
<colgroup>
|
<table
|
||||||
<col />
|
class="table overflow-x-auto table-fixed relative"
|
||||||
<col />
|
style="width: 100%;"
|
||||||
<col />
|
>
|
||||||
<col />
|
<colgroup class="table-fixed">
|
||||||
<col />
|
<col width="20%" />
|
||||||
</colgroup>
|
<col width="30%" />
|
||||||
<thead class="text-left">
|
<col width="25%" class="overflow-x-auto" />
|
||||||
<tr>
|
<col width="30%" />
|
||||||
<th>Action</th>
|
<col width="30%" />
|
||||||
<th>Moderator</th>
|
<col width="40%" />
|
||||||
<th>Moderatee</th>
|
<col width="50%" />
|
||||||
<th>Community</th>
|
<col width="30%" />
|
||||||
<th>Link</th>
|
</colgroup>
|
||||||
</tr>
|
<thead class="text-left sticky top-16">
|
||||||
</thead>
|
<tr class="sticky top-16 rounded-t-lg overflow-hidden">
|
||||||
{#each data.modlog as modlog}
|
<th>Time</th>
|
||||||
<ModlogItem item={modlog} />
|
<th>Moderator</th>
|
||||||
{/each}
|
<th>Action</th>
|
||||||
</table>
|
<th>User</th>
|
||||||
|
<th>Community</th>
|
||||||
|
<th>Content</th>
|
||||||
|
<th>Reason</th>
|
||||||
|
<th>Link</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="text-xs">
|
||||||
|
{#each data.modlog as modlog}
|
||||||
|
<ModlogItem item={modlog} />
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
<Pageination
|
||||||
|
page={data.page}
|
||||||
|
on:change={(e) => searchParam($page.url, 'page', e.detail.toString())}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style lang="postcss">
|
<style lang="postcss">
|
||||||
:global(.table thead tr th) {
|
:global(.table thead tr th) {
|
||||||
@apply border border-slate-200 dark:border-zinc-800 px-4 py-2;
|
@apply border border-slate-200 dark:border-zinc-800 px-4 py-2 bg-slate-100;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.table tr td) {
|
:global(.table tr td) {
|
||||||
@@ -45,6 +71,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
:global(.dark thead tr th) {
|
:global(.dark thead tr th) {
|
||||||
@apply border-zinc-800;
|
@apply border-zinc-800 bg-zinc-900;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -34,13 +34,13 @@ export const _toModLog = (item: ModAction): ModLog => {
|
|||||||
moderator: item.moderator,
|
moderator: item.moderator,
|
||||||
moderatee: item.banned_person,
|
moderatee: item.banned_person,
|
||||||
community: item.community,
|
community: item.community,
|
||||||
actionName: 'Ban',
|
actionName: 'ban',
|
||||||
reason: item.mod_ban_from_community.reason,
|
reason: item.mod_ban_from_community.reason,
|
||||||
timestamp: Date.parse(`${item.mod_ban_from_community.when_}Z`),
|
timestamp: Date.parse(`${item.mod_ban_from_community.when_}Z`),
|
||||||
}
|
}
|
||||||
} else if ('mod_remove_comment' in item) {
|
} else if ('mod_remove_comment' in item) {
|
||||||
return {
|
return {
|
||||||
actionName: 'Comment Removal',
|
actionName: 'commentRemoval',
|
||||||
community: item.community,
|
community: item.community,
|
||||||
content: item.comment.content,
|
content: item.comment.content,
|
||||||
timestamp: Date.parse(`${item.mod_remove_comment.when_}Z`),
|
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) {
|
} else if ('mod_remove_post' in item) {
|
||||||
return {
|
return {
|
||||||
actionName: 'Post Removal',
|
actionName: 'postRemoval',
|
||||||
community: item.community,
|
community: item.community,
|
||||||
content: item.post.name,
|
content: item.post.name,
|
||||||
timestamp: Date.parse(`${item.mod_remove_post.when_}Z`),
|
timestamp: Date.parse(`${item.mod_remove_post.when_}Z`),
|
||||||
@@ -68,9 +68,9 @@ export const _toModLog = (item: ModAction): ModLog => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function load({ url }) {
|
export async function load({ url }) {
|
||||||
if (!get(profile)) return
|
if (!get(profile)) return { page: 1 }
|
||||||
const { jwt } = get(profile)!
|
const { jwt } = get(profile)!
|
||||||
if (!jwt) return
|
if (!jwt) return { page: 1 }
|
||||||
|
|
||||||
let community = Number(url.searchParams.get('community')) || undefined
|
let community = Number(url.searchParams.get('community')) || undefined
|
||||||
let modId = Number(url.searchParams.get('mod_id')) || 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)
|
.sort((b, a) => b.timestamp - a.timestamp)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
page: page,
|
||||||
modlog: moderationActions,
|
modlog: moderationActions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,28 +4,67 @@
|
|||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
import Card from '$lib/components/ui/Card.svelte'
|
import Card from '$lib/components/ui/Card.svelte'
|
||||||
import SectionTitle from '$lib/components/ui/SectionTitle.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'
|
import type { ModLog } from './+page.js'
|
||||||
|
|
||||||
export let item: ModLog
|
export let item: ModLog
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<tr class="text-sm">
|
<tr class="">
|
||||||
<td>
|
<td>
|
||||||
<span class="font-bold">{item.actionName}</span>
|
<span>
|
||||||
|
<RelativeDate date={new Date(item.timestamp)} />
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{#if item.moderator}
|
{#if item.moderator}
|
||||||
<UserLink showInstance={false} avatar user={item.moderator} />
|
<UserLink
|
||||||
|
showInstance={false}
|
||||||
|
avatar
|
||||||
|
avatarSize={20}
|
||||||
|
user={item.moderator}
|
||||||
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="font-bold">
|
||||||
|
{#if item.actionName == 'ban'}
|
||||||
|
<span class="flex items-center gap-1 text-red-600 dark:text-red-400">
|
||||||
|
<Icon src={XCircle} size="16" mini class="inline" /> Ban
|
||||||
|
</span>
|
||||||
|
{:else if item.actionName == 'postRemoval' || item.actionName == 'commentRemoval'}
|
||||||
|
<span class="flex items-center gap-1 text-red-600 dark:text-red-400">
|
||||||
|
<Icon src={Trash} size="16" mini class="inline" /> Removal
|
||||||
|
</span>
|
||||||
|
{:else}
|
||||||
|
{item.actionName}
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{#if item.moderatee}
|
{#if item.moderatee}
|
||||||
<UserLink showInstance={false} avatar user={item.moderatee} />
|
<UserLink showInstance={false} user={item.moderatee} />
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{#if item.community}
|
{#if item.community}
|
||||||
<CommunityLink showInstance={false} avatar community={item.community} />
|
<CommunityLink
|
||||||
|
showInstance={false}
|
||||||
|
avatar
|
||||||
|
avatarSize={20}
|
||||||
|
community={item.community}
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{#if item.content}
|
||||||
|
<p>{item.content}</p>
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{#if item.reason}
|
||||||
|
<p>{item.reason}</p>
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
Reference in new issue
Block a user