Skip to content

Commit

Permalink
fix: missing types
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Nov 27, 2023
1 parent 15c1945 commit 538d992
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
18 changes: 10 additions & 8 deletions src/main/webapp/src/components/dialogs/FileDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const modelValue = computed<boolean>({
},
});
const roles = [];
const roles: Array<string> = [];
const newUser = ref<any>();
const newRole = ref<string>();
Expand Down
18 changes: 12 additions & 6 deletions src/main/webapp/src/services/fileService.ts
Original file line number Diff line number Diff line change
@@ -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');
Expand All @@ -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}`);
Expand All @@ -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}`);
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/src/types/collaborationBody.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type CollaborationBody = {
userId: number;
role: number;
};
7 changes: 7 additions & 0 deletions src/main/webapp/src/types/fileBodyType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type FileBody = {
title: string;
description: string | null;
blob: any;
associatedAppId: number;
pub: boolean;
};
3 changes: 3 additions & 0 deletions src/main/webapp/src/types/historyBodyType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type HistoryBody = {
blob: any;
};
3 changes: 3 additions & 0 deletions src/main/webapp/src/types/metadataBodyType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type MetadataBody = {
starred: boolean;
};

0 comments on commit 538d992

Please sign in to comment.