diff --git a/app/Views/admin/traffic/dashboard.php b/app/Views/admin/traffic/dashboard.php index 12f375b..92b6071 100644 --- a/app/Views/admin/traffic/dashboard.php +++ b/app/Views/admin/traffic/dashboard.php @@ -126,6 +126,11 @@ const endpoint = `${baseEndpoint}?${params.toString()}`; + // ** 디버깅: 요청 정보 로깅 ** + console.log("--- API 요청 시작 (Debugging) ---"); + console.log(`요청 기간: ${startDate} ~ ${endDate}`); + console.log(`요청 URL: ${endpoint}`); + const maxRetries = 3; let delay = 1000; @@ -135,15 +140,22 @@ method: 'GET', }); - const result = await response.json(); - - if (!response.ok || result.status === 'error') { - throw new Error(result.message || `HTTP error! Status: ${response.status}`); + if (!response.ok) { + throw new Error(`HTTP error! Status: ${response.status}`); } - // ********************************************** - // ** 중요: 데이터가 비어있는 경우를 여기서 감지 ** - // ********************************************** + const result = await response.json(); + + // ** 디버깅: 서버 응답 로깅 ** + console.log("서버 응답 JSON (Raw Result):", result); + console.log("--- API 요청 종료 (Debugging) ---"); + + + if (result.status === 'error') { + throw new Error(result.message || "서버에서 오류 상태를 반환했습니다."); + } + + // 데이터가 비어있는 경우 if (!result.data || result.data.length === 0) { return []; // 빈 배열 반환하여 데이터 없음 처리 } @@ -202,9 +214,8 @@ return; } - // 데이터 추출 + // 데이터 추출 및 Number 변환 (데이터가 유효함을 가정) const labels = aggregatedData.map(d => d.created_at); - // 데이터 타입을 Number로 명시적 변환하여 Chart.js가 숫자로 인식하도록 보장 const inData = aggregatedData.map(d => Number(d.in_kbits)); const outData = aggregatedData.map(d => Number(d.out_kbits)); @@ -217,7 +228,6 @@ } finally { loadingIndicator.style.display = 'none'; - // 차트가 성공적으로 그려졌거나 '데이터 없음' 메시지가 표시된 경우에만 캔버스 영역 표시 canvas.style.opacity = (trafficChart || noDataMessage.style.display === 'block') ? '1' : '0'; viewChartBtn.disabled = false; }