@extends('layouts.admin') @section('title', 'Admin Dashboard — DaisyRisk') @section('page-title', 'Dashboard') @push('styles') @endpush @section('content') {{-- ══════════════════════════════════════════════════════════════ STATISTICS CARDS (5 Cards) ══════════════════════════════════════════════════════════════ --}}
{{-- Card 1: Total Users --}}
{{ $statsCards['users']['icon'] }}
{{ number_format($statsCards['users']['total']) }}
{{ $statsCards['users']['label'] }}
@if($statsCards['users']['new_today'] > 0)
↗ {{ $statsCards['users']['new_today'] }} new today
@else
{{ $statsCards['users']['trend'] }}% from last month
@endif
{{-- Card 2: Total Ports --}}
{{ $statsCards['ports']['icon'] }}
{{ number_format($statsCards['ports']['total']) }}
{{ $statsCards['ports']['label'] }}
{{ $statsCards['ports']['percentage'] }}% active ports
{{-- Card 3: Total Articles --}}
{{ $statsCards['articles']['icon'] }}
{{ number_format($statsCards['articles']['total']) }}
{{ $statsCards['articles']['label'] }}
@if($statsCards['articles']['today'] > 0)
↗ {{ $statsCards['articles']['today'] }} published today
@else
{{ number_format($statsCards['articles']['published']) }} published
@endif
{{-- Card 4: Contact Messages --}}
{{ $statsCards['messages']['icon'] }}
{{ number_format($statsCards['messages']['total']) }}
{{ $statsCards['messages']['label'] }}
@if($statsCards['messages']['unread'] > 0)
⚠ {{ $statsCards['messages']['unread'] }} unread
@else
All messages read
@endif
{{-- Card 5: API Requests --}}
{{ $statsCards['api_requests']['icon'] }}
{{ number_format($statsCards['api_requests']['today']) }}
{{ $statsCards['api_requests']['label'] }}
{{ $statsCards['api_requests']['success_rate'] }}% success rate
{{-- ══════════════════════════════════════════════════════════════ DASHBOARD WIDGETS ══════════════════════════════════════════════════════════════ --}}
{{-- Left Column --}}
{{-- Risk Distribution Chart --}}

📊 Risk Level Distribution (by Countries)

@if(!empty($riskDistribution))
{{-- Chart Statistics Summary --}}
@php $totalCountries = array_sum($riskDistribution); @endphp @foreach($riskDistribution as $riskLevel => $count) @php $percentage = $totalCountries > 0 ? round(($count / $totalCountries) * 100, 1) : 0; $badgeColor = match($riskLevel) { 'Critical', 'High' => 'danger', 'Medium' => 'warning', 'Low' => 'info', default => 'success' }; @endphp
{{ $riskLevel }}
{{ $count }}
({{ $percentage }}%)
@endforeach
@else
📊

No risk data available

Risk scores will appear here once countries are analyzed
@endif
{{-- Top 5 High Risk Countries --}}

🚨 Top 5 High Risk Countries

@if(is_array($topRiskCountries) && count($topRiskCountries) > 0)
@foreach($topRiskCountries as $index => $risk) @php $riskData = is_array($risk) ? $risk : []; $countryData = $riskData['country'] ?? []; $totalScore = $riskData['total_score'] ?? 0; $riskLevel = $riskData['risk_level'] ?? 'Unknown'; $calculatedAt = $riskData['calculated_at'] ?? null; @endphp
{{ $index + 1 }}
@if(!empty($countryData['flag_url']) && !empty($countryData['iso2'])) {{ $countryData['name'] ?? '' }} @else 🌍 @endif
{{ $countryData['name'] ?? 'Unknown Country' }}
{{ $riskLevel }} @if($calculatedAt) {{ \Carbon\Carbon::parse($calculatedAt)->format('M d') }} @endif
{{ number_format($totalScore, 1) }}
@php // Get previous risk score for trend (simplified) $trend = $totalScore > 70 ? 'up' : ($totalScore > 50 ? 'stable' : 'down'); @endphp @if($trend === 'up') ↗️ @elseif($trend === 'down') ↘️ @else → @endif
@endforeach
{{-- View All Button --}} @else
🚨

No risk data available

Risk assessments will appear here once countries are analyzed
@endif
{{-- Right Column --}}
{{-- Recent Activities --}}

📋 Recent Activities

@if(is_array($recentActivities) && count($recentActivities) > 0)
@foreach($recentActivities as $activity) @php $activityData = is_array($activity) ? $activity : []; $userData = $activityData['user'] ?? []; $userName = $userData['name'] ?? 'Unknown User'; $description = $activityData['description'] ?? 'No description'; $action = $activityData['action'] ?? 'unknown'; $modelType = $activityData['model_type'] ?? null; $createdAt = $activityData['created_at'] ?? null; @endphp
@if(!empty($userData)) @if(($userData['role_name'] ?? null) === 'Admin' || ($userData['role_name'] ?? null) === 'Super Admin') @else
{{ strtoupper(substr($userName, 0, 1)) }}
@endif @else
🤖
@endif
@if(!empty($userData)) {{ $userName }} @else System @endif {{ $description }}
{{ $createdAt ? \Carbon\Carbon::parse($createdAt)->diffForHumans() : 'Unknown time' }} @if($action) {{ ucfirst($action) }} @endif @if($modelType) {{ class_basename($modelType) }} @endif
@switch($action) @case('login') 🔑 @break @case('logout') 🚪 @break @case('created') ➕ @break @case('updated') ✏️ @break @case('deleted') 🗑️ @break @case('viewed') 👁️ @break @default 📝 @endswitch
@endforeach
{{-- View All Button --}} @else
📋

No recent activities

User activities and system events will appear here
@endif
{{-- Latest Articles --}}

📰 Latest Articles

@if(is_array($latestArticles) && count($latestArticles) > 0)
@foreach($latestArticles as $article) @php $articleData = is_array($article) ? $article : []; $title = $articleData['title'] ?? 'Untitled'; $source = $articleData['source'] ?? 'Unknown Source'; $country = $articleData['country'] ?? 'Global'; $publishedAt = $articleData['published_at'] ?? null; $status = $articleData['status'] ?? 'Published'; $sentiment = $articleData['sentiment'] ?? 'Unknown'; $riskLevel = $articleData['risk_level'] ?? 'Unknown'; $url = $articleData['url'] ?? '#'; @endphp

{{ Str::limit($title, 80) }}

View Article ↗️
@endforeach
{{-- View All Button --}} @else
📰

Belum ada artikel hasil sinkronisasi.

Artikel akan muncul di sini setelah proses sinkronisasi dari API berhasil
@endif
{{-- Contact Messages --}}

💬 Recent Contact Messages

@if(is_array($recentMessages) && count($recentMessages) > 0)
@foreach($recentMessages as $message) @php $messageData = is_array($message) ? $message : []; $name = $messageData['name'] ?? 'Unknown'; $email = $messageData['email'] ?? ''; $company = $messageData['company'] ?? null; $subject = $messageData['subject'] ?? 'No subject'; $messageText = $messageData['message'] ?? 'No message'; $status = $messageData['status'] ?? 'new'; $category = $messageData['category'] ?? null; $createdAt = $messageData['created_at'] ?? null; $messageId = $messageData['id'] ?? 0; @endphp
{{ strtoupper(substr($name, 0, 1)) }}
{{ $name }} @if($company) from {{ $company }} @endif
@switch($status) @case('new') 🔵 New @break @case('read') 👁️ Read @break @case('replied') ✅ Replied @break @default 📝 Pending @endswitch
{{ Str::limit($subject, 60) }}
{{ Str::limit($messageText, 100) }}
{{ $createdAt ? \Carbon\Carbon::parse($createdAt)->diffForHumans() : 'Unknown time' }} @if($category) {{ $category }} @endif {{ $email }}
@endforeach
{{-- View All Button --}} @else
💬

No contact messages

Contact form submissions will appear here
@endif
@endsection @push('scripts') @endpush