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:
Hyungi Ahn
2026-03-06 23:18:09 +09:00
parent ec755ed52f
commit 61c810bd47
63 changed files with 255 additions and 1357 deletions

View File

@@ -62,7 +62,7 @@ document.addEventListener('DOMContentLoaded', async () => {
}
if (!window.apiCall) {
console.error(' API 함수를 로드할 수 없습니다.');
console.error(' API 함수를 로드할 수 없습니다.');
showToast('시스템을 초기화할 수 없습니다. 페이지를 새로고침해주세요.', 'error');
return;
}
@@ -76,7 +76,6 @@ document.addEventListener('DOMContentLoaded', async () => {
});
async function initializeDashboard() {
console.log('🚀 모던 대시보드 초기화 시작');
// 사용자 정보 설정
setupUserInfo();
@@ -104,7 +103,6 @@ async function initializeDashboard() {
// TBM 페이지 접근 권한 확인
checkTbmPageAccess();
console.log('✅ 모던 대시보드 초기화 완료');
}
// ========== 사용자 정보 설정 ========== //
@@ -113,7 +111,6 @@ function setupUserInfo() {
const authData = getAuthData();
if (authData && authData.user) {
currentUser = authData.user;
console.log('👤 사용자 정보 로드 완료:', currentUser.name, currentUser.role);
}
}
@@ -179,7 +176,6 @@ function setupEventListeners() {
// ========== 데이터 로드 ========== //
async function loadDashboardData() {
console.log('📊 대시보드 데이터 로딩 시작');
try {
// 로딩 상태 표시
@@ -200,10 +196,9 @@ async function loadDashboardData() {
// 작업자 현황 표시
displayWorkers(workersData, 'card');
console.log('✅ 대시보드 데이터 로딩 완료');
} catch (error) {
console.error(' 대시보드 데이터 로딩 오류:', error);
console.error(' 대시보드 데이터 로딩 오류:', error);
showErrorState();
showToast('데이터를 불러오는 중 오류가 발생했습니다.', 'error');
}
@@ -211,7 +206,6 @@ async function loadDashboardData() {
async function loadWorkers() {
try {
console.log('👥 작업자 데이터 로딩...');
const response = await window.apiCall('/workers');
const allWorkers = Array.isArray(response) ? response : (response.data || []);
@@ -220,7 +214,6 @@ async function loadWorkers() {
return worker.status === 'active' || worker.is_active === 1 || worker.is_active === true;
});
console.log(`✅ 작업자 ${workersData.length}명 로드 완료 (전체: ${allWorkers.length}명)`);
return workersData;
} catch (error) {
console.error('작업자 데이터 로딩 오류:', error);
@@ -231,10 +224,8 @@ async function loadWorkers() {
async function loadWorkData(date) {
try {
console.log(`📋 ${date} 작업 데이터 로딩...`);
const response = await window.apiCall(`/daily-work-reports?date=${date}&view_all=true`);
workData = Array.isArray(response) ? response : (response.data || []);
console.log(`✅ 작업 데이터 ${workData.length}건 로드 완료`);
return workData;
} catch (error) {
console.error('작업 데이터 로딩 오류:', error);
@@ -683,7 +674,6 @@ function checkAdminAccess() {
const isFullAdmin = currentUser && ['admin', 'system'].includes(currentUser.access_level);
const isGroupLeader = currentUser && currentUser.access_level === 'group_leader';
console.log(`🔐 권한 확인: 사용자=${currentUser?.username}, 역할=${currentUser.access_level}, 전체관리자=${isFullAdmin}, 그룹리더=${isGroupLeader}`);
adminElements.forEach(element => {
const href = element.getAttribute('href');
@@ -725,22 +715,18 @@ function checkAdminAccess() {
async function checkTbmPageAccess() {
try {
if (!currentUser || !currentUser.user_id) {
console.log('⚠️ TBM 페이지 권한 확인: 사용자 정보 없음');
return;
}
const tbmQuickAction = document.getElementById('tbmQuickAction');
if (!tbmQuickAction) {
console.log('⚠️ TBM 빠른 작업 버튼 요소를 찾을 수 없습니다');
return;
}
console.log('🛠️ TBM 페이지 권한 확인 중...', { role: currentUser.role, access_level: currentUser.access_level });
// Admin은 모든 페이지 접근 가능
if (currentUser.role === 'Admin' || currentUser.role === 'System Admin' || currentUser.access_level === 'admin' || currentUser.access_level === 'system') {
tbmQuickAction.style.display = 'block';
console.log('✅ Admin 사용자 - TBM 빠른 작업 버튼 표시');
return;
}
@@ -755,15 +741,12 @@ async function checkTbmPageAccess() {
if (tbmPage && tbmPage.can_access) {
tbmQuickAction.style.display = 'block';
console.log('✅ TBM 페이지 접근 권한 있음 - 빠른 작업 버튼 표시');
} else {
console.log('❌ TBM 페이지 접근 권한 없음 - 빠른 작업 버튼 숨김');
}
} else {
console.log('⚠️ TBM 페이지 권한 확인 실패');
}
} catch (error) {
console.error(' TBM 페이지 권한 확인 오류:', error);
console.error(' TBM 페이지 권한 확인 오류:', error);
}
}
@@ -811,7 +794,6 @@ function showErrorState() {
// ========== 작업자 관련 액션 함수들 ========== //
function openWorkerModal(workerId, workerName) {
console.log(`📝 ${workerName}(ID: ${workerId}) 작업 보고서 모달 열기`);
// 모달 데이터 설정
currentModalWorker = {
@@ -825,7 +807,6 @@ function openWorkerModal(workerId, workerName) {
}
function handleVacation(workerId, vacationType) {
console.log(`🏖️ 작업자 ${workerId} 휴가 처리: ${vacationType}`);
const vacationNames = {
'full': '연차',
@@ -873,7 +854,6 @@ async function processVacation(workerId, vacationType, hours) {
}
function confirmOvertime(workerId) {
console.log(`⚠️ 작업자 ${workerId} 초과근무 확인`);
if (confirm('12시간을 초과한 작업시간이 정상적인 입력인지 확인하시겠습니까?')) {
// 초과근무 확인 처리
@@ -1269,8 +1249,6 @@ async function saveModalNewWork() {
}]
};
console.log('📤 전송할 작업 데이터:', workData);
console.log('📋 현재 사용자:', currentUser);
await window.apiCall('/daily-work-reports', 'POST', workData);