initial commit
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
<script setup>
|
||||
import SupervisorLayout from '@/Layouts/SupervisorLayout.vue';
|
||||
import { Head, Link, router } from '@inertiajs/vue3';
|
||||
import { reactive, watch } from 'vue';
|
||||
|
||||
const props = defineProps({
|
||||
machines: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
filters: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
statusOptions: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
typeOptions: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
|
||||
const localFilters = reactive({
|
||||
search: props.filters.search ?? '',
|
||||
status: props.filters.status ?? '',
|
||||
type: props.filters.type ?? '',
|
||||
});
|
||||
|
||||
let debounceTimer = null;
|
||||
|
||||
watch(localFilters, () => {
|
||||
clearTimeout(debounceTimer);
|
||||
debounceTimer = setTimeout(() => {
|
||||
router.get(route('supervisor.machines.index'), localFilters, {
|
||||
preserveState: true,
|
||||
replace: true,
|
||||
});
|
||||
}, 300);
|
||||
});
|
||||
|
||||
const statusColor = (status) => {
|
||||
const colors = {
|
||||
available: 'bg-green-100 text-green-800',
|
||||
reserved: 'bg-yellow-100 text-yellow-800',
|
||||
running: 'bg-blue-100 text-blue-800',
|
||||
maintenance: 'bg-orange-100 text-orange-800',
|
||||
offline: 'bg-gray-100 text-gray-800',
|
||||
error: 'bg-red-100 text-red-800',
|
||||
};
|
||||
return colors[status] ?? 'bg-gray-100 text-gray-800';
|
||||
};
|
||||
|
||||
const formatDate = (iso) => {
|
||||
if (!iso) return '—';
|
||||
return new Intl.DateTimeFormat('fr-FR', {
|
||||
dateStyle: 'short',
|
||||
timeStyle: 'short',
|
||||
}).format(new Date(iso));
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head title="Machines" />
|
||||
|
||||
<SupervisorLayout title="Machines">
|
||||
<!-- Filters -->
|
||||
<div class="mb-6 flex flex-wrap gap-4 rounded-lg bg-white p-4 shadow">
|
||||
<div class="min-w-[200px] flex-1">
|
||||
<label class="block text-xs font-medium text-gray-500">Recherche</label>
|
||||
<input
|
||||
v-model="localFilters.search"
|
||||
type="text"
|
||||
placeholder="Nom ou QR code…"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-500">Statut</label>
|
||||
<select
|
||||
v-model="localFilters.status"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||||
>
|
||||
<option value="">Tous</option>
|
||||
<option v-for="(label, value) in statusOptions" :key="value" :value="value">
|
||||
{{ label }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-gray-500">Type</label>
|
||||
<select
|
||||
v-model="localFilters.type"
|
||||
class="mt-1 block w-full rounded-md border-gray-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500"
|
||||
>
|
||||
<option value="">Tous</option>
|
||||
<option v-for="(label, value) in typeOptions" :key="value" :value="value">
|
||||
{{ label }}
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Table -->
|
||||
<div class="overflow-hidden rounded-lg bg-white shadow">
|
||||
<table class="min-w-full divide-y divide-gray-200">
|
||||
<thead class="bg-gray-50">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">
|
||||
Machine
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">
|
||||
Établissement
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">
|
||||
Type
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">
|
||||
Statut
|
||||
</th>
|
||||
<th class="px-4 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">
|
||||
Dernier signal
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-gray-100 bg-white">
|
||||
<tr v-if="machines.data.length === 0">
|
||||
<td colspan="5" class="px-4 py-8 text-center text-sm text-gray-500">
|
||||
Aucune machine trouvée.
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-for="machine in machines.data" :key="machine.uuid" class="hover:bg-gray-50">
|
||||
<td class="whitespace-nowrap px-4 py-3">
|
||||
<Link
|
||||
:href="route('supervisor.machines.show', machine.uuid)"
|
||||
class="font-medium text-indigo-600 hover:text-indigo-800"
|
||||
>
|
||||
{{ machine.name }}
|
||||
</Link>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-sm text-gray-600">
|
||||
{{ machine.establishment_name ?? '—' }}
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-sm text-gray-600">
|
||||
{{ machine.type_label }}
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-4 py-3">
|
||||
<span
|
||||
class="rounded-full px-2.5 py-0.5 text-xs font-medium"
|
||||
:class="statusColor(machine.status)"
|
||||
>
|
||||
{{ machine.status_label }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="whitespace-nowrap px-4 py-3 text-sm text-gray-500">
|
||||
{{ formatDate(machine.last_heartbeat_at) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Pagination -->
|
||||
<div v-if="machines.links.length > 3" class="flex items-center justify-between border-t px-4 py-3">
|
||||
<p class="text-sm text-gray-600">
|
||||
{{ machines.from ?? 0 }}–{{ machines.to ?? 0 }} sur {{ machines.total }}
|
||||
</p>
|
||||
<div class="flex gap-1">
|
||||
<Link
|
||||
v-for="link in machines.links"
|
||||
:key="link.label"
|
||||
:href="link.url"
|
||||
v-html="link.label"
|
||||
class="rounded px-3 py-1 text-sm"
|
||||
:class="
|
||||
link.active
|
||||
? 'bg-indigo-600 text-white'
|
||||
: link.url
|
||||
? 'text-gray-600 hover:bg-gray-100'
|
||||
: 'cursor-not-allowed text-gray-300'
|
||||
"
|
||||
preserve-state
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SupervisorLayout>
|
||||
</template>
|
||||
@@ -0,0 +1,142 @@
|
||||
<script setup>
|
||||
import SupervisorLayout from '@/Layouts/SupervisorLayout.vue';
|
||||
import { Head, Link } from '@inertiajs/vue3';
|
||||
|
||||
defineProps({
|
||||
machine: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
recentEvents: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const formatDate = (iso) => {
|
||||
if (!iso) return '—';
|
||||
return new Intl.DateTimeFormat('fr-FR', {
|
||||
dateStyle: 'medium',
|
||||
timeStyle: 'short',
|
||||
}).format(new Date(iso));
|
||||
};
|
||||
|
||||
const statusColor = (status) => {
|
||||
const colors = {
|
||||
available: 'bg-green-100 text-green-800',
|
||||
reserved: 'bg-yellow-100 text-yellow-800',
|
||||
running: 'bg-blue-100 text-blue-800',
|
||||
maintenance: 'bg-orange-100 text-orange-800',
|
||||
offline: 'bg-gray-100 text-gray-800',
|
||||
error: 'bg-red-100 text-red-800',
|
||||
};
|
||||
return colors[status] ?? 'bg-gray-100 text-gray-800';
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Head :title="machine.name" />
|
||||
|
||||
<SupervisorLayout>
|
||||
<template #header>
|
||||
<Link
|
||||
:href="route('supervisor.machines.index')"
|
||||
class="text-sm text-indigo-600 hover:text-indigo-800"
|
||||
>
|
||||
← Retour aux machines
|
||||
</Link>
|
||||
</template>
|
||||
|
||||
<div class="mb-4">
|
||||
<h1 class="text-2xl font-bold text-gray-900">{{ machine.name }}</h1>
|
||||
<p class="text-sm text-gray-500">{{ machine.establishment?.name }}</p>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
<!-- Details -->
|
||||
<div class="rounded-lg bg-white p-6 shadow">
|
||||
<h2 class="mb-4 text-lg font-semibold text-gray-800">Informations</h2>
|
||||
<dl class="space-y-3 text-sm">
|
||||
<div class="flex justify-between">
|
||||
<dt class="text-gray-500">Type</dt>
|
||||
<dd class="font-medium text-gray-800">{{ machine.type_label }}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<dt class="text-gray-500">Statut</dt>
|
||||
<dd>
|
||||
<span
|
||||
class="rounded-full px-2.5 py-0.5 text-xs font-medium"
|
||||
:class="statusColor(machine.status)"
|
||||
>
|
||||
{{ machine.status_label }}
|
||||
</span>
|
||||
</dd>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<dt class="text-gray-500">QR code</dt>
|
||||
<dd class="font-mono text-gray-800">{{ machine.qr_code }}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<dt class="text-gray-500">Dernier signal</dt>
|
||||
<dd class="text-gray-800">{{ formatDate(machine.last_heartbeat_at) }}</dd>
|
||||
</div>
|
||||
<div v-if="machine.cycle_started_at" class="flex justify-between">
|
||||
<dt class="text-gray-500">Cycle démarré</dt>
|
||||
<dd class="text-gray-800">{{ formatDate(machine.cycle_started_at) }}</dd>
|
||||
</div>
|
||||
<div v-if="machine.cycle_ends_at" class="flex justify-between">
|
||||
<dt class="text-gray-500">Fin de cycle prévue</dt>
|
||||
<dd class="text-gray-800">{{ formatDate(machine.cycle_ends_at) }}</dd>
|
||||
</div>
|
||||
<div v-if="machine.current_user" class="flex justify-between">
|
||||
<dt class="text-gray-500">Utilisateur actuel</dt>
|
||||
<dd class="text-gray-800">
|
||||
{{ machine.current_user.name }}
|
||||
<span class="text-gray-500">({{ machine.current_user.email }})</span>
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<div v-if="machine.establishment" class="mt-6 border-t pt-4">
|
||||
<h3 class="mb-2 text-sm font-semibold text-gray-700">Établissement</h3>
|
||||
<p class="text-sm text-gray-600">{{ machine.establishment.address }}</p>
|
||||
<p v-if="machine.establishment.city" class="text-sm text-gray-600">
|
||||
{{ machine.establishment.city }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="machine.integration" class="mt-6 border-t pt-4">
|
||||
<h3 class="mb-2 text-sm font-semibold text-gray-700">Intégration</h3>
|
||||
<dl class="space-y-2 text-sm">
|
||||
<div class="flex justify-between">
|
||||
<dt class="text-gray-500">Fournisseur</dt>
|
||||
<dd>{{ machine.integration.provider }}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<dt class="text-gray-500">Mode</dt>
|
||||
<dd>{{ machine.integration.mode }}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between">
|
||||
<dt class="text-gray-500">Active</dt>
|
||||
<dd>{{ machine.integration.is_active ? 'Oui' : 'Non' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Events -->
|
||||
<div class="rounded-lg bg-white p-6 shadow">
|
||||
<h2 class="mb-4 text-lg font-semibold text-gray-800">Événements récents</h2>
|
||||
<div v-if="recentEvents.length === 0" class="text-sm text-gray-500">
|
||||
Aucun événement enregistré.
|
||||
</div>
|
||||
<ul v-else class="divide-y divide-gray-100">
|
||||
<li v-for="(event, index) in recentEvents" :key="index" class="py-3">
|
||||
<p class="text-sm font-medium text-gray-800">{{ event.event_type_label }}</p>
|
||||
<p class="text-xs text-gray-500">{{ formatDate(event.occurred_at) }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</SupervisorLayout>
|
||||
</template>
|
||||
Reference in New Issue
Block a user