This commit is contained in:
@@ -1,23 +1,31 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title')
|
||||
{{ $pageInfo['title'] }}
|
||||
@endsection
|
||||
|
||||
@section('title', $pageInfo['title'])
|
||||
|
||||
@section('admin-content')
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="row mb-3">
|
||||
<div class="col-sm-6">
|
||||
<h1>{{ $pageInfo['title'] }}</h1>
|
||||
<h1 class="fw-bold text-dark">{{ $pageInfo['title'] }}</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ route('admin.dashboard') }}">{{ __('Dashboard') }}</a></li>
|
||||
<li class="breadcrumb-item active"><a href="{{ $pageInfo['path'] }}">{{ $pageInfo['title'] }}</a>
|
||||
</li>
|
||||
</ol>
|
||||
<!-- Tombol Aksi Global (Kanan Atas) -->
|
||||
<div class="float-sm-right d-flex align-items-center" style="gap: 10px;">
|
||||
<a href="{{ route('admin.audit-trail.clear-cache') }}"
|
||||
class="btn btn-outline-info btn-sm shadow-sm"
|
||||
onclick="return confirm('Apakah Anda yakin ingin mereset cache sistem?')">
|
||||
<i class="fa fa-sync"></i> Reset Cache
|
||||
</a>
|
||||
|
||||
<form action="{{ route('admin.audit-trail.clear') }}" method="POST" onsubmit="return confirm('PERINGATAN! Semua log audit akan dihapus permanen. Lanjutkan?')">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit" class="btn btn-outline-danger btn-sm shadow-sm">
|
||||
<i class="fa fa-trash"></i> Clear All Logs
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -25,82 +33,137 @@
|
||||
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title float-left">{{ $pageInfo['title'] }}</h4>
|
||||
<div class="clearfix"></div>
|
||||
<div class="data-tables">
|
||||
@include('backend.layouts.partials.messages')
|
||||
<div class="table-responsive">
|
||||
<table id="dataTable" class="text-center">
|
||||
<thead class="bg-light text-capitalize">
|
||||
<tr>
|
||||
<th width="5%">{{ __('User') }}</th>
|
||||
<th width="5%">{{ __('Ip Address') }}</th>
|
||||
<th width="5%">{{ __('Action') }}</th>
|
||||
<th width="15%">{{ __('Activity') }}</th>
|
||||
<th width="5%">Browser</th>
|
||||
<th width="15%">User Agent</th>
|
||||
<th width="5%">Tanggal</th>
|
||||
<th width="5%">Waktu</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($data as $item)
|
||||
<tr>
|
||||
<td>
|
||||
{{ $item->user ? $item->user->username : preg_replace('/\).*$/', '', explode('(', $item->activity)[1]) }}
|
||||
</td>
|
||||
<td>{{ $item->ip_address }}</td>
|
||||
<td>
|
||||
@php
|
||||
$color = 'info';
|
||||
if ($item->action == 'Create') {
|
||||
$color = 'success';
|
||||
} elseif ($item->action == 'Update') {
|
||||
$color = 'warning';
|
||||
} elseif ($item->action == 'Delete' || $item->action == 'Error') {
|
||||
$color = 'danger';
|
||||
}
|
||||
@endphp
|
||||
<div class="badge badge-{{ $color }} text-white">
|
||||
{{ $item->action }}
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ $item->activity }}</td>
|
||||
<td>{{ $item->browser }}</td>
|
||||
<td>{{ $item->user_agent }}</td>
|
||||
<td>{{ $item->created_at }}</td>
|
||||
<td>{{ $item->created_at->diffForHumans() }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- CARD FILTER -->
|
||||
<div class="card shadow-sm mb-4" style="border-radius: 12px; border: none; border-top: 3px solid #007bff;">
|
||||
<div class="card-header bg-white py-3">
|
||||
<h6 class="m-0 font-weight-bold text-primary"><i class="fa fa-filter mr-1"></i> Panel Pencarian & Filter</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="{{ route('admin.audit-trail.index') }}" method="GET">
|
||||
<div class="row">
|
||||
<!-- Filter User -->
|
||||
<div class="col-md-3 mb-3">
|
||||
<label class="small font-weight-bold text-muted text-uppercase">Berdasarkan User</label>
|
||||
<select name="admin_id" class="form-control select2 shadow-none">
|
||||
<option value="">-- Semua User --</option>
|
||||
@foreach($admins as $admin)
|
||||
<option value="{{ $admin->id }}" {{ request('admin_id') == $admin->id ? 'selected' : '' }}>
|
||||
{{ $admin->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Filter Region -->
|
||||
<div class="col-md-3 mb-3">
|
||||
<label class="small font-weight-bold text-muted text-uppercase">Berdasarkan Region</label>
|
||||
<select name="region" class="form-control shadow-none">
|
||||
<option value="">-- Semua Region --</option>
|
||||
@foreach($regions as $reg)
|
||||
<option value="{{ $reg->code }}" {{ request('region') == $reg->code ? 'selected' : '' }}>
|
||||
{{ $reg->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Filter Rentang Waktu -->
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="small font-weight-bold text-muted text-uppercase">Rentang Waktu</label>
|
||||
<div class="input-group">
|
||||
<input type="date" name="start_date" class="form-control shadow-none" value="{{ request('start_date') }}">
|
||||
<div class="input-group-append">
|
||||
<span class="input-group-text bg-light border-left-0 border-right-0">s/d</span>
|
||||
</div>
|
||||
<input type="date" name="end_date" class="form-control shadow-none" value="{{ request('end_date') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tombol Eksekusi Filter -->
|
||||
<div class="col-md-2 mb-3 text-right d-flex align-items-end justify-content-end" style="gap: 5px;">
|
||||
<button type="submit" class="btn btn-primary btn-block mb-0 shadow-sm">
|
||||
<i class="fa fa-search"></i> Cari
|
||||
</button>
|
||||
<a href="{{ route('admin.audit-trail.index') }}" class="btn btn-light border shadow-sm px-3" title="Reset Filter">
|
||||
<i class="fa fa-undo"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr class="my-3">
|
||||
|
||||
<!-- Tombol Export Excel -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<a href="{{ route('admin.audit-trail.export', request()->all()) }}" class="btn btn-success shadow-sm">
|
||||
<i class="fa fa-file-excel"></i> Export Hasil Pencarian ke Excel
|
||||
</a>
|
||||
<span class="text-muted small ml-2 mt-2 d-inline-block">
|
||||
* Menampilkan <strong>{{ $data->firstItem() }}</strong> sampai <strong>{{ $data->lastItem() }}</strong> dari <strong>{{ $data->total() }}</strong> log.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- TABEL DATA -->
|
||||
<div class="card shadow-sm" style="border-radius: 12px; border: none;">
|
||||
<div class="card-body p-0">
|
||||
@include('backend.layouts.partials.messages')
|
||||
<div class="table-responsive">
|
||||
<table id="dataTable" class="table table-hover mb-0">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="border-top-0" width="10%">User</th>
|
||||
<th class="border-top-0" width="10%">IP Address</th>
|
||||
<th class="border-top-0" width="10%">Aksi</th>
|
||||
<th class="border-top-0" width="35%">Aktivitas</th>
|
||||
<th class="border-top-0" width="10%">Browser</th>
|
||||
<th class="border-top-0" width="15%">Waktu</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($data as $item)
|
||||
<tr>
|
||||
<td class="align-middle">
|
||||
<span class="text-primary font-weight-bold">{{ $item->user->username ?? 'System' }}</span>
|
||||
</td>
|
||||
<td class="align-middle text-muted small">{{ $item->ip_address }}</td>
|
||||
<td class="align-middle text-center">
|
||||
@php
|
||||
$badge = match($item->action) {
|
||||
'Insert', 'Create' => 'success',
|
||||
'Update' => 'warning',
|
||||
'Delete', 'Reject', 'Error' => 'danger',
|
||||
'Approve' => 'primary',
|
||||
default => 'info'
|
||||
};
|
||||
@endphp
|
||||
<span class="badge badge-{{ $badge }} px-2 py-1 text-white shadow-xs">{{ $item->action }}</span>
|
||||
</td>
|
||||
<td class="align-middle text-left"><small class="text-dark">{{ $item->activity }}</small></td>
|
||||
<td class="align-middle"><small class="text-muted">{{ $item->browser }}</small></td>
|
||||
<td class="align-middle">
|
||||
<div style="line-height: 1.1;">
|
||||
<small class="d-block font-weight-bold">{{ $item->created_at->format('d M Y') }}</small>
|
||||
<small class="text-muted" style="font-size: 10px;">{{ $item->created_at->format('H:i') }} ({{ $item->created_at->diffForHumans() }})</small>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<!-- FOOTER CARD UNTUK PAGINATION -->
|
||||
<div class="card-footer bg-white py-3 border-top-0">
|
||||
<div class="d-flex justify-content-center">
|
||||
{{ $data->links() }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
if ($('#dataTable').length) {
|
||||
$('#dataTable').DataTable({
|
||||
responsive: false,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
'excel', 'pdf', 'print'
|
||||
],
|
||||
order: [[6, 'desc']]
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endsection
|
||||
@endsection
|
||||
Reference in New Issue
Block a user