From 538d9921db298d116150935eb121dd3f9cb90731 Mon Sep 17 00:00:00 2001 From: Quentin Guillemin Date: Mon, 27 Nov 2023 13:02:56 +0100 Subject: [PATCH] fix: missing types --- .../src/components/dialogs/FileDialog.vue | 18 ++++++++++-------- .../components/drawers/InformationDrawer.vue | 2 +- src/main/webapp/src/services/fileService.ts | 18 ++++++++++++------ src/main/webapp/src/types/collaborationBody.ts | 4 ++++ src/main/webapp/src/types/fileBodyType.ts | 7 +++++++ src/main/webapp/src/types/historyBodyType.ts | 3 +++ src/main/webapp/src/types/metadataBodyType.ts | 3 +++ 7 files changed, 40 insertions(+), 15 deletions(-) create mode 100644 src/main/webapp/src/types/collaborationBody.ts create mode 100644 src/main/webapp/src/types/fileBodyType.ts create mode 100644 src/main/webapp/src/types/historyBodyType.ts create mode 100644 src/main/webapp/src/types/metadataBodyType.ts diff --git a/src/main/webapp/src/components/dialogs/FileDialog.vue b/src/main/webapp/src/components/dialogs/FileDialog.vue index 77b3fea5..d94622a7 100644 --- a/src/main/webapp/src/components/dialogs/FileDialog.vue +++ b/src/main/webapp/src/components/dialogs/FileDialog.vue @@ -33,14 +33,16 @@ const save = () => { }; const addElement = async () => { - await saveFile({ - title: title.value, - description: description.value && description.value.trim.length > 0 ? description.value : null, - blob: '', - associatedAppId: fileType.value, - pub: pub.value, - }); - refresh(true); + if (canSave.value) { + await saveFile({ + title: title.value!, + description: description.value && description.value.trim.length > 0 ? description.value : null, + blob: '', + associatedAppId: fileType.value!, + pub: pub.value, + }); + refresh(true); + } }; diff --git a/src/main/webapp/src/components/drawers/InformationDrawer.vue b/src/main/webapp/src/components/drawers/InformationDrawer.vue index 35e96aa0..2ffabc8c 100644 --- a/src/main/webapp/src/components/drawers/InformationDrawer.vue +++ b/src/main/webapp/src/components/drawers/InformationDrawer.vue @@ -21,7 +21,7 @@ const modelValue = computed({ }, }); -const roles = []; +const roles: Array = []; const newUser = ref(); const newRole = ref(); diff --git a/src/main/webapp/src/services/fileService.ts b/src/main/webapp/src/services/fileService.ts index 78cf8033..079c74c3 100644 --- a/src/main/webapp/src/services/fileService.ts +++ b/src/main/webapp/src/services/fileService.ts @@ -1,3 +1,7 @@ +import type { CollaborationBody } from '@/types/collaborationBody.ts'; +import type { FileBody } from '@/types/fileBodyType.ts'; +import type { HistoryBody } from '@/types/historyBodyType.ts'; +import type { MetadataBody } from '@/types/metadataBodyType.ts'; import { instance as axios } from '@/utils/axiosUtils'; const getFiles = async () => await axios.get('/api/file'); @@ -8,21 +12,22 @@ const getStarred = async () => await axios.get('/api/file/starred'); const getPublic = async () => await axios.get('/api/file/public'); -const saveFile = async (body) => await axios.post('/api/file', body); +const saveFile = async (body: FileBody) => await axios.post('/api/file', body); const getFile = async (fileId: number) => await axios.get(`/api/file/${fileId}`); -const setFile = async (fileId: number, body) => await axios.put(`/api/file/${fileId}`, body); +const setFile = async (fileId: number, body: FileBody) => await axios.put(`/api/file/${fileId}`, body); const deleteFile = async (fileId: number) => await axios.delete(`/api/file/${fileId}`); -const setMetadata = async (fileId: number, body) => await axios.put(`/api/file/${fileId}/metadata`, body); +const setMetadata = async (fileId: number, body: MetadataBody) => await axios.put(`/api/file/${fileId}/metadata`, body); const getShare = async (fileId: number) => await axios.get(`/api/file/${fileId}`); -const saveShare = async (fileId: number, body) => await axios.post(`/api/file/${fileId}/share`, body); +const saveShare = async (fileId: number, body: CollaborationBody) => + await axios.post(`/api/file/${fileId}/share`, body); -const setShare = async (fileId: number, userId: number, body) => +const setShare = async (fileId: number, userId: number, body: CollaborationBody) => await axios.put(`/api/file/${fileId}/share/${userId}`, body); const deleteShare = async (fileId: number, userId: number) => await axios.delete(`/api/file/${fileId}/share/${userId}`); @@ -31,7 +36,8 @@ const deleteSharing = async (fileId: number) => await axios.delete(`/api/file/${ const getHistories = async (fileId: number) => await axios.get(`/api/file/${fileId}/history`); -const createHistory = async (fileId: number, body) => await axios.post(`/api/file/${fileId}/history`, body); +const createHistory = async (fileId: number, body: HistoryBody) => + await axios.post(`/api/file/${fileId}/history`, body); const getHistory = async (fileId: number, historyId: number) => await axios.get(`/api/file/${fileId}/history/${historyId}`); diff --git a/src/main/webapp/src/types/collaborationBody.ts b/src/main/webapp/src/types/collaborationBody.ts new file mode 100644 index 00000000..38ec2b95 --- /dev/null +++ b/src/main/webapp/src/types/collaborationBody.ts @@ -0,0 +1,4 @@ +export type CollaborationBody = { + userId: number; + role: number; +}; diff --git a/src/main/webapp/src/types/fileBodyType.ts b/src/main/webapp/src/types/fileBodyType.ts new file mode 100644 index 00000000..0e57d33e --- /dev/null +++ b/src/main/webapp/src/types/fileBodyType.ts @@ -0,0 +1,7 @@ +export type FileBody = { + title: string; + description: string | null; + blob: any; + associatedAppId: number; + pub: boolean; +}; diff --git a/src/main/webapp/src/types/historyBodyType.ts b/src/main/webapp/src/types/historyBodyType.ts new file mode 100644 index 00000000..3b92c4db --- /dev/null +++ b/src/main/webapp/src/types/historyBodyType.ts @@ -0,0 +1,3 @@ +export type HistoryBody = { + blob: any; +}; diff --git a/src/main/webapp/src/types/metadataBodyType.ts b/src/main/webapp/src/types/metadataBodyType.ts new file mode 100644 index 00000000..93e8ba28 --- /dev/null +++ b/src/main/webapp/src/types/metadataBodyType.ts @@ -0,0 +1,3 @@ +export type MetadataBody = { + starred: boolean; +};