Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query refactor #152

Merged
merged 41 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8b374b0
fix useUserQuery
reyniersbram Apr 25, 2024
2740319
remove top level package lock
reyniersbram Apr 25, 2024
5a61ac5
add some documentation to user queries
reyniersbram Apr 25, 2024
886c149
useUserQuery now accepts either a ref or a raw value
reyniersbram Apr 25, 2024
ee6f579
run formatter
reyniersbram Apr 25, 2024
c04cc1e
changed enabled from computed to getter
reyniersbram Apr 25, 2024
dde750c
update Subject queries, fixes: #143
reyniersbram Apr 25, 2024
f22c40e
Merge branch 'dev' into query-refactor
reyniersbram May 2, 2024
3b35138
update mutation to register to subject
reyniersbram May 2, 2024
9c472c8
improved authorized_fetch
reyniersbram May 2, 2024
85fc313
show projects on homescreen, fixes: #134
reyniersbram May 2, 2024
75f9684
Merge branch 'dev' into query-refactor
reyniersbram May 7, 2024
dc05ff5
run formatter
reyniersbram May 7, 2024
e591b82
fix download_file util
reyniersbram May 10, 2024
b2d3fdd
Merge branch 'dev' into query-refactor
reyniersbram May 10, 2024
3e7b81e
clean up subject queries
reyniersbram May 10, 2024
0a08785
clean up user services
reyniersbram May 10, 2024
8004cfa
Merge branch 'dev' into query-refactor
reyniersbram May 10, 2024
7f1871b
clean up project queries and services
reyniersbram May 10, 2024
1027333
Merge branch 'dev' into query-refactor
reyniersbram May 12, 2024
815ef87
review group services
reyniersbram May 12, 2024
3b053a0
review submission services
reyniersbram May 12, 2024
07473d5
refactor submission queries
reyniersbram May 12, 2024
38f36fc
optimistic updates for group queries
reyniersbram May 13, 2024
46cd89e
fix views using group/submission queries
reyniersbram May 13, 2024
171bbaf
Merge branch 'dev' into query-refactor
reyniersbram May 13, 2024
60e00db
try to fix some tests
reyniersbram May 13, 2024
47d55ca
run formatter
reyniersbram May 13, 2024
4de0cbd
remove todo's
reyniersbram May 13, 2024
271d9af
frontend warnings fix
masinnae May 13, 2024
7c818d7
Merge remote-tracking branch 'origin/query-refactor' into query-refactor
masinnae May 13, 2024
bec85c2
fix subjects query
reyniersbram May 13, 2024
5baca93
run formatter
reyniersbram May 13, 2024
e4fe143
fix useProjectGroupsQuery
reyniersbram May 13, 2024
7e5e0a0
fix tests
reyniersbram May 13, 2024
1703906
fix delete group mutation
reyniersbram May 15, 2024
5acbe54
fix leave and join group mutations
reyniersbram May 15, 2024
bd68539
Merge branch 'dev' into query-refactor
reyniersbram May 15, 2024
601d23d
run formatter
reyniersbram May 15, 2024
e7bbe9b
Merge branch 'dev' into query-refactor
reyniersbram May 16, 2024
7595918
fix user groups query not refreshing
reyniersbram May 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frontend/src/components/buttons/GroupButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { computed, toRefs } from "vue";
import {
useJoinGroupUserMutation,
useLeaveGroupUserMutation,
useRemoveGroupMutation,
useDeleteGroupMutation,
useUserGroupsQuery,
} from "@/queries/Group";

Expand Down Expand Up @@ -63,7 +63,7 @@ const { mutateAsync: leaveGroup } = useLeaveGroupUserMutation();

const { mutateAsync: joinGroup } = useJoinGroupUserMutation();

const { mutateAsync: removeGroup } = useRemoveGroupMutation();
const { mutateAsync: removeGroup } = useDeleteGroupMutation();
</script>

<style scoped></style>
44 changes: 11 additions & 33 deletions frontend/src/components/home/cards/DeadlinesCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,15 @@
import HomeScreenCard from "@/components/home/cards/HomeScreenCard.vue";
import DeadlineItem from "@/components/home/listcontent/DeadlineItem.vue";
import { type Deadline } from "@/models/Project";
import { ref } from "vue";
const deadlines = ref<Deadline[]>([
{
project: {
id: 1,
name: "project A",
subject_id: 1,
deadline: new Date(2024, 4, 28, 23, 59),
description: "a description",
},
status: "none",
},
{
project: {
id: 2,
name: "project B",
subject_id: 2,
deadline: new Date(2024, 6, 2, 17, 0),
description: "another description",
},
status: "accepted",
},
{
project: {
id: 3,
name: "project C",
subject_id: 3,
deadline: new Date(2024, 5, 5, 22, 0),
description: "last description",
},
status: "rejected",
},
]);
import { useProjectsQuery } from "@/queries/Project";
import { computed } from "vue";

const { data: projects } = useProjectsQuery();
const deadlines = computed<Deadline[]>(
() =>
projects.value?.map((project) => ({
project,
status: "none",
reyniersbram marked this conversation as resolved.
Show resolved Hide resolved
})) || []
);
pieterjanin marked this conversation as resolved.
Show resolved Hide resolved
</script>
6 changes: 5 additions & 1 deletion frontend/src/components/home/cards/SubjectsCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<!-- TODO: Add error handling -->
<h1 v-else-if="isSubjectsError">Error loading subjects</h1>
<HomeScreenCard v-else :title="'homescreen.subjects'">
<SubjectItem v-for="subject in subjects" :subject="subject" :key="subject.id" />
<SubjectItem
v-for="subject in [...subjects!.as_student, ...subjects!.as_instructor]"
:subject="subject"
:key="subject.id"
/>
</HomeScreenCard>
</template>

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/project/ProjectSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import type Subject from "@/models/Subject";
import NeedHelpButton from "@/components/buttons/NeedHelpButton.vue";
import { computed, toRefs } from "vue";
import type User from "@/models/User";
import { useUserQuery } from "@/queries/User";
import { useCurrentUserQuery } from "@/queries/User";

const props = defineProps<{
project: Project;
Expand All @@ -44,7 +44,7 @@ const props = defineProps<{

const { project, group, subject, instructors } = toRefs(props);

const { data: user } = useUserQuery(null);
const { data: user } = useCurrentUserQuery();

const isTeacher = computed(() => {
if (!user.value || !instructors.value) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/project/submit/SubmitForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { computed, ref, toRefs } from "vue";
import FilesInput from "@/components/form_elements/FilesInput.vue";
import { useRouter } from "vue-router";
import { useCreateSubmissionMutation } from "@/queries/Submission";
import { useUserGroupQuery } from "@/queries/Group";
import { useProjectGroupQuery } from "@/queries/Group";
import { useI18n } from "vue-i18n";

const props = defineProps<{
Expand All @@ -24,7 +24,7 @@ const { t } = useI18n();

const inputFiles = ref<File[]>([]);
const remarksInput = ref<string | null>(null);
const { data: group } = useUserGroupQuery(projectId);
const { data: group } = useProjectGroupQuery(projectId);
const { mutateAsync } = useCreateSubmissionMutation(computed(() => group.value?.id));

async function formOnSubmit(event: SubmitEvent) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/project/submit/SubmitInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</template>

<script setup lang="ts">
import { useSubmissionsQuery } from "@/queries/Group";
import { useSubmissionsQuery } from "@/queries/Submission";
import { toRefs, computed } from "vue";
import type Project from "@/models/Project";
import type Group from "@/models/Group";
Expand Down
14 changes: 10 additions & 4 deletions frontend/src/components/submission/SubmissionCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@
{{ $t("submission.download_info") }}
</v-card-subtitle>
<v-container>
<v-alert v-if="isError" title="Error" color="error" :text="error.message"></v-alert>
<v-alert
v-if="isError"
title="Error"
color="error"
:text="error!.message"
></v-alert>
<v-skeleton-loader v-else :loading="isLoading" type="card" color="white">
<v-col>
<v-chip
Expand All @@ -65,11 +70,12 @@
</template>

<script setup lang="ts">
import { Status, type Submission } from "@/models/Submission";
import type { Status } from "@/models/Submission";
import { useFilesQuery } from "@/queries/Submission";
import { toRefs, computed } from "vue";
import { download_file } from "@/utils.ts";
import Project from "@/models/Project";
import { download_file } from "@/utils";
import type Project from "@/models/Project";
import type Submission from "@/models/Submission";

const props = defineProps<{
submission: Submission;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/composables/useIsAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { computed } from "vue";
import { useUserQuery } from "@/queries/User";
import { useCurrentUserQuery } from "@/queries/User";

export default function useIsAdmin() {
const { data: user } = useUserQuery(null);
const { data: user } = useCurrentUserQuery();
const isAdmin = computed(() => user.value?.is_admin || false);
return { isAdmin };
}
4 changes: 2 additions & 2 deletions frontend/src/composables/useIsTeacher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { computed } from "vue";
import { useUserQuery } from "@/queries/User";
import { useCurrentUserQuery } from "@/queries/User";

export default function useIsTeacher() {
const { data: user } = useUserQuery(null);
const { data: user } = useCurrentUserQuery();
const isTeacher = computed(() => user.value?.is_teacher || false);
return { isTeacher };
}
2 changes: 1 addition & 1 deletion frontend/src/models/Group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import User from "@/models/User";
import type User from "@/models/User";

export default interface Group {
id: number;
Expand Down
Loading
Loading