wip: Move loading of data to parent component
This commit is contained in:
parent
3cc46f70a5
commit
d8316b177d
|
|
@ -619,10 +619,13 @@ export function useCourseStatisticsv2(courseSlug: string) {
|
||||||
const courseStatistics = ref<CourseStatisticsType[] | null>(null);
|
const courseStatistics = ref<CourseStatisticsType[] | null>(null);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
const courseId = courseIdForCourseSlug(dashboardStore.dashboardConfigsv2, courseSlug);
|
|
||||||
|
|
||||||
const fetchData = async () => {
|
const fetchData = async () => {
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
|
await dashboardStore.loadDashboardDetails();
|
||||||
|
const courseId = courseIdForCourseSlug(
|
||||||
|
dashboardStore.dashboardConfigsv2,
|
||||||
|
courseSlug
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
courseStatistics.value = await fetchStatisticData(courseId);
|
courseStatistics.value = await fetchStatisticData(courseId);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -649,6 +652,5 @@ export function useCourseStatisticsv2(courseSlug: string) {
|
||||||
loading,
|
loading,
|
||||||
courseSessionName,
|
courseSessionName,
|
||||||
circleMeta,
|
circleMeta,
|
||||||
courseId,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,17 @@ import type {
|
||||||
AssignmentStatisticsRecordType,
|
AssignmentStatisticsRecordType,
|
||||||
} from "@/gql/graphql";
|
} from "@/gql/graphql";
|
||||||
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
||||||
import { useCourseStatisticsv2 } from "@/composables";
|
|
||||||
import { getDateString } from "@/components/dueDates/dueDatesUtils";
|
import { getDateString } from "@/components/dueDates/dueDatesUtils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import ItProgress from "@/components/ui/ItProgress.vue";
|
import ItProgress from "@/components/ui/ItProgress.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
|
courseStatistics: any;
|
||||||
|
courseSessionName: any;
|
||||||
|
circleMeta: any;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
|
||||||
useCourseStatisticsv2(props.courseSlug);
|
|
||||||
|
|
||||||
const assignmentStats = (metrics: AssignmentCompletionMetricsType) => {
|
const assignmentStats = (metrics: AssignmentCompletionMetricsType) => {
|
||||||
if (!metrics.ranking_completed) {
|
if (!metrics.ranking_completed) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -38,7 +37,7 @@ const total = (metrics: AssignmentCompletionMetricsType) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main v-if="!loading">
|
<main>
|
||||||
<div class="mb-10 flex items-center justify-between">
|
<div class="mb-10 flex items-center justify-between">
|
||||||
<h3>{{ $t("a.Kompetenznachweis-Elemente") }}</h3>
|
<h3>{{ $t("a.Kompetenznachweis-Elemente") }}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,16 @@
|
||||||
import type { PresenceRecordStatisticsType } from "@/gql/graphql";
|
import type { PresenceRecordStatisticsType } from "@/gql/graphql";
|
||||||
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
||||||
import ItProgress from "@/components/ui/ItProgress.vue";
|
import ItProgress from "@/components/ui/ItProgress.vue";
|
||||||
import { useCourseStatisticsv2 } from "@/composables";
|
|
||||||
import { getDateString } from "@/components/dueDates/dueDatesUtils";
|
import { getDateString } from "@/components/dueDates/dueDatesUtils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
|
courseStatistics: any;
|
||||||
|
courseSessionName: any;
|
||||||
|
circleMeta: any;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
|
||||||
useCourseStatisticsv2(props.courseSlug);
|
|
||||||
|
|
||||||
const attendanceStats = (present: number, total: number) => {
|
const attendanceStats = (present: number, total: number) => {
|
||||||
return {
|
return {
|
||||||
SUCCESS: present,
|
SUCCESS: present,
|
||||||
|
|
@ -23,7 +22,7 @@ const attendanceStats = (present: number, total: number) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main v-if="!loading">
|
<main>
|
||||||
<div class="mb-10 flex items-center justify-between">
|
<div class="mb-10 flex items-center justify-between">
|
||||||
<h3>{{ $t("Anwesenheit") }}</h3>
|
<h3>{{ $t("Anwesenheit") }}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { CompetenceRecordStatisticsType } from "@/gql/graphql";
|
import type { CompetenceRecordStatisticsType } from "@/gql/graphql";
|
||||||
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
||||||
import { useCourseStatisticsv2 } from "@/composables";
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
|
courseStatistics: any;
|
||||||
|
courseSessionName: any;
|
||||||
|
circleMeta: any;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
|
||||||
useCourseStatisticsv2(props.courseSlug);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main v-if="!loading">
|
<main>
|
||||||
<div class="mb-10 flex items-center justify-between">
|
<div class="mb-10 flex items-center justify-between">
|
||||||
<h3>{{ $t("a.Selbsteinschätzung") }}</h3>
|
<h3>{{ $t("a.Selbsteinschätzung") }}</h3>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,23 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
|
|
||||||
import type {
|
import type {
|
||||||
FeedbackStatisticsRecordType,
|
FeedbackStatisticsRecordType,
|
||||||
PresenceRecordStatisticsType,
|
PresenceRecordStatisticsType,
|
||||||
} from "@/gql/graphql";
|
} from "@/gql/graphql";
|
||||||
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
||||||
import { useCourseStatisticsv2 } from "@/composables";
|
|
||||||
import { getBlendedColorForRating } from "@/utils/ratingToColor";
|
import { getBlendedColorForRating } from "@/utils/ratingToColor";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
|
courseStatistics: any;
|
||||||
|
courseSessionName: any;
|
||||||
|
circleMeta: any;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
|
||||||
useCourseStatisticsv2(props.courseSlug);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main v-if="!loading">
|
<main>
|
||||||
<div class="mb-10 flex items-center justify-between">
|
<div class="mb-10 flex items-center justify-between">
|
||||||
<h3>{{ $t("a.Feedback Teilnehmer") }}</h3>
|
<h3>{{ $t("a.Feedback Teilnehmer") }}</h3>
|
||||||
<ItDropdownSelect
|
|
||||||
:model-value="dashboardStore.currentDashboardConfig"
|
|
||||||
class="mt-4 w-full lg:mt-0 lg:w-96"
|
|
||||||
:items="dashboardStore.dashboardConfigs"
|
|
||||||
@update:model-value="dashboardStore.switchAndLoadDashboardConfig"
|
|
||||||
></ItDropdownSelect>
|
|
||||||
</div>
|
</div>
|
||||||
<div v-if="courseStatistics?.feedback_responses.records" class="mt-8 bg-white">
|
<div v-if="courseStatistics?.feedback_responses.records" class="mt-8 bg-white">
|
||||||
<StatisticFilterList
|
<StatisticFilterList
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,18 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDashboardStore } from "@/stores/dashboard";
|
|
||||||
import { onMounted } from "vue";
|
|
||||||
import LoadingSpinner from "@/components/ui/LoadingSpinner.vue";
|
import LoadingSpinner from "@/components/ui/LoadingSpinner.vue";
|
||||||
|
import { useCourseStatisticsv2 } from "@/composables";
|
||||||
|
|
||||||
const dashboardStore = useDashboardStore();
|
const props = defineProps<{
|
||||||
dashboardStore.loading = true;
|
courseSlug: string;
|
||||||
|
}>();
|
||||||
|
|
||||||
onMounted(async () => {
|
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
||||||
console.log("onMount StatisticParentPage", dashboardStore.loading);
|
useCourseStatisticsv2(props.courseSlug);
|
||||||
await dashboardStore.loadDashboardDetails();
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="bg-gray-200">
|
<div class="bg-gray-200">
|
||||||
<div v-if="dashboardStore.loading" class="m-8 flex justify-center">
|
<div v-if="loading" class="m-8 flex justify-center">
|
||||||
<LoadingSpinner />
|
<LoadingSpinner />
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="container-large flex flex-col space-y-8">
|
<div v-else class="container-large flex flex-col space-y-8">
|
||||||
|
|
@ -22,7 +20,11 @@ onMounted(async () => {
|
||||||
<it-icon-arrow-left />
|
<it-icon-arrow-left />
|
||||||
<span>{{ $t("general.back") }}</span>
|
<span>{{ $t("general.back") }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
<router-view></router-view>
|
<router-view
|
||||||
|
:course-statistics="courseStatistics"
|
||||||
|
:course-session-name="courseSessionName"
|
||||||
|
:circle-meta="circleMeta"
|
||||||
|
></router-view>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue