🎨 Run updated prettier
This commit is contained in:
@ -30,7 +30,7 @@ async function listTimetables(_, res) {
|
|||||||
source: true,
|
source: true,
|
||||||
trusted: true,
|
trusted: true,
|
||||||
},
|
},
|
||||||
})
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,8 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Clean up expired sessions every hour
|
// Clean up expired sessions every hour
|
||||||
setInterval(async () => {
|
setInterval(
|
||||||
|
async () => {
|
||||||
const sessions = await prisma.session.findMany();
|
const sessions = await prisma.session.findMany();
|
||||||
for (const session of sessions) {
|
for (const session of sessions) {
|
||||||
if (session.validUntil < new Date()) {
|
if (session.validUntil < new Date()) {
|
||||||
@ -152,4 +153,6 @@ setInterval(async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1000 * 60 * 60);
|
},
|
||||||
|
1000 * 60 * 60,
|
||||||
|
);
|
||||||
|
@ -87,15 +87,16 @@ export async function revokeKey(sessionToken, key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clean up expired keys every hour
|
// Clean up expired keys every hour
|
||||||
setInterval(async () => {
|
setInterval(
|
||||||
|
async () => {
|
||||||
const keys = await prisma.key.findMany();
|
const keys = await prisma.key.findMany();
|
||||||
for (const key of keys) {
|
for (const key of keys) {
|
||||||
if (key.validUntil && key.validUntil < new Date()) {
|
if (key.validUntil && key.validUntil < new Date()) {
|
||||||
log(
|
log(
|
||||||
"API / Permissions",
|
"API / Permissions",
|
||||||
`Removed expired key: ${key.key}; Permissions: ${key.permissions.join(
|
`Removed expired key: ${key.key}; Permissions: ${key.permissions.join(
|
||||||
", "
|
", ",
|
||||||
)}`
|
)}`,
|
||||||
);
|
);
|
||||||
await prisma.key.delete({
|
await prisma.key.delete({
|
||||||
where: {
|
where: {
|
||||||
@ -104,4 +105,6 @@ setInterval(async () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1000 * 60 * 60);
|
},
|
||||||
|
1000 * 60 * 60,
|
||||||
|
);
|
||||||
|
@ -44,10 +44,10 @@ new Parser(
|
|||||||
new BolleClient(
|
new BolleClient(
|
||||||
process.env.BOLLE_URL,
|
process.env.BOLLE_URL,
|
||||||
process.env.BOLLE_USER,
|
process.env.BOLLE_USER,
|
||||||
process.env.BOLLE_KEY
|
process.env.BOLLE_KEY,
|
||||||
),
|
),
|
||||||
parseSubstitutionPlan,
|
parseSubstitutionPlan,
|
||||||
process.env.UPDATE_INTERVAL || 1 * 60 * 1000 // Default to 1 minute
|
process.env.UPDATE_INTERVAL || 1 * 60 * 1000, // Default to 1 minute
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create new Auth class to store sessions
|
// Create new Auth class to store sessions
|
||||||
|
@ -5,7 +5,7 @@ const baseUrl = "https://mobileapi.dsbcontrol.de";
|
|||||||
|
|
||||||
export async function getAuthtoken(username, password) {
|
export async function getAuthtoken(username, password) {
|
||||||
const response = await axios.get(
|
const response = await axios.get(
|
||||||
`${baseUrl}/authid?user=${username}&password=${password}&bundleid&appversion&osversion&pushid`
|
`${baseUrl}/authid?user=${username}&password=${password}&bundleid&appversion&osversion&pushid`,
|
||||||
);
|
);
|
||||||
if (response.data == "") throw "Wrong DSB username or password";
|
if (response.data == "") throw "Wrong DSB username or password";
|
||||||
return response.data;
|
return response.data;
|
||||||
@ -13,7 +13,7 @@ export async function getAuthtoken(username, password) {
|
|||||||
|
|
||||||
export async function getTimetables(authtoken) {
|
export async function getTimetables(authtoken) {
|
||||||
const response = await axios.get(
|
const response = await axios.get(
|
||||||
`${baseUrl}/dsbtimetables?authid=${authtoken}`
|
`${baseUrl}/dsbtimetables?authid=${authtoken}`,
|
||||||
);
|
);
|
||||||
const timetables = response.data;
|
const timetables = response.data;
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ export class Parser {
|
|||||||
substitution.class.sort().join(",") &&
|
substitution.class.sort().join(",") &&
|
||||||
substitution.changedSubject == change.subject &&
|
substitution.changedSubject == change.subject &&
|
||||||
substitution.teacher == (change.teacher || "");
|
substitution.teacher == (change.teacher || "");
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
const matchingSubstitution = knownSubstitutions[matchingSubstitutionId];
|
const matchingSubstitution = knownSubstitutions[matchingSubstitutionId];
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ export class Parser {
|
|||||||
});
|
});
|
||||||
log(
|
log(
|
||||||
"Insert / DB",
|
"Insert / DB",
|
||||||
`Created new substitution: S:${newSubstitution.id} C:${substitutionChange.id}`
|
`Created new substitution: S:${newSubstitution.id} C:${substitutionChange.id}`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// If the entry was updated, find the differences
|
// If the entry was updated, find the differences
|
||||||
@ -178,7 +178,7 @@ export class Parser {
|
|||||||
});
|
});
|
||||||
log(
|
log(
|
||||||
"Insert / DB",
|
"Insert / DB",
|
||||||
`Found changed substitution: S:${matchingSubstitution.id} C:${substitutionChange.id}`
|
`Found changed substitution: S:${matchingSubstitution.id} C:${substitutionChange.id}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Remove the substitution from the array to later know the
|
// Remove the substitution from the array to later know the
|
||||||
@ -219,7 +219,7 @@ export class Parser {
|
|||||||
});
|
});
|
||||||
log(
|
log(
|
||||||
"Insert / DB",
|
"Insert / DB",
|
||||||
`Deleted removed substitution: S:${remainingSubstitution.id} C:${substitutionChange.id}`
|
`Deleted removed substitution: S:${remainingSubstitution.id} C:${substitutionChange.id}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ const colorSchemeMedia = window.matchMedia("(prefers-color-scheme: dark)");
|
|||||||
autoTheme.value = autoThemes[colorSchemeMedia.matches];
|
autoTheme.value = autoThemes[colorSchemeMedia.matches];
|
||||||
colorSchemeMedia.addEventListener(
|
colorSchemeMedia.addEventListener(
|
||||||
"change",
|
"change",
|
||||||
(e) => (autoTheme.value = autoThemes[e.matches])
|
(e) => (autoTheme.value = autoThemes[e.matches]),
|
||||||
);
|
);
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -68,7 +68,7 @@ const chars = {
|
|||||||
$t(
|
$t(
|
||||||
getSubstitutionText(
|
getSubstitutionText(
|
||||||
event.change,
|
event.change,
|
||||||
!classFilter || classFilter == "none"
|
!classFilter || classFilter == "none",
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
subject: event.change.change.subject,
|
subject: event.change.change.subject,
|
||||||
@ -76,7 +76,7 @@ const chars = {
|
|||||||
teacher: event.change.teacher,
|
teacher: event.change.teacher,
|
||||||
new_teacher: event.change.change.teacher,
|
new_teacher: event.change.change.teacher,
|
||||||
room: event.change.change.room,
|
room: event.change.change.room,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
}}<span class="notes" v-if="event.change.notes">
|
}}<span class="notes" v-if="event.change.notes">
|
||||||
{{ $t("timetable.notes") }} {{ event.change.notes }}
|
{{ $t("timetable.notes") }} {{ event.change.notes }}
|
||||||
|
@ -15,7 +15,7 @@ watch(
|
|||||||
() => props.lesson,
|
() => props.lesson,
|
||||||
(value) => {
|
(value) => {
|
||||||
if (!props.edit) lesson.value = value;
|
if (!props.edit) lesson.value = value;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const subjectElement = ref();
|
const subjectElement = ref();
|
||||||
|
@ -23,7 +23,7 @@ watch(
|
|||||||
() => props.progress,
|
() => props.progress,
|
||||||
() => {
|
() => {
|
||||||
if (visible.value) computedProgress.value = props.progress;
|
if (visible.value) computedProgress.value = props.progress;
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
watch(
|
watch(
|
||||||
() => props.active,
|
() => props.active,
|
||||||
@ -44,7 +44,7 @@ watch(
|
|||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ const substitutionsForDate = computed(() => {
|
|||||||
$t(
|
$t(
|
||||||
getSubstitutionText(
|
getSubstitutionText(
|
||||||
substitution,
|
substitution,
|
||||||
!classFilter || classFilter == "none"
|
!classFilter || classFilter == "none",
|
||||||
),
|
),
|
||||||
{
|
{
|
||||||
subject: substitution.change.subject,
|
subject: substitution.change.subject,
|
||||||
@ -57,7 +57,7 @@ const substitutionsForDate = computed(() => {
|
|||||||
teacher: substitution.teacher,
|
teacher: substitution.teacher,
|
||||||
new_teacher: substitution.change.teacher,
|
new_teacher: substitution.change.teacher,
|
||||||
room: substitution.change.room,
|
room: substitution.change.room,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
}}</span>
|
}}</span>
|
||||||
<span class="notes" v-if="substitution.notes">
|
<span class="notes" v-if="substitution.notes">
|
||||||
|
@ -26,7 +26,7 @@ const linkedTimetable = computed(() => {
|
|||||||
entryDay == props.date.getTime() &&
|
entryDay == props.date.getTime() &&
|
||||||
(entry.teacher == e.teacher || !entry.teacher || !e.teacher)
|
(entry.teacher == e.teacher || !entry.teacher || !e.teacher)
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
return newElement;
|
return newElement;
|
||||||
});
|
});
|
||||||
|
22
src/store.js
22
src/store.js
@ -12,10 +12,10 @@ export const loadingFailed = ref(false);
|
|||||||
export const classFilter = ref(localStorage.getItem("classFilter") || "none");
|
export const classFilter = ref(localStorage.getItem("classFilter") || "none");
|
||||||
export const timetableId = ref(localStorage.getItem("timetableId") || "none");
|
export const timetableId = ref(localStorage.getItem("timetableId") || "none");
|
||||||
export const timetableGroups = ref(
|
export const timetableGroups = ref(
|
||||||
JSON.parse(localStorage.getItem("timetableGroups") || "[]")
|
JSON.parse(localStorage.getItem("timetableGroups") || "[]"),
|
||||||
);
|
);
|
||||||
export const localTimetables = ref(
|
export const localTimetables = ref(
|
||||||
JSON.parse(localStorage.getItem("timetables")) || []
|
JSON.parse(localStorage.getItem("timetables")) || [],
|
||||||
);
|
);
|
||||||
|
|
||||||
export const theme = ref(localStorage.getItem("theme") || "auto");
|
export const theme = ref(localStorage.getItem("theme") || "auto");
|
||||||
@ -32,14 +32,14 @@ watch(
|
|||||||
(newValue) => {
|
(newValue) => {
|
||||||
localStorage.setItem("timetableGroups", JSON.stringify(newValue));
|
localStorage.setItem("timetableGroups", JSON.stringify(newValue));
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true },
|
||||||
);
|
);
|
||||||
watch(
|
watch(
|
||||||
localTimetables,
|
localTimetables,
|
||||||
(newValue) => {
|
(newValue) => {
|
||||||
localStorage.setItem("timetables", JSON.stringify(newValue));
|
localStorage.setItem("timetables", JSON.stringify(newValue));
|
||||||
},
|
},
|
||||||
{ deep: true }
|
{ deep: true },
|
||||||
);
|
);
|
||||||
watch(theme, (newValue) => {
|
watch(theme, (newValue) => {
|
||||||
localStorage.setItem("theme", newValue);
|
localStorage.setItem("theme", newValue);
|
||||||
@ -63,10 +63,10 @@ export const changeDate = ref(new Date());
|
|||||||
/* Data store */
|
/* Data store */
|
||||||
export const timetable = computed(() => {
|
export const timetable = computed(() => {
|
||||||
const localTimetable = localTimetables.value.find(
|
const localTimetable = localTimetables.value.find(
|
||||||
(e) => e.id == timetableId.value
|
(e) => e.id == timetableId.value,
|
||||||
);
|
);
|
||||||
const remoteTimetable = timetables.value.find(
|
const remoteTimetable = timetables.value.find(
|
||||||
(e) => e.id == timetableId.value
|
(e) => e.id == timetableId.value,
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
localTimetable || remoteTimetable || { trusted: true, source: "", data: [] }
|
localTimetable || remoteTimetable || { trusted: true, source: "", data: [] }
|
||||||
@ -124,7 +124,7 @@ export async function fetchData(days, partial) {
|
|||||||
|
|
||||||
// Load new data if date changes
|
// Load new data if date changes
|
||||||
watch(selectedDate, () =>
|
watch(selectedDate, () =>
|
||||||
fetchData(getNextAndPrevDay(selectedDate.value), true)
|
fetchData(getNextAndPrevDay(selectedDate.value), true),
|
||||||
);
|
);
|
||||||
|
|
||||||
export async function fetchSessionInfo() {
|
export async function fetchSessionInfo() {
|
||||||
@ -154,7 +154,7 @@ export async function fetchClassList() {
|
|||||||
|
|
||||||
export async function fetchTimetables() {
|
export async function fetchTimetables() {
|
||||||
const timetableResponse = await fetch(
|
const timetableResponse = await fetch(
|
||||||
`${baseUrl}/timetable?class=${classFilter.value}`
|
`${baseUrl}/timetable?class=${classFilter.value}`,
|
||||||
);
|
);
|
||||||
const timetableData = await timetableResponse.json();
|
const timetableData = await timetableResponse.json();
|
||||||
if (timetableData.error) {
|
if (timetableData.error) {
|
||||||
@ -171,7 +171,7 @@ export async function fetchSubstitutions(day) {
|
|||||||
const substitutionResponse = await fetch(
|
const substitutionResponse = await fetch(
|
||||||
classFilter.value == "none"
|
classFilter.value == "none"
|
||||||
? `${baseUrl}/substitutions${requestDate}`
|
? `${baseUrl}/substitutions${requestDate}`
|
||||||
: `${baseUrl}/substitutions${requestDate}&class=${classFilter.value}`
|
: `${baseUrl}/substitutions${requestDate}&class=${classFilter.value}`,
|
||||||
);
|
);
|
||||||
const substitutionData = await substitutionResponse.json();
|
const substitutionData = await substitutionResponse.json();
|
||||||
substitutions.value[day] = substitutionData;
|
substitutions.value[day] = substitutionData;
|
||||||
@ -182,7 +182,7 @@ export async function fetchHistory(day) {
|
|||||||
const historyResponse = await fetch(
|
const historyResponse = await fetch(
|
||||||
classFilter.value == "none"
|
classFilter.value == "none"
|
||||||
? `${baseUrl}/history${requestDate}`
|
? `${baseUrl}/history${requestDate}`
|
||||||
: `${baseUrl}/history${requestDate}&class=${classFilter.value}`
|
: `${baseUrl}/history${requestDate}&class=${classFilter.value}`,
|
||||||
);
|
);
|
||||||
const historyData = await historyResponse.json();
|
const historyData = await historyResponse.json();
|
||||||
if (historyData.error) console.warn("API Error: " + historyData.error);
|
if (historyData.error) console.warn("API Error: " + historyData.error);
|
||||||
@ -201,7 +201,7 @@ export const parsedTimetable = computed(() => {
|
|||||||
// (timetable groups)
|
// (timetable groups)
|
||||||
if (Array.isArray(lesson) && lesson.length > 1) {
|
if (Array.isArray(lesson) && lesson.length > 1) {
|
||||||
let matchingLesson = lesson.find((e) =>
|
let matchingLesson = lesson.find((e) =>
|
||||||
timetableGroups.value.includes(e.group)
|
timetableGroups.value.includes(e.group),
|
||||||
);
|
);
|
||||||
// If no valid timetable group is configured
|
// If no valid timetable group is configured
|
||||||
// add a dummy lesson showing a notice
|
// add a dummy lesson showing a notice
|
||||||
|
@ -33,7 +33,7 @@ export function getDateSkippingWeekend(date, onlyNext) {
|
|||||||
// Go from sunday to last friday or next monday
|
// Go from sunday to last friday or next monday
|
||||||
if (date.getDay() == 0)
|
if (date.getDay() == 0)
|
||||||
return new Date(
|
return new Date(
|
||||||
onlyNext ? date.getTime() + 86400000 * 1 : date.getTime() - 86400000 * 2
|
onlyNext ? date.getTime() + 86400000 * 1 : date.getTime() - 86400000 * 2,
|
||||||
);
|
);
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
@ -49,6 +49,6 @@ export function getNextAndPrevDay(date) {
|
|||||||
export function setUTCMidnight(date) {
|
export function setUTCMidnight(date) {
|
||||||
// Set the time to UTC midnight while keeping the correct date
|
// Set the time to UTC midnight while keeping the correct date
|
||||||
return new Date(
|
return new Date(
|
||||||
Date.UTC(date.getFullYear(), date.getMonth(), date.getDate())
|
Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ async function fetchObjects(type) {
|
|||||||
async function deleteObject(type, id) {
|
async function deleteObject(type, id) {
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
baseUrl + `/admin/${type}?id=${encodeURIComponent(id)}`,
|
baseUrl + `/admin/${type}?id=${encodeURIComponent(id)}`,
|
||||||
{ method: "delete" }
|
{ method: "delete" },
|
||||||
);
|
);
|
||||||
if (response.status != 200) alert("Delete failed!");
|
if (response.status != 200) alert("Delete failed!");
|
||||||
updateData();
|
updateData();
|
||||||
@ -47,7 +47,7 @@ async function updateObject(type, id, data) {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
if (response.status != 201) alert("Post failed!");
|
if (response.status != 201) alert("Post failed!");
|
||||||
updateData();
|
updateData();
|
||||||
|
@ -20,7 +20,7 @@ async function applyKey() {
|
|||||||
baseUrl + "/key?key=" + encodeURIComponent(key.value),
|
baseUrl + "/key?key=" + encodeURIComponent(key.value),
|
||||||
{
|
{
|
||||||
method: "put",
|
method: "put",
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
loadingProgress.value = 0.5;
|
loadingProgress.value = 0.5;
|
||||||
if (result.status == 400) {
|
if (result.status == 400) {
|
||||||
|
@ -11,7 +11,7 @@ import LessonGroupList from "@/components/lesson-group-list.vue";
|
|||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const timetable = localTimetables.value.find(
|
const timetable = localTimetables.value.find(
|
||||||
(e) => e.id == route.params.id
|
(e) => e.id == route.params.id,
|
||||||
) || {
|
) || {
|
||||||
data: [],
|
data: [],
|
||||||
};
|
};
|
||||||
@ -97,7 +97,7 @@ const forceUpdate = ref(0);
|
|||||||
arrayMove(
|
arrayMove(
|
||||||
timetableClone.data[day - 1],
|
timetableClone.data[day - 1],
|
||||||
index,
|
index,
|
||||||
index - 1
|
index - 1,
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
direction == 'down' &&
|
direction == 'down' &&
|
||||||
@ -106,7 +106,7 @@ const forceUpdate = ref(0);
|
|||||||
arrayMove(
|
arrayMove(
|
||||||
timetableClone.data[day - 1],
|
timetableClone.data[day - 1],
|
||||||
index,
|
index,
|
||||||
index + 1
|
index + 1,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
forceUpdate++;
|
forceUpdate++;
|
||||||
|
@ -53,7 +53,7 @@ function exportTimetable(timetable) {
|
|||||||
download(
|
download(
|
||||||
JSON.stringify(timetable),
|
JSON.stringify(timetable),
|
||||||
`timetable-${timetable.id}.json`,
|
`timetable-${timetable.id}.json`,
|
||||||
"application/json"
|
"application/json",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ async function uploadTimetable(id) {
|
|||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
body: JSON.stringify(timetableData),
|
body: JSON.stringify(timetableData),
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.status != 201) {
|
if (response.status != 201) {
|
||||||
@ -103,7 +103,7 @@ async function uploadTimetable(id) {
|
|||||||
@delete="
|
@delete="
|
||||||
localTimetables.splice(
|
localTimetables.splice(
|
||||||
localTimetables.findIndex((e) => e.id == timetable.id),
|
localTimetables.findIndex((e) => e.id == timetable.id),
|
||||||
1
|
1,
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
@export="exportTimetable(timetable)"
|
@export="exportTimetable(timetable)"
|
||||||
|
@ -9,10 +9,10 @@ import * as child from "child_process";
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
define: {
|
define: {
|
||||||
GITVERSION: JSON.stringify(
|
GITVERSION: JSON.stringify(
|
||||||
child.execSync("git rev-parse --short HEAD").toString()
|
child.execSync("git rev-parse --short HEAD").toString(),
|
||||||
),
|
),
|
||||||
GITURL: JSON.stringify(
|
GITURL: JSON.stringify(
|
||||||
child.execSync("git config --get remote.origin.url").toString()
|
child.execSync("git config --get remote.origin.url").toString(),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
Reference in New Issue
Block a user