diff --git a/app/Helpers/helpers.php b/app/Helpers/helpers.php index ef95f70..e647294 100644 --- a/app/Helpers/helpers.php +++ b/app/Helpers/helpers.php @@ -1,22 +1,35 @@ locale($locale); +use Carbon\Carbon; - // Tentukan format berdasarkan parameter - if ($showDay && $time) { - return $carbon->isoFormat('dddd, LL HH:mm:ss'); - } elseif ($showDay) { - return $carbon->isoFormat('dddd, LL'); - } elseif ($time) { - return $carbon->isoFormat('LL HH:mm:ss'); - } else { - return $carbon->isoFormat('LL'); - } +if (!function_exists('formatTanggalWaktu')) { + function formatTanggalWaktu($tanggal, $time = false, $showDay = false, $locale = 'id_ID') + { + // Parse tanggal dan waktu + $datetime = $time ? $tanggal . ' ' . $time : $tanggal; + $carbon = Carbon::parse($datetime)->locale($locale); + + // Tentukan format berdasarkan parameter + if ($showDay && $time) { + return $carbon->isoFormat('dddd, LL HH:mm:ss'); + } elseif ($showDay) { + return $carbon->isoFormat('dddd, LL'); + } elseif ($time) { + return $carbon->isoFormat('LL HH:mm:ss'); + } else { + return $carbon->isoFormat('LL'); } } +} + +function formatNotifikasi($notifikasi) +{ + $data = json_decode(json_encode($notifikasi->data)); + $message = $data->message; + $data = $data->data; + $notifikasi = [ + 'title' => $message->title, + 'message' => $message->message, + ]; + return $notifikasi; +} diff --git a/composer.json b/composer.json index af4eaee..dabc62f 100644 --- a/composer.json +++ b/composer.json @@ -15,12 +15,13 @@ "intervention/image": "^3.10", "joshbrw/laravel-module-installer": "^2.0", "laravel/framework": "^12.0", + "jackiedo/log-reader": "^2.4", "laravel/pulse": "^1.2", "laravel/tinker": "^2.9", "maatwebsite/excel": "^3.1", "nwidart/laravel-modules": "^11.0", "opcodesio/log-viewer": "^3.10", - "rasyahroel/itsecurity": "dev-main", + "rasyahroel/itsecurity-module": "dev-main", "rasyahroel/usermanagement-module": "dev-master", "spatie/laravel-activitylog": "^4.8", "spatie/laravel-pdf": "^1.5", @@ -41,7 +42,10 @@ "App\\": "app/", "Database\\Factories\\": "database/factories/", "Database\\Seeders\\": "database/seeders/" - } + }, + "files": [ + "app/Helpers/helpers.php" + ] }, "autoload-dev": { "psr-4": { @@ -106,9 +110,14 @@ "url": "https://git.putrakuningan.com/daengdeni/authentication" }, { - "name": "rasyahroel/itsecurity", + "name": "rasyahroel/itsecurity-module", "type": "vcs", "url": "https://git.putrakuningan.com/rasyahroel/itsecurity" + }, + { + "name": "jackiedo/log-reader", + "type": "vcs", + "url": "https://github.com/daengdeni/Laravel-Log-Reader.git" } ] } diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index cae76d4..c3f5455 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -50,75 +50,17 @@ -
- {{-- Report History User --}} -
-
-
-

- Report History User Akses -

-
-
-
- - - - - - - - - - -
- NIK - - - Nama User - - - Unit - - - Akses Yang Di Miliki - - - Periode - -
-
- -
+ {{-- Report History User --}} +
+
+
+

+ Report History User Akses +

-
- - {{-- Audit Rail --}} -
-
-
-

- Audit Trail -

-
+
@@ -129,23 +71,19 @@ - - - - @@ -169,6 +107,98 @@ + +
+ {{-- History User --}} +
+
+
+

+ History User Akses +

+
+
+ @foreach (auth()->user()->unreadNotifications->take(5) as $notification) +
+
+ + +
+
+ + {{ formatNotifikasi($notification)['title'] }}
+ {{ formatNotifikasi($notification)['message'] }}
+ +
+ + {{ $notification->created_at->diffForHumans() }} + +
+
+ @if (!$loop->last) +
+ @endif + @endforeach +
+
+
+ + {{-- Audit Rail --}} +
+
+
+

+ Audit Logs +

+
+
+
- Name + Nama User - Action Type + + Unit - Action Description + + Akses Yang Di Miliki - Target Table - - - Target Record Id + + Periode
+ + + + + + + + + +
+ Log Type + + + Subject Type + + + Description + + + Causer ID + + + Date/Time + +
+
+ +
+
+
@endsection @@ -182,7 +212,7 @@ const ctx = document.getElementById('dashboardChart').getContext('2d'); new Chart(ctx, { - type: 'pie', // tipe chart + type: 'pie', data: { labels: labels, datasets: [{ @@ -276,34 +306,43 @@ }; const datatableReport = new KTDataTable(elementReport, dataTableReportOptions); - const elementAudit = document.querySelector('#audit-table'); + const elementAudit = document.querySelector('#audit-logs-table'); const apiUrlAudit = elementAudit.getAttribute('data-api-url'); - // Inisialisasi DataTable + // Inisialisasi DataTable Audit const dataTableAuditOptions = { apiEndpoint: apiUrlAudit, pageSize: 5, columns: { - nik: { - title: 'nik', - render: (item, data) => data?.user?.nik || 'Unknown', + log_name: { + title: 'Log Type', + render: (item, data) => { + return `${data.log_name || 'N/A'}`; + } }, - name: { - title: 'name', - render: (item, data) => data?.user?.name || 'Unknown', + description: { + title: 'Description', }, - action_type: { - title: 'action_type', + subject_type: { + title: 'Subject Type', + render: (item, data) => { + if (!data.subject_type) return 'N/A'; + return data.subject_type.split('\\').pop(); + } }, - action_description: { - title: 'action_description', - }, - target_table: { - title: 'target_table', - }, - target_record_id: { - title: 'target_record_id', + causer_id: { + title: 'Causer ID', + render: (item, data) => { + return data.creator_name || 'System'; + } }, + created_at: { + title: 'Date/Time', + render: (item, data) => { + const date = new Date(data.created_at); + return window.formatTanggalWaktuIndonesia(date) + } + } }, }; const datatableAudit = new KTDataTable(elementAudit, dataTableAuditOptions); diff --git a/routes/web.php b/routes/web.php index 1912683..ddd6b4d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,15 +1,15 @@ json([ - 'count' => auth()->user()->unreadNotifications->count() - ]); - })->name('notifications.count')->middleware('auth'); - }); Route::middleware(['auth'])->group(function () { + Route::get('/notifications/count', function () { + return response()->json([ + 'count' => auth()->user()->unreadNotifications->count() + ]); + })->name('notifications.count')->middleware('auth'); + Route::get('/', [DashboardController::class, 'index'])->name('dashboard'); });