Skip to content

Commit

Permalink
chore: better error messages (#446)
Browse files Browse the repository at this point in the history
* chore: make services throw errors to caller if requested

* chore: make services throw errors to caller if requested

* chore: place init?:boolean back

* chore: rewrite landers code

* chore: fix linter

* chore: fix linter

* chore: fix linter

* chore: fix linter

* chore: fix linter

* chore: fix linter

* chore: fix linter

* chore: fix linter

* chore: first part of merge

* fix: project service

* chore: linting

* chore: fix help

* chore: merge & toast example

---------

Co-authored-by: EwoutV <ewoutverlinde@hotmail.com>
  • Loading branch information
tyboro2002 and EwoutV committed May 23, 2024
1 parent 694a932 commit 4c95b46
Show file tree
Hide file tree
Showing 21 changed files with 587 additions and 350 deletions.
10 changes: 0 additions & 10 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@ export default defineConfig({
// { text: 'Examples', link: '/markdown-examples' }
],

sidebar: [
{
text: "Algemeen",
items: [
// { text: 'Markdown Examples', link: '/markdown-examples' },
// { text: 'Runtime API Examples', link: '/api-examples' }
],
},
],

socialLinks: [
{ icon: "github", link: "https://github.com/SELab-2/UGent-7" },
],
Expand Down
11 changes: 1 addition & 10 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ layout: home

hero:
name: "Ypovoli"
text: "TODO"
tagline: TODO
text: Help pagina
actions:
- theme: brand
text: Student
Expand All @@ -19,13 +18,5 @@ hero:
- theme: brand
text: Admin
link: /en/admin-examples

features:
- title: Feature A
details: lorem english
- title: Feature B
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
- title: Feature C
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
---

5 changes: 1 addition & 4 deletions docs/en/student-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ This page describes how to interact with Ypovoli as a student.
- Scroll to the "My Courses" section.
- Click on the course of the desired project.
- Under the "Current Projects" section, you will see all projects for this specific course.
- Option 4:
- Click on "Projects" in the navigation bar.
- You will see an overview of all your projects.

::: info Project card explanation
![project card](../assets/en/project-card.png)
Expand Down Expand Up @@ -135,4 +132,4 @@ This page describes how to interact with Ypovoli as a student.

## View Previous Submissions Status
- Go to the submission page.
- It says there. !!! TODO !!!
- It says there.
11 changes: 1 addition & 10 deletions docs/nl/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ layout: home

hero:
name: "Ypovoli"
text: "TODO"
tagline: TODO
text: Help page
actions:
- theme: brand
text: Student
Expand All @@ -19,13 +18,5 @@ hero:
- theme: brand
text: Admin
link: /nl/admin-examples

features:
- title: Feature A
details: lorem nederlands
- title: Feature B
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
- title: Feature C
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
---

5 changes: 1 addition & 4 deletions docs/nl/student-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ Deze pagina beschrijft hoe u als student met Ypovoli interageert.
- Scrol naar de sectie "Mijn vakken".
- Druk hier op het vak van het gezochte project.
- Onder de sectie "Lopende projecten" ziet u alle projecten voor dit specifieke vak.
- Optie 4:
- Druk in de navigatiebalk op "Projecten".
- U ziet een overzicht van al uw projecten.

::: info Project kaart uitleg
<!-- TODO maybey ne fotoke en me numerkes aanduide -->
Expand Down Expand Up @@ -136,4 +133,4 @@ De kaart is als volgt ingedeeld:

## Status vorige indieningen bekijken
- Ga naar indien pagina.
- Staat daar bij. !!! TODO !!!
- Staat daar bij.
24 changes: 13 additions & 11 deletions frontend/src/composables/services/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ import { User } from '@/types/users/User.ts';
interface AdminState {
admins: Ref<User[] | null>;
admin: Ref<User | null>;
getAdminByID: (id: string) => Promise<void>;
getAdmins: () => Promise<void>;
createAdmin: (adminData: User) => Promise<void>;
deleteAdmin: (id: string) => Promise<void>;
getAdminByID: (id: string, selfProcessError?: boolean) => Promise<void>;
getAdmins: (selfProcessError?: boolean) => Promise<void>;
createAdmin: (adminData: User, selfProcessError?: boolean) => Promise<void>;
deleteAdmin: (id: string, selfProcessError?: boolean) => Promise<void>;
}

export function useAdmin(): AdminState {
const admins = ref<User[] | null>(null);
const admin = ref<User | null>(null);

async function getAdminByID(id: string): Promise<void> {
async function getAdminByID(id: string, selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.admins.retrieve.replace('{id}', id);
await get<User>(endpoint, admin, User.fromJSON);
await get<User>(endpoint, admin, User.fromJSON, selfProcessError);
}

async function getAdmins(): Promise<void> {
async function getAdmins(selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.admins.index;
await getList<User>(endpoint, admins, User.fromJSON);
await getList<User>(endpoint, admins, User.fromJSON, selfProcessError);
}

async function createAdmin(user: User): Promise<void> {
async function createAdmin(user: User, selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.admins.index;
await createToast<User>(
'admin',
Expand All @@ -36,12 +36,14 @@ export function useAdmin(): AdminState {
},
admin,
User.fromJSON,
undefined,
selfProcessError,
);
}

async function deleteAdmin(id: string): Promise<void> {
async function deleteAdmin(id: string, selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.admins.retrieve.replace('{id}', id);
await deleteId<User>(endpoint, admin, User.fromJSON);
await deleteId<User>(endpoint, admin, User.fromJSON, selfProcessError);
}

return {
Expand Down
82 changes: 59 additions & 23 deletions frontend/src/composables/services/assistant.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ interface AssistantState {
assistant: Ref<Assistant | null>;
response: Ref<Response | null>;
assistantPagination: Ref<PaginatorResponse<Assistant> | null>;
getAssistantByID: (id: string, init?: boolean) => Promise<void>;
getAssistantsByCourse: (courseId: string) => Promise<void>;
getAssistants: () => Promise<void>;
searchAssistants: (filters: Filter, page: number, pageSize: number) => Promise<void>;
assistantJoinCourse: (courseId: string, assistantId: string) => Promise<void>;
assistantLeaveCourse: (courseId: string, assistantId: string) => Promise<void>;
createAssistant: (assistantData: Assistant) => Promise<void>;
deleteAssistant: (id: string) => Promise<void>;
getAssistantByID: (id: string, init?: boolean, selfProcessError?: boolean) => Promise<void>;
getAssistantsByCourse: (courseId: string, selfProcessError?: boolean) => Promise<void>;
getAssistants: (selfProcessError?: boolean) => Promise<void>;
searchAssistants: (filters: Filter, page: number, pageSize: number, selfProcessError?: boolean) => Promise<void>;
assistantJoinCourse: (courseId: string, assistantId: string, selfProcessError?: boolean) => Promise<void>;
assistantLeaveCourse: (courseId: string, assistantId: string, selfProcessError?: boolean) => Promise<void>;
createAssistant: (assistantData: Assistant, selfProcessError?: boolean) => Promise<void>;
deleteAssistant: (id: string, selfProcessError?: boolean) => Promise<void>;
}

export function useAssistant(): AssistantState {
Expand All @@ -37,37 +37,71 @@ export function useAssistant(): AssistantState {
const response = ref<Response | null>(null);
const assistantPagination = ref<PaginatorResponse<Assistant> | null>(null);

async function getAssistantByID(id: string): Promise<void> {
async function getAssistantByID(id: string, selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.assistants.retrieve.replace('{id}', id);
await get<Assistant>(endpoint, assistant, Assistant.fromJSON);
await get<Assistant>(endpoint, assistant, Assistant.fromJSON, selfProcessError);
}

async function getAssistantsByCourse(courseId: string): Promise<void> {
async function getAssistantsByCourse(courseId: string, selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.assistants.byCourse.replace('{courseId}', courseId);
await getList<Assistant>(endpoint, assistants, Assistant.fromJSON);
await getList<Assistant>(endpoint, assistants, Assistant.fromJSON, selfProcessError);
}

async function getAssistants(): Promise<void> {
async function getAssistants(selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.assistants.index;
await getList<Assistant>(endpoint, assistants, Assistant.fromJSON);
await getList<Assistant>(endpoint, assistants, Assistant.fromJSON, selfProcessError);
}

async function searchAssistants(filters: Filter, page: number, pageSize: number): Promise<void> {
async function searchAssistants(
filters: Filter,
page: number,
pageSize: number,
selfProcessError: boolean = true,
): Promise<void> {
const endpoint = endpoints.assistants.search;
await getPaginatedList<Assistant>(endpoint, filters, page, pageSize, assistantPagination, Assistant.fromJSON);
await getPaginatedList<Assistant>(
endpoint,
filters,
page,
pageSize,
assistantPagination,
Assistant.fromJSON,
selfProcessError,
);
}

async function assistantJoinCourse(courseId: string, assistantId: string): Promise<void> {
async function assistantJoinCourse(
courseId: string,
assistantId: string,
selfProcessError: boolean = true,
): Promise<void> {
const endpoint = endpoints.assistants.byCourse.replace('{courseId}', courseId);
await create<Response>(endpoint, { assistant: assistantId }, response, Response.fromJSON);
await create<Response>(
endpoint,
{ assistant: assistantId },
response,
Response.fromJSON,
undefined,
selfProcessError,
);
}

async function assistantLeaveCourse(courseId: string, assistantId: string): Promise<void> {
async function assistantLeaveCourse(
courseId: string,
assistantId: string,
selfProcessError: boolean = true,
): Promise<void> {
const endpoint = endpoints.assistants.byCourse.replace('{courseId}', courseId);
await deleteIdWithData<Response>(endpoint, { assistant: assistantId }, response, Response.fromJSON);
await deleteIdWithData<Response>(
endpoint,
{ assistant: assistantId },
response,
Response.fromJSON,
selfProcessError,
);
}

async function createAssistant(user: User): Promise<void> {
async function createAssistant(user: User, selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.assistants.index;
await createToast<Assistant>(
'assistant',
Expand All @@ -77,12 +111,14 @@ export function useAssistant(): AssistantState {
},
assistant,
Assistant.fromJSON,
undefined,
selfProcessError,
);
}

async function deleteAssistant(id: string): Promise<void> {
async function deleteAssistant(id: string, selfProcessError: boolean = true): Promise<void> {
const endpoint = endpoints.assistants.retrieve.replace('{id}', id);
await deleteId<Assistant>(endpoint, assistant, Assistant.fromJSON);
await deleteId<Assistant>(endpoint, assistant, Assistant.fromJSON, selfProcessError);
}

return {
Expand Down
Loading

0 comments on commit 4c95b46

Please sign in to comment.