✨ Add "trusted" and "source" to Timetable
This commit is contained in:
@ -29,7 +29,11 @@ export async function getTimetable(req, res) {
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.send(timetable.data);
|
res.send({
|
||||||
|
trusted: timetable.trused,
|
||||||
|
source: timetable.source,
|
||||||
|
data: timetable.data,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function for converting a date string
|
// Helper function for converting a date string
|
||||||
|
@ -15,6 +15,8 @@ model Timetable {
|
|||||||
validFrom DateTime @default(now())
|
validFrom DateTime @default(now())
|
||||||
validUntil DateTime?
|
validUntil DateTime?
|
||||||
data Json
|
data Json
|
||||||
|
source String?
|
||||||
|
trused Boolean @default(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
model Substitution {
|
model Substitution {
|
||||||
|
@ -22,7 +22,7 @@ watch(timetableGroups, (newValue) => {
|
|||||||
export const selectedDate = ref(new Date(new Date().setUTCHours(0, 0, 0, 0)));
|
export const selectedDate = ref(new Date(new Date().setUTCHours(0, 0, 0, 0)));
|
||||||
export const selectedDay = computed(() => selectedDate.value.getDay() - 1);
|
export const selectedDay = computed(() => selectedDate.value.getDay() - 1);
|
||||||
|
|
||||||
export const timetable = ref([]);
|
export const timetable = ref({ trusted: true });
|
||||||
export const substitutions = ref([]);
|
export const substitutions = ref([]);
|
||||||
export const history = ref([]);
|
export const history = ref([]);
|
||||||
export const classList = ref([]);
|
export const classList = ref([]);
|
||||||
@ -48,7 +48,8 @@ export const substitutionsForDate = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const parsedTimetable = computed(() => {
|
export const parsedTimetable = computed(() => {
|
||||||
return timetable.value.map((day) => {
|
if (!timetable.value.data) return [];
|
||||||
|
return timetable.value.data.map((day) => {
|
||||||
const newDay = [];
|
const newDay = [];
|
||||||
for (const lesson of day) {
|
for (const lesson of day) {
|
||||||
var usedLesson = lesson;
|
var usedLesson = lesson;
|
||||||
@ -76,7 +77,8 @@ export const parsedTimetable = computed(() => {
|
|||||||
|
|
||||||
export const possibleTimetableGroups = computed(() => {
|
export const possibleTimetableGroups = computed(() => {
|
||||||
const foundTimetableGroups = [];
|
const foundTimetableGroups = [];
|
||||||
for (const day of timetable.value) {
|
if (!timetable.value.data) return [];
|
||||||
|
for (const day of timetable.value.data) {
|
||||||
for (const lesson of day) {
|
for (const lesson of day) {
|
||||||
if (Array.isArray(lesson)) {
|
if (Array.isArray(lesson)) {
|
||||||
for (const group of lesson) {
|
for (const group of lesson) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
|
timetable,
|
||||||
parsedTimetable,
|
parsedTimetable,
|
||||||
classFilter,
|
classFilter,
|
||||||
classList,
|
classList,
|
||||||
@ -11,7 +12,7 @@ import { getSubstitutionColor } from "../util";
|
|||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import TimetableSetup from "../components/initial-setup.vue";
|
import TimetableSetup from "../components/initial-setup.vue";
|
||||||
|
|
||||||
const timetable = computed(() => {
|
const linkedTimetable = computed(() => {
|
||||||
const currentDay = parsedTimetable.value[selectedDay.value];
|
const currentDay = parsedTimetable.value[selectedDay.value];
|
||||||
if (!currentDay) return [];
|
if (!currentDay) return [];
|
||||||
const newDay = currentDay.map((e, index) => {
|
const newDay = currentDay.map((e, index) => {
|
||||||
@ -59,7 +60,14 @@ function isCancelled(substitution) {
|
|||||||
v-model="classFilter"
|
v-model="classFilter"
|
||||||
/>
|
/>
|
||||||
<div class="timetable">
|
<div class="timetable">
|
||||||
<template v-for="(lesson, index) in timetable" :key="index">
|
<div class="container">
|
||||||
|
<div class="trust-warning" v-if="!timetable.trusted">
|
||||||
|
<b>Warning:</b> The Data source of the Timetable data
|
||||||
|
<b>({{ timetable.source }})</b> is not trustworthy, which means the
|
||||||
|
timetable may be incorrect!
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<template v-for="(lesson, index) in linkedTimetable" :key="index">
|
||||||
<div class="lesson" :style="getSubstitutionColor(lesson.substitution)">
|
<div class="lesson" :style="getSubstitutionColor(lesson.substitution)">
|
||||||
<span class="hour">{{ index + 1 }}</span>
|
<span class="hour">{{ index + 1 }}</span>
|
||||||
<div class="infos">
|
<div class="infos">
|
||||||
@ -104,6 +112,19 @@ function isCancelled(substitution) {
|
|||||||
padding: 0px 10px 80px 10px;
|
padding: 0px 10px 80px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
.trust-warning {
|
||||||
|
border: 1px solid #b71c1c;
|
||||||
|
background-color: #412727;
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 3px 10px;
|
||||||
|
margin-top: 10px;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
.lesson {
|
.lesson {
|
||||||
display: grid;
|
display: grid;
|
||||||
background-color: var(--substitution-background-unchanged);
|
background-color: var(--substitution-background-unchanged);
|
||||||
|
Reference in New Issue
Block a user