API 로그 기능 개선: 정렬, UI, 커스텀 모달

- 필터 적용 시 오래된 순 정렬 (시간순 추적 용이)
- 상세 페이지 그룹 요청 섹션: 접힌 상태 기본, 메서드별 뱃지
- 리스트 아이콘 버튼 (상세, AI 복사), 세로 중앙 정렬
- 응답 바디 슬래시 이스케이프 처리
- 시스템 alert를 커스텀 Tailwind 모달로 교체
This commit is contained in:
2025-12-15 22:07:34 +09:00
parent dff2a886e7
commit 1d4725e464
4 changed files with 218 additions and 66 deletions

View File

@@ -13,9 +13,17 @@ class ApiLogController extends Controller
*/
public function index(Request $request): View
{
// 필터가 적용되면 오래된 순, 아니면 최신순
$hasFilter = $request->hasAny(['method', 'status', 'search', 'group_id', 'tenant_id']);
$query = ApiRequestLog::query()
->with(['tenant', 'user'])
->orderByDesc('created_at');
->with(['tenant', 'user']);
if ($hasFilter) {
$query->orderBy('created_at'); // 오래된 순
} else {
$query->orderByDesc('created_at'); // 최신순
}
// 필터: HTTP 메서드
if ($request->filled('method')) {
@@ -81,16 +89,23 @@ public function show(int $id): View
{
$log = ApiRequestLog::with(['tenant', 'user'])->findOrFail($id);
// 같은 그룹의 다른 요청들
$groupLogs = [];
// 같은 그룹의 다른 요청들 (오래된 순)
$groupLogs = collect();
$groupMethodCounts = [];
if ($log->group_id) {
$groupLogs = ApiRequestLog::where('group_id', $log->group_id)
->where('id', '!=', $log->id)
->orderByDesc('created_at')
->orderBy('created_at') // 오래된 순
->get();
// 메서드별 개수 집계
$groupMethodCounts = $groupLogs->groupBy('method')
->map(fn($items) => $items->count())
->sortKeys()
->toArray();
}
return view('api-logs.show', compact('log', 'groupLogs'));
return view('api-logs.show', compact('log', 'groupLogs', 'groupMethodCounts'));
}
/**