주요 변경 사항: - 리스트 보안 강화: 서버 자산 리스트에서 IP 주소 및 원격접속 컬럼 제거 (상세 모달에서만 노출) - 보안 배지 가독성 개선: 상세 모달 내 개별 필드 배지를 '네트워크 정보' 섹션 타이틀 옆으로 통합 이동 - 위치 정보 포맷팅: 서버 리스트 내 '서관/동관' 시작 위치에 'IDC' 접두사 자동 추가 (예: IDC(서관 204번)) - 모달 시스템 복구: 이벤트 위임 방식을 통한 전역 ESC 키 및 닫기 버튼 기능 완벽 복구 - 안정성 확보: BaseModal 초기화 로직 보완 및 동적 DOM 요소 대응 강화
93 lines
3.8 KiB
TypeScript
93 lines
3.8 KiB
TypeScript
import { state } from './core/state';
|
|
import { renderSidebar } from './components/Sidebar';
|
|
import { renderDashboard } from './views/DashboardView';
|
|
import { renderTable } from './views/AssetTableView';
|
|
import { downloadTemplate, exportToExcel, parseExcel, HardwareAsset } from './core/excelHandler';
|
|
import { initBaseModal } from './components/Modal/BaseModal';
|
|
import { initPcModal } from './components/Modal/PCModal';
|
|
import { initHwModal, openHwModal } from './components/Modal/HWModal';
|
|
import { initStorageModal } from './components/Modal/StorageModal';
|
|
import { initSwModal } from './components/Modal/SWModal';
|
|
import { initSwUserModal } from './components/Modal/SWUserModal';
|
|
import { initDashboardDetailModal } from './components/Modal/DashboardDetailModal';
|
|
import { createIcons, Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw } from 'lucide';
|
|
|
|
// --- App Initialization ---
|
|
function initApp() {
|
|
const mainContent = document.getElementById('main-content')!;
|
|
if (!mainContent) return;
|
|
|
|
// 1. 초기 뷰 렌더링 (대시보드)
|
|
renderDashboard(mainContent);
|
|
|
|
// 2. 사이드바 초기화
|
|
renderSidebar((tab) => {
|
|
if (tab === '대시보드') {
|
|
renderDashboard(mainContent);
|
|
document.getElementById('btn-add-asset')?.classList.add('hidden');
|
|
} else {
|
|
renderTable(mainContent);
|
|
document.getElementById('btn-add-asset')?.classList.remove('hidden');
|
|
}
|
|
// 상단 타이틀 업데이트
|
|
const titleEl = document.getElementById('current-tab-title')!;
|
|
if (titleEl) {
|
|
const catName = state.activeCategory === 'hw' ? '하드웨어' : '소프트웨어';
|
|
titleEl.textContent = `${catName} / ${state.activeSubTab}`;
|
|
}
|
|
});
|
|
|
|
// 3. 모달 초기화 (HTML 주입 및 개별 로직 바인딩)
|
|
const { closeAllModals } = initBaseModal();
|
|
|
|
initPcModal(() => renderTable(mainContent), closeAllModals);
|
|
initHwModal(); // HW 모달은 내부에서 자체 닫기 로직 포함 중이나 추후 통일 가능
|
|
initStorageModal(() => renderTable(mainContent), closeAllModals);
|
|
initSwModal(() => renderTable(mainContent), closeAllModals);
|
|
initSwUserModal(() => renderTable(mainContent), closeAllModals);
|
|
initDashboardDetailModal();
|
|
|
|
// 4. 전역 버튼 이벤트 바인딩
|
|
document.getElementById('btn-download-template')?.addEventListener('click', () => downloadTemplate());
|
|
document.getElementById('btn-export-excel')?.addEventListener('click', () => exportToExcel(state.masterData));
|
|
|
|
const uploadInput = document.getElementById('excel-upload') as HTMLInputElement;
|
|
uploadInput?.addEventListener('change', async (e) => {
|
|
const file = (e.target as HTMLInputElement).files?.[0];
|
|
if (file) {
|
|
const data = await parseExcel(file);
|
|
state.masterData = data;
|
|
renderTable(mainContent);
|
|
}
|
|
});
|
|
|
|
document.getElementById('btn-add-asset')?.addEventListener('click', () => {
|
|
if (state.activeSubTab === '서버' || state.activeSubTab === '전산비품' || state.activeSubTab === '스토리지') {
|
|
const newAsset: HardwareAsset = {
|
|
id: Math.random().toString(36).substring(2, 9),
|
|
type: state.activeSubTab,
|
|
법인: '한맥',
|
|
자산코드: '',
|
|
명칭: '',
|
|
위치: '',
|
|
관리자: '',
|
|
IP주소: '',
|
|
MACaddress: '',
|
|
HW사양: '',
|
|
OS: '',
|
|
납품업체: '',
|
|
품의서명: ''
|
|
};
|
|
openHwModal(newAsset);
|
|
}
|
|
});
|
|
|
|
// 전역 아이콘 초기화
|
|
createIcons({
|
|
icons: { Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw }
|
|
});
|
|
}
|
|
|
|
// Start the app
|
|
document.addEventListener('DOMContentLoaded', initApp);
|