@extends('layouts.app')
@section('title', '壓力測試')
@php $isAdmin = auth()->user()->can('module-admin', 'K6TestController'); @endphp
@section('content')
壓力測試
@foreach(['success','info','warning','danger'] as $type)
@if(session($type))
{{ session($type) }}
@endif
@endforeach
{{-- ══ 工具選擇卡片 ══ --}}
@php
$toolMeta = [
'k6' => [
'label' => 'k6',
'sub' => 'Grafana Labs',
'color' => 'warning',
'icon' => 'bi-speedometer2',
'desc' => '以 VUs(虛擬用戶)分階段加壓,支援登入後腳本測試,產出詳細 HTML 與 JSON 報告',
'tags' => ['多階段 VUs', '登入腳本', 'HTML 報告'],
'badge' => '本機安裝',
'route' => 'k6.create',
],
'locust' => [
'label' => 'Locust',
'sub' => 'locust.io',
'color' => 'success',
'icon' => 'bi-bug-fill',
'desc' => '以 Python 撰寫使用者行為腳本,支援登入操作流程,提供 HTML 報告與 CSV 詳細統計',
'tags' => ['Python 腳本', '登入測試', 'CSV 統計'],
'badge' => '本機安裝',
'route' => 'locust.create',
],
];
@endphp
@foreach($toolMeta as $tkey => $t)
{{ $t['label'] }}
{{ $t['badge'] }}
{{ $t['sub'] }}
{{ $t['desc'] }}
@foreach($t['tags'] as $tag)
{{ $tag }}
@endforeach
@endforeach
{{-- ══ 測試記錄列表(k6 + Locust 合併)══ --}}
| 工具 |
名稱 / 網址 |
參數 |
時長 |
測試時間 |
狀態 |
操作 |
@foreach($tests as $test)
@php
$statusMap = [
'pending' => ['secondary', '待執行'],
'running' => ['warning', '執行中'],
'completed' => ['success', '已完成'],
'failed' => ['danger', '失敗'],
];
[$statusColor, $statusLabel] = $statusMap[$test->status] ?? ['secondary', $test->status];
$isK6 = $test->tool === 'k6';
$showRoute = $isK6 ? route('k6.show', $test->_model) : route('locust.show', $test->_model);
$editRoute = $isK6 ? route('k6.edit', $test->_model) : route('locust.edit', $test->_model);
$delRoute = $isK6 ? route('k6.destroy', $test->_model) : route('locust.destroy', $test->_model);
$pdfRoute = $isK6 ? route('k6.export-pdf', $test->_model) : null;
$hasReport = $test->status === 'completed' && $test->report_path
&& file_exists(public_path($test->report_path));
@endphp
|
@if($isK6)
k6
@else
Locust
@endif
|
{{ $test->school_name }}
{{ $test->url }}
|
{{ $test->params }} |
{{ $test->duration }} |
{{ $test->test_time ? \Carbon\Carbon::parse($test->test_time)->format('Y-m-d H:i') : '—' }}
|
{{ $statusLabel }}
|
@if($hasReport)
報告
@else
詳情
@endif
@if($hasReport && $pdfRoute)
@endif
@if($isAdmin)
@endif
|
@endforeach
@endsection
@push('scripts')
@endpush