From 4f13b70ac83d6408b1063695141fc08410c6b05b Mon Sep 17 00:00:00 2001 From: Julian Krauser Date: Wed, 22 Jan 2025 11:55:48 +0100 Subject: [PATCH] form update & token copy --- .../admin/user/webapi/CreateWebapiModal.vue | 15 ++++- .../admin/user/webapi/WebapiListItem.vue | 55 +++++++++++++++++- .../admin/user/webapi/WebapiTokenModal.vue | 56 +++++++++++++++++++ src/stores/admin/user/webapi.ts | 21 ++++--- src/viewmodels/admin/user/webapi.models.ts | 6 -- src/views/admin/user/webapi/WebapiEdit.vue | 18 ++++-- 6 files changed, 148 insertions(+), 23 deletions(-) create mode 100644 src/components/admin/user/webapi/WebapiTokenModal.vue diff --git a/src/components/admin/user/webapi/CreateWebapiModal.vue b/src/components/admin/user/webapi/CreateWebapiModal.vue index ec87edc..1b3df8d 100644 --- a/src/components/admin/user/webapi/CreateWebapiModal.vue +++ b/src/components/admin/user/webapi/CreateWebapiModal.vue @@ -6,8 +6,12 @@
- - + + +
+
+ +
@@ -35,6 +39,7 @@ import Spinner from "@/components/Spinner.vue"; import SuccessCheckmark from "@/components/SuccessCheckmark.vue"; import FailureXMark from "@/components/FailureXMark.vue"; import { useWebapiStore } from "@/stores/admin/user/webapi"; +import type { CreateWebapiViewModel } from "../../../../viewmodels/admin/user/webapi.models"; + + diff --git a/src/stores/admin/user/webapi.ts b/src/stores/admin/user/webapi.ts index 4ddf939..66a57e7 100644 --- a/src/stores/admin/user/webapi.ts +++ b/src/stores/admin/user/webapi.ts @@ -1,5 +1,9 @@ import { defineStore } from "pinia"; -import type { WebapiViewModel } from "@/viewmodels/admin/user/webapi.models"; +import type { + CreateWebapiViewModel, + UpdateWebapiViewModel, + WebapiViewModel, +} from "@/viewmodels/admin/user/webapi.models"; import { http } from "@/serverCom"; import type { PermissionObject } from "@/types/permissionTypes"; import type { AxiosResponse } from "axios"; @@ -27,17 +31,16 @@ export const useWebapiStore = defineStore("webapi", { fetchWebapiById(id: number): Promise> { return http.get(`/admin/webapi/${id}`); }, - async createWebapi(webapi: string): Promise> { - const result = await http.post("/admin/webapi", { - webapi: webapi, - }); + fetchWebapiTokenById(id: number): Promise> { + return http.get(`/admin/webapi/${id}/token`); + }, + async createWebapi(webapi: CreateWebapiViewModel): Promise> { + const result = await http.post("/admin/webapi", webapi); this.fetchWebapis(); return result; }, - async updateActiveWebapi(id: number, webapi: string): Promise> { - const result = await http.patch(`/admin/webapi/${id}`, { - webapi: webapi, - }); + async updateActiveWebapi(id: number, webapi: UpdateWebapiViewModel): Promise> { + const result = await http.patch(`/admin/webapi/${id}`, webapi); this.fetchWebapis(); return result; }, diff --git a/src/viewmodels/admin/user/webapi.models.ts b/src/viewmodels/admin/user/webapi.models.ts index 1bdf93c..015837c 100644 --- a/src/viewmodels/admin/user/webapi.models.ts +++ b/src/viewmodels/admin/user/webapi.models.ts @@ -11,16 +11,10 @@ export interface WebapiViewModel { export interface CreateWebapiViewModel { title: string; - token: string; expiry?: Date; } export interface UpdateWebapiViewModel { - id: number; title: string; expiry?: Date; } - -export interface DeleteWebapiViewModel { - id: number; -} diff --git a/src/views/admin/user/webapi/WebapiEdit.vue b/src/views/admin/user/webapi/WebapiEdit.vue index 7c17d94..8eb85f7 100644 --- a/src/views/admin/user/webapi/WebapiEdit.vue +++ b/src/views/admin/user/webapi/WebapiEdit.vue @@ -17,8 +17,12 @@ @submit.prevent="triggerWebapiUpdate" >
- - + + +
+
+ +