- ApiLogCapturer 추가: 플로우 실행 중 API 로그 캡처
- resolveBaseUrl() 추가: .env 환경변수 기반 baseUrl 지원
- 실행 상세 페이지: 스텝별 접기/펼치기 기능 (성공=접힘, 실패=펼침)
- JSON 가이드 및 예제 플로우 최신화
- AI 프롬프트 템플릿 업데이트
- bindExpectVariables() 추가: expect jsonPath 값에 변수 바인딩 적용
- areNumericEqual() 추가: 숫자 타입 유연 비교 ("2" == 2)
313 lines
21 KiB
PHP
313 lines
21 KiB
PHP
@extends('layouts.app')
|
|
|
|
@section('title', '실행 상세 - #' . $run->id)
|
|
|
|
@section('content')
|
|
<!-- 페이지 헤더 -->
|
|
<div class="flex justify-between items-center mb-6">
|
|
<div class="flex items-center gap-4">
|
|
<a href="{{ route('dev-tools.flow-tester.history', $run->flow_id) }}"
|
|
class="p-2 text-gray-600 hover:bg-gray-100 rounded-lg transition">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
|
|
</svg>
|
|
</a>
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-gray-800">실행 상세 #{{ $run->id }}</h1>
|
|
<p class="text-sm text-gray-500">{{ $run->flow->name }}</p>
|
|
</div>
|
|
</div>
|
|
<span class="px-3 py-1 text-sm font-medium rounded {{ $run->status_color }}">
|
|
{{ $run->status_label }}
|
|
</span>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
<!-- 요약 정보 -->
|
|
<div class="lg:col-span-1">
|
|
<div class="bg-white rounded-lg shadow-sm p-6">
|
|
<h2 class="text-lg font-semibold text-gray-800 mb-4">실행 정보</h2>
|
|
|
|
<dl class="space-y-3">
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-500">상태</dt>
|
|
<dd>
|
|
<span class="px-2 py-1 text-xs font-medium rounded {{ $run->status_color }}">
|
|
{{ $run->status_label }}
|
|
</span>
|
|
</dd>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-500">진행률</dt>
|
|
<dd class="text-gray-900">{{ $run->progress }}%</dd>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-500">완료 스텝</dt>
|
|
<dd class="text-gray-900">{{ $run->completed_steps }}/{{ $run->total_steps ?? '-' }}</dd>
|
|
</div>
|
|
@if($run->failed_step)
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-500">실패 스텝</dt>
|
|
<dd class="text-red-600">Step {{ $run->failed_step }}</dd>
|
|
</div>
|
|
@endif
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-500">소요시간</dt>
|
|
<dd class="text-gray-900">
|
|
@if($run->duration_ms)
|
|
{{ number_format($run->duration_ms / 1000, 2) }}s
|
|
@else
|
|
-
|
|
@endif
|
|
</dd>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-500">시작시간</dt>
|
|
<dd class="text-gray-900">{{ $run->started_at?->format('H:i:s') ?? '-' }}</dd>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-500">완료시간</dt>
|
|
<dd class="text-gray-900">{{ $run->completed_at?->format('H:i:s') ?? '-' }}</dd>
|
|
</div>
|
|
<div class="flex justify-between">
|
|
<dt class="text-gray-500">실행일</dt>
|
|
<dd class="text-gray-900">{{ $run->created_at->format('Y-m-d') }}</dd>
|
|
</div>
|
|
</dl>
|
|
</div>
|
|
|
|
@if($run->error_message)
|
|
<div class="mt-4 bg-red-50 border border-red-200 rounded-lg p-4">
|
|
<h3 class="text-sm font-medium text-red-800 mb-2">에러 메시지</h3>
|
|
<p class="text-sm text-red-700">{{ $run->error_message }}</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- 실행 로그 및 API 로그 (탭) -->
|
|
<div class="lg:col-span-2">
|
|
<div class="bg-white rounded-lg shadow-sm" x-data="{ activeTab: 'execution' }">
|
|
<!-- 탭 헤더 -->
|
|
<div class="flex border-b">
|
|
<button @click="activeTab = 'execution'"
|
|
:class="activeTab === 'execution' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'"
|
|
class="px-6 py-3 text-sm font-medium border-b-2 transition-colors">
|
|
실행 로그
|
|
@if($run->execution_log)
|
|
<span class="ml-1 text-xs text-gray-400">({{ count($run->execution_log) }})</span>
|
|
@endif
|
|
</button>
|
|
<button @click="activeTab = 'api'"
|
|
:class="activeTab === 'api' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500 hover:text-gray-700'"
|
|
class="px-6 py-3 text-sm font-medium border-b-2 transition-colors flex items-center gap-2">
|
|
API 로그
|
|
@if($run->api_logs)
|
|
<span class="text-xs text-gray-400">({{ count($run->api_logs) }})</span>
|
|
@if($run->hasApiErrors())
|
|
<span class="w-2 h-2 bg-red-500 rounded-full"></span>
|
|
@endif
|
|
@endif
|
|
</button>
|
|
</div>
|
|
|
|
<!-- 실행 로그 탭 -->
|
|
<div x-show="activeTab === 'execution'" class="p-6">
|
|
@if($run->execution_log)
|
|
<div class="space-y-3">
|
|
@foreach($run->execution_log as $index => $log)
|
|
<div x-data="{ expanded: {{ ($log['success'] ?? false) ? 'false' : 'true' }} }"
|
|
class="border rounded-lg {{ ($log['success'] ?? false) ? 'border-green-200 bg-green-50' : 'border-red-200 bg-red-50' }}">
|
|
{{-- 헤더 (항상 표시, 클릭으로 토글) --}}
|
|
<div @click="expanded = !expanded"
|
|
class="flex justify-between items-center p-4 cursor-pointer hover:bg-opacity-80 transition">
|
|
<div class="flex items-center gap-2">
|
|
{{-- 펼침/접힘 아이콘 --}}
|
|
<svg class="w-4 h-4 text-gray-400 transition-transform duration-200"
|
|
:class="expanded ? 'rotate-90' : ''"
|
|
fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
|
|
</svg>
|
|
{{-- 성공/실패 아이콘 --}}
|
|
@if($log['success'] ?? false)
|
|
<svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
|
</svg>
|
|
@else
|
|
<svg class="w-5 h-5 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
|
|
</svg>
|
|
@endif
|
|
<span class="font-medium">{{ $log['step_id'] ?? 'Step '.($index + 1) }}</span>
|
|
<span class="text-gray-500">{{ $log['name'] ?? '' }}</span>
|
|
{{-- 간단한 요약 정보 --}}
|
|
@if(isset($log['request']))
|
|
<code class="text-xs text-gray-600 bg-white bg-opacity-50 px-2 py-0.5 rounded">
|
|
{{ $log['request']['method'] ?? '' }} {{ Str::limit($log['request']['endpoint'] ?? '', 30) }}
|
|
</code>
|
|
@endif
|
|
</div>
|
|
<div class="flex items-center gap-3">
|
|
@if(isset($log['response']['status']))
|
|
<span class="px-2 py-0.5 text-xs font-medium rounded {{ ($log['response']['status'] ?? 0) < 400 ? 'bg-green-600 text-white' : 'bg-red-600 text-white' }}">
|
|
{{ $log['response']['status'] }}
|
|
</span>
|
|
@endif
|
|
<span class="text-sm text-gray-500">{{ $log['duration'] ?? '' }}ms</span>
|
|
</div>
|
|
</div>
|
|
|
|
{{-- 상세 내용 (펼쳤을 때만 표시) --}}
|
|
<div x-show="expanded" x-collapse class="px-4 pb-4 border-t border-gray-200 border-opacity-50">
|
|
<div class="pt-3 space-y-3">
|
|
{{-- Request 상세 --}}
|
|
@if(isset($log['request']))
|
|
<div class="text-sm">
|
|
<div class="font-medium text-gray-700 mb-1">Request</div>
|
|
<div class="bg-white bg-opacity-60 rounded p-2">
|
|
<code class="text-gray-800">{{ $log['request']['method'] ?? '' }} {{ $log['request']['endpoint'] ?? '' }}</code>
|
|
@if(!empty($log['request']['body']))
|
|
<details class="mt-2">
|
|
<summary class="cursor-pointer text-xs text-gray-500 hover:text-gray-700">요청 데이터</summary>
|
|
<pre class="mt-1 p-2 bg-gray-100 rounded text-xs overflow-x-auto">{{ json_encode($log['request']['body'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) }}</pre>
|
|
</details>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
{{-- Response 상세 --}}
|
|
@if(isset($log['response']))
|
|
<div class="text-sm">
|
|
<div class="font-medium text-gray-700 mb-1">Response</div>
|
|
<div class="bg-white bg-opacity-60 rounded p-2">
|
|
<div class="flex items-center gap-2">
|
|
<span class="px-2 py-0.5 text-xs font-medium rounded {{ ($log['response']['status'] ?? 0) < 400 ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700' }}">
|
|
{{ $log['response']['status'] ?? '-' }}
|
|
</span>
|
|
@if(isset($log['expect']['status']))
|
|
<span class="text-xs text-gray-500">
|
|
예상: {{ is_array($log['expect']['status']) ? implode(', ', $log['expect']['status']) : $log['expect']['status'] }}
|
|
</span>
|
|
@endif
|
|
</div>
|
|
@if(!empty($log['response']['body']))
|
|
<details class="mt-2">
|
|
<summary class="cursor-pointer text-xs text-gray-500 hover:text-gray-700">응답 데이터</summary>
|
|
<pre class="mt-1 p-2 bg-gray-100 rounded text-xs overflow-x-auto max-h-60 overflow-y-auto">{{ json_encode($log['response']['body'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) }}</pre>
|
|
</details>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
@endif
|
|
|
|
{{-- 성공/실패 이유 --}}
|
|
@if(isset($log['reason']))
|
|
<div class="text-sm {{ ($log['success'] ?? false) ? 'text-green-700 bg-green-100' : 'text-red-700 bg-red-100' }} px-3 py-2 rounded">
|
|
<span class="font-medium">{{ ($log['success'] ?? false) ? '성공' : '실패' }} 이유:</span>
|
|
{{ $log['reason'] }}
|
|
</div>
|
|
@endif
|
|
|
|
{{-- 스텝 설명 --}}
|
|
@if(isset($log['description']) && $log['description'])
|
|
<div class="text-xs text-gray-500 italic">
|
|
{{ $log['description'] }}
|
|
</div>
|
|
@endif
|
|
|
|
{{-- 에러 상세 --}}
|
|
@if(isset($log['error']))
|
|
<div class="text-sm bg-red-100 rounded p-3">
|
|
<div class="font-medium text-red-800 mb-1">에러</div>
|
|
<div class="text-red-700">{{ $log['error'] }}</div>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@else
|
|
<div class="text-center py-8 text-gray-500">
|
|
<p>실행 로그가 없습니다.</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
|
|
<!-- API 로그 탭 -->
|
|
<div x-show="activeTab === 'api'" class="p-6">
|
|
@if($run->api_logs && count($run->api_logs) > 0)
|
|
<div class="space-y-3">
|
|
@foreach($run->api_logs as $index => $apiLog)
|
|
@php
|
|
$isRequest = ($apiLog['type'] ?? '') === 'request';
|
|
$isError = !$isRequest && (($apiLog['status'] ?? 0) >= 400 || ($apiLog['success'] ?? true) === false);
|
|
@endphp
|
|
<div class="border rounded-lg p-3 {{ $isRequest ? 'border-blue-200 bg-blue-50' : ($isError ? 'border-red-200 bg-red-50' : 'border-green-200 bg-green-50') }}">
|
|
<div class="flex justify-between items-start">
|
|
<div class="flex items-center gap-2">
|
|
@if($isRequest)
|
|
<span class="px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-700 rounded">REQ</span>
|
|
@else
|
|
<span class="px-2 py-0.5 text-xs font-medium {{ $isError ? 'bg-red-100 text-red-700' : 'bg-green-100 text-green-700' }} rounded">RES</span>
|
|
@endif
|
|
|
|
@if($isRequest)
|
|
<code class="text-sm font-medium text-gray-800">
|
|
{{ $apiLog['method'] ?? '' }} {{ $apiLog['uri'] ?? '' }}
|
|
</code>
|
|
@else
|
|
<code class="text-sm text-gray-800">
|
|
{{ $apiLog['uri'] ?? '' }}
|
|
</code>
|
|
<span class="px-2 py-0.5 text-xs font-medium {{ $isError ? 'bg-red-600 text-white' : 'bg-green-600 text-white' }} rounded">
|
|
{{ $apiLog['status'] ?? '-' }}
|
|
</span>
|
|
@endif
|
|
</div>
|
|
<span class="text-xs text-gray-500">{{ $apiLog['timestamp'] ?? '' }}</span>
|
|
</div>
|
|
|
|
@if($isRequest && !empty($apiLog['input']))
|
|
<div class="mt-2">
|
|
<details class="text-sm">
|
|
<summary class="cursor-pointer text-gray-600 hover:text-gray-800">요청 데이터</summary>
|
|
<pre class="mt-1 p-2 bg-gray-100 rounded text-xs overflow-x-auto">{{ json_encode($apiLog['input'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) }}</pre>
|
|
</details>
|
|
</div>
|
|
@endif
|
|
|
|
@if(!$isRequest)
|
|
@if(isset($apiLog['message']) && $apiLog['message'])
|
|
<div class="mt-2 text-sm {{ $isError ? 'text-red-700' : 'text-green-700' }}">
|
|
{{ $apiLog['message'] }}
|
|
</div>
|
|
@endif
|
|
|
|
@if(isset($apiLog['error']))
|
|
<div class="mt-2">
|
|
<details class="text-sm" open>
|
|
<summary class="cursor-pointer text-red-700 font-medium">오류 상세</summary>
|
|
<pre class="mt-1 p-2 bg-red-100 rounded text-xs overflow-x-auto text-red-800">{{ is_array($apiLog['error']) ? json_encode($apiLog['error'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) : $apiLog['error'] }}</pre>
|
|
</details>
|
|
</div>
|
|
@endif
|
|
@endif
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
@else
|
|
<div class="text-center py-8 text-gray-500">
|
|
<svg class="w-12 h-12 mx-auto mb-3 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
|
|
</svg>
|
|
<p>API 로그가 없습니다.</p>
|
|
<p class="text-xs mt-1">API 서버의 로그 파일에서 캡처됩니다.</p>
|
|
</div>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|