Error handling in Admin-Queries (loading bleibt nicht hängen)

This commit is contained in:
rene 2026-05-17 13:38:32 +02:00
parent c7d4d5ae81
commit ea7a48a995
3 changed files with 46 additions and 31 deletions

View file

@ -14,22 +14,27 @@
let loading = $state(true);
onMount(async () => {
const today = new Date();
today.setHours(0, 0, 0, 0);
const tenantId = (pb.authStore.record as any)?.tenant;
try {
const today = new Date();
today.setHours(0, 0, 0, 0);
const tenantId = (pb.authStore.record as any)?.tenant;
const result = await pb.collection('check_logs').getList(1, 50, {
filter: `tenant = "${tenantId}" && created >= "${today.toISOString()}"`,
expand: 'station',
sort: '-created'
});
const result = await pb.collection('check_logs').getList(1, 50, {
filter: `tenant = "${tenantId}" && created >= "${today.toISOString()}"`,
expand: 'station',
sort: '-created'
});
logs = result.items;
stats.total = result.totalItems;
stats.ok = logs.filter(l => l.status === 'ok').length;
stats.abweichung = logs.filter(l => l.status === 'abweichung').length;
stats.kritisch = logs.filter(l => l.status === 'kritisch').length;
loading = false;
logs = result.items;
stats.total = result.totalItems;
stats.ok = logs.filter(l => l.status === 'ok').length;
stats.abweichung = logs.filter(l => l.status === 'abweichung').length;
stats.kritisch = logs.filter(l => l.status === 'kritisch').length;
} catch {
// Keine Einträge oder Zugriffsrechte noch nicht gesetzt
} finally {
loading = false;
}
});
function formatTime(iso: string) {

View file

@ -19,16 +19,21 @@
async function loadPage(p: number) {
loading = true;
const tenantId = (pb.authStore.record as any)?.tenant;
const result = await pb.collection('check_logs').getList(p, PER_PAGE, {
filter: `tenant = "${tenantId}"`,
expand: 'station',
sort: '-created'
});
logs = result.items;
page = p;
totalPages = Math.ceil(result.totalItems / PER_PAGE);
loading = false;
try {
const tenantId = (pb.authStore.record as any)?.tenant;
const result = await pb.collection('check_logs').getList(p, PER_PAGE, {
filter: `tenant = "${tenantId}"`,
expand: 'station',
sort: '-created'
});
logs = result.items;
page = p;
totalPages = Math.ceil(result.totalItems / PER_PAGE);
} catch {
// Keine Einträge
} finally {
loading = false;
}
}
function formatDate(iso: string) {

View file

@ -15,13 +15,18 @@
let copied = $state<string | null>(null);
onMount(async () => {
const tenantId = (pb.authStore.record as any)?.tenant;
const result = await pb.collection('stations').getFullList({
filter: `tenant = "${tenantId}" && active = true`,
sort: 'name'
});
stations = result;
loading = false;
try {
const tenantId = (pb.authStore.record as any)?.tenant;
const result = await pb.collection('stations').getFullList({
filter: `tenant = "${tenantId}" && active = true`,
sort: 'name'
});
stations = result;
} catch {
// Keine Stationen
} finally {
loading = false;
}
});
function qrUrl(qrId: string) {