Error handling in Admin-Queries (loading bleibt nicht hängen)
This commit is contained in:
parent
c7d4d5ae81
commit
ea7a48a995
3 changed files with 46 additions and 31 deletions
|
|
@ -14,22 +14,27 @@
|
||||||
let loading = $state(true);
|
let loading = $state(true);
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const today = new Date();
|
try {
|
||||||
today.setHours(0, 0, 0, 0);
|
const today = new Date();
|
||||||
const tenantId = (pb.authStore.record as any)?.tenant;
|
today.setHours(0, 0, 0, 0);
|
||||||
|
const tenantId = (pb.authStore.record as any)?.tenant;
|
||||||
|
|
||||||
const result = await pb.collection('check_logs').getList(1, 50, {
|
const result = await pb.collection('check_logs').getList(1, 50, {
|
||||||
filter: `tenant = "${tenantId}" && created >= "${today.toISOString()}"`,
|
filter: `tenant = "${tenantId}" && created >= "${today.toISOString()}"`,
|
||||||
expand: 'station',
|
expand: 'station',
|
||||||
sort: '-created'
|
sort: '-created'
|
||||||
});
|
});
|
||||||
|
|
||||||
logs = result.items;
|
logs = result.items;
|
||||||
stats.total = result.totalItems;
|
stats.total = result.totalItems;
|
||||||
stats.ok = logs.filter(l => l.status === 'ok').length;
|
stats.ok = logs.filter(l => l.status === 'ok').length;
|
||||||
stats.abweichung = logs.filter(l => l.status === 'abweichung').length;
|
stats.abweichung = logs.filter(l => l.status === 'abweichung').length;
|
||||||
stats.kritisch = logs.filter(l => l.status === 'kritisch').length;
|
stats.kritisch = logs.filter(l => l.status === 'kritisch').length;
|
||||||
loading = false;
|
} catch {
|
||||||
|
// Keine Einträge oder Zugriffsrechte noch nicht gesetzt
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function formatTime(iso: string) {
|
function formatTime(iso: string) {
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,21 @@
|
||||||
|
|
||||||
async function loadPage(p: number) {
|
async function loadPage(p: number) {
|
||||||
loading = true;
|
loading = true;
|
||||||
const tenantId = (pb.authStore.record as any)?.tenant;
|
try {
|
||||||
const result = await pb.collection('check_logs').getList(p, PER_PAGE, {
|
const tenantId = (pb.authStore.record as any)?.tenant;
|
||||||
filter: `tenant = "${tenantId}"`,
|
const result = await pb.collection('check_logs').getList(p, PER_PAGE, {
|
||||||
expand: 'station',
|
filter: `tenant = "${tenantId}"`,
|
||||||
sort: '-created'
|
expand: 'station',
|
||||||
});
|
sort: '-created'
|
||||||
logs = result.items;
|
});
|
||||||
page = p;
|
logs = result.items;
|
||||||
totalPages = Math.ceil(result.totalItems / PER_PAGE);
|
page = p;
|
||||||
loading = false;
|
totalPages = Math.ceil(result.totalItems / PER_PAGE);
|
||||||
|
} catch {
|
||||||
|
// Keine Einträge
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDate(iso: string) {
|
function formatDate(iso: string) {
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,18 @@
|
||||||
let copied = $state<string | null>(null);
|
let copied = $state<string | null>(null);
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
const tenantId = (pb.authStore.record as any)?.tenant;
|
try {
|
||||||
const result = await pb.collection('stations').getFullList({
|
const tenantId = (pb.authStore.record as any)?.tenant;
|
||||||
filter: `tenant = "${tenantId}" && active = true`,
|
const result = await pb.collection('stations').getFullList({
|
||||||
sort: 'name'
|
filter: `tenant = "${tenantId}" && active = true`,
|
||||||
});
|
sort: 'name'
|
||||||
stations = result;
|
});
|
||||||
loading = false;
|
stations = result;
|
||||||
|
} catch {
|
||||||
|
// Keine Stationen
|
||||||
|
} finally {
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function qrUrl(qrId: string) {
|
function qrUrl(qrId: string) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue