From 587301b119e3b153333bc63a1b1c8707b66a46c5 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Thu, 19 Jan 2023 00:54:16 +0100 Subject: [PATCH] Fix Articles front before table pagination impl. --- web/admin-gui/src/utils/database.ts | 15 ++++++++++++++- web/admin-gui/src/views/Articles.vue | 2 +- web/admin-gui/src/views/ArticlesEdit.vue | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/web/admin-gui/src/utils/database.ts b/web/admin-gui/src/utils/database.ts index 5a0ddaf..4114451 100644 --- a/web/admin-gui/src/utils/database.ts +++ b/web/admin-gui/src/utils/database.ts @@ -11,7 +11,20 @@ export interface Article { online: boolean } -export async function getArticles(id: string): Promise> { +export interface GetArticle { + content: Article[], + total: number + pagination: { + skip: number, + take: number + links: { + next: string, + previous: string + } + } +} + +export async function getArticles(id: string): Promise { return await fetch(`${baseApiUrl}/articles/${id}`, { credentials: 'include', method: 'GET', diff --git a/web/admin-gui/src/views/Articles.vue b/web/admin-gui/src/views/Articles.vue index 4c6fc4f..05525cf 100644 --- a/web/admin-gui/src/views/Articles.vue +++ b/web/admin-gui/src/views/Articles.vue @@ -10,7 +10,7 @@ const table = ref('') const tabulator: Ref = ref(undefined) onMounted(async () => { - articles.value = await getArticles('') + articles.value = await (await getArticles('')).content tabulator.value = new Tabulator(table.value, { data: articles.value, reactiveData: true, diff --git a/web/admin-gui/src/views/ArticlesEdit.vue b/web/admin-gui/src/views/ArticlesEdit.vue index 1705836..4448a40 100644 --- a/web/admin-gui/src/views/ArticlesEdit.vue +++ b/web/admin-gui/src/views/ArticlesEdit.vue @@ -16,7 +16,7 @@ const errorModalDescription: Ref = ref("Quelque chose s'est mal passé.. onMounted(async () => { await getArticles(useRoute().params.articleID as string) .then(articleFetch => { - article.value = articleFetch[0] + article.value = articleFetch.content[0] editorData.value = article.value.content.html }) .catch(error => {