feat: implement role-based entry and navigation enhancements
- Replace credential login with Admin/Practitioner role selection - Add role-switcher toggle in header with automatic reversion for Admin mode - Implement immediate return to role selection via system logo click - Integrate role state management into global app state
This commit is contained in:
31
index.html
31
index.html
@@ -27,17 +27,22 @@
|
|||||||
<h2>ITAM 시스템</h2>
|
<h2>ITAM 시스템</h2>
|
||||||
<p>자산 관리 포털에 오신 것을 환영합니다</p>
|
<p>자산 관리 포털에 오신 것을 환영합니다</p>
|
||||||
</div>
|
</div>
|
||||||
<form id="login-form" class="login-form">
|
<div id="login-selection" class="login-selection">
|
||||||
<div class="form-group">
|
<div class="role-card" data-role="admin">
|
||||||
<label for="username">사용자 아이디</label>
|
<div class="role-icon">
|
||||||
<input type="text" id="username" placeholder="아이디를 입력하세요" required autofocus />
|
<i data-lucide="settings"></i>
|
||||||
|
</div>
|
||||||
|
<h3>관리자</h3>
|
||||||
|
<p>시스템 설정 및 자산 마스터 관리</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="role-card" data-role="user">
|
||||||
<label for="password">비밀번호</label>
|
<div class="role-icon">
|
||||||
<input type="password" id="password" placeholder="비밀번호를 입력하세요" required />
|
<i data-lucide="monitor"></i>
|
||||||
|
</div>
|
||||||
|
<h3>실무자</h3>
|
||||||
|
<p>자산 조회 및 현황 확인</p>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn-login">로그인</button>
|
</div>
|
||||||
</form>
|
|
||||||
<div class="login-footer">
|
<div class="login-footer">
|
||||||
<p>© 2026 BARON Consultant Co,Ltd. All rights reserved.</p>
|
<p>© 2026 BARON Consultant Co,Ltd. All rights reserved.</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -59,6 +64,14 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<div class="header-actions">
|
<div class="header-actions">
|
||||||
|
<div class="role-switcher" id="role-switcher">
|
||||||
|
<span class="role-label user active">실무자</span>
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox" id="role-toggle-checkbox">
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
<span class="role-label admin">관리자</span>
|
||||||
|
</div>
|
||||||
<button id="btn-admin-page" class="hidden"></button> <!-- JS 호환용 숨김 -->
|
<button id="btn-admin-page" class="hidden"></button> <!-- JS 호환용 숨김 -->
|
||||||
<button id="btn-open-guide-header" class="btn btn-outline" title="프로세스 가이드">
|
<button id="btn-open-guide-header" class="btn btn-outline" title="프로세스 가이드">
|
||||||
<i data-lucide="book-open"></i> 가이드
|
<i data-lucide="book-open"></i> 가이드
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export interface AppState {
|
|||||||
activeSubTab: string;
|
activeSubTab: string;
|
||||||
masterData: MasterAssetData;
|
masterData: MasterAssetData;
|
||||||
activeCharts: any[];
|
activeCharts: any[];
|
||||||
|
currentUserRole: 'admin' | 'user';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 초기 상태
|
// 초기 상태
|
||||||
@@ -45,6 +46,7 @@ export const state: AppState = {
|
|||||||
activeCategory: 'hw',
|
activeCategory: 'hw',
|
||||||
activeSubTab: '서버', // 대시보드 제거됨에 따라 기본값 변경
|
activeSubTab: '서버', // 대시보드 제거됨에 따라 기본값 변경
|
||||||
activeCharts: [],
|
activeCharts: [],
|
||||||
|
currentUserRole: 'user',
|
||||||
masterData: {
|
masterData: {
|
||||||
users: [],
|
users: [],
|
||||||
pc: [], server: [], storage: [], network: [],
|
pc: [], server: [], storage: [], network: [],
|
||||||
|
|||||||
81
src/main.ts
81
src/main.ts
@@ -136,35 +136,76 @@ function initApp() {
|
|||||||
window.addEventListener('refresh-view', () => refreshView());
|
window.addEventListener('refresh-view', () => refreshView());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 헤더 역할 전환 토글 로직
|
||||||
|
*/
|
||||||
|
function initRoleSwitcher() {
|
||||||
|
const checkbox = document.getElementById('role-toggle-checkbox') as HTMLInputElement;
|
||||||
|
const userLabel = document.querySelector('.role-label.user');
|
||||||
|
const adminLabel = document.querySelector('.role-label.admin');
|
||||||
|
|
||||||
|
if (!checkbox || !userLabel || !adminLabel) return;
|
||||||
|
|
||||||
|
checkbox.addEventListener('change', () => {
|
||||||
|
if (checkbox.checked) {
|
||||||
|
alert('관리자 모드는 현재 준비 중입니다. 나중에 관리자 전용 페이지와 연결될 예정입니다.');
|
||||||
|
checkbox.checked = false; // UI 강제 되돌리기
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 실무자 모드 전환 (현재는 Admin 진입이 차단되므로 사실상 fallback 로직)
|
||||||
|
state.currentUserRole = 'user';
|
||||||
|
adminLabel.classList.remove('active');
|
||||||
|
userLabel.classList.add('active');
|
||||||
|
document.body.classList.remove('admin-mode');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 로그인 처리 로직
|
* 로그인 처리 로직
|
||||||
*/
|
*/
|
||||||
function handleLogin() {
|
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 loginForm = document.getElementById('login-form') as HTMLFormElement;
|
const roleCards = document.querySelectorAll('.role-card');
|
||||||
|
|
||||||
if (!loginForm || !loginContainer || !appLayout) return;
|
if (!loginContainer || !appLayout || roleCards.length === 0) return;
|
||||||
|
|
||||||
loginForm.addEventListener('submit', (e) => {
|
roleCards.forEach(card => {
|
||||||
e.preventDefault();
|
card.addEventListener('click', () => {
|
||||||
|
const role = card.getAttribute('data-role');
|
||||||
// Mock 로그인: 아이디/비밀번호 입력 여부만 확인
|
|
||||||
const username = (document.getElementById('username') as HTMLInputElement).value;
|
|
||||||
const password = (document.getElementById('password') as HTMLInputElement).value;
|
|
||||||
|
|
||||||
if (username && password) {
|
|
||||||
console.log('🔓 Login successful (Mock)');
|
|
||||||
|
|
||||||
// UI 전환
|
if (role === 'admin') {
|
||||||
loginContainer.style.display = 'none';
|
alert('관리자 모드는 현재 준비 중입니다. 실무자 모드를 이용해 주세요.');
|
||||||
appLayout.style.display = 'flex';
|
return;
|
||||||
|
}
|
||||||
// 앱 초기화 시작
|
|
||||||
initApp();
|
if (role === 'user') {
|
||||||
} else {
|
console.log('🔓 Entering as Practitioner');
|
||||||
alert('아이디와 비밀번호를 입력해주세요.');
|
|
||||||
}
|
// 초기 토글 상태 설정 (실무자 고정)
|
||||||
|
const checkbox = document.getElementById('role-toggle-checkbox') as HTMLInputElement;
|
||||||
|
if (checkbox) checkbox.checked = false;
|
||||||
|
state.currentUserRole = 'user';
|
||||||
|
|
||||||
|
// UI 전환
|
||||||
|
loginContainer.style.display = 'none';
|
||||||
|
appLayout.style.display = 'flex';
|
||||||
|
|
||||||
|
// 역할 스위처 및 앱 초기화 시작
|
||||||
|
initRoleSwitcher();
|
||||||
|
initApp();
|
||||||
|
|
||||||
|
// 로고 클릭 시 초기화면 복귀 로직 (한 번만 등록)
|
||||||
|
const brand = document.querySelector('.brand') as HTMLElement;
|
||||||
|
if (brand) {
|
||||||
|
brand.style.cursor = 'pointer';
|
||||||
|
brand.onclick = () => {
|
||||||
|
location.reload(); // 즉시 초기화면으로 복귀
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,6 +229,85 @@ body {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --- Role Switcher Toggle --- */
|
||||||
|
.role-switcher {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.75rem;
|
||||||
|
margin-right: 0.5rem;
|
||||||
|
padding: 0 0.75rem;
|
||||||
|
border-right: 1px solid var(--border-color);
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-label {
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-muted);
|
||||||
|
transition: color 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-label.active {
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-label.admin.active {
|
||||||
|
color: var(--color-orange);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toggle Switch Base */
|
||||||
|
.switch {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
width: 34px;
|
||||||
|
height: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch input {
|
||||||
|
opacity: 0;
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider {
|
||||||
|
position: absolute;
|
||||||
|
cursor: pointer;
|
||||||
|
top: 0; left: 0; right: 0; bottom: 0;
|
||||||
|
background-color: #ccc;
|
||||||
|
transition: .4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider:before {
|
||||||
|
position: absolute;
|
||||||
|
content: "";
|
||||||
|
height: 12px;
|
||||||
|
width: 12px;
|
||||||
|
left: 3px;
|
||||||
|
bottom: 3px;
|
||||||
|
background-color: white;
|
||||||
|
transition: .4s;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked + .slider {
|
||||||
|
background-color: var(--color-orange);
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus + .slider {
|
||||||
|
box-shadow: 0 0 1px var(--color-orange);
|
||||||
|
}
|
||||||
|
|
||||||
|
input:checked + .slider:before {
|
||||||
|
transform: translateX(16px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider.round {
|
||||||
|
border-radius: 34px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.slider.round:before {
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
/* --- Global Actions & Buttons --- */
|
/* --- Global Actions & Buttons --- */
|
||||||
.header-actions {
|
.header-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -11,12 +11,12 @@
|
|||||||
|
|
||||||
.login-card {
|
.login-card {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 400px;
|
max-width: 500px;
|
||||||
background-color: var(--white);
|
background-color: var(--white);
|
||||||
border: 1px solid var(--border-color);
|
border: 1px solid var(--border-color);
|
||||||
border-radius: 12px;
|
border-radius: 12px;
|
||||||
padding: 2.5rem;
|
padding: 3rem;
|
||||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
|
box-shadow: 0 4px 30px rgba(0, 0, 0, 0.08);
|
||||||
animation: slideUp 0.4s ease-out;
|
animation: slideUp 0.4s ease-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -27,79 +27,89 @@
|
|||||||
|
|
||||||
.login-header {
|
.login-header {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-bottom: 2rem;
|
margin-bottom: 2.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-logo {
|
.login-logo {
|
||||||
height: 48px;
|
height: 52px;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-header h2 {
|
.login-header h2 {
|
||||||
font-size: 1.5rem;
|
font-size: 1.75rem;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
color: var(--text-main);
|
color: var(--text-main);
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-header p {
|
.login-header p {
|
||||||
font-size: 0.875rem;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-form {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-form .form-group {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-form label {
|
|
||||||
font-size: 0.8125rem;
|
|
||||||
font-weight: 600;
|
|
||||||
color: var(--text-muted);
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-form input {
|
|
||||||
height: 44px;
|
|
||||||
padding: 0 1rem;
|
|
||||||
border: 1px solid var(--border-color);
|
|
||||||
border-radius: 6px;
|
|
||||||
font-size: 0.9375rem;
|
font-size: 0.9375rem;
|
||||||
outline: none;
|
color: var(--text-muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-selection {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-card {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
text-align: center;
|
||||||
|
padding: 2rem 1.5rem;
|
||||||
|
border: 2px solid var(--bg-light);
|
||||||
|
border-radius: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
background-color: var(--bg-light);
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-card:hover {
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
background-color: var(--white);
|
||||||
|
transform: translateY(-4px);
|
||||||
|
box-shadow: 0 10px 20px rgba(30, 81, 73, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-icon {
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
background-color: var(--white);
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
color: var(--primary-color);
|
||||||
|
border: 1px solid var(--border-color);
|
||||||
transition: all 0.2s;
|
transition: all 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-form input:focus {
|
.role-card:hover .role-icon {
|
||||||
border-color: var(--primary-color);
|
|
||||||
box-shadow: 0 0 0 3px rgba(30, 81, 73, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-login {
|
|
||||||
height: 48px;
|
|
||||||
margin-top: 0.5rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
background-color: var(--primary-color);
|
background-color: var(--primary-color);
|
||||||
color: var(--white);
|
color: var(--white);
|
||||||
border: none;
|
border-color: var(--primary-color);
|
||||||
border-radius: 6px;
|
|
||||||
font-weight: 700;
|
|
||||||
cursor: pointer;
|
|
||||||
transition: background-color 0.2s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-login:hover {
|
.role-card h3 {
|
||||||
background-color: var(--primary-hover);
|
font-size: 1.125rem;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--text-main);
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.role-card p {
|
||||||
|
font-size: 0.8125rem;
|
||||||
|
color: var(--text-muted);
|
||||||
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-footer {
|
.login-footer {
|
||||||
margin-top: 2rem;
|
margin-top: 3rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
color: var(--text-muted);
|
color: var(--text-muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user