mirror of
https://github.com/C9Glax/tranga-website.git
synced 2025-10-18 03:10:47 +02:00
Add Action Filters
Fix LibrarySelect for the 100th time
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
<template>
|
||||
<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>
|
||||
<UTooltip text="Reload" :kbds="['meta', 'R']">
|
||||
<UButton variant="soft" color="secondary" icon="i-lucide-refresh-ccw" loading-auto @click="refreshData" />
|
||||
@@ -13,10 +18,10 @@
|
||||
{{ new Date(row.original.performedAt).toLocaleString() }}
|
||||
</template>
|
||||
<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 #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 #additional-cell="{ row }">
|
||||
<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 ActionRecord = components['schemas']['ActionRecord'];
|
||||
|
||||
const params = ref<Partial<Filter>>(useRoute().query);
|
||||
const { data, refresh } = useApi('/v2/Actions/Filter', { method: 'POST', body: params.value, immediate: false });
|
||||
const { $api } = useNuxtApp();
|
||||
|
||||
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>[] = [
|
||||
{
|
||||
@@ -65,7 +76,7 @@ const columns: TableColumn<ActionRecord>[] = [
|
||||
];
|
||||
|
||||
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 } });
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user