Replace circular with linear loading indicator

This commit is contained in:
2022-10-03 14:28:40 +02:00
parent 257f665ce6
commit 2e4039cd70
5 changed files with 75 additions and 40 deletions

View File

@ -5,6 +5,7 @@ import i18n from "./main";
export const lastRoute = ref();
export const loading = ref(false);
export const loadingProgress = ref(0);
export const classFilter = ref(localStorage.getItem("classFilter") || "none");
export const timetableGroups = ref(
@ -45,9 +46,12 @@ if (selectedDay.value == -1)
// Load new data if date changes
watch(selectedDate, async () => {
loadingProgress.value = 0.1;
loading.value = true;
await fetchSubstitutions();
loadingProgress.value = 1 / 2;
await fetchHistory();
loadingProgress.value = 1;
loading.value = false;
});
@ -124,16 +128,22 @@ export const possibleTimetableGroups = computed(() => {
const baseUrl = import.meta.env.VITE_API_ENDPOINT || "/api";
export async function fetchData() {
loadingProgress.value = 0.1;
loading.value = true;
const checkResponse = await fetch(`${baseUrl}/check`);
if (checkResponse.status != 200) router.push("/login");
loadingProgress.value = 1 / 5;
await fetchClassList();
loadingProgress.value = 2 / 5;
await fetchTimetable();
loadingProgress.value = 3 / 5;
await fetchSubstitutions();
loadingProgress.value = 4 / 5;
await fetchHistory();
loadingProgress.value = 1;
loading.value = false;
}