refactor: 프론트엔드 SSO 인증 통합 및 API 경로 정리
- Gateway 로그인/포탈 페이지 SSO 연동 - System1 web/fastapi-bridge API base URL 동적 설정 - SSO 토큰 기반 인증 흐름 통일 - deprecated JS 파일 삭제 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -44,7 +44,6 @@ function formatDate(d) { return window.CommonUtils.formatDate(d); }
|
||||
|
||||
// 페이지 초기화
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
console.log('🛠️ TBM 관리 페이지 초기화');
|
||||
|
||||
// API 함수가 로드될 때까지 대기
|
||||
let retryCount = 0;
|
||||
@@ -542,7 +541,6 @@ function populateLeaderSelect() {
|
||||
const jobTypeText = worker.job_type ? ` (${escapeHtml(worker.job_type)})` : '';
|
||||
leaderSelect.innerHTML = `<option value="${escapeHtml(worker.user_id)}" selected>${escapeHtml(worker.worker_name)}${jobTypeText}</option>`;
|
||||
leaderSelect.disabled = true;
|
||||
console.log('✅ 입력자 자동 설정:', worker.worker_name);
|
||||
} else {
|
||||
// 작업자를 찾을 수 없는 경우
|
||||
leaderSelect.innerHTML = '<option value="">입력자를 찾을 수 없습니다</option>';
|
||||
@@ -560,7 +558,6 @@ function populateLeaderSelect() {
|
||||
return `<option value="${escapeHtml(w.user_id)}">${escapeHtml(w.worker_name)}${jobTypeText}</option>`;
|
||||
}).join('');
|
||||
leaderSelect.disabled = false;
|
||||
console.log('✅ 관리자: 입력자 선택 가능');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -637,16 +634,14 @@ window.closeTbmModal = closeTbmModal;
|
||||
|
||||
// TBM 세션 저장 (간소화: 프로젝트+공정+작업자, task/workplace=null)
|
||||
async function saveTbmSession() {
|
||||
console.log('💾 TBM 저장 시작...');
|
||||
|
||||
let leaderId = parseInt(document.getElementById('leaderId').value);
|
||||
|
||||
if (!leaderId || isNaN(leaderId)) {
|
||||
if (!currentUser.user_id) {
|
||||
console.log('📝 관리자 계정: leader_user_id를 NULL로 설정');
|
||||
leaderId = null;
|
||||
} else {
|
||||
console.error('❌ 입력자 설정 오류');
|
||||
console.error(' 입력자 설정 오류');
|
||||
showToast('입력자 정보가 올바르지 않습니다.', 'error');
|
||||
return;
|
||||
}
|
||||
@@ -704,7 +699,7 @@ async function saveTbmSession() {
|
||||
throw new Error(teamResponse.message || '팀원 수정에 실패했습니다.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ TBM 세션 수정 오류:', error);
|
||||
console.error(' TBM 세션 수정 오류:', error);
|
||||
showToast('TBM 세션 수정 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
return;
|
||||
@@ -745,7 +740,6 @@ async function saveTbmSession() {
|
||||
|
||||
if (response && response.success) {
|
||||
createdSessionId = response.data.session_id;
|
||||
console.log('✅ TBM 세션 생성 완료:', createdSessionId);
|
||||
|
||||
const teamResponse = await window.TbmAPI.addTeamMembers(createdSessionId, members);
|
||||
|
||||
@@ -765,7 +759,7 @@ async function saveTbmSession() {
|
||||
throw new Error(response.message || '저장에 실패했습니다.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ TBM 세션 저장 오류:', error);
|
||||
console.error(' TBM 세션 저장 오류:', error);
|
||||
|
||||
// 409 중복 배정 에러 처리
|
||||
if (error.duplicates && error.duplicates.length > 0) {
|
||||
@@ -1540,7 +1534,7 @@ async function loadWorkplacesByCategory(categoryId) {
|
||||
</button>
|
||||
`).join('');
|
||||
} catch (error) {
|
||||
console.error('❌ 작업장 로드 오류:', error);
|
||||
console.error(' 작업장 로드 오류:', error);
|
||||
workplaceList.innerHTML = '<div style="color: #ef4444; text-align: center; padding: 2rem;">작업장을 불러오는 중 오류가 발생했습니다</div>';
|
||||
}
|
||||
}
|
||||
@@ -1641,7 +1635,6 @@ async function loadWorkplaceMap(categoryId, layoutImagePath) {
|
||||
? layoutImagePath
|
||||
: `${apiBaseUrl}${layoutImagePath}`;
|
||||
|
||||
console.log('🖼️ 이미지 로드 시도:', fullImageUrl);
|
||||
|
||||
// 지도 영역 데이터 로드
|
||||
mapRegions = await window.TbmAPI.loadMapRegions(categoryId);
|
||||
@@ -1666,11 +1659,10 @@ async function loadWorkplaceMap(categoryId, layoutImagePath) {
|
||||
// 클릭 이벤트 리스너 추가
|
||||
mapCanvas.onclick = handleMapClick;
|
||||
|
||||
console.log(`✅ 작업장 지도 로드 완료: ${mapRegions.length}개 영역`);
|
||||
};
|
||||
|
||||
mapImage.onerror = function() {
|
||||
console.error('❌ 지도 이미지 로드 실패');
|
||||
console.error(' 지도 이미지 로드 실패');
|
||||
document.getElementById('layoutMapArea').style.display = 'none';
|
||||
document.getElementById('workplaceListSection').style.display = 'block';
|
||||
document.getElementById('workplaceList').style.display = 'flex';
|
||||
@@ -1681,7 +1673,7 @@ async function loadWorkplaceMap(categoryId, layoutImagePath) {
|
||||
mapImage.src = fullImageUrl;
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 작업장 지도 로드 오류:', error);
|
||||
console.error(' 작업장 지도 로드 오류:', error);
|
||||
document.getElementById('layoutMapArea').style.display = 'none';
|
||||
document.getElementById('workplaceList').style.display = 'flex';
|
||||
}
|
||||
@@ -2030,7 +2022,7 @@ async function openTeamCompositionModal(sessionId) {
|
||||
lockBodyScroll();
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 팀 구성 로드 오류:', error);
|
||||
console.error(' 팀 구성 로드 오류:', error);
|
||||
showToast('팀 구성을 불러오는 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
}
|
||||
@@ -2130,7 +2122,7 @@ async function saveTeamComposition() {
|
||||
throw new Error(response.message || '저장에 실패했습니다.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 팀 구성 저장 오류:', error);
|
||||
console.error(' 팀 구성 저장 오류:', error);
|
||||
showToast('팀 구성 저장 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
}
|
||||
@@ -2222,7 +2214,7 @@ async function openSafetyCheckModal(sessionId) {
|
||||
lockBodyScroll();
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 안전 체크 조회 오류:', error);
|
||||
console.error(' 안전 체크 조회 오류:', error);
|
||||
showToast('안전 체크 정보를 불러오는 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
}
|
||||
@@ -2328,7 +2320,7 @@ async function saveSafetyChecklist() {
|
||||
showToast('안전 체크가 완료되었습니다.', 'success');
|
||||
closeSafetyModal();
|
||||
} catch (error) {
|
||||
console.error('❌ 안전 체크 저장 오류:', error);
|
||||
console.error(' 안전 체크 저장 오류:', error);
|
||||
showToast('안전 체크 저장 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
}
|
||||
@@ -2473,7 +2465,7 @@ async function completeTbmSession() {
|
||||
throw new Error(response.message || '완료 처리에 실패했습니다.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ TBM 완료 처리 오류:', error);
|
||||
console.error(' TBM 완료 처리 오류:', error);
|
||||
showToast('TBM 완료 처리 중 오류가 발생했습니다.', 'error');
|
||||
} finally {
|
||||
if (btn) { btn.disabled = false; btn.innerHTML = '<span class="tbm-btn-icon">✓</span> 완료'; }
|
||||
@@ -2622,7 +2614,6 @@ async function viewTbmSession(sessionId) {
|
||||
// 푸터 버튼 동적 생성
|
||||
const footer = document.getElementById('detailModalFooter');
|
||||
const safeId = parseInt(session.session_id) || 0;
|
||||
console.log('📋 TBM 상세 - session_id:', safeId, 'status:', session.status);
|
||||
if (session.status === 'draft') {
|
||||
footer.innerHTML = `
|
||||
<button type="button" class="tbm-btn tbm-btn-danger" onclick="confirmDeleteTbm(${safeId})">
|
||||
@@ -2649,7 +2640,7 @@ async function viewTbmSession(sessionId) {
|
||||
lockBodyScroll();
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ TBM 상세 조회 오류:', error);
|
||||
console.error(' TBM 상세 조회 오류:', error);
|
||||
showToast('상세 정보를 불러오는 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
}
|
||||
@@ -2674,7 +2665,7 @@ async function deleteTbmSession(sessionId) {
|
||||
await loadRecentTbmGroupedByDate();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ TBM 삭제 오류:', error);
|
||||
console.error(' TBM 삭제 오류:', error);
|
||||
showToast(error?.message || 'TBM 삭제 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
}
|
||||
@@ -2747,7 +2738,7 @@ async function openHandoverModal(sessionId) {
|
||||
lockBodyScroll();
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ 인계 모달 열기 오류:', error);
|
||||
console.error(' 인계 모달 열기 오류:', error);
|
||||
showToast('인계 정보를 불러오는 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
}
|
||||
@@ -2815,7 +2806,7 @@ async function saveHandover() {
|
||||
throw new Error(response.message || '인계 요청에 실패했습니다.');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('❌ 작업 인계 저장 오류:', error);
|
||||
console.error(' 작업 인계 저장 오류:', error);
|
||||
showToast('작업 인계 중 오류가 발생했습니다.', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user