Neues Plugin IT-Service (OpenNIT); Abteilung bei „Geschrieben von“
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 4m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m27s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m41s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m32s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m7s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m30s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m35s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 4m42s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m27s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m41s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m32s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 6m7s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 6m29s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 5m33s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m30s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 5m35s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c713194a83
commit
c1117829c3
139 changed files with 2455 additions and 398 deletions
|
|
@ -0,0 +1,130 @@
|
|||
<script setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { ChevronLeft, ChevronRight } from '@lucide/vue';
|
||||
|
||||
/**
|
||||
* Zwei Monate zum Wählen eines Zeitraums; belegte Tage (slots) sind gesperrt.
|
||||
* v-model:start / v-model:end als „YYYY-MM-DD“.
|
||||
*/
|
||||
const props = defineProps({
|
||||
slots: { type: Array, default: () => [] },
|
||||
start: { type: String, default: '' },
|
||||
end: { type: String, default: '' },
|
||||
maxDays: { type: Number, default: 180 },
|
||||
});
|
||||
const emit = defineEmits(['update:start', 'update:end']);
|
||||
|
||||
const iso = (date) => `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
|
||||
const today = iso(new Date());
|
||||
const cursor = ref(new Date(new Date().getFullYear(), new Date().getMonth(), 1));
|
||||
|
||||
const booked = computed(() => {
|
||||
const days = new Set();
|
||||
|
||||
for (const slot of props.slots) {
|
||||
const day = new Date(`${slot.start}T12:00:00`);
|
||||
const last = new Date(`${slot.end || slot.start}T12:00:00`);
|
||||
|
||||
for (let i = 0; day <= last && i < 400; i++) {
|
||||
days.add(iso(day));
|
||||
day.setDate(day.getDate() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return days;
|
||||
});
|
||||
|
||||
const monthFormat = new Intl.DateTimeFormat('de-DE', { month: 'long', year: 'numeric' });
|
||||
const months = computed(() => [0, 1].map((offset) => {
|
||||
const first = new Date(cursor.value.getFullYear(), cursor.value.getMonth() + offset, 1);
|
||||
const days = [];
|
||||
const lead = (first.getDay() + 6) % 7; // Montag zuerst
|
||||
|
||||
for (let i = 0; i < lead; i++) days.push(null);
|
||||
|
||||
for (let d = 1; d <= new Date(first.getFullYear(), first.getMonth() + 1, 0).getDate(); d++) {
|
||||
days.push(iso(new Date(first.getFullYear(), first.getMonth(), d)));
|
||||
}
|
||||
|
||||
return { label: monthFormat.format(first), days };
|
||||
}));
|
||||
|
||||
function rangeFree(from, to) {
|
||||
for (const day of booked.value) {
|
||||
if (day >= from && day <= to) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function pick(day) {
|
||||
if (!day || day < today || booked.value.has(day)) return;
|
||||
|
||||
if (!props.start || props.end || day < props.start) {
|
||||
emit('update:start', day);
|
||||
emit('update:end', '');
|
||||
} else if (rangeFree(props.start, day)) {
|
||||
emit('update:end', day);
|
||||
} else {
|
||||
emit('update:start', day);
|
||||
emit('update:end', '');
|
||||
}
|
||||
}
|
||||
|
||||
function state(day) {
|
||||
if (!day) return 'empty';
|
||||
if (booked.value.has(day)) return 'booked';
|
||||
if (day < today) return 'past';
|
||||
if (day === props.start || day === props.end) return 'edge';
|
||||
if (props.start && props.end && day > props.start && day < props.end) return 'inside';
|
||||
|
||||
return 'free';
|
||||
}
|
||||
|
||||
const classes = {
|
||||
booked: 'bg-red-50 text-red-400 line-through cursor-not-allowed dark:bg-red-950/30',
|
||||
past: 'text-muted-foreground/40 cursor-not-allowed',
|
||||
edge: 'bg-brand text-brand-foreground font-semibold',
|
||||
inside: 'bg-brand-soft text-brand-soft-foreground',
|
||||
free: 'hover:bg-accent',
|
||||
empty: '',
|
||||
};
|
||||
|
||||
function shift(step) {
|
||||
cursor.value = new Date(cursor.value.getFullYear(), cursor.value.getMonth() + step, 1);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<button type="button" class="grid size-8 place-items-center rounded-md hover:bg-accent" aria-label="Früher" @click="shift(-1)"><ChevronLeft class="size-4" /></button>
|
||||
<span class="text-xs text-muted-foreground">Beginn und Ende anklicken</span>
|
||||
<button type="button" class="grid size-8 place-items-center rounded-md hover:bg-accent" aria-label="Später" @click="shift(1)"><ChevronRight class="size-4" /></button>
|
||||
</div>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div v-for="month in months" :key="month.label">
|
||||
<p class="mb-1.5 text-center text-sm font-medium">{{ month.label }}</p>
|
||||
<div class="grid grid-cols-7 gap-0.5 text-center text-xs">
|
||||
<span v-for="w in ['Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So']" :key="w" class="py-1 text-muted-foreground">{{ w }}</span>
|
||||
<button
|
||||
v-for="(day, i) in month.days"
|
||||
:key="day ?? `e${i}`"
|
||||
type="button"
|
||||
class="aspect-square rounded-md tabular-nums transition-colors"
|
||||
:class="classes[state(day)]"
|
||||
:disabled="!day || state(day) === 'booked' || state(day) === 'past'"
|
||||
:title="state(day) === 'booked' ? 'Belegt' : undefined"
|
||||
@click="pick(day)"
|
||||
>
|
||||
{{ day ? Number(day.slice(8)) : '' }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="mt-2 flex items-center gap-3 text-[11px] text-muted-foreground">
|
||||
<span class="inline-flex items-center gap-1"><span class="size-2.5 rounded-sm bg-red-100 dark:bg-red-950" /> belegt</span>
|
||||
<span class="inline-flex items-center gap-1"><span class="size-2.5 rounded-sm bg-brand" /> Ihr Zeitraum</span>
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
label: { type: String, required: true },
|
||||
tone: { type: String, default: 'neutral' }, // open | progress | waiting | done | neutral
|
||||
});
|
||||
|
||||
const classes = computed(() => ({
|
||||
open: 'bg-sky-100 text-sky-800 dark:bg-sky-900/50 dark:text-sky-200',
|
||||
progress: 'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-200',
|
||||
waiting: 'bg-violet-100 text-violet-800 dark:bg-violet-900/50 dark:text-violet-200',
|
||||
done: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200',
|
||||
neutral: 'bg-muted text-muted-foreground',
|
||||
})[props.tone]);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="inline-flex shrink-0 items-center rounded-full px-2 py-0.5 text-[11px] font-semibold whitespace-nowrap" :class="classes">{{ label }}</span>
|
||||
</template>
|
||||
149
plugins-core/it-service/resources/js/pages/Index.vue
Normal file
149
plugins-core/it-service/resources/js/pages/Index.vue
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
<script setup>
|
||||
import { watch } from 'vue';
|
||||
import { Deferred, Link, router, usePage } from '@inertiajs/vue3';
|
||||
import { CalendarClock, CircleAlert, Laptop, LifeBuoy, MessageSquarePlus, Plug, ShieldCheck, TicketCheck, X } from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import PageHeader from '@/components/PageHeader.vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import StatusBadge from '../components/StatusBadge.vue';
|
||||
import { formatDate, loanTone, ticketTone } from '../status';
|
||||
|
||||
defineProps({
|
||||
configured: { type: Boolean, default: false },
|
||||
intro: { type: String, default: null },
|
||||
assets: { type: Object, default: null },
|
||||
tickets: { type: Object, default: null },
|
||||
loans: { type: Object, default: null },
|
||||
});
|
||||
|
||||
const page = usePage();
|
||||
watch(() => page.props.flash.status, (status) => status && toast.success(status), { immediate: true });
|
||||
watch(() => page.props.errors?.loan, (error) => error && toast.error(error));
|
||||
|
||||
function warranty(asset) {
|
||||
if (!asset.warranty_end) return null;
|
||||
const end = new Date(asset.warranty_end);
|
||||
const days = Math.round((end - new Date()) / 86_400_000);
|
||||
|
||||
if (Number.isNaN(days)) return { text: `Garantie bis ${asset.warranty_end}`, tone: '' };
|
||||
if (days < 0) return { text: `Garantie abgelaufen (${formatDate(asset.warranty_end)})`, tone: 'text-muted-foreground' };
|
||||
if (days < 90) return { text: `Garantie endet am ${formatDate(asset.warranty_end)}`, tone: 'text-amber-700 dark:text-amber-300' };
|
||||
|
||||
return { text: `Garantie bis ${formatDate(asset.warranty_end)}`, tone: 'text-muted-foreground' };
|
||||
}
|
||||
|
||||
function cancel(loan) {
|
||||
if (window.confirm(`Ausleihe „${loan.device}“ stornieren?`)) {
|
||||
router.post(`/it-service/ausleihen/${loan.id}/stornieren`, {}, { preserveScroll: true });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Meine IT">
|
||||
<PageHeader title="Meine IT" description="Ihre Geräte, Tickets und Leihgeräte an einem Ort.">
|
||||
<template v-if="configured" #actions>
|
||||
<Button variant="outline" as-child><Link href="/it-service/leihgeraete"><CalendarClock /> Leihgerät ausleihen</Link></Button>
|
||||
<Button as-child><Link href="/it-service/tickets/neu"><MessageSquarePlus /> Ticket erstellen</Link></Button>
|
||||
</template>
|
||||
</PageHeader>
|
||||
|
||||
<div v-if="!configured" class="rounded-lg border bg-card">
|
||||
<EmptyState :icon="Plug" title="Der IT-Service ist noch nicht eingerichtet" text="Die Administration verbindet das Portal unter „Portal → IT-Service“ mit OpenNIT." />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div v-if="intro" class="prose prose-sm mb-6 max-w-none rounded-lg border border-brand-200 bg-brand-soft/60 px-5 py-4 dark:prose-invert" v-html="intro" />
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-12">
|
||||
<!-- Tickets -->
|
||||
<Panel title="Meine Tickets" class="min-w-0 lg:col-span-7 xl:col-span-8">
|
||||
<Deferred data="tickets">
|
||||
<template #fallback>
|
||||
<div class="grid gap-2"><Skeleton v-for="n in 4" :key="n" class="h-14" /></div>
|
||||
</template>
|
||||
<p v-if="!tickets.ok" class="flex items-center gap-2 text-sm text-destructive"><CircleAlert class="size-4" /> {{ tickets.error }}</p>
|
||||
<EmptyState v-else-if="!tickets.data.length" :icon="TicketCheck" title="Keine Tickets" text="Wenn etwas nicht funktioniert: „Ticket erstellen“ – die IT kümmert sich darum." />
|
||||
<ul v-else class="-mx-2 divide-y">
|
||||
<li v-for="ticket in tickets.data" :key="ticket.id">
|
||||
<Link :href="`/it-service/tickets/${ticket.id}`" class="flex items-center gap-3 rounded-md px-2 py-3 hover:bg-accent/60">
|
||||
<span class="grid size-9 shrink-0 place-items-center rounded-md" :class="ticket.open ? 'bg-brand-soft text-brand-text' : 'bg-muted text-muted-foreground'">
|
||||
<LifeBuoy class="size-4" />
|
||||
</span>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate text-sm font-medium" :class="{ 'text-muted-foreground': !ticket.open }">{{ ticket.subject }}</span>
|
||||
<span class="block text-xs text-muted-foreground">
|
||||
<template v-if="ticket.number">#{{ ticket.number }} · </template>erstellt {{ formatDate(ticket.created_at, true) }}
|
||||
</span>
|
||||
</span>
|
||||
<StatusBadge :label="ticket.status_label" :tone="ticketTone(ticket)" />
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</Deferred>
|
||||
</Panel>
|
||||
|
||||
<div class="grid content-start gap-6 lg:col-span-5 xl:col-span-4">
|
||||
<!-- Geräte -->
|
||||
<Panel title="Meine Geräte">
|
||||
<Deferred data="assets">
|
||||
<template #fallback>
|
||||
<div class="grid gap-2"><Skeleton v-for="n in 2" :key="n" class="h-20" /></div>
|
||||
</template>
|
||||
<p v-if="!assets.ok" class="flex items-center gap-2 text-sm text-destructive"><CircleAlert class="size-4" /> {{ assets.error }}</p>
|
||||
<p v-else-if="!assets.data.length" class="text-[13px] text-muted-foreground">Ihnen sind keine Geräte zugeordnet.</p>
|
||||
<ul v-else class="grid gap-3">
|
||||
<li v-for="asset in assets.data" :key="asset.id" class="rounded-lg border p-3">
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="grid size-10 shrink-0 place-items-center rounded-md bg-muted text-foreground/70"><Laptop class="size-5" /></span>
|
||||
<div class="min-w-0 flex-1">
|
||||
<p class="font-medium leading-tight">{{ asset.name }}</p>
|
||||
<p class="mt-0.5 text-xs text-muted-foreground">
|
||||
{{ [asset.type, asset.manufacturer && asset.model ? `${asset.manufacturer} ${asset.model}` : asset.model].filter(Boolean).join(' · ') }}
|
||||
</p>
|
||||
<dl class="mt-2 grid gap-0.5 text-xs">
|
||||
<div v-if="asset.inventory" class="flex gap-1.5"><dt class="text-muted-foreground">Inventar-Nr.</dt><dd class="font-mono">{{ asset.inventory }}</dd></div>
|
||||
<div v-if="asset.serial" class="flex gap-1.5"><dt class="text-muted-foreground">Seriennummer</dt><dd class="font-mono">{{ asset.serial }}</dd></div>
|
||||
<div v-if="warranty(asset)" class="flex items-center gap-1.5" :class="warranty(asset).tone"><ShieldCheck class="size-3.5" /> {{ warranty(asset).text }}</div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" class="mt-3 w-full" as-child>
|
||||
<Link :href="`/it-service/tickets/neu?geraet=${asset.id}`"><MessageSquarePlus /> Problem mit diesem Gerät melden</Link>
|
||||
</Button>
|
||||
</li>
|
||||
</ul>
|
||||
</Deferred>
|
||||
</Panel>
|
||||
|
||||
<!-- Ausleihen -->
|
||||
<Panel title="Meine Ausleihen" action-label="Leihgeräte" action-href="/it-service/leihgeraete">
|
||||
<Deferred data="loans">
|
||||
<template #fallback>
|
||||
<div class="grid gap-2"><Skeleton v-for="n in 2" :key="n" class="h-12" /></div>
|
||||
</template>
|
||||
<p v-if="!loans.ok" class="flex items-center gap-2 text-sm text-destructive"><CircleAlert class="size-4" /> {{ loans.error }}</p>
|
||||
<p v-else-if="!loans.data.length" class="text-[13px] text-muted-foreground">Keine laufenden Ausleihen oder Anfragen.</p>
|
||||
<ul v-else class="-mx-1 divide-y">
|
||||
<li v-for="loan in loans.data" :key="loan.id" class="flex items-center gap-3 px-1 py-2.5">
|
||||
<div class="min-w-0 flex-1">
|
||||
<p class="truncate text-sm font-medium">{{ loan.device }}</p>
|
||||
<p class="text-xs text-muted-foreground tabular-nums">{{ formatDate(loan.start) }} – {{ formatDate(loan.end) }}</p>
|
||||
</div>
|
||||
<StatusBadge :label="loan.status_label" :tone="loanTone(loan)" />
|
||||
<button v-if="loan.cancellable" type="button" class="grid size-7 place-items-center rounded-md text-muted-foreground hover:bg-accent hover:text-destructive" :title="`„${loan.device}“ stornieren`" @click="cancel(loan)">
|
||||
<X class="size-4" />
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
</Deferred>
|
||||
</Panel>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</AppLayout>
|
||||
</template>
|
||||
139
plugins-core/it-service/resources/js/pages/Loans.vue
Normal file
139
plugins-core/it-service/resources/js/pages/Loans.vue
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<script setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { Link, router, useForm } from '@inertiajs/vue3';
|
||||
import { ArrowLeft, CalendarClock, CircleAlert, LoaderCircle, MonitorSmartphone, Send } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||
import EmptyState from '@/components/EmptyState.vue';
|
||||
import FormField from '@/components/FormField.vue';
|
||||
import NativeSelect from '@/components/NativeSelect.vue';
|
||||
import PageHeader from '@/components/PageHeader.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import { http } from '@/lib/http';
|
||||
import RangeCalendar from '../components/RangeCalendar.vue';
|
||||
import { formatDate } from '../status';
|
||||
|
||||
const props = defineProps({
|
||||
filters: { type: Object, required: true },
|
||||
types: { type: Object, required: true },
|
||||
devices: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const filter = ref({ typ: props.filters.type ?? '', von: props.filters.from ?? '', bis: props.filters.to ?? '' });
|
||||
const typeOptions = computed(() => (props.types.ok ? props.types.data.map((t) => ({ value: t, label: t })) : []));
|
||||
|
||||
watch(filter, (value) => {
|
||||
const query = Object.fromEntries(Object.entries(value).filter(([, v]) => v));
|
||||
router.get('/it-service/leihgeraete', query, { preserveState: true, preserveScroll: true, replace: true });
|
||||
}, { deep: true });
|
||||
|
||||
// Anfrage-Dialog
|
||||
const device = ref(null);
|
||||
const slots = ref([]);
|
||||
const slotsError = ref(null);
|
||||
const loadingSlots = ref(false);
|
||||
const form = useForm({ device_id: null, planned_start: '', planned_end: '', purpose: '' });
|
||||
|
||||
async function open(item) {
|
||||
device.value = item;
|
||||
form.reset();
|
||||
form.clearErrors();
|
||||
form.device_id = item.id;
|
||||
form.planned_start = props.filters.from ?? '';
|
||||
form.planned_end = props.filters.to ?? '';
|
||||
slots.value = [];
|
||||
slotsError.value = null;
|
||||
loadingSlots.value = true;
|
||||
|
||||
try {
|
||||
slots.value = (await http.get(`/it-service/leihgeraete/${item.id}/belegung`)).slots;
|
||||
} catch (error) {
|
||||
slotsError.value = error.message;
|
||||
} finally {
|
||||
loadingSlots.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function submit() {
|
||||
form.post('/it-service/leihgeraete/anfragen', { onSuccess: () => (device.value = null) });
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Leihgeräte">
|
||||
<Link href="/it-service" class="mb-3 inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground"><ArrowLeft class="size-4" /> Meine IT</Link>
|
||||
<PageHeader title="Leihgeräte" description="Laptops, Beamer, Kameras & Co. für einen bestimmten Zeitraum ausleihen." />
|
||||
|
||||
<div class="mb-6 grid gap-3 rounded-lg border bg-card p-4 sm:grid-cols-3">
|
||||
<FormField id="type" label="Gerätetyp">
|
||||
<NativeSelect id="type" v-model="filter.typ" :options="typeOptions" placeholder="Alle Typen" />
|
||||
</FormField>
|
||||
<FormField id="from" label="Benötigt ab">
|
||||
<Input id="from" v-model="filter.von" type="date" />
|
||||
</FormField>
|
||||
<FormField id="to" label="Benötigt bis">
|
||||
<Input id="to" v-model="filter.bis" type="date" :min="filter.von || undefined" />
|
||||
</FormField>
|
||||
</div>
|
||||
|
||||
<p v-if="!devices.ok" class="flex items-center gap-2 rounded-lg border bg-card p-4 text-sm text-destructive"><CircleAlert class="size-4" /> {{ devices.error }}</p>
|
||||
<div v-else-if="!devices.data.length" class="rounded-lg border bg-card">
|
||||
<EmptyState :icon="MonitorSmartphone" title="Keine passenden Leihgeräte" text="Anderen Zeitraum oder Gerätetyp versuchen." />
|
||||
</div>
|
||||
<div v-else class="grid gap-4 sm:grid-cols-2 xl:grid-cols-3">
|
||||
<article v-for="item in devices.data" :key="item.id" class="flex flex-col rounded-lg border bg-card p-4">
|
||||
<div class="flex items-start gap-3">
|
||||
<span class="grid size-10 shrink-0 place-items-center rounded-md bg-muted text-foreground/70"><MonitorSmartphone class="size-5" /></span>
|
||||
<div class="min-w-0 flex-1">
|
||||
<h2 class="font-medium leading-tight">{{ item.title }}</h2>
|
||||
<p v-if="item.type" class="text-xs text-muted-foreground">{{ item.type }}</p>
|
||||
</div>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 text-[11px] font-semibold"
|
||||
:class="item.available ? 'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-200' : 'bg-muted text-muted-foreground'"
|
||||
>
|
||||
{{ item.available ? 'verfügbar' : 'belegt' }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="item.description" class="mt-3 line-clamp-3 text-[13px] text-muted-foreground">{{ item.description }}</p>
|
||||
<Button class="mt-4" variant="outline" @click="open(item)"><CalendarClock /> Zeitraum wählen</Button>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<Dialog :open="!!device" @update:open="(v) => !v && (device = null)">
|
||||
<DialogContent class="sm:max-w-2xl">
|
||||
<DialogHeader>
|
||||
<DialogTitle>{{ device?.title }} ausleihen</DialogTitle>
|
||||
<DialogDescription>Die IT bestätigt die Anfrage bzw. organisiert die Übergabe.</DialogDescription>
|
||||
</DialogHeader>
|
||||
<form class="grid gap-4" @submit.prevent="submit">
|
||||
<div v-if="loadingSlots" class="grid h-64 place-items-center text-sm text-muted-foreground"><LoaderCircle class="size-5 animate-spin" /></div>
|
||||
<template v-else>
|
||||
<p v-if="slotsError" class="text-xs text-muted-foreground">Belegung konnte nicht geladen werden – bitte Zeitraum trotzdem wählen.</p>
|
||||
<RangeCalendar v-model:start="form.planned_start" v-model:end="form.planned_end" :slots="slots" />
|
||||
</template>
|
||||
<div class="grid gap-3 sm:grid-cols-2">
|
||||
<FormField id="start" label="Von" :error="form.errors.planned_start">
|
||||
<Input id="start" v-model="form.planned_start" type="date" required />
|
||||
</FormField>
|
||||
<FormField id="end" label="Bis" :error="form.errors.planned_end">
|
||||
<Input id="end" v-model="form.planned_end" type="date" :min="form.planned_start || undefined" required />
|
||||
</FormField>
|
||||
</div>
|
||||
<FormField id="purpose" label="Wofür? (optional)" :error="form.errors.purpose">
|
||||
<Textarea id="purpose" v-model="form.purpose" rows="2" maxlength="500" placeholder="z. B. Präsentation beim Fachtag" />
|
||||
</FormField>
|
||||
<DialogFooter>
|
||||
<p v-if="form.planned_start && form.planned_end" class="mr-auto self-center text-[13px] text-muted-foreground">{{ formatDate(form.planned_start) }} – {{ formatDate(form.planned_end) }}</p>
|
||||
<Button type="button" variant="outline" @click="device = null">Abbrechen</Button>
|
||||
<Button type="submit" :disabled="form.processing || !form.planned_start || !form.planned_end">
|
||||
<LoaderCircle v-if="form.processing" class="animate-spin" /><Send v-else /> Anfragen
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</AppLayout>
|
||||
</template>
|
||||
103
plugins-core/it-service/resources/js/pages/Ticket.vue
Normal file
103
plugins-core/it-service/resources/js/pages/Ticket.vue
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<script setup>
|
||||
import { watch } from 'vue';
|
||||
import { Link, useForm, usePage } from '@inertiajs/vue3';
|
||||
import { ArrowLeft, Headset, Laptop, LoaderCircle, MapPin, Paperclip, Send, Tag, UserRound } from '@lucide/vue';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import PersonAvatar from '@/components/PersonAvatar.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
import StatusBadge from '../components/StatusBadge.vue';
|
||||
import { formatDate, ticketTone } from '../status';
|
||||
|
||||
const props = defineProps({
|
||||
ticket: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const page = usePage();
|
||||
const me = page.props.auth?.user;
|
||||
watch(() => page.props.flash.status, (status) => status && toast.success(status), { immediate: true });
|
||||
|
||||
const form = useForm({ message: '' });
|
||||
|
||||
function send() {
|
||||
form.post(`/it-service/tickets/${props.ticket.id}/antworten`, { preserveScroll: true, onSuccess: () => form.reset() });
|
||||
}
|
||||
|
||||
const size = (bytes) => (bytes ? (bytes > 1_048_576 ? `${(bytes / 1_048_576).toFixed(1)} MB` : `${Math.max(1, Math.round(bytes / 1024))} KB`) : '');
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout :title="ticket.subject">
|
||||
<Link href="/it-service" class="mb-3 inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground"><ArrowLeft class="size-4" /> Meine IT</Link>
|
||||
|
||||
<div class="grid grid-cols-1 items-start gap-6 lg:grid-cols-12">
|
||||
<div class="grid min-w-0 grid-cols-1 gap-6 lg:col-span-8">
|
||||
<!-- Ticket -->
|
||||
<article class="rounded-xl border bg-card p-6 shadow-xs">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
<div class="min-w-0">
|
||||
<p class="text-xs font-medium text-muted-foreground"><template v-if="ticket.number">Ticket #{{ ticket.number }} · </template>erstellt {{ formatDate(ticket.created_at, true) }}</p>
|
||||
<h1 class="mt-1 text-2xl font-semibold tracking-tight text-balance">{{ ticket.subject }}</h1>
|
||||
</div>
|
||||
<StatusBadge :label="ticket.status_label" :tone="ticketTone(ticket)" class="text-xs" />
|
||||
</div>
|
||||
<p v-if="ticket.description" class="mt-5 text-[15px] leading-relaxed whitespace-pre-line">{{ ticket.description }}</p>
|
||||
</article>
|
||||
|
||||
<!-- Verlauf -->
|
||||
<section v-if="ticket.replies.length" aria-label="Verlauf" class="grid gap-4">
|
||||
<div v-for="(reply, index) in ticket.replies" :key="index" class="flex gap-3" :class="reply.from_staff ? '' : 'flex-row-reverse'">
|
||||
<span v-if="reply.from_staff" class="grid size-9 shrink-0 place-items-center rounded-full bg-brand text-brand-foreground"><Headset class="size-4" /></span>
|
||||
<PersonAvatar v-else-if="me" :person="me" class="size-9" />
|
||||
<span v-else class="grid size-9 shrink-0 place-items-center rounded-full bg-muted"><UserRound class="size-4" /></span>
|
||||
<div class="max-w-[85%] rounded-xl border px-4 py-3" :class="reply.from_staff ? 'bg-card' : 'border-brand-200 bg-brand-soft/60'">
|
||||
<p class="mb-1 text-xs text-muted-foreground">
|
||||
<span class="font-medium text-foreground">{{ reply.from_staff ? reply.author || 'IT-Service' : 'Sie' }}</span>
|
||||
<template v-if="reply.created_at"> · {{ formatDate(reply.created_at, true) }}</template>
|
||||
</p>
|
||||
<p class="text-sm leading-relaxed whitespace-pre-line">{{ reply.message }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Antworten -->
|
||||
<form class="rounded-xl border bg-card p-4 shadow-xs" @submit.prevent="send">
|
||||
<label for="message" class="text-sm font-medium">{{ ticket.open ? 'Antworten' : 'Das Ticket ist abgeschlossen – mit einer Antwort können Sie sich erneut melden.' }}</label>
|
||||
<Textarea id="message" v-model="form.message" rows="4" maxlength="20000" class="mt-2" placeholder="Ihre Nachricht an die IT …" />
|
||||
<p v-if="form.errors.message" class="mt-1 text-[13px] text-destructive">{{ form.errors.message }}</p>
|
||||
<div class="mt-3 flex justify-end">
|
||||
<Button type="submit" :disabled="form.processing || !form.message.trim()">
|
||||
<LoaderCircle v-if="form.processing" class="animate-spin" /><Send v-else /> Senden
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<aside class="grid content-start gap-4 lg:col-span-4">
|
||||
<section class="rounded-xl border bg-card p-5 shadow-xs">
|
||||
<h2 class="mb-3 text-xs font-semibold tracking-wider text-muted-foreground uppercase">Details</h2>
|
||||
<dl class="grid gap-2.5 text-sm">
|
||||
<div v-if="ticket.asset" class="flex items-center gap-2"><Laptop class="size-4 text-muted-foreground" /><dt class="sr-only">Gerät</dt><dd>{{ ticket.asset }}</dd></div>
|
||||
<div v-if="ticket.category" class="flex items-center gap-2"><Tag class="size-4 text-muted-foreground" /><dt class="sr-only">Kategorie</dt><dd>{{ ticket.category }}</dd></div>
|
||||
<div v-if="ticket.location" class="flex items-center gap-2"><MapPin class="size-4 text-muted-foreground" /><dt class="sr-only">Standort</dt><dd>{{ ticket.location }}</dd></div>
|
||||
<div class="flex items-center gap-2"><Headset class="size-4 text-muted-foreground" /><dt class="sr-only">Bearbeitet von</dt><dd>{{ ticket.assignees.length ? ticket.assignees.join(', ') : 'Noch nicht zugewiesen' }}</dd></div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<section v-if="ticket.attachments.length" class="rounded-xl border bg-card p-5 shadow-xs">
|
||||
<h2 class="mb-3 text-xs font-semibold tracking-wider text-muted-foreground uppercase">Anhänge</h2>
|
||||
<ul class="grid gap-1">
|
||||
<li v-for="file in ticket.attachments" :key="file.id">
|
||||
<a :href="`/it-service/anhaenge/${file.id}`" class="flex items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-accent">
|
||||
<Paperclip class="size-4 text-muted-foreground" />
|
||||
<span class="min-w-0 flex-1 truncate">{{ file.name }}</span>
|
||||
<span class="text-xs text-muted-foreground">{{ size(file.size) }}</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</aside>
|
||||
</div>
|
||||
</AppLayout>
|
||||
</template>
|
||||
103
plugins-core/it-service/resources/js/pages/TicketCreate.vue
Normal file
103
plugins-core/it-service/resources/js/pages/TicketCreate.vue
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<script setup>
|
||||
import { computed } from 'vue';
|
||||
import { Link, useForm } from '@inertiajs/vue3';
|
||||
import { ArrowLeft, CircleAlert, HelpCircle, Laptop, LoaderCircle, Send } from '@lucide/vue';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import FormField from '@/components/FormField.vue';
|
||||
import NativeSelect from '@/components/NativeSelect.vue';
|
||||
import PageHeader from '@/components/PageHeader.vue';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import AppLayout from '@/layouts/AppLayout.vue';
|
||||
|
||||
const props = defineProps({
|
||||
assetId: { type: Number, default: null },
|
||||
assets: { type: Object, required: true },
|
||||
options: { type: Object, required: true },
|
||||
});
|
||||
|
||||
const myAssets = computed(() => (props.assets.ok ? props.assets.data : []));
|
||||
const categories = computed(() => (props.options.ok ? props.options.data.categories : []));
|
||||
const locations = computed(() => (props.options.ok ? props.options.data.locations : []));
|
||||
|
||||
const form = useForm({
|
||||
asset_id: myAssets.value.some((a) => a.id === props.assetId) ? props.assetId : null,
|
||||
subject: '',
|
||||
description: '',
|
||||
category_id: null,
|
||||
location_id: null,
|
||||
});
|
||||
|
||||
function submit() {
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
asset_id: data.asset_id || null,
|
||||
category_id: data.category_id ? Number(data.category_id) : null,
|
||||
location_id: data.location_id ? Number(data.location_id) : null,
|
||||
})).post('/it-service/tickets');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<AppLayout title="Ticket erstellen">
|
||||
<Link href="/it-service" class="mb-3 inline-flex items-center gap-1.5 text-sm font-medium text-muted-foreground hover:text-foreground"><ArrowLeft class="size-4" /> Meine IT</Link>
|
||||
<PageHeader title="Ticket erstellen" description="Beschreiben Sie kurz, was nicht funktioniert – die IT meldet sich." />
|
||||
|
||||
<form class="grid grid-cols-1 items-start gap-6 lg:grid-cols-12" @submit.prevent="submit">
|
||||
<Panel title="Worum geht es?" class="lg:col-span-5 xl:col-span-4">
|
||||
<div class="grid gap-2" role="radiogroup" aria-label="Gerät">
|
||||
<label
|
||||
v-for="asset in myAssets"
|
||||
:key="asset.id"
|
||||
class="flex cursor-pointer items-center gap-3 rounded-lg border p-3 transition-colors"
|
||||
:class="form.asset_id === asset.id ? 'border-brand bg-brand-soft/60 ring-1 ring-brand' : 'hover:bg-accent/60'"
|
||||
>
|
||||
<input v-model="form.asset_id" type="radio" :value="asset.id" class="sr-only" />
|
||||
<span class="grid size-9 shrink-0 place-items-center rounded-md bg-muted text-foreground/70"><Laptop class="size-4" /></span>
|
||||
<span class="min-w-0">
|
||||
<span class="block text-sm font-medium">{{ asset.name }}</span>
|
||||
<span class="block truncate text-xs text-muted-foreground">{{ [asset.type, asset.serial && `SN ${asset.serial}`].filter(Boolean).join(' · ') }}</span>
|
||||
</span>
|
||||
</label>
|
||||
<label
|
||||
class="flex cursor-pointer items-center gap-3 rounded-lg border p-3 transition-colors"
|
||||
:class="!form.asset_id ? 'border-brand bg-brand-soft/60 ring-1 ring-brand' : 'hover:bg-accent/60'"
|
||||
>
|
||||
<input v-model="form.asset_id" type="radio" :value="null" class="sr-only" />
|
||||
<span class="grid size-9 shrink-0 place-items-center rounded-md bg-muted text-foreground/70"><HelpCircle class="size-4" /></span>
|
||||
<span>
|
||||
<span class="block text-sm font-medium">Allgemeines Anliegen</span>
|
||||
<span class="block text-xs text-muted-foreground">ohne bestimmtes Gerät, z. B. Zugang, Software, Frage</span>
|
||||
</span>
|
||||
</label>
|
||||
<p v-if="!assets.ok" class="flex items-center gap-2 text-xs text-muted-foreground"><CircleAlert class="size-3.5" /> Ihre Geräte konnten nicht geladen werden.</p>
|
||||
</div>
|
||||
</Panel>
|
||||
|
||||
<Panel title="Beschreibung" class="lg:col-span-7 xl:col-span-8">
|
||||
<div class="grid gap-4">
|
||||
<FormField id="subject" label="Betreff" :error="form.errors.subject">
|
||||
<Input id="subject" v-model="form.subject" maxlength="200" placeholder="z. B. Drucker im 2. OG druckt nicht" required />
|
||||
</FormField>
|
||||
<FormField id="description" label="Was ist passiert?" :error="form.errors.description" hint="Seit wann? Gibt es eine Fehlermeldung? Was haben Sie schon versucht?">
|
||||
<Textarea id="description" v-model="form.description" rows="7" maxlength="20000" required />
|
||||
</FormField>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<FormField v-if="categories.length" id="category" label="Kategorie" :error="form.errors.category_id">
|
||||
<NativeSelect id="category" v-model="form.category_id" :options="categories" placeholder="– bitte wählen –" />
|
||||
</FormField>
|
||||
<FormField v-if="locations.length" id="location" label="Standort" :error="form.errors.location_id">
|
||||
<NativeSelect id="location" v-model="form.location_id" :options="locations" placeholder="– bitte wählen –" />
|
||||
</FormField>
|
||||
</div>
|
||||
<div class="flex justify-end border-t pt-4">
|
||||
<Button type="submit" :disabled="form.processing">
|
||||
<LoaderCircle v-if="form.processing" class="animate-spin" /><Send v-else /> Ticket absenden
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Panel>
|
||||
</form>
|
||||
</AppLayout>
|
||||
</template>
|
||||
25
plugins-core/it-service/resources/js/status.js
Normal file
25
plugins-core/it-service/resources/js/status.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/** Farbe der Status-Plakette zu Tickets und Ausleihen */
|
||||
export function ticketTone(ticket) {
|
||||
const status = (ticket.status || '').toLowerCase();
|
||||
|
||||
if (!ticket.open) return 'done';
|
||||
if (['in_progress', 'in_bearbeitung', 'assigned'].includes(status)) return 'progress';
|
||||
if (['pending', 'waiting', 'wartend', 'on_hold'].includes(status)) return 'waiting';
|
||||
|
||||
return 'open';
|
||||
}
|
||||
|
||||
export function loanTone(loan) {
|
||||
return { pending: 'waiting', reserved: 'open', active: 'progress', returned: 'done' }[loan.status] ?? 'neutral';
|
||||
}
|
||||
|
||||
const dateFormat = new Intl.DateTimeFormat('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric' });
|
||||
const dateTimeFormat = new Intl.DateTimeFormat('de-DE', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit' });
|
||||
|
||||
/** Datumsangaben aus OpenNIT („2026-04-17 10:30“ oder ISO) lesbar machen */
|
||||
export function formatDate(value, withTime = false) {
|
||||
if (!value) return '';
|
||||
const date = new Date(String(value).replace(' ', 'T'));
|
||||
|
||||
return Number.isNaN(date.getTime()) ? String(value) : (withTime && /\d{2}:\d{2}/.test(value) ? dateTimeFormat : dateFormat).format(date);
|
||||
}
|
||||
53
plugins-core/it-service/resources/js/widgets/MyIt.vue
Normal file
53
plugins-core/it-service/resources/js/widgets/MyIt.vue
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<script setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { Link } from '@inertiajs/vue3';
|
||||
import { CalendarClock, LifeBuoy, MessageSquarePlus } from '@lucide/vue';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import Panel from '@/components/Panel.vue';
|
||||
import { http } from '@/lib/http';
|
||||
|
||||
/**
|
||||
* „Meine IT“ auf der Startseite. Lädt die Zahlen selbst nach, damit die Startseite
|
||||
* nicht auf OpenNIT warten muss.
|
||||
*/
|
||||
const data = ref(null);
|
||||
const failed = ref(false);
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
data.value = await http.get('/it-service/uebersicht');
|
||||
} catch {
|
||||
failed.value = true;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Panel title="Meine IT" action-label="Öffnen" action-href="/it-service">
|
||||
<div v-if="!data && !failed" class="grid grid-cols-2 gap-2"><Skeleton class="h-16" /><Skeleton class="h-16" /></div>
|
||||
<template v-else-if="data">
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<Link href="/it-service" class="rounded-md bg-muted px-3 py-2.5 hover:bg-brand-soft">
|
||||
<span class="block text-xl font-semibold tabular-nums">{{ data.open_tickets }}</span>
|
||||
<span class="flex items-center gap-1 text-xs text-muted-foreground"><LifeBuoy class="size-3.5" /> offene Tickets</span>
|
||||
</Link>
|
||||
<Link href="/it-service" class="rounded-md bg-muted px-3 py-2.5 hover:bg-brand-soft">
|
||||
<span class="block text-xl font-semibold tabular-nums">{{ data.loans }}</span>
|
||||
<span class="flex items-center gap-1 text-xs text-muted-foreground"><CalendarClock class="size-3.5" /> Ausleihen</span>
|
||||
</Link>
|
||||
</div>
|
||||
<ul v-if="data.latest.length" class="mt-3 grid gap-0.5">
|
||||
<li v-for="ticket in data.latest" :key="ticket.id">
|
||||
<Link :href="`/it-service/tickets/${ticket.id}`" class="flex items-center justify-between gap-2 rounded px-1 py-1 text-[13px] hover:bg-accent">
|
||||
<span class="truncate">{{ ticket.subject }}</span>
|
||||
<span class="shrink-0 text-[11px] text-muted-foreground">{{ ticket.status_label }}</span>
|
||||
</Link>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
<p v-else class="text-[13px] text-muted-foreground">Der IT-Service ist gerade nicht erreichbar.</p>
|
||||
<Link href="/it-service/tickets/neu" class="mt-3 flex items-center gap-1.5 border-t pt-3 text-[13px] font-medium text-brand-text hover:underline">
|
||||
<MessageSquarePlus class="size-4" /> IT-Problem melden
|
||||
</Link>
|
||||
</Panel>
|
||||
</template>
|
||||
Loading…
Add table
Add a link
Reference in a new issue