feat: SW 통합 모달 구현 및 대시보드 자산 추가 기능 고도화

- SW 모달(구독, 영구, 클라우드) 통합 및 레이아웃 최적화
- 모든 자산 상세 모달에 '조회/수정 모드' 전환 로직(Edit Lock) 적용
- 하드웨어/소프트웨어 대시보드에서 '자산 추가' 버튼 연동 및 기본값 설정
- 클라우드 자산 리스트의 데이터 소스를 DB 직결(cloud_assets) 방식으로 변경
- 클라우드 자산 저장 API 연동 및 불필요한 구형 모달(CloudModal) 제거
- 리스트 뷰에서 상세 보기 시 '조회 모드'로 열리도록 호출 로직 수정
This commit is contained in:
2026-04-21 11:37:13 +09:00
parent 153e422180
commit d983ad469f
4 changed files with 258 additions and 96 deletions

View File

@@ -7,12 +7,11 @@ import { initBaseModal } from './components/Modal/BaseModal';
import { initPcModal } from './components/Modal/PCModal';
import { initHwModal, openHwModal } from './components/Modal/HWModal';
import { initSwModal, openSwModal } from './components/Modal/SWModal';
import { initCloudModal, openCloudModal } from './components/Modal/CloudModal';
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';
// --- DB 저장을 위한 세분화된 헬퍼 함수들 (setting 브랜치 기반) ---
// --- DB 저장을 위한 세분화된 헬퍼 함수들 ---
async function apiBatchSave(url: string, data: any[], label: string) {
try {
const response = await fetch(url, {
@@ -34,6 +33,7 @@ const saveEquipToDB = () => apiBatchSave('http://localhost:3000/api/equip/batch'
const saveMobileToDB = () => apiBatchSave('http://localhost:3000/api/mobile/batch', state.masterData.mobile, '모바일기기');
const saveSubSwToDB = () => apiBatchSave('http://localhost:3000/api/sw/sub/batch', state.masterData.subSw, '구독SW');
const savePermSwToDB = () => apiBatchSave('http://localhost:3000/api/sw/perm/batch', state.masterData.permSw, '영구SW');
const saveCloudToDB = () => apiBatchSave('http://localhost:3000/api/cloud/batch', state.masterData.cloud, '클라우드');
const saveSwUsersToDB = () => apiBatchSave('http://localhost:3000/api/sw-users/batch', state.masterData.swUsers, 'SW사용자');
// 모든 하드웨어 DB 동기화
@@ -47,6 +47,16 @@ async function saveAllHardwareToDB() {
]);
}
// 모든 소프트웨어 DB 동기화
async function saveAllSoftwareToDB() {
await Promise.all([
saveSubSwToDB(),
savePermSwToDB(),
saveCloudToDB(),
saveSwUsersToDB()
]);
}
// --- App Initialization ---
function initApp() {
console.log('🚀 ITAM Dedicated System Initializing...');
@@ -64,23 +74,20 @@ function initApp() {
}
});
// 모달 초기화: StorageModal은 HWModal에 통합됨
// 모달 초기화
initPcModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
initHwModal(() => { saveAllHardwareToDB(); renderSWTable(mainContent); }, closeAllModals);
initSwModal(() => {
if (state.activeSubTab === '구독SW') saveSubSwToDB();
else savePermSwToDB();
saveAllSoftwareToDB();
renderSWTable(mainContent);
}, closeAllModals);
initCloudModal(() => {
// 클라우드 저장 로직 (필요 시 API 추가 구현 가능)
renderSWTable(mainContent);
initSwUserModal(() => {
saveSwUsersToDB();
renderSWTable(mainContent);
}, closeAllModals);
initSwUserModal(() => { saveSwUsersToDB(); renderSWTable(mainContent); }, closeAllModals);
initDashboardDetailModal();
} catch (e) { console.error('❌ Initialization failed:', e); }
@@ -107,7 +114,7 @@ function initApp() {
state.masterData = data;
await Promise.all([
saveAllHardwareToDB(),
saveSubSwToDB(), savePermSwToDB(), saveSwUsersToDB()
saveAllSoftwareToDB()
]);
renderSWTable(mainContent);
}
@@ -115,16 +122,25 @@ function initApp() {
document.getElementById('btn-add-asset')?.addEventListener('click', () => {
const tab = state.activeSubTab;
if (['개인PC', '서버', '전산비품', '스토리지', '모바일기기'].includes(tab)) {
const cat = state.activeCategory;
if (cat === 'hw') {
// 하드웨어 대시보드 또는 개별 탭에서 추가
const defaultType = (tab === '대시보드') ? '' : tab;
openHwModal({
id: Math.random().toString(36).substring(2, 9),
type: tab,
: '한맥', : '', : '', : '', : '', IP주소: '', MACaddress: '', HW사양: '', OS: '', : '', : ''
type: defaultType,
: '한맥', : '', : '', : '', MACaddress: '', HW사양: '', OS: '', : '', : ''
} as any, 'add');
} else if (cat === 'sw') {
// 소프트웨어 대시보드 또는 개별 탭에서 추가
let defaultType = tab;
if (tab === '대시보드') defaultType = '구독SW'; // SW는 기본 레이아웃을 위해 하나 지정하되 필드는 빈값
openSwModal({
id: Math.random().toString(36).substring(2, 9),
type: defaultType, : '', : '', 수량: 1, : '', : '', : '', : '한맥'
} as any, 'add');
} else if (tab === '클라우드') {
openCloudModal({ type: '클라우드', : '', : '한맥', : '', : '', : '', : '', : '', : '', : '', : '' } as any);
} else if (tab === '구독SW' || tab === '영구SW') {
openSwModal({ type: tab, : '', : '', 수량: 1, : '', : '', : '', : '한맥' } as any);
}
});
@@ -133,4 +149,4 @@ function initApp() {
});
}
document.addEventListener('DOMContentLoaded', initApp);
document.addEventListener('DOMContentLoaded', initApp);