diff --git a/web-ui/js/api-config.js b/web-ui/js/api-config.js index 946e515..2ba2a26 100644 --- a/web-ui/js/api-config.js +++ b/web-ui/js/api-config.js @@ -28,10 +28,11 @@ function getApiBaseUrl() { // API 설정 const API_URL = getApiBaseUrl(); -export const API = API_URL; -export const API_BASE_URL = API_URL; +// 전역 변수로 설정 +window.API = API_URL; +window.API_BASE_URL = API_URL; -export function ensureAuthenticated() { +function ensureAuthenticated() { const token = localStorage.getItem('token'); if (!token || token === 'undefined') { alert('로그인이 필요합니다'); @@ -51,7 +52,7 @@ export function getAuthHeaders() { } // 🔧 개선된 API 호출 함수 (에러 처리 강화) -export async function apiCall(url, options = {}) { +async function apiCall(url, options = {}) { const defaultOptions = { headers: getAuthHeaders() }; @@ -137,6 +138,12 @@ export async function testApiConnection() { } } +// 전역 함수로 설정 +window.ensureAuthenticated = ensureAuthenticated; +window.getAuthHeaders = getAuthHeaders; +window.apiCall = apiCall; +window.testApiConnection = testApiConnection; + // 개발 모드에서 자동 테스트 if (window.location.hostname === 'localhost' || window.location.hostname.startsWith('192.168.')) { setTimeout(() => { diff --git a/web-ui/js/modern-dashboard.js b/web-ui/js/modern-dashboard.js index b726010..c421f54 100644 --- a/web-ui/js/modern-dashboard.js +++ b/web-ui/js/modern-dashboard.js @@ -1,7 +1,17 @@ // ✅ modern-dashboard.js - 모던 대시보드 JavaScript -import { apiCall, API } from './api-config.js'; -import { getAuthData } from './auth.js'; +// API 설정 및 함수들은 api-config.js에서 로드됨 +// window.API, window.apiCall, window.getAuthHeaders 사용 + +// 인증 관련 함수들 +function getAuthData() { + const token = localStorage.getItem('token'); + const user = localStorage.getItem('user'); + return { + token, + user: user ? JSON.parse(user) : null + }; +} // 전역 변수 let currentUser = null; @@ -182,7 +192,7 @@ async function loadDashboardData() { async function loadWorkers() { try { console.log('👥 작업자 데이터 로딩...'); - const response = await apiCall(`${API}/workers`); + const response = await window.apiCall(`${window.API}/workers`); workersData = Array.isArray(response) ? response : (response.data || []); console.log(`✅ 작업자 ${workersData.length}명 로드 완료`); return workersData; @@ -196,7 +206,7 @@ async function loadWorkers() { async function loadWorkData(date) { try { console.log(`📋 ${date} 작업 데이터 로딩...`); - const response = await apiCall(`${API}/daily-work-reports?date=${date}&view_all=true`); + const response = await window.apiCall(`${window.API}/daily-work-reports?date=${date}&view_all=true`); workData = Array.isArray(response) ? response : (response.data || []); console.log(`✅ 작업 데이터 ${workData.length}건 로드 완료`); return workData; @@ -509,11 +519,5 @@ function showToast(message, type = 'info', duration = 3000) { // ========== 전역 함수 (HTML에서 호출) ========== // window.loadDashboardData = loadDashboardData; window.showToast = showToast; - -// ========== 내보내기 ========== // -export { - loadDashboardData, - showToast, - updateSummaryCards, - displayWorkers -}; +window.updateSummaryCards = updateSummaryCards; +window.displayWorkers = displayWorkers; diff --git a/web-ui/pages/dashboard/group-leader.html b/web-ui/pages/dashboard/group-leader.html index d2dfdd4..2be714c 100644 --- a/web-ui/pages/dashboard/group-leader.html +++ b/web-ui/pages/dashboard/group-leader.html @@ -12,8 +12,7 @@ - - +