wip: Move code to composable
This commit is contained in:
parent
bfdb992d60
commit
3cc46f70a5
|
|
@ -10,6 +10,7 @@ import {
|
||||||
} from "@/services/circle";
|
} from "@/services/circle";
|
||||||
import type { DashboardDueDate, DashboardPersonType } from "@/services/dashboard";
|
import type { DashboardDueDate, DashboardPersonType } from "@/services/dashboard";
|
||||||
import {
|
import {
|
||||||
|
courseIdForCourseSlug,
|
||||||
fetchDashboardDueDates,
|
fetchDashboardDueDates,
|
||||||
fetchDashboardPersons,
|
fetchDashboardPersons,
|
||||||
fetchStatisticData,
|
fetchStatisticData,
|
||||||
|
|
@ -613,10 +614,13 @@ export function useCourseCircleProgress(circles: Ref<CircleType[] | undefined>)
|
||||||
return { inProgressCirclesCount, circlesCount };
|
return { inProgressCirclesCount, circlesCount };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useCourseStatisticsv2(courseId: string) {
|
export function useCourseStatisticsv2(courseSlug: string) {
|
||||||
|
const dashboardStore = useDashboardStore();
|
||||||
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;
|
||||||
try {
|
try {
|
||||||
|
|
@ -645,5 +649,6 @@ export function useCourseStatisticsv2(courseId: string) {
|
||||||
loading,
|
loading,
|
||||||
courseSessionName,
|
courseSessionName,
|
||||||
circleMeta,
|
circleMeta,
|
||||||
|
courseId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDashboardStore } from "@/stores/dashboard";
|
|
||||||
import type {
|
import type {
|
||||||
AssignmentCompletionMetricsType,
|
AssignmentCompletionMetricsType,
|
||||||
AssignmentStatisticsRecordType,
|
AssignmentStatisticsRecordType,
|
||||||
|
|
@ -8,21 +7,14 @@ import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue"
|
||||||
import { useCourseStatisticsv2 } from "@/composables";
|
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 { courseIdForCourseSlug } from "@/services/dashboard";
|
|
||||||
import ItProgress from "@/components/ui/ItProgress.vue";
|
import ItProgress from "@/components/ui/ItProgress.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const dashboardStore = useDashboardStore();
|
|
||||||
|
|
||||||
const courseId = courseIdForCourseSlug(
|
|
||||||
dashboardStore.dashboardConfigsv2,
|
|
||||||
props.courseSlug
|
|
||||||
);
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
||||||
useCourseStatisticsv2(courseId);
|
useCourseStatisticsv2(props.courseSlug);
|
||||||
|
|
||||||
const assignmentStats = (metrics: AssignmentCompletionMetricsType) => {
|
const assignmentStats = (metrics: AssignmentCompletionMetricsType) => {
|
||||||
if (!metrics.ranking_completed) {
|
if (!metrics.ranking_completed) {
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,17 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDashboardStore } from "@/stores/dashboard";
|
|
||||||
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 { useCourseStatisticsv2 } from "@/composables";
|
||||||
import { getDateString } from "@/components/dueDates/dueDatesUtils";
|
import { getDateString } from "@/components/dueDates/dueDatesUtils";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { courseIdForCourseSlug } from "@/services/dashboard";
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const dashboardStore = useDashboardStore();
|
|
||||||
|
|
||||||
const courseId = courseIdForCourseSlug(
|
|
||||||
dashboardStore.dashboardConfigsv2,
|
|
||||||
props.courseSlug
|
|
||||||
);
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
||||||
useCourseStatisticsv2(courseId);
|
useCourseStatisticsv2(props.courseSlug);
|
||||||
|
|
||||||
const attendanceStats = (present: number, total: number) => {
|
const attendanceStats = (present: number, total: number) => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,36 +1,20 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDashboardStore } from "@/stores/dashboard";
|
|
||||||
import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
|
|
||||||
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";
|
import { useCourseStatisticsv2 } from "@/composables";
|
||||||
import { courseIdForCourseSlug } from "@/services/dashboard";
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const dashboardStore = useDashboardStore();
|
|
||||||
|
|
||||||
const courseId = courseIdForCourseSlug(
|
|
||||||
dashboardStore.dashboardConfigsv2,
|
|
||||||
props.courseSlug
|
|
||||||
);
|
|
||||||
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
||||||
useCourseStatisticsv2(courseId);
|
useCourseStatisticsv2(props.courseSlug);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<main v-if="!loading">
|
<main v-if="!loading">
|
||||||
<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>
|
||||||
<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?.competences.records" class="mt-8 bg-white">
|
<div v-if="courseStatistics?.competences.records" class="mt-8 bg-white">
|
||||||
<StatisticFilterList
|
<StatisticFilterList
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDashboardStore } from "@/stores/dashboard";
|
|
||||||
import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
|
import ItDropdownSelect from "@/components/ui/ItDropdownSelect.vue";
|
||||||
import type {
|
import type {
|
||||||
FeedbackStatisticsRecordType,
|
FeedbackStatisticsRecordType,
|
||||||
|
|
@ -8,21 +7,13 @@ import type {
|
||||||
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
import StatisticFilterList from "@/components/dashboard/StatisticFilterList.vue";
|
||||||
import { useCourseStatisticsv2 } from "@/composables";
|
import { useCourseStatisticsv2 } from "@/composables";
|
||||||
import { getBlendedColorForRating } from "@/utils/ratingToColor";
|
import { getBlendedColorForRating } from "@/utils/ratingToColor";
|
||||||
import { courseIdForCourseSlug } from "@/services/dashboard";
|
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
courseSlug: string;
|
courseSlug: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const dashboardStore = useDashboardStore();
|
|
||||||
|
|
||||||
const courseId = courseIdForCourseSlug(
|
|
||||||
dashboardStore.dashboardConfigsv2,
|
|
||||||
props.courseSlug
|
|
||||||
);
|
|
||||||
|
|
||||||
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
const { courseStatistics, loading, courseSessionName, circleMeta } =
|
||||||
useCourseStatisticsv2(courseId);
|
useCourseStatisticsv2(props.courseSlug);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue