From 322c77549c99f7d75cd0a34cf52fadaf840bc3c4 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Fri, 6 Jan 2023 23:28:06 +0100 Subject: [PATCH] Article edition now getting article from DB by ID --- web/admin-gui/src/router/index.ts | 6 +++--- web/admin-gui/src/utils/database.ts | 24 ++++++++++++++++++++++++ web/admin-gui/src/views/ArticlesEdit.vue | 10 ++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 web/admin-gui/src/utils/database.ts diff --git a/web/admin-gui/src/router/index.ts b/web/admin-gui/src/router/index.ts index e660c56..e6b7a88 100644 --- a/web/admin-gui/src/router/index.ts +++ b/web/admin-gui/src/router/index.ts @@ -44,7 +44,7 @@ const router = createRouter({ } }, { - path: '/articles/edit/:articleID?', + path: '/articles/edit/:articleID', name: 'edition', component: ArticlesEdit, meta: { @@ -53,10 +53,10 @@ const router = createRouter({ }, { path: '/articles/new', - name: 'edition', + name: 'new', component: ArticlesNew, meta: { - title: 'GohCMS - Edition' + title: 'GohCMS - Nouveau' } }, ] diff --git a/web/admin-gui/src/utils/database.ts b/web/admin-gui/src/utils/database.ts new file mode 100644 index 0000000..8416e6c --- /dev/null +++ b/web/admin-gui/src/utils/database.ts @@ -0,0 +1,24 @@ +import { useAuthStore } from "@/stores/AuthStore" + +export interface Article { + idName: string, + date: number, + content: { + html: string + }, + pageId: string, + online: boolean +} + +const baseURL = `http://${__APP_ENV__.APP_HOST_ADDRESS}:${__APP_ENV__.APP_API_PORT}` + +export async function getArticle(id: string) : Promise
{ + return await fetch(`${baseURL}/articles/${id}`, { + method: 'GET', + headers: { "Authorization": `Bearer ${useAuthStore().token}` } + }) + .then(result => result.json()) + .catch(error => { + console.error(error) + }) +} \ No newline at end of file diff --git a/web/admin-gui/src/views/ArticlesEdit.vue b/web/admin-gui/src/views/ArticlesEdit.vue index 28babb0..45ce695 100644 --- a/web/admin-gui/src/views/ArticlesEdit.vue +++ b/web/admin-gui/src/views/ArticlesEdit.vue @@ -1,11 +1,17 @@