feat: login activity statistic
This commit is contained in:
parent
9514ce0be2
commit
dfa787853e
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\LoginHistory;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\Report;
|
||||
use Carbon\Carbon;
|
||||
@ -18,7 +19,7 @@ public function index(Request $request){
|
||||
[
|
||||
'name' => 'Aktivitas Login',
|
||||
'category' => 'login-activities',
|
||||
'is_available' => false
|
||||
'is_available' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Jurnalis',
|
||||
@ -89,7 +90,6 @@ public function show(Request $request, $category){
|
||||
];
|
||||
|
||||
$upComings = [
|
||||
'login-activities',
|
||||
'journalists',
|
||||
'media-cooperations',
|
||||
'media',
|
||||
@ -254,6 +254,23 @@ public function show(Request $request, $category){
|
||||
$data['proofAiringThemeRejected'] = $airingProofThemeCount->get('2', 0);
|
||||
|
||||
return view('dashboard.statistics.show.airing-proof-report', $data);
|
||||
case 'login-activities':
|
||||
$data['title'] = 'Statistik Aktivitas Login';
|
||||
|
||||
$monthlyCount = array_fill(0, 12, 0);
|
||||
|
||||
$loginActivities = LoginHistory::with(['user'])->get();
|
||||
$loginActivities->groupBy(function ($item) {
|
||||
return (int) \Carbon\Carbon::parse($item->created_at)->format('m');
|
||||
})->each(function ($items, $month) use (&$monthlyCount) {
|
||||
// Simpan jumlah item tiap bulan ke index bulan - 1 (0-based)
|
||||
$monthlyCount[$month - 1] = $items->count();
|
||||
});
|
||||
|
||||
$data['loginActivities'] = $monthlyCount;
|
||||
|
||||
return view('dashboard.statistics.show.login-activity', $data);
|
||||
|
||||
default:
|
||||
abort(404);
|
||||
}
|
||||
|
||||
@ -0,0 +1,85 @@
|
||||
<script>
|
||||
const monthlyTotalData = @json($loginActivities);
|
||||
var publicationOptions = {
|
||||
series: [{
|
||||
name: 'Aktivitas Login',
|
||||
data: monthlyTotalData
|
||||
}],
|
||||
chart: {
|
||||
height: 350,
|
||||
type: 'bar',
|
||||
},
|
||||
plotOptions: {
|
||||
bar: {
|
||||
borderRadius: 3,
|
||||
dataLabels: {
|
||||
position: 'center', // top, center, bottom
|
||||
},
|
||||
}
|
||||
},
|
||||
dataLabels: {
|
||||
enabled: true,
|
||||
formatter: function (val) {
|
||||
return val + " Aktivitas";
|
||||
},
|
||||
offsetY: -20,
|
||||
style: {
|
||||
fontSize: '12px',
|
||||
colors: ["#304758"]
|
||||
}
|
||||
},
|
||||
|
||||
xaxis: {
|
||||
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
position: 'top',
|
||||
axisBorder: {
|
||||
show: false
|
||||
},
|
||||
axisTicks: {
|
||||
show: false
|
||||
},
|
||||
crosshairs: {
|
||||
fill: {
|
||||
type: 'gradient',
|
||||
gradient: {
|
||||
colorFrom: '#3572EF',
|
||||
colorTo: '#3ABEF9',
|
||||
stops: [0, 100],
|
||||
opacityFrom: 0.4,
|
||||
opacityTo: 0.5,
|
||||
}
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
enabled: true,
|
||||
}
|
||||
},
|
||||
yaxis: {
|
||||
axisBorder: {
|
||||
show: false
|
||||
},
|
||||
axisTicks: {
|
||||
show: false,
|
||||
},
|
||||
labels: {
|
||||
show: false,
|
||||
formatter: function (val) {
|
||||
return val + " Aktivitas";
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
title: {
|
||||
text: 'Aktivitas Login Aplikasi Simedkom',
|
||||
floating: true,
|
||||
offsetY: 330,
|
||||
align: 'center',
|
||||
style: {
|
||||
color: '#444'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var publicationChart = new ApexCharts(document.querySelector("#loginActivityMonth"), publicationOptions);
|
||||
publicationChart.render();
|
||||
</script>
|
||||
@ -0,0 +1,119 @@
|
||||
@include('partials.dashboard.head')
|
||||
@include('partials.dashboard.sidebar', ['page' => 'statistics'])
|
||||
@include('partials.dashboard.header')
|
||||
<!-- content @s -->
|
||||
<div class="nk-content ">
|
||||
<div class="container-fluid">
|
||||
<div class="nk-content-inner">
|
||||
<div class="nk-content-body">
|
||||
<div class="nk-block-head nk-block-head-sm">
|
||||
<div class="nk-block-between">
|
||||
<div class="nk-block-head-content">
|
||||
<h3 class="nk-block-title page-title">{{$title}}</h3>
|
||||
{{-- <div class="nk-block-des text-soft">
|
||||
<p>Data: Tahun {{$data_year}}</p>
|
||||
</div> --}}
|
||||
</div><!-- .nk-block-head-content -->
|
||||
{{-- {{dd($cooperationRequests)}} --}}
|
||||
<div class="nk-block-head-content">
|
||||
<div class="toggle-wrap nk-block-tools-toggle">
|
||||
<a href="#" class="btn btn-icon btn-trigger toggle-expand me-n1" data-target="pageMenu"><em class="icon ni ni-more-v"></em></a>
|
||||
<div class="toggle-expand-content" data-content="pageMenu">
|
||||
<ul class="nk-block-tools g-3">
|
||||
<li>
|
||||
<div>
|
||||
<a href="{{route('dashboard.statistics.index')}}" class="btn btn-white btn-dim btn-outline-light"><em class="icon ni ni-arrow-left"></em><span class="d-none d-md-inline">Kembali</a>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
@if (filled($year) || filled($from_month) || filled($to_month))
|
||||
<span class="mx-1">
|
||||
<a href="{{route('dashboard.statistics.show', ['category' => $category])}}" class="text-secondary">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor" class="icon icon-tabler icons-tabler-filled icon-tabler-xbox-x"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M12 2c5.523 0 10 4.477 10 10s-4.477 10 -10 10s-10 -4.477 -10 -10s4.477 -10 10 -10m3.6 5.2a1 1 0 0 0 -1.4 .2l-2.2 2.933l-2.2 -2.933a1 1 0 1 0 -1.6 1.2l2.55 3.4l-2.55 3.4a1 1 0 1 0 1.6 1.2l2.2 -2.933l2.2 2.933a1 1 0 0 0 1.6 -1.2l-2.55 -3.4l2.55 -3.4a1 1 0 0 0 -.2 -1.4" /></svg>
|
||||
</a>
|
||||
</span>
|
||||
@endif
|
||||
<div>
|
||||
<a href="javascript: void(0);" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#modalFilter"><em class="d-none d-sm-inline icon ni ni-filter"></em><span><span class="d-none d-md-inline">Filter</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- .nk-block-head-content -->
|
||||
</div><!-- .nk-block-between -->
|
||||
</div><!-- .nk-block-head -->
|
||||
<div class="nk-block">
|
||||
<div class="row g-gs">
|
||||
<div class="col-xxl-3 col-md-12">
|
||||
<div class="card card-full overflow-hidden">
|
||||
<div class="nk-ecwg nk-ecwg7 h-100">
|
||||
<div class="card-inner flex-grow-1">
|
||||
<div class="card-title-group mb-4">
|
||||
<div class="card-title">
|
||||
<h6 class="title">Aktivitas Login</h6>
|
||||
</div>
|
||||
</div>
|
||||
<div id="loginActivityMonth" style="width: 100%; height: 350px !important;"></div>
|
||||
</div><!-- .card-inner -->
|
||||
</div>
|
||||
</div><!-- .card -->
|
||||
</div><!-- .col -->
|
||||
<div class="modal fade" id="modalFilter">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Filter</h5>
|
||||
<a href="javascript:void(0);" class="close" data-bs-dismiss="modal" aria-label="Close">
|
||||
<em class="icon ni ni-cross"></em>
|
||||
</a>
|
||||
</div>
|
||||
<form action="{{route('dashboard.statistics.show', ['category' => $category])}}" class="form-validate is-alter" method="get">
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="year">Tahun</label>
|
||||
<div class="form-control-wrap">
|
||||
<input type="number" class="form-control" id="year" placeholder="Contoh: 2025" name="year" value="{{ old('year', $year ?? '') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<label class="form-label" for="from_month">Dari Bulan</label>
|
||||
<div class="form-control-wrap">
|
||||
<input type="month" class="form-control" id="from_month" placeholder="Data berita pada bulan dan tahun" name="from_month" value="{{ old('from_month', $from_month ?? '') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label class="form-label" for="to_month">Sampai Bulan</label>
|
||||
<div class="form-control-wrap">
|
||||
<input type="month" class="form-control" id="to_month" placeholder="Data berita pada bulan dan tahun" name="to_month" value="{{ old('to_month', $to_month ?? '') }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-light">
|
||||
<span class="sub-text">
|
||||
<button type="submit" class="btn btn-sm btn-primary">Filter</button>
|
||||
</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{-- <div class="col-xxl-3 col-md-12">
|
||||
<div class="card card-bordered card-preview">
|
||||
<div class="card-inner">
|
||||
<div class="nk-ck">
|
||||
<canvas class="bar-chart" id="barChartMultiple"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- .card-preview -->
|
||||
</div><!-- .col --> --}}
|
||||
</div><!-- .row -->
|
||||
</div><!-- .nk-block -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- content @e -->
|
||||
@include('partials.dashboard.footer', ['statistic_chart' => 'login-activities'])
|
||||
@ -115,6 +115,9 @@
|
||||
@case('airing-proof-report')
|
||||
@include('dashboard.statistics.chart.airing-proof-report')
|
||||
@break
|
||||
@case('login-activities')
|
||||
@include('dashboard.statistics.chart.login-activity')
|
||||
@break
|
||||
@default
|
||||
|
||||
@endswitch
|
||||
|
||||
Loading…
Reference in New Issue
Block a user