From fb1517b598f919cce6e79871bc521327c4fe961c Mon Sep 17 00:00:00 2001 From: tyboro2002 Date: Tue, 21 May 2024 12:16:05 +0200 Subject: [PATCH] chore: fix linter --- .../composables/services/assistant.service.ts | 14 ++--- .../composables/services/course.service.ts | 45 ++++++++++++---- .../composables/services/docker.service.ts | 25 +++++++-- .../services/extra_checks.service.ts | 8 ++- .../composables/services/faculty.service.ts | 9 +++- .../src/composables/services/group.service.ts | 2 +- frontend/src/composables/services/helpers.ts | 51 ++++++++++++------- .../composables/services/project.service.ts | 2 +- 8 files changed, 113 insertions(+), 43 deletions(-) diff --git a/frontend/src/composables/services/assistant.service.ts b/frontend/src/composables/services/assistant.service.ts index 7bd9e815..a6f73176 100644 --- a/frontend/src/composables/services/assistant.service.ts +++ b/frontend/src/composables/services/assistant.service.ts @@ -48,7 +48,7 @@ export function useAssistant(): AssistantState { filters: Filter, page: number, pageSize: number, - selfprocessError: boolean = true + selfprocessError: boolean = true, ): Promise { const endpoint = endpoints.assistants.search; await getPaginatedList( @@ -58,14 +58,14 @@ export function useAssistant(): AssistantState { pageSize, assistantPagination, Assistant.fromJSON, - selfprocessError + selfprocessError, ); } async function assistantJoinCourse( courseId: string, assistantId: string, - selfprocessError: boolean = true + selfprocessError: boolean = true, ): Promise { const endpoint = endpoints.assistants.byCourse.replace('{courseId}', courseId); await create( @@ -74,14 +74,14 @@ export function useAssistant(): AssistantState { response, Response.fromJSON, undefined, - selfprocessError + selfprocessError, ); } async function assistantLeaveCourse( courseId: string, assistantId: string, - selfprocessError: boolean = true + selfprocessError: boolean = true, ): Promise { const endpoint = endpoints.assistants.byCourse.replace('{courseId}', courseId); await deleteIdWithData( @@ -89,7 +89,7 @@ export function useAssistant(): AssistantState { { assistant: assistantId }, response, Response.fromJSON, - selfprocessError + selfprocessError, ); } @@ -103,7 +103,7 @@ export function useAssistant(): AssistantState { assistant, Assistant.fromJSON, undefined, - selfprocessError + selfprocessError, ); } diff --git a/frontend/src/composables/services/course.service.ts b/frontend/src/composables/services/course.service.ts index 54fd835a..30e07c45 100644 --- a/frontend/src/composables/services/course.service.ts +++ b/frontend/src/composables/services/course.service.ts @@ -18,7 +18,12 @@ interface CoursesState { getCourseByAssistant: (assistantId: string, selfprocessError?: boolean) => Promise; createCourse: (courseData: Course, selfprocessError?: boolean) => Promise; updateCourse: (courseData: Course, selfprocessError?: boolean) => Promise; - cloneCourse: (courseId: string, cloneAssistants: boolean, cloneTeachers: boolean, selfprocessError?: boolean) => Promise; + cloneCourse: ( + courseId: string, + cloneAssistants: boolean, + cloneTeachers: boolean, + selfprocessError?: boolean, + ) => Promise; activateInvitationLink: (courseId: string, linkDuration: number, selfprocessError?: boolean) => Promise; deleteCourse: (id: string, selfprocessError?: boolean) => Promise; } @@ -39,9 +44,22 @@ export function useCourses(): CoursesState { await getList(endpoint, courses, Course.fromJSON, selfprocessError); } - async function searchCourses(filters: Filter, page: number, pageSize: number, selfprocessError: boolean = true): Promise { + async function searchCourses( + filters: Filter, + page: number, + pageSize: number, + selfprocessError: boolean = true, + ): Promise { const endpoint = endpoints.courses.search; - await getPaginatedList(endpoint, filters, page, pageSize, pagination, Course.fromJSON, selfprocessError); + await getPaginatedList( + endpoint, + filters, + page, + pageSize, + pagination, + Course.fromJSON, + selfprocessError, + ); } async function getCoursesByStudent(studentId: string, selfprocessError: boolean = true): Promise { @@ -75,7 +93,7 @@ export function useCourses(): CoursesState { course, Course.fromJSON, undefined, - selfprocessError + selfprocessError, ); } @@ -94,11 +112,16 @@ export function useCourses(): CoursesState { }, response, undefined, - selfprocessError + selfprocessError, ); } - async function cloneCourse(courseId: string, cloneAssistants: boolean, cloneTeachers: boolean, selfprocessError: boolean = true): Promise { + async function cloneCourse( + courseId: string, + cloneAssistants: boolean, + cloneTeachers: boolean, + selfprocessError: boolean = true, + ): Promise { const endpoint = endpoints.courses.clone.replace('{courseId}', courseId); await create( endpoint, @@ -109,7 +132,7 @@ export function useCourses(): CoursesState { course, Course.fromJSON, undefined, - selfprocessError + selfprocessError, ); } @@ -118,7 +141,11 @@ export function useCourses(): CoursesState { await deleteId(endpoint, course, Course.fromJSON, selfprocessError); } - async function activateInvitationLink(courseId: string, linkDuration: number, selfprocessError: boolean = true): Promise { + async function activateInvitationLink( + courseId: string, + linkDuration: number, + selfprocessError: boolean = true, + ): Promise { const endpoint = endpoints.courses.invitationLink.replace('{courseId}', courseId); await patch( endpoint, @@ -127,7 +154,7 @@ export function useCourses(): CoursesState { }, response, undefined, - selfprocessError + selfprocessError, ); } diff --git a/frontend/src/composables/services/docker.service.ts b/frontend/src/composables/services/docker.service.ts index df9bdd31..708a8a5b 100644 --- a/frontend/src/composables/services/docker.service.ts +++ b/frontend/src/composables/services/docker.service.ts @@ -35,9 +35,22 @@ export function useDockerImages(): DockerImagesState { await getList(endpoint, dockerImages, DockerImage.fromJSON, selfprocessError); } - async function searchDockerImages(filters: Filter, page: number, pageSize: number, selfprocessError: boolean = true): Promise { + async function searchDockerImages( + filters: Filter, + page: number, + pageSize: number, + selfprocessError: boolean = true, + ): Promise { const endpoint = endpoints.dockerImages.search; - await getPaginatedList(endpoint, filters, page, pageSize, pagination, DockerImage.fromJSON, selfprocessError); + await getPaginatedList( + endpoint, + filters, + page, + pageSize, + pagination, + DockerImage.fromJSON, + selfprocessError, + ); } async function patchDockerImage(dockerData: DockerImage, selfprocessError: boolean = true): Promise { @@ -45,7 +58,11 @@ export function useDockerImages(): DockerImagesState { await patch(endpoint, { public: dockerData.public }, response, undefined, selfprocessError); } - async function createDockerImage(dockerData: DockerImage, file: File, selfprocessError: boolean = true): Promise { + async function createDockerImage( + dockerData: DockerImage, + file: File, + selfprocessError: boolean = true, + ): Promise { const endpoint = endpoints.dockerImages.index; await create( endpoint, @@ -57,7 +74,7 @@ export function useDockerImages(): DockerImagesState { response, Response.fromJSON, 'multipart/form-data', - selfprocessError + selfprocessError, ); } diff --git a/frontend/src/composables/services/extra_checks.service.ts b/frontend/src/composables/services/extra_checks.service.ts index 8cac1ecd..14a6f129 100644 --- a/frontend/src/composables/services/extra_checks.service.ts +++ b/frontend/src/composables/services/extra_checks.service.ts @@ -22,7 +22,11 @@ export function useExtraCheck(): ExtraCheckState { await getList(endpoint, extraChecks, ExtraCheck.fromJSON, selfprocessError); } - async function addExtraCheck(extraCheckData: ExtraCheck, projectId: string, selfprocessError: boolean = true): Promise { + async function addExtraCheck( + extraCheckData: ExtraCheck, + projectId: string, + selfprocessError: boolean = true, + ): Promise { const endpoint = endpoints.extraChecks.byProject.replace('{projectId}', projectId); await create( endpoint, @@ -37,7 +41,7 @@ export function useExtraCheck(): ExtraCheckState { extraCheck, ExtraCheck.fromJSON, 'multipart/form-data', - selfprocessError + selfprocessError, ); } diff --git a/frontend/src/composables/services/faculty.service.ts b/frontend/src/composables/services/faculty.service.ts index 23fcb85f..195ce918 100644 --- a/frontend/src/composables/services/faculty.service.ts +++ b/frontend/src/composables/services/faculty.service.ts @@ -28,7 +28,14 @@ export function useFaculty(): FacultyState { async function createFaculty(facultyData: Faculty, selfprocessError: boolean = true): Promise { const endpoint = endpoints.faculties.index; - await create(endpoint, { id: facultyData.id, name: facultyData.name }, faculty, Faculty.fromJSON, undefined, selfprocessError); + await create( + endpoint, + { id: facultyData.id, name: facultyData.name }, + faculty, + Faculty.fromJSON, + undefined, + selfprocessError, + ); } async function deleteFaculty(id: string, selfprocessError: boolean = true): Promise { diff --git a/frontend/src/composables/services/group.service.ts b/frontend/src/composables/services/group.service.ts index 39d50ba7..ec748c04 100644 --- a/frontend/src/composables/services/group.service.ts +++ b/frontend/src/composables/services/group.service.ts @@ -43,7 +43,7 @@ export function useGroup(): GroupState { group, Group.fromJSON, undefined, - selfprocessError + selfprocessError, ); } diff --git a/frontend/src/composables/services/helpers.ts b/frontend/src/composables/services/helpers.ts index 14d659c2..2b4b0803 100644 --- a/frontend/src/composables/services/helpers.ts +++ b/frontend/src/composables/services/helpers.ts @@ -14,15 +14,20 @@ import { type Filter } from '@/types/filter/Filter.ts'; * @param ref * @param fromJson */ -export async function get(endpoint: string, ref: Ref, fromJson: (data: any) => T, selfprocessError: boolean = true): Promise { +export async function get( + endpoint: string, + ref: Ref, + fromJson: (data: any) => T, + selfprocessError: boolean = true, +): Promise { try { const response = await client.get(endpoint); ref.value = fromJson(response.data); } catch (error: any) { - if(selfprocessError){ + if (selfprocessError){ processError(error); console.error(error); // Log the error for debugging - }else{ + } else { throw error; // Re-throw the error to the caller } } @@ -52,10 +57,10 @@ export async function create( }); ref.value = fromJson(response.data); } catch (error: any) { - if(selfprocessError){ + if (selfprocessError){ processError(error); console.error(error); // Log the error for debugging - }else{ + } else { throw error; // Re-throw the error to the caller } } @@ -84,10 +89,10 @@ export async function patch( }); ref.value = Response.fromJSON(response.data); } catch (error: any) { - if(selfprocessError){ + if (selfprocessError){ processError(error); console.error(error); // Log the error for debugging - }else{ + } else { throw error; // Re-throw the error to the caller } } @@ -100,15 +105,20 @@ export async function patch( * @param ref * @param fromJson */ -export async function deleteId(endpoint: string, ref: Ref, fromJson: (data: any) => T, selfprocessError: boolean = true): Promise { +export async function deleteId( + endpoint: string, + ref: Ref, + fromJson: (data: any) => T, + selfprocessError: boolean = true, +): Promise { try { const response = await client.delete(endpoint); ref.value = fromJson(response.data); } catch (error: any) { - if(selfprocessError){ + if (selfprocessError){ processError(error); console.error(error); // Log the error for debugging - }else{ + } else { throw error; // Re-throw the error to the caller } } @@ -133,10 +143,10 @@ export async function deleteIdWithData( const response = await client.delete(endpoint, { data }); ref.value = fromJson(response.data); } catch (error: any) { - if(selfprocessError){ + if (selfprocessError){ processError(error); console.error(error); // Log the error for debugging - }else{ + } else { throw error; // Re-throw the error to the caller } } @@ -149,16 +159,21 @@ export async function deleteIdWithData( * @param ref * @param fromJson */ -export async function getList(endpoint: string, ref: Ref, fromJson: (data: any) => T, selfprocessError: boolean = true): Promise { +export async function getList( + endpoint: string, + ref: Ref, + fromJson: (data: any) => T, + selfprocessError: boolean = true, +): Promise { try { const response = await client.get(endpoint); ref.value = response.data.map((data: T) => fromJson(data)); } catch (error: any) { ref.value = []; // Set the ref to an empty array - if(selfprocessError){ + if (selfprocessError){ processError(error); console.error(error); // Log the error for debugging - }else{ + } else { throw error; // Re-throw the error to the caller } } @@ -204,10 +219,10 @@ export async function getPaginatedList( results: [], }; - if(selfprocessError){ + if (selfprocessError){ processError(error); console.error(error); // Log the error for debugging - }else{ + } else { throw error; // Re-throw the error to the caller } } @@ -239,7 +254,7 @@ export async function getListMerged( if(selfprocessError){ processError(error); console.error(error); // Log the error for debugging - }else{ + } else { throw error; // Re-throw the error to the caller } } diff --git a/frontend/src/composables/services/project.service.ts b/frontend/src/composables/services/project.service.ts index 63150293..92d6c7f0 100644 --- a/frontend/src/composables/services/project.service.ts +++ b/frontend/src/composables/services/project.service.ts @@ -1,7 +1,7 @@ import { Project } from '@/types/Project'; import { type Ref, ref } from 'vue'; import { endpoints } from '@/config/endpoints.ts'; -import { create, deleteId, get, getList, patch} from '@/composables/services/helpers.ts'; +import { create, deleteId, get, getList, patch } from '@/composables/services/helpers.ts'; import { type Response } from '@/types/Response.ts'; interface ProjectState {