MIF_E31230820/resources/views/riwayat.blade.php

188 lines
9.3 KiB
PHP

@extends('layouts.main')
@section('title', 'Riwayat Prediksi AI - Rice Leaf AI')
@section('content')
<div class="max-w-7xl mx-auto px-6 py-10">
<div class="bg-white p-8 rounded-3xl shadow-sm border border-gray-100">
<div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-8 gap-4">
<div>
<h1 class="text-3xl font-extrabold text-gray-800">
Riwayat Prediksi
</h1>
<p class="text-gray-500 mt-1 text-sm">Kelola dan pantau hasil klasifikasi daun padi yang telah dilakukan.</p>
</div>
<div class="flex gap-3">
<a href="/export-pdf" class="bg-red-50 text-red-600 hover:bg-red-600 hover:text-white px-5 py-2.5 rounded-xl font-semibold transition-all duration-300 flex items-center gap-2 border border-red-100 hover:border-transparent shadow-sm">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path></svg>
Download PDF
</a>
</div>
</div>
<div class="bg-gray-50 p-4 rounded-2xl border border-gray-100 mb-8">
<form method="GET" class="flex flex-col md:flex-row gap-4">
<div class="relative flex-grow">
<div class="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
</div>
<input type="text"
name="search"
placeholder="Cari berdasarkan penyakit..."
value="{{ request('search') }}"
class="w-full pl-11 pr-4 py-3 bg-white border border-gray-200 rounded-xl focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-shadow outline-none text-gray-700 shadow-sm">
</div>
<div class="md:w-48 shrink-0">
<select name="filter"
class="w-full px-4 py-3 bg-white border border-gray-200 rounded-xl focus:ring-2 focus:ring-green-500 focus:border-green-500 transition-shadow outline-none text-gray-700 shadow-sm appearance-none cursor-pointer">
<option value="">Semua Penyakit</option>
<option value="Blast" {{ request('filter') == 'Blast' ? 'selected' : '' }}>Blast</option>
<option value="Blight" {{ request('filter') == 'Blight' ? 'selected' : '' }}>Blight</option>
<option value="Tungro" {{ request('filter') == 'Tungro' ? 'selected' : '' }}>Tungro</option>
<option value="Healthy" {{ request('filter') == 'Healthy' ? 'selected' : '' }}>Healthy</option>
</select>
</div>
<button type="submit"
class="bg-green-600 hover:bg-green-700 text-white px-8 py-3 rounded-xl font-semibold transition-all duration-300 shadow-md hover:shadow-lg flex items-center justify-center gap-2 shrink-0">
Cari Data
</button>
</form>
</div>
<div class="overflow-x-auto rounded-2xl border border-gray-100">
<table class="w-full whitespace-nowrap">
<thead class="bg-gray-50 border-b border-gray-100 text-gray-500 text-xs uppercase tracking-wider font-semibold text-center">
<tr>
<th class="p-4 w-16">No</th>
<th class="p-4 text-left">Gambar</th>
<th class="p-4">Penyakit</th>
<th class="p-4">Confidence</th>
<th class="p-4">Tanggal</th>
<th class="p-4">Aksi</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-50 text-center">
@foreach($data as $item)
<tr class="hover:bg-green-50/30 transition-colors group">
<td class="p-4 text-gray-500 font-medium">
{{ $loop->iteration }}
</td>
<td class="p-4 text-left">
<img src="{{ asset('uploads/' . $item->gambar) }}"
class="w-20 h-20 object-cover rounded-xl shadow-sm border border-gray-200 group-hover:scale-105 transition-transform duration-300">
</td>
<td class="p-4">
@if($item->penyakit == 'Blast')
<span class="inline-flex items-center justify-center bg-red-50 text-red-600 px-4 py-1.5 rounded-lg font-bold border border-red-100">
Blast
</span>
@elseif($item->penyakit == 'Blight')
<span class="inline-flex items-center justify-center bg-yellow-50 text-yellow-600 px-4 py-1.5 rounded-lg font-bold border border-yellow-100">
Blight
</span>
@elseif($item->penyakit == 'Tungro')
<span class="inline-flex items-center justify-center bg-orange-50 text-orange-600 px-4 py-1.5 rounded-lg font-bold border border-orange-100">
Tungro
</span>
@else
<span class="inline-flex items-center justify-center bg-green-50 text-green-600 px-4 py-1.5 rounded-lg font-bold border border-green-100">
Healthy
</span>
@endif
</td>
<td class="p-4">
<span class="font-bold text-gray-700">{{ $item->confidence }}%</span>
</td>
<td class="p-4 text-sm text-gray-500">
{{ $item->created_at }}
</td>
<td class="p-4">
<form action="/hapus/{{ $item->id }}" method="POST" class="formHapus inline-block">
@csrf
@method('DELETE')
<button type="submit"
class="bg-white border border-red-200 text-red-500 hover:bg-red-50 hover:text-red-600 px-4 py-2 rounded-xl text-sm font-semibold transition-all duration-300 flex items-center gap-2 mx-auto">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>
Hapus
</button>
</form>
</td>
</tr>
@endforeach
@if($data->isEmpty())
<tr>
<td colspan="6" class="p-10 text-center text-gray-400 font-medium">
Belum ada data riwayat prediksi.
</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
@if(session('success'))
<script>
Swal.fire({
icon: 'success',
title: 'Berhasil!',
text: '{{ session('success') }}',
timer: 2000,
showConfirmButton: false,
customClass: {
popup: 'rounded-3xl'
}
});
</script>
@endif
<script>
const forms = document.querySelectorAll('.formHapus');
forms.forEach(form => {
form.addEventListener('submit', function(e) {
e.preventDefault();
Swal.fire({
title: 'Yakin ingin menghapus?',
text: "Data prediksi ini tidak dapat dikembalikan!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#16a34a',
cancelButtonColor: '#ef4444',
confirmButtonText: 'Ya, Hapus!',
cancelButtonText: 'Batal',
customClass: {
popup: 'rounded-3xl',
confirmButton: 'rounded-xl px-6 py-2.5 font-semibold',
cancelButton: 'rounded-xl px-6 py-2.5 font-semibold'
}
}).then((result) => {
if (result.isConfirmed) {
form.submit();
}
});
});
});
</script>
@endpush
```