feat: admin media browser (#554)
This commit is contained in:
1 parent
84703b8aa2
commit
8232903bbe
6 files changed
+93
-5
No files matched your search
+7
-2
@@ -6,9 +6,10 @@
|
||||
import { instance } from '$lib/instance.svelte'
|
||||
import { client } from '$lib/lemmy.svelte'
|
||||
import { instanceToURL } from '$lib/util.svelte'
|
||||
import type { LocalImage } from 'lemmy-js-client'
|
||||
import type { LocalImage, Person } from 'lemmy-js-client'
|
||||
import { Button, toast } from 'mono-svelte'
|
||||
import { ArrowDownTray, Icon, Trash } from 'svelte-hero-icons'
|
||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||
|
||||
let loading = $state(false)
|
||||
|
||||
@@ -31,10 +32,11 @@
|
||||
|
||||
interface Props {
|
||||
image: LocalImage
|
||||
user?: Person
|
||||
ondelete?: (res: boolean) => void
|
||||
}
|
||||
|
||||
let { image, ondelete }: Props = $props()
|
||||
let { image, user, ondelete }: Props = $props()
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1">
|
||||
@@ -45,6 +47,9 @@
|
||||
class="aspect-square w-full h-full object-cover rounded-xl"
|
||||
alt="pictrs"
|
||||
/>
|
||||
{#if user}
|
||||
<UserLink {user} />
|
||||
{/if}
|
||||
<div class="flex items-center gap-2">
|
||||
<RelativeDate
|
||||
class="text-sm text-slate-700 dark:text-zinc-300"
|
||||
@@ -407,6 +407,9 @@
|
||||
"title": "No whitelisted instances",
|
||||
"description": "Whitelisting an instance will block every other instance."
|
||||
}
|
||||
},
|
||||
"media": {
|
||||
"title": "Media"
|
||||
}
|
||||
},
|
||||
"verifyEmail": {
|
||||
@@ -941,4 +944,4 @@
|
||||
"body": "What do you have to say?",
|
||||
"comments": "Join the conversation"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,10 @@
|
||||
href: '/admin/federation',
|
||||
name: $t('routes.admin.federation.title'),
|
||||
},
|
||||
{
|
||||
href: '/admin/media',
|
||||
name: $t('routes.admin.media.title'),
|
||||
},
|
||||
]}
|
||||
class="overflow-auto"
|
||||
/>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { flip } from 'svelte/animate'
|
||||
import PictrsImage from '$lib/components/lemmy/PictrsImage.svelte'
|
||||
import { expoInOut } from 'svelte/easing'
|
||||
|
||||
let { data = $bindable() } = $props()
|
||||
</script>
|
||||
|
||||
<Header pageHeader>{$t('routes.profile.media.title')}</Header>
|
||||
<div class="media-grid">
|
||||
{#each data.images as image (image.local_image.pictrs_delete_token)}
|
||||
<div animate:flip={{ duration: 500, easing: expoInOut }}>
|
||||
<PictrsImage
|
||||
image={image.local_image}
|
||||
user={image.person}
|
||||
ondelete={() => {
|
||||
data.images = data.images.toSpliced(
|
||||
data.images.findIndex(
|
||||
i =>
|
||||
i.local_image.pictrs_delete_token ==
|
||||
image.local_image.pictrs_delete_token,
|
||||
),
|
||||
1,
|
||||
)
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{#if data.images.length == 20}
|
||||
<Pageination
|
||||
page={Number(page.url.searchParams.get('page')) || 1}
|
||||
href={page => `?page=${page}`}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
<style>
|
||||
.media-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 768px) {
|
||||
.media-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1024px) {
|
||||
.media-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,15 @@
|
||||
import { profile } from '$lib/auth.svelte'
|
||||
import { client } from '$lib/lemmy.svelte.js'
|
||||
|
||||
export async function load({ fetch, url }) {
|
||||
const { jwt } = profile.data
|
||||
|
||||
const page = Number(url.searchParams.get('page')) || 1
|
||||
|
||||
const res = await client({ func: fetch, auth: jwt }).listAllMedia({
|
||||
limit: 20,
|
||||
page: page,
|
||||
})
|
||||
|
||||
return { images: res.images }
|
||||
}
|
||||
@@ -5,12 +5,12 @@
|
||||
import { t } from '$lib/i18n/translations'
|
||||
import { flip } from 'svelte/animate'
|
||||
import { expoInOut } from 'svelte/easing'
|
||||
import PictrsImage from './PictrsImage.svelte'
|
||||
import PictrsImage from '$lib/components/lemmy/PictrsImage.svelte'
|
||||
|
||||
let { data = $bindable() } = $props()
|
||||
</script>
|
||||
|
||||
<Header pageHeader>{$t('routes.profile.media.title')}</Header>
|
||||
<Header pageHeader>{$t('routes.admin.media.title')}</Header>
|
||||
<div class="media-grid">
|
||||
{#each data.images as image (image.local_image.pictrs_delete_token)}
|
||||
<div animate:flip={{ duration: 500, easing: expoInOut }}>
|
||||
|
||||
Reference in new issue
Block a user