frontend: Workload pages

This commit is contained in:
Frank Agerholm 2026-01-25 19:47:11 +01:00
commit 9eb9be7318
No known key found for this signature in database
8 changed files with 372 additions and 21 deletions

View file

@ -5,6 +5,7 @@ definePageMeta({
})
import { ref, onMounted } from "vue"
import { isUnauthorized } from "~/utils/auth"
const { apiFetch } = useApi()
@ -49,6 +50,10 @@ async function saveEdit(serverId: number) {
}
})
if (isUnauthorized(updated)) {
return updated
}
// Liste aktualisieren
const idx = servers.value.findIndex(s => s.id === serverId)
if (idx !== -1) servers.value[idx] = updated
@ -64,7 +69,11 @@ const owners = ref([])
async function loadOwners() {
try {
owners.value = await apiFetch("/owners")
const result = await apiFetch("/owners")
if (isUnauthorized(result)) {
return result
}
owners.value = result
} catch (e: any) {
error.value = e.message
}
@ -73,7 +82,11 @@ async function loadOwners() {
async function loadServers() {
loading.value = true
try {
servers.value = await apiFetch("/servers")
const result = await apiFetch("/servers")
if (isUnauthorized(result)) {
return result
}
servers.value = result
} catch (e: any) {
error.value = e.message
} finally {
@ -93,6 +106,9 @@ async function createServer() {
owner_id: newServer.value.owner_id
}
})
if (isUnauthorized(server)) {
return server
}
servers.value.push(server)
newServer.value = { hostname: "", description: "" }
@ -101,9 +117,9 @@ async function createServer() {
}
}
onMounted(() => {
loadOwners()
loadServers()
onMounted(async () => {
if (isUnauthorized(await loadOwners())) return
if (isUnauthorized(await loadServers())) return
})
</script>