diff --git a/app/Http/Controllers/SuperAdminController.php b/app/Http/Controllers/SuperAdminController.php index f0ad885..1deb6bd 100644 --- a/app/Http/Controllers/SuperAdminController.php +++ b/app/Http/Controllers/SuperAdminController.php @@ -188,16 +188,27 @@ class SuperAdminController extends Controller $recentVideos = Video::with('user')->latest()->take(5)->get(); // ── Storage ─────────────────────────────────────────────── - $disk = Storage::disk('public'); + // NAS is the primary store; walking the local disk here would miss + // every file that's been pushed to NAS and purged locally. We use + // the DB-captured file sizes instead: videos.size is set at upload + // time, and thumbnail / avatar counts × a rough per-file average + // give us a usable picture. True NAS-side bytes could be queried + // with `smbclient du`, but that's slow and locks the dashboard; the + // DB figure is accurate for everything uploaded through this app. + $sizeVideos = (int) Video::sum('size'); // bytes + $thumbnailCount = Video::whereNotNull('thumbnail')->count(); + $avatarCount = User::whereNotNull('avatar')->count(); + $bannerCount = User::whereNotNull('banner')->count(); + $postImageCount = \DB::table('post_images')->count(); - $sizeVideos = $this->dirSize($disk, 'videos'); - $sizeThumbnails = $this->dirSize($disk, 'thumbnails'); - $sizeAvatars = $this->dirSize($disk, 'avatars'); - $sizeImages = $this->dirSize($disk, 'images'); - $totalPublicSize = $sizeVideos + $sizeThumbnails + $sizeAvatars + $sizeImages; + // Images are variable but ~120 KB is a solid conservative estimate + // for a web-sized JPEG/PNG upload. + $sizeImages = ($thumbnailCount + $avatarCount + $bannerCount + $postImageCount) * 120 * 1024; + $sizeThumbnails = $thumbnailCount * 120 * 1024; + $sizeAvatars = $avatarCount * 120 * 1024; + $totalPublicSize = $sizeVideos + $sizeImages; $videosUsagePercent = $totalPublicSize > 0 ? round(($sizeVideos / $totalPublicSize) * 100, 1) : 0; - // Convert to MB $toMb = fn($b) => round($b / 1024 / 1024, 1); $storage = [ 'videos' => $toMb($sizeVideos), diff --git a/resources/views/admin/logs.blade.php b/resources/views/admin/logs.blade.php index eb585ce..0cc62a9 100644 --- a/resources/views/admin/logs.blade.php +++ b/resources/views/admin/logs.blade.php @@ -64,25 +64,73 @@ - {{-- Log lines --}} + {{-- Log lines, grouped — each entry's stack trace (lines beginning with + `#N `, `[stacktrace]`, or `Stack trace:`) is folded into its parent + header line. Headers show their level color; stack trace lines + render in a muted indent and preserve their natural #0 → #N order + inside each group even when the overall list is newest-first. --}} @if(empty($lines))
- + No log entries found{{ $filter || $level ? ' matching your filter' : '' }}.
@else + @php + // Group the flat list of lines into [{header, trace[]}, …]. + // Any line that is NOT a header starts/continues the current + // group's trace. Lines that look like a header (ERROR/WARNING/ + // INFO/DEBUG) start a new group. + $groups = []; + $current = null; + $isHeader = fn ($l) => (bool) preg_match('/\.(ERROR|WARNING|INFO|DEBUG|CRITICAL|ALERT|EMERGENCY|NOTICE):/', $l); + foreach ($lines as $line) { + if ($isHeader($line) || $current === null) { + if ($current) $groups[] = $current; + $current = ['header' => $line, 'trace' => []]; + } else { + $current['trace'][] = $line; + } + } + if ($current) $groups[] = $current; + @endphp
- @foreach($lines as $line) + @foreach($groups as $gi => $g) @php $color = '#aaa'; - if (str_contains($line, '.ERROR:')) $color = '#f87171'; - elseif (str_contains($line, '.WARNING:')) $color = '#fbbf24'; - elseif (str_contains($line, '.INFO:')) $color = '#6ee7b7'; - elseif (str_contains($line, '.DEBUG:')) $color = '#93c5fd'; + if (str_contains($g['header'], '.ERROR:') || str_contains($g['header'], '.CRITICAL:')) $color = '#f87171'; + elseif (str_contains($g['header'], '.WARNING:')) $color = '#fbbf24'; + elseif (str_contains($g['header'], '.INFO:')) $color = '#6ee7b7'; + elseif (str_contains($g['header'], '.DEBUG:')) $color = '#93c5fd'; + $hasTrace = !empty($g['trace']); @endphp -
{{ $line }}
+
+
+ @if($hasTrace) + + @else + + @endif + {{ $g['header'] }} +
+ @if($hasTrace) + + @endif +
@endforeach
+ @endif