mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-10-17 10:50:46 +02:00
Add Action Filters
Fix LibrarySelect for the 100th time
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
<UNavigationMenu :items="items" orientation="horizontal" variant="link" color="neutral" />
|
<UNavigationMenu :items="items" orientation="horizontal" variant="link" color="neutral" />
|
||||||
</template>
|
</template>
|
||||||
<template #right>
|
<template #right>
|
||||||
<UButton icon="i-lucide-brick-wall-shield" :to="`/actions?return=${$route.fullPath}`" variant="soft" color="secondary" />
|
<UButton icon="i-lucide-brick-wall-shield" :to="`/actions?return=${$route.fullPath}`" :disabled="$route.fullPath.startsWith('/actions')" variant="soft" color="secondary" />
|
||||||
<UButton icon="i-lucide-plus" to="/search" color="primary" label="Manga" />
|
<UButton icon="i-lucide-plus" to="/search" color="primary" label="Manga" />
|
||||||
<UColorModeButton color="secondary" />
|
<UColorModeButton color="secondary" />
|
||||||
<UButton icon="i-lucide-settings" variant="ghost" :to="`/settings?return=${$route.fullPath}`" color="secondary" />
|
<UButton icon="i-lucide-settings" variant="ghost" :to="`/settings?return=${$route.fullPath}`" color="secondary" />
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
<USelect
|
<USelect
|
||||||
v-else
|
v-else
|
||||||
v-model="library"
|
v-model="library"
|
||||||
|
:default-value="libraryId ?? undefined"
|
||||||
placeholder="Library"
|
placeholder="Library"
|
||||||
icon="i-lucide-library-big"
|
icon="i-lucide-library-big"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
@@ -35,8 +36,8 @@ export interface LibrarySelectProps {
|
|||||||
|
|
||||||
const props = defineProps<LibrarySelectProps>();
|
const props = defineProps<LibrarySelectProps>();
|
||||||
|
|
||||||
const library = ref(props.libraryId);
|
const library = ref();
|
||||||
const { data: libraries } = await useApi('/v2/FileLibrary', { key: FetchKeys.FileLibraries });
|
const { data: libraries } = await useApi('/v2/FileLibrary');
|
||||||
|
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const onLibrarySelectChange = async () => {
|
const onLibrarySelectChange = async () => {
|
||||||
|
@@ -18,6 +18,9 @@
|
|||||||
<p v-if="title" class="text-2xl text-primary font-semibold">{{ title }}</p>
|
<p v-if="title" class="text-2xl text-primary font-semibold">{{ title }}</p>
|
||||||
</slot>
|
</slot>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flew-row gap-2">
|
||||||
|
<slot name="center" />
|
||||||
|
</div>
|
||||||
<div class="flex flew-row gap-2">
|
<div class="flex flew-row gap-2">
|
||||||
<slot name="actions" />
|
<slot name="actions" />
|
||||||
</div>
|
</div>
|
||||||
|
@@ -6,4 +6,5 @@ export const FetchKeys = {
|
|||||||
Metadata: { Fetchers: 'Metadata', Links: 'Metadata/Links', Manga: (mangaId: string) => `Metadata/Links/${mangaId}` },
|
Metadata: { Fetchers: 'Metadata', Links: 'Metadata/Links', Manga: (mangaId: string) => `Metadata/Links/${mangaId}` },
|
||||||
Libraries: { All: 'Libraries', Id: (id: string) => `Libraries/${id}` },
|
Libraries: { All: 'Libraries', Id: (id: string) => `Libraries/${id}` },
|
||||||
Settings: { All: 'Settings' },
|
Settings: { All: 'Settings' },
|
||||||
|
Actions: { Types: 'Actions/Types'}
|
||||||
};
|
};
|
||||||
|
@@ -1,5 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<TrangaPage rimless>
|
<TrangaPage rimless>
|
||||||
|
<template #center>
|
||||||
|
<USelect v-model="params.action" :items="ActionTypes?.map(a => a.split(/(?=[A-Z])/).join(' '))" class="w-50" @change="refreshData" />
|
||||||
|
<UInput v-model="params.start" trailing-icon="i-lucide-chevron-first" type="datetime-local" @change="refreshData" />
|
||||||
|
<UInput v-model="params.end" icon="i-lucide-chevron-last" type="datetime-local" @change="refreshData" />
|
||||||
|
</template>
|
||||||
<template #actions>
|
<template #actions>
|
||||||
<UTooltip text="Reload" :kbds="['meta', 'R']">
|
<UTooltip text="Reload" :kbds="['meta', 'R']">
|
||||||
<UButton variant="soft" color="secondary" icon="i-lucide-refresh-ccw" loading-auto @click="refreshData" />
|
<UButton variant="soft" color="secondary" icon="i-lucide-refresh-ccw" loading-auto @click="refreshData" />
|
||||||
@@ -13,10 +18,10 @@
|
|||||||
{{ new Date(row.original.performedAt).toLocaleString() }}
|
{{ new Date(row.original.performedAt).toLocaleString() }}
|
||||||
</template>
|
</template>
|
||||||
<template #manga-cell="{ row }">
|
<template #manga-cell="{ row }">
|
||||||
<UButton v-if="row.original.mangaId" :to="`/manga/${row.original.mangaId}?return=${$route.fullPath}`">Manga</UButton>
|
<UButton v-if="row.original.mangaId" :to="`/manga/${row.original.mangaId}?return=${$route.fullPath}`" variant="ghost" color="primary">Manga</UButton>
|
||||||
</template>
|
</template>
|
||||||
<template #chapter-cell="{ row }">
|
<template #chapter-cell="{ row }">
|
||||||
<UButton v-if="row.original.chapterId" :to="`/manga/${row.original.chapterId}?return=${$route.fullPath}`">Chapter</UButton>
|
<UButton v-if="row.original.chapterId" :to="`/manga/${row.original.chapterId}?return=${$route.fullPath}`" variant="ghost" color="secondary">Chapter</UButton>
|
||||||
</template>
|
</template>
|
||||||
<template #additional-cell="{ row }">
|
<template #additional-cell="{ row }">
|
||||||
<p v-if="row.original.from">From: {{ row.original.from }}</p>
|
<p v-if="row.original.from">From: {{ row.original.from }}</p>
|
||||||
@@ -34,8 +39,14 @@ import type { TableColumn } from '#ui/components/Table.vue';
|
|||||||
type Filter = components['schemas']['Filter'];
|
type Filter = components['schemas']['Filter'];
|
||||||
type ActionRecord = components['schemas']['ActionRecord'];
|
type ActionRecord = components['schemas']['ActionRecord'];
|
||||||
|
|
||||||
const params = ref<Partial<Filter>>(useRoute().query);
|
const { $api } = useNuxtApp();
|
||||||
const { data, refresh } = useApi('/v2/Actions/Filter', { method: 'POST', body: params.value, immediate: false });
|
|
||||||
|
const params = computed<Partial<Filter>>(() => { return { ...useRoute().query,
|
||||||
|
start: new Date(Date.now()-(24 * 60 * 60 * 1000)).toISOString().slice(0, 16),
|
||||||
|
end: new Date(Date.now()).toISOString().slice(0, 16),
|
||||||
|
}});
|
||||||
|
const data = ref(await $api('/v2/Actions/Filter', { method: 'POST', body: params.value }));
|
||||||
|
const { data: ActionTypes } = useApi('/v2/Actions/Types', { key : FetchKeys.Actions.Types });
|
||||||
|
|
||||||
const columns: TableColumn<ActionRecord>[] = [
|
const columns: TableColumn<ActionRecord>[] = [
|
||||||
{
|
{
|
||||||
@@ -65,7 +76,7 @@ const columns: TableColumn<ActionRecord>[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const refreshData = async (): Promise<void> => {
|
const refreshData = async (): Promise<void> => {
|
||||||
await refresh();
|
data.value = await $api('/v2/Actions/Filter', { method: 'POST', body: params.value });
|
||||||
};
|
};
|
||||||
defineShortcuts({ meta_r: { usingInput: true, handler: refreshData } });
|
defineShortcuts({ meta_r: { usingInput: true, handler: refreshData } });
|
||||||
</script>
|
</script>
|
||||||
|
@@ -66,6 +66,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<template #actions>
|
<template #actions>
|
||||||
|
<UButton icon="i-lucide-brick-wall-shield" :to="`/actions?mangaId=${mangaId}&return=${$route.fullPath}`" variant="soft" color="secondary" />
|
||||||
<UButton trailing-icon="i-lucide-merge" :to="`/manga/${manga?.key}/merge?return=${$route.fullPath}`" color="secondary"
|
<UButton trailing-icon="i-lucide-merge" :to="`/manga/${manga?.key}/merge?return=${$route.fullPath}`" color="secondary"
|
||||||
>Merge</UButton
|
>Merge</UButton
|
||||||
>
|
>
|
||||||
|
Reference in New Issue
Block a user