Phase 8 Mobil: REST-API, Web-Push, installierbare App (0.25.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m54s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m0s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m54s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m50s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m48s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m38s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m56s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 7m5s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-27 08:20:07 +00:00
parent 232dc5c59c
commit f11a3e24b3
201 changed files with 3604 additions and 427 deletions

View file

@ -1,4 +1,5 @@
<script setup>
import PushToggle from '@/components/PushToggle.vue';
import { computed, ref } from 'vue';
import { router, usePage } from '@inertiajs/vue3';
import { Bell, CheckCheck, FileCheck, LoaderCircle, MessageSquare, Newspaper, Undo2 } from '@lucide/vue';
@ -75,6 +76,7 @@ function open(item) {
</li>
</ul>
</div>
<div class="border-t px-4 py-2.5"><PushToggle compact /></div>
</PopoverContent>
</Popover>
</template>

View file

@ -0,0 +1,67 @@
<script setup>
import { onMounted, ref } from 'vue';
import { usePage } from '@inertiajs/vue3';
import { BellRing, LoaderCircle } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Switch } from '@/components/ui/switch';
import { http } from '@/lib/http';
import { currentSubscription, disablePush, enablePush, pushSupported } from '@/lib/push';
/**
* Schalter „Push-Benachrichtigungen auf diesem Gerät“.
*/
defineProps({
compact: { type: Boolean, default: false },
});
const page = usePage();
const supported = ref(false);
const enabled = ref(false);
const busy = ref(false);
const isIos = /iPhone|iPad|iPod/.test(navigator.userAgent) && !window.matchMedia('(display-mode: standalone)').matches;
onMounted(async () => {
supported.value = pushSupported() && !!page.props.push?.key;
if (supported.value) {
enabled.value = !!(await currentSubscription()) && Notification.permission === 'granted';
}
});
async function toggle(value) {
busy.value = true;
try {
if (value) {
await enablePush(page.props.push.key);
enabled.value = true;
await http.post('/push/test').catch(() => {});
toast.success('Push ist eingeschaltet – eine Testnachricht ist unterwegs.');
} else {
await disablePush();
enabled.value = false;
toast.success('Push auf diesem Gerät ausgeschaltet');
}
} catch (error) {
toast.error(error.message);
enabled.value = !!(await currentSubscription());
} finally {
busy.value = false;
}
}
</script>
<template>
<div v-if="supported" class="flex items-center gap-3" :class="compact ? 'text-[13px]' : 'text-sm'">
<BellRing class="size-4 shrink-0 text-muted-foreground" />
<span class="min-w-0 flex-1">
Push auf diesem Gerät
<span v-if="!compact" class="block text-xs text-muted-foreground">Hinweise erscheinen auch, wenn das Portal nicht geöffnet ist.</span>
</span>
<LoaderCircle v-if="busy" class="size-4 animate-spin text-muted-foreground" />
<Switch :model-value="enabled" :disabled="busy" aria-label="Push-Benachrichtigungen auf diesem Gerät" @update:model-value="toggle" />
</div>
<p v-else-if="isIos && !compact" class="text-[13px] text-muted-foreground">
Auf iPhone und iPad gibt es Push-Benachrichtigungen, sobald das Portal über „Teilen → Zum Home-Bildschirm“ als App hinzugefügt wurde.
</p>
</template>

View file

@ -0,0 +1,93 @@
<script setup>
import { ref } from 'vue';
import { router } from '@inertiajs/vue3';
import { Copy, KeyRound, LoaderCircle, Plus, Smartphone, Trash2 } from '@lucide/vue';
import { toast } from 'vue-sonner';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import Panel from '@/components/Panel.vue';
import PushToggle from '@/components/PushToggle.vue';
import { http } from '@/lib/http';
import { formatRelative } from '@/lib/format';
/**
* „Benachrichtigungen & Apps“: Push auf diesem Gerät und Zugänge für Apps (REST-API).
*/
defineProps({
tokens: { type: Array, default: () => [] },
});
const adding = ref(false);
const name = ref('');
const busy = ref(false);
const created = ref(null);
async function create() {
busy.value = true;
try {
const data = await http.post('/profil/apps', { name: name.value });
created.value = data.token;
name.value = '';
adding.value = false;
router.reload({ only: ['tokens'] });
} catch (error) {
toast.error(error.data?.errors?.name?.[0] ?? error.message);
} finally {
busy.value = false;
}
}
async function copy() {
try {
await navigator.clipboard.writeText(created.value);
toast.success('Zugangsschlüssel kopiert');
} catch {
toast.error('Kopieren nicht möglich – bitte markieren und kopieren.');
}
}
function remove(token) {
if (window.confirm(`Zugang „${token.name}“ entfernen? Die App wird sofort abgemeldet.`)) {
router.delete(`/profil/apps/${token.id}`, { preserveScroll: true, only: ['tokens'], onSuccess: () => toast.success('Zugang entfernt') });
}
}
</script>
<template>
<Panel title="Benachrichtigungen & Apps">
<PushToggle />
<div class="mt-5 border-t pt-4">
<div class="flex items-center justify-between gap-3">
<h3 class="text-sm font-medium">Apps & Geräte</h3>
<Button v-if="!adding" size="sm" variant="ghost" @click="(adding = true), (created = null)"><Plus /> Zugang</Button>
</div>
<p class="mt-1 text-[13px] text-muted-foreground">Für Apps, die das Portal über die Schnittstelle nutzen. Jeder Zugang lässt sich einzeln entfernen.</p>
<form v-if="adding" class="mt-3 flex gap-2" @submit.prevent="create">
<Input v-model="name" maxlength="100" placeholder="z. B. Diensthandy" aria-label="Name des Geräts" autofocus />
<Button type="submit" size="sm" class="h-9" :disabled="busy || !name.trim()"><LoaderCircle v-if="busy" class="animate-spin" /> Anlegen</Button>
</form>
<div v-if="created" class="mt-3 rounded-md border border-amber-300 bg-amber-50 p-3 dark:border-amber-800 dark:bg-amber-950/40">
<p class="flex items-center gap-1.5 text-[13px] font-medium"><KeyRound class="size-4" /> Zugangsschlüssel – wird nur jetzt angezeigt</p>
<div class="mt-2 flex items-center gap-2">
<code class="min-w-0 flex-1 truncate rounded bg-card px-2 py-1 text-xs select-all">{{ created }}</code>
<Button size="icon" variant="outline" class="size-8" aria-label="Kopieren" @click="copy"><Copy /></Button>
</div>
</div>
<ul v-if="tokens.length" class="mt-3 divide-y rounded-md border">
<li v-for="token in tokens" :key="token.id" class="flex items-center gap-3 px-3 py-2">
<Smartphone class="size-4 shrink-0 text-muted-foreground" />
<div class="min-w-0 flex-1">
<p class="truncate text-sm">{{ token.name }}</p>
<p class="text-xs text-muted-foreground">{{ token.last_used_at ? `zuletzt ${formatRelative(token.last_used_at)}` : 'noch nicht benutzt' }}</p>
</div>
<Button size="icon" variant="ghost" class="size-8 text-muted-foreground hover:text-destructive" :aria-label="`${token.name} entfernen`" @click="remove(token)"><Trash2 /></Button>
</li>
</ul>
</div>
</Panel>
</template>