Visual edits and fixes, navigation sorting fix
This commit is contained in:
parent
2855d4ba2e
commit
20ab51a66c
BIN
db.sqlite-shm
BIN
db.sqlite-shm
Binary file not shown.
BIN
db.sqlite-wal
BIN
db.sqlite-wal
Binary file not shown.
|
|
@ -78,19 +78,19 @@
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
<Tree v-if="pages" v-model="pages" :getKey="(item) => item.path">
|
<Tree v-if="pages" v-model="pages" :getKey="(item) => item.path">
|
||||||
<template #default="{ item, isExpanded }">
|
<template #default="{ item, isExpanded }">
|
||||||
<NuxtLink :href="item.value.path && !item.hasChildren ? { name: 'explore-path', params: { path: item.value.path } } : undefined" no-prefetch class="group flex flex-1 items-center hover:border-accent-blue" :class="{ 'font-medium': item.hasChildren }" active-class="text-accent-blue" :data-private="item.value.private">
|
<NuxtLink :href="item.value.path && !item.hasChildren ? { name: 'explore-path', params: { path: item.value.path } } : undefined" no-prefetch class="flex flex-1 items-center hover:border-accent-blue hover:text-accent-purple" :class="{ 'font-medium': item.hasChildren }" active-class="text-accent-blue" :data-private="item.value.private">
|
||||||
<Icon v-if="item.hasChildren" icon="radix-icons:chevron-right" :class="{ 'rotate-90': isExpanded }" class="h-4 w-4 transition-transform absolute group-[:hover]:text-accent-purple" :style="{ 'left': `${item.level - 1}em` }" />
|
<Icon v-if="item.hasChildren" icon="radix-icons:chevron-right" :class="{ 'rotate-90': isExpanded }" class="h-4 w-4 transition-transform absolute" :style="{ 'left': `${item.level - 1}em` }" />
|
||||||
<Icon v-else-if="iconByType[item.value.type]" :icon="iconByType[item.value.type]" class="group-[:hover]:text-accent-purple" />
|
<Icon v-else-if="iconByType[item.value.type]" :icon="iconByType[item.value.type]" class="w-5 h-5" />
|
||||||
<div class="pl-3 py-1 flex-1 truncate">
|
<div class="pl-3 py-1 flex-1 truncate">
|
||||||
{{ item.value.title }}
|
{{ item.value.title }}
|
||||||
</div>
|
</div>
|
||||||
|
<Tooltip message="Privé" side="right"><Icon v-show="item.value.private" icon="radix-icons:lock-closed" /></Tooltip>
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</template>
|
</template>
|
||||||
</Tree>
|
</Tree>
|
||||||
</div>
|
</div>
|
||||||
<div class="xl:px-12 px-6 text-start text-xs text-light-60 dark:text-dark-60 relative top-4">
|
<div class="xl:px-12 px-6 text-start text-xs text-light-60 dark:text-dark-60 relative top-4">
|
||||||
<NuxtLink class="hover:underline italic" :to="{ name: 'roadmap' }">Roadmap</NuxtLink> -
|
<NuxtLink class="hover:underline italic" :to="{ name: 'roadmap' }">Roadmap</NuxtLink> - <NuxtLink class="hover:underline italic" :to="{ name: 'legal' }">Mentions légales</NuxtLink>
|
||||||
<NuxtLink class="hover:underline italic" :to="{ name: 'legal' }">Mentions légales</NuxtLink>
|
|
||||||
<p>Copyright Peaceultime - 2024</p>
|
<p>Copyright Peaceultime - 2024</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,50 @@
|
||||||
|
<script lang="ts">
|
||||||
|
const mailSchema = z.object({
|
||||||
|
to: z.string().email(),
|
||||||
|
message: z.string(),
|
||||||
|
subject: z.string(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const schemaList: Record<string, z.ZodObject<any> | null> = {
|
||||||
|
'pull': null,
|
||||||
|
'push': null,
|
||||||
|
'mail': mailSchema,
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { z } from 'zod';
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
rights: ['admin'],
|
rights: ['admin'],
|
||||||
})
|
})
|
||||||
const job = ref<string>('');
|
const job = ref<string>('');
|
||||||
|
|
||||||
const toaster = useToast();
|
const toaster = useToast();
|
||||||
const data = ref(), status = ref<'idle' | 'pending' | 'success' | 'error'>('idle'), success = ref(false), err = ref(false), error = ref();
|
const payload = reactive<Record<string, any>>({});
|
||||||
|
const data = ref(), status = ref<'idle' | 'pending' | 'success' | 'error'>('idle'), success = ref(false), error = ref<Error | null>();
|
||||||
async function fetch()
|
async function fetch()
|
||||||
{
|
{
|
||||||
status.value = 'pending';
|
status.value = 'pending';
|
||||||
data.value = null;
|
data.value = null;
|
||||||
error.value = null;
|
error.value = null;
|
||||||
err.value = false;
|
|
||||||
success.value = false;
|
success.value = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
const schema = schemaList[job.value];
|
||||||
|
|
||||||
|
if(schema)
|
||||||
|
{
|
||||||
|
const parsedPayload = schema.parse(payload);
|
||||||
|
}
|
||||||
|
|
||||||
data.value = await $fetch(`/api/admin/jobs/${job.value}`, {
|
data.value = await $fetch(`/api/admin/jobs/${job.value}`, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
body: payload,
|
||||||
});
|
});
|
||||||
status.value = 'success';
|
status.value = 'success';
|
||||||
error.value = null;
|
error.value = null;
|
||||||
err.value = false;
|
|
||||||
success.value = true;
|
success.value = true;
|
||||||
|
|
||||||
toaster.add({ duration: 10000, content: data.value ?? 'Job executé avec succès', type: 'success', timer: true, });
|
toaster.add({ duration: 10000, content: data.value ?? 'Job executé avec succès', type: 'success', timer: true, });
|
||||||
|
|
@ -29,11 +52,10 @@ async function fetch()
|
||||||
catch(e)
|
catch(e)
|
||||||
{
|
{
|
||||||
status.value = 'error';
|
status.value = 'error';
|
||||||
error.value = e;
|
error.value = e as Error;
|
||||||
err.value = true;
|
|
||||||
success.value = false;
|
success.value = false;
|
||||||
|
|
||||||
toaster.add({ duration: 10000, content: error.value, type: 'error', timer: true, });
|
toaster.add({ duration: 10000, content: error.value.message, type: 'error', timer: true, });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -42,13 +64,18 @@ async function fetch()
|
||||||
<Head>
|
<Head>
|
||||||
<Title>d[any] - Administration</Title>
|
<Title>d[any] - Administration</Title>
|
||||||
</Head>
|
</Head>
|
||||||
<div class="flex flex-col justify-start">
|
<div class="flex flex-col justify-start items-center">
|
||||||
<ProseH2>Administration</ProseH2>
|
<ProseH2>Administration</ProseH2>
|
||||||
<Select label="Job" v-model="job">
|
<Select label="Job" v-model="job" @update:model-value="payload = {}">
|
||||||
<SelectItem label="Récupérer les données d'Obsidian" value="pull" />
|
<SelectItem label="Récupérer les données d'Obsidian" value="pull" />
|
||||||
<SelectItem label="Envoyer les données dans Obsidian" value="push" disabled />
|
<SelectItem label="Envoyer les données dans Obsidian" value="push" disabled />
|
||||||
<SelectItem label="Envoyer un mail de test" value="mail" />
|
<SelectItem label="Envoyer un mail de test" value="mail" />
|
||||||
</Select>
|
</Select>
|
||||||
|
<div v-if="job === 'mail'" class="flex justify-center items-center flex-col">
|
||||||
|
<TextInput label="Destinataire" class="w-full" v-model="payload.to" />
|
||||||
|
<TextInput label="Objet" class="w-full" v-model="payload.subject" />
|
||||||
|
<TextInput label="Message" class="w-full" v-model="payload.message" />
|
||||||
|
</div>
|
||||||
<Button class="self-center" @click="() => !!job && fetch()" :loading="status === 'pending'">
|
<Button class="self-center" @click="() => !!job && fetch()" :loading="status === 'pending'">
|
||||||
<span>Executer</span>
|
<span>Executer</span>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ export default defineEventHandler(async (e) => {
|
||||||
const id = getRouterParam(e, 'id');
|
const id = getRouterParam(e, 'id');
|
||||||
const payload: Record<string, any> = await readBody(e);
|
const payload: Record<string, any> = await readBody(e);
|
||||||
|
|
||||||
console.log(payload);
|
|
||||||
|
|
||||||
if(!id)
|
if(!id)
|
||||||
{
|
{
|
||||||
setResponseStatus(e, 400);
|
setResponseStatus(e, 400);
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,11 @@ export default defineEventHandler(async (e) => {
|
||||||
navigable: explorerContentTable.navigable,
|
navigable: explorerContentTable.navigable,
|
||||||
private: explorerContentTable.private,
|
private: explorerContentTable.private,
|
||||||
order: explorerContentTable.order,
|
order: explorerContentTable.order,
|
||||||
}).from(explorerContentTable).prepare().all();
|
}).from(explorerContentTable).all();
|
||||||
|
|
||||||
|
content.sort((a, b) => {
|
||||||
|
return a.path.split('/').length - b.path.split('/').length;
|
||||||
|
});
|
||||||
|
|
||||||
if(content.length > 0)
|
if(content.length > 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,12 @@ export default defineTask({
|
||||||
},
|
},
|
||||||
async run(e) {
|
async run(e) {
|
||||||
try {
|
try {
|
||||||
|
const payload: { to: string[], message: string, subject: string } = e.payload;
|
||||||
const status = await transport.sendMail({
|
const status = await transport.sendMail({
|
||||||
from: 'Message automatique d[any] <no-reply@peaceultime.com>',
|
from: 'Message automatique d[any] <no-reply@peaceultime.com>',
|
||||||
to: ['peaceultime@peaceultime.com', 'clem31470@gmail.com'],
|
to: payload.to,
|
||||||
text: 'Ceci est un texte de mail.',
|
text: payload.message,
|
||||||
subject: 'Test',
|
subject: payload.subject,
|
||||||
});
|
});
|
||||||
|
|
||||||
if(status.rejected.length > 0)
|
if(status.rejected.length > 0)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue