@extends('layouts.app') @section('title', 'Dashboard chi tiết') @section('page_title', 'Dashboard chi tiết') @section('breadcrumb') @endsection @push('styles') @endpush @section('content')

Bộ lọc

@error('domain_id')
{{ $message }}
@enderror
@if ($hasFilter) @if ($servers->isEmpty())
Domain này chưa có IP nào. Thêm IP để bắt đầu giám sát.
@elseif (empty($days))
Domain này chưa có dữ liệu giám sát nào.
@else @php $metricRows = [ ['label' => 'RAM', 'field' => 'ram_usage_pct'], ['label' => 'CPU', 'field' => 'cpu_usage_pct'], ['label' => 'DISK', 'field' => 'disk_usage_pct'], ]; $displayTz = config('app.display_timezone'); $now = \Carbon\Carbon::now($displayTz); // Build dataset cho Chart.js — chỉ làm 1 lần ở PHP side, JS chỉ render. $chartData = []; foreach ($days as $day) { $dayItem = [ 'dateKey' => $day['date']->format('Ymd'), 'labels' => collect($day['slots'])->map(fn ($s) => $s->format('H:i'))->all(), 'servers' => [], ]; foreach ($servers as $server) { $ram = $cpu = $disk = []; foreach ($day['slots'] as $slot) { $key = $server->id.'|'.$slot->format('Y-m-d H:i:s'); $metric = $day['metrics']->get($key); $ram[] = $metric !== null ? $metric['ram_usage_pct'] : null; $cpu[] = $metric !== null ? $metric['cpu_usage_pct'] : null; $disk[] = $metric !== null ? $metric['disk_usage_pct'] : null; } $dayItem['servers'][] = [ 'id' => $server->id, 'ram' => $ram, 'cpu' => $cpu, 'disk' => $disk, ]; } $chartData[] = $dayItem; } @endphp
@foreach ($days as $day) @php $date = $day['date']; $slots = $day['slots']; $metrics = $day['metrics']; $collapseId = 'day-'.$date->format('Ymd'); $currentSlotIndex = $now->isSameDay($date) ? $now->hour * 2 + ($now->minute >= 30 ? 1 : 0) : -1; @endphp

{{ $date->format('d/m/Y') }} {{ $date->isoFormat('dddd') }}

@foreach ($slots as $slotIdx => $slot) @endforeach @foreach ($servers as $server) @foreach ($metricRows as $i => $row) $i === count($metricRows) - 1, 'ip-block-alt' => $loop->parent->iteration % 2 === 0, ])> @if ($i === 0) @endif @foreach ($slots as $slotIdx => $slot) @php $key = $server->id.'|'.$slot->format('Y-m-d H:i:s'); $metric = $metrics->get($key); $value = $metric !== null ? $metric[$row['field']] : null; $color = 'bg-empty'; if ($value !== null) { $color = $value < 60 ? 'bg-success' : ($value < 80 ? 'bg-warning' : 'bg-danger'); } @endphp @endforeach @endforeach @endforeach
IP Chỉ số {{ $slot->format('H:i') }}
{{ $server->ip_address }} {{ $row['label'] }} {{ $value !== null ? $value.'%' : '—' }}
@endforeach @endif @endif @endsection @push('scripts') @if ($hasFilter && ! empty($days ?? [])) @endif @endpush