@extends('layouts.app') @section('title', 'Locust 壓力測試') @php $isAdmin = auth()->user()->can('module-admin', 'K6TestController'); @endphp @section('content')

Locust 壓力測試

切換 k6 @if($isAdmin) 新增測試 @endif
@foreach(['success','info','warning','danger'] as $type) @if(session($type))
{{ session($type) }}
@endif @endforeach {{-- ══ 狀態統計卡片 ══ --}} @php $statusMeta = [ 'all' => [ 'label' => '全部', 'color' => 'secondary', 'icon' => 'bi-list-ul', 'desc' => '所有 Locust 測試記錄', 'tags' => ['全部狀態'], 'total' => array_sum($counts), ], 'pending' => [ 'label' => '待執行', 'color' => 'secondary', 'icon' => 'bi-hourglass', 'desc' => '已排程,等待執行中', 'tags' => ['已排程'], 'total' => $counts['pending'] ?? 0, ], 'running' => [ 'label' => '執行中', 'color' => 'warning', 'icon' => 'bi-lightning-charge-fill', 'desc' => '正在對目標進行壓力測試', 'tags' => ['進行中', '即時監控'], 'total' => $counts['running'] ?? 0, ], 'completed' => [ 'label' => '已完成', 'color' => 'success', 'icon' => 'bi-check-circle-fill', 'desc' => '測試完成,報告已產生', 'tags' => ['有報告'], 'total' => $counts['completed'] ?? 0, ], 'failed' => [ 'label' => '失敗', 'color' => 'danger', 'icon' => 'bi-x-circle-fill', 'desc' => '執行過程發生錯誤', 'tags' => ['異常', '需檢查'], 'total' => $counts['failed'] ?? 0, ], ]; @endphp
@foreach($statusMeta as $skey => $s) @php $active = ($skey === 'all' && !$statusFilter) || $statusFilter === $skey; $href = $skey === 'all' ? route('locust.index') : route('locust.index', array_filter(['status'=>$skey,'q'=>$search])); @endphp @endforeach
{{-- ══ 測試記錄列表 ══ --}}
@if($statusFilter) {{ $statusMeta[$statusFilter]['label'] }} @else @endif 測試記錄
@if($statusFilter) @endif
@if($search) @endif
@if($statusFilter) 清除篩選 @endif
@foreach($tests as $index => $test) @php $statusMap = [ 'pending' => ['secondary','待執行'], 'running' => ['warning','執行中'], 'completed' => ['success','已完成'], 'failed' => ['danger','失敗'], ]; [$statusColor, $statusLabel] = $statusMap[$test->status] ?? ['secondary', $test->status]; $hasReport = $test->status === 'completed' && $test->report_path && file_exists(public_path($test->report_path)); @endphp @endforeach
# 名稱 / 網址 用戶數 時長 測試時間 狀態 操作
{{ $index + 1 }}
{{ $test->school_name }}
{{ $test->url }}{{ $test->target_path !== '/' ? $test->target_path : '' }}
{{ $test->users }}u / {{ $test->spawn_rate }}r/s {{ $test->duration }} {{ $test->test_time ? $test->test_time->format('Y-m-d H:i') : '—' }} {{ $statusLabel }}
@if($test->status === 'completed') 報告 @elseif(in_array($test->status, ['pending','running','failed'])) 詳情 @endif @if($isAdmin)
@csrf @method('DELETE')
@endif
@endsection @push('scripts') @endpush