feat(role): enable admin login, default Admin to Dashboard, and default Practitioner to Server list
This commit is contained in:
66
src/main.ts
66
src/main.ts
@@ -138,17 +138,42 @@ function initRoleSwitcher() {
|
|||||||
if (!checkbox || !userLabel || !adminLabel) return;
|
if (!checkbox || !userLabel || !adminLabel) return;
|
||||||
|
|
||||||
checkbox.addEventListener('change', () => {
|
checkbox.addEventListener('change', () => {
|
||||||
|
const mainContent = document.getElementById('main-content')!;
|
||||||
if (checkbox.checked) {
|
if (checkbox.checked) {
|
||||||
alert('관리자 모드는 현재 준비 중입니다. 나중에 관리자 전용 페이지와 연결될 예정입니다.');
|
state.currentUserRole = 'admin';
|
||||||
checkbox.checked = false; // UI 강제 되돌리기
|
userLabel.classList.remove('active');
|
||||||
return;
|
adminLabel.classList.add('active');
|
||||||
}
|
document.body.classList.add('admin-mode');
|
||||||
|
|
||||||
// 실무자 모드 전환 (현재는 Admin 진입이 차단되므로 사실상 fallback 로직)
|
// 관리자 모드 전환 시 대시보드로 이동
|
||||||
|
state.activeCategory = 'hw';
|
||||||
|
state.activeSubTab = '대시보드';
|
||||||
|
refreshView();
|
||||||
|
renderNavigation((tab) => {
|
||||||
|
if (tab === '대시보드') {
|
||||||
|
renderDashboard(mainContent);
|
||||||
|
} else {
|
||||||
|
renderSWTable(mainContent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
state.currentUserRole = 'user';
|
state.currentUserRole = 'user';
|
||||||
adminLabel.classList.remove('active');
|
adminLabel.classList.remove('active');
|
||||||
userLabel.classList.add('active');
|
userLabel.classList.add('active');
|
||||||
document.body.classList.remove('admin-mode');
|
document.body.classList.remove('admin-mode');
|
||||||
|
|
||||||
|
// 실무자 모드 전환 시 서버 목록으로 이동
|
||||||
|
state.activeCategory = 'hw';
|
||||||
|
state.activeSubTab = '서버';
|
||||||
|
refreshView();
|
||||||
|
renderNavigation((tab) => {
|
||||||
|
if (tab === '대시보드') {
|
||||||
|
renderDashboard(mainContent);
|
||||||
|
} else {
|
||||||
|
renderSWTable(mainContent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,25 +184,41 @@ function handleLogin() {
|
|||||||
const loginContainer = document.getElementById('login-container');
|
const loginContainer = document.getElementById('login-container');
|
||||||
const appLayout = document.getElementById('app-layout');
|
const appLayout = document.getElementById('app-layout');
|
||||||
const roleCards = document.querySelectorAll('.role-card');
|
const roleCards = document.querySelectorAll('.role-card');
|
||||||
|
const userLabel = document.querySelector('.role-label.user');
|
||||||
|
const adminLabel = document.querySelector('.role-label.admin');
|
||||||
|
|
||||||
if (!loginContainer || !appLayout || roleCards.length === 0) return;
|
if (!loginContainer || !appLayout || roleCards.length === 0) return;
|
||||||
|
|
||||||
roleCards.forEach(card => {
|
roleCards.forEach(card => {
|
||||||
card.addEventListener('click', () => {
|
card.addEventListener('click', () => {
|
||||||
const role = card.getAttribute('data-role');
|
const role = card.getAttribute('data-role');
|
||||||
|
const checkbox = document.getElementById('role-toggle-checkbox') as HTMLInputElement;
|
||||||
|
|
||||||
if (role === 'admin') {
|
if (role === 'admin') {
|
||||||
alert('관리자 모드는 현재 준비 중입니다. 실무자 모드를 이용해 주세요.');
|
console.log('🔓 Entering as Admin');
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (role === 'user') {
|
state.currentUserRole = 'admin';
|
||||||
|
state.activeCategory = 'hw';
|
||||||
|
state.activeSubTab = '대시보드'; // 관리자는 대시보드로 진입
|
||||||
|
|
||||||
|
if (checkbox) checkbox.checked = true;
|
||||||
|
if (userLabel) userLabel.classList.remove('active');
|
||||||
|
if (adminLabel) adminLabel.classList.add('active');
|
||||||
|
document.body.classList.add('admin-mode');
|
||||||
|
} else if (role === 'user') {
|
||||||
console.log('🔓 Entering as Practitioner');
|
console.log('🔓 Entering as Practitioner');
|
||||||
|
|
||||||
// 초기 토글 상태 설정 (실무자 고정)
|
|
||||||
const checkbox = document.getElementById('role-toggle-checkbox') as HTMLInputElement;
|
|
||||||
if (checkbox) checkbox.checked = false;
|
|
||||||
state.currentUserRole = 'user';
|
state.currentUserRole = 'user';
|
||||||
|
state.activeCategory = 'hw';
|
||||||
|
state.activeSubTab = '서버'; // 실무자는 서버 목록으로 진입
|
||||||
|
|
||||||
|
if (checkbox) checkbox.checked = false;
|
||||||
|
if (userLabel) userLabel.classList.add('active');
|
||||||
|
if (adminLabel) adminLabel.classList.remove('active');
|
||||||
|
document.body.classList.remove('admin-mode');
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// UI 전환
|
// UI 전환
|
||||||
loginContainer.style.display = 'none';
|
loginContainer.style.display = 'none';
|
||||||
@@ -195,7 +236,6 @@ function handleLogin() {
|
|||||||
location.reload(); // 즉시 초기화면으로 복귀
|
location.reload(); // 즉시 초기화면으로 복귀
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user