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