Merge all feature branches into main and optimize core architecture

This commit is contained in:
2026-04-23 10:16:31 +09:00
27 changed files with 1924 additions and 1306 deletions

View File

@@ -1,109 +1,77 @@
import { state } from '../../core/state';
import { openHwModal } from '../../components/Modal/HWModal';
import { formatInline, createBadge, sortAssets } from '../../core/utils';
import { createIcons, RefreshCcw } from 'lucide';
export function renderServerList(container: HTMLElement) {
const fullList = sortAssets(state.masterData.server);
const filterBar = document.createElement('div');
filterBar.className = 'search-bar';
const corps = Array.from(new Set(fullList.map(a => a.))).filter(Boolean).sort();
const orgUnits = Array.from(new Set(fullList.map(a => a.))).filter(Boolean).sort();
export function renderServerList(filterKeyword: string = '') {
const container = document.getElementById('view-container');
if (!container) return;
filterBar.innerHTML = `
<div class="search-item flex-1">
<label>통합 검색 (자산번호/조직/모델명)</label>
<input type="text" id="filter-keyword" placeholder="검색어를 입력하세요..." autocomplete="off">
const servers = state.masterData.server.filter(s =>
s.?.includes(filterKeyword) ||
s.?.includes(filterKeyword) ||
s.IP주소?.includes(filterKeyword) ||
s.?.includes(filterKeyword)
);
container.innerHTML = `
<div class="view-header">
<div class="header-left">
<h2>서버 자산 현황</h2>
<span class="count-badge">총 ${servers.length}대</span>
</div>
<div class="header-actions">
<button id="btn-add-server" class="btn btn-primary"><i data-lucide="plus"></i> 서버 등록</button>
</div>
</div>
<div class="search-item">
<label>구매법인</label>
<select id="filter-corp"><option value="">전체 법인</option>${corps.map(c => `<option value="${c}">${c}</option>`).join('')}</select>
<div class="table-container">
<table class="itam-table">
<thead>
<tr>
<th>구분</th>
<th>자산번호</th>
<th>용도</th>
<th>실사용조직</th>
<th>IP 주소</th>
<th>모델명</th>
<th>상태</th>
<th>관리</th>
</tr>
</thead>
<tbody>
${servers.length === 0 ? '<tr><td colspan="8" class="empty-row">데이터가 없습니다.</td></tr>' :
servers.map(s => `
<tr class="asset-row" data-id="${s.id}">
<td>${s. || 'HM'}</td>
<td><span class="code-link">${s. || '미부여'}</span></td>
<td>${s. || '-'}</td>
<td>${s. || '-'}</td>
<td><code>${s.IP주소 || '-'}</code></td>
<td>${s. || '-'}</td>
<td><span class="status-badge ${s. === '사용중' ? 'active' : ''}">${s. || '운영'}</span></td>
<td><button class="btn btn-sm btn-outline btn-detail" data-id="${s.id}">상세</button></td>
</tr>
`).join('')}
</tbody>
</table>
</div>
<div class="search-item">
<label>현 사용조직</label>
<select id="filter-org-unit"><option value="">전체 조직</option>${orgUnits.map(o => `<option value="${o}">${o}</option>`).join('')}</select>
</div>
<button id="btn-reset-filters" class="btn btn-outline btn-reset">
<i data-lucide="refresh-ccw"></i> 필터 초기화
</button>
`;
container.appendChild(filterBar);
const tableWrapper = document.createElement('div');
tableWrapper.className = 'table-container';
const table = document.createElement('table');
table.innerHTML = `<thead><tr><th>No</th><th>구매법인</th><th>현 사용조직</th><th>자산번호</th><th>용도</th><th>상세</th><th>설치위치</th><th>담당자</th><th>IP주소</th><th>모델명</th><th>OS</th><th>CPU/RAM</th><th>Storage</th><th>관리</th></tr></thead><tbody id="dynamic-tbody"></tbody>`;
tableWrapper.appendChild(table);
container.appendChild(tableWrapper);
const tbody = table.querySelector('tbody')!;
const updateTable = () => {
const keywordInput = document.getElementById('filter-keyword') as HTMLInputElement;
const corpSelect = document.getElementById('filter-corp') as HTMLSelectElement;
const orgSelect = document.getElementById('filter-org-unit') as HTMLSelectElement;
const keyword = keywordInput ? keywordInput.value.toLowerCase().trim() : '';
const corp = corpSelect ? corpSelect.value : '';
const orgUnit = orgSelect ? orgSelect.value : '';
const filtered = fullList.filter(asset => {
const matchKeyword = !keyword || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword) || String(asset.||'').toLowerCase().includes(keyword);
const matchCorp = !corp || asset. === corp;
const matchOrg = !orgUnit || asset. === orgUnit;
return matchKeyword && matchCorp && matchOrg;
container.querySelectorAll('.asset-row, .btn-detail').forEach(el => {
el.addEventListener('click', (e) => {
e.stopPropagation();
const id = (el as HTMLElement).getAttribute('data-id');
const asset = state.masterData.server.find(a => a.id === id);
if (asset) openHwModal(asset, 'view');
});
});
tbody.innerHTML = '';
if (filtered.length === 0) {
tbody.innerHTML = `<tr><td colspan="14" style="text-align:center; padding: 3rem; color: var(--text-muted);">검색 결과가 없습니다.</td></tr>`;
return;
}
filtered.forEach((asset, idx) => {
const tr = document.createElement('tr');
tr.style.cursor = 'pointer';
const mainManager = asset._정 || '';
const subManager = asset._부 || '';
const managerHtml = [mainManager ? `${createBadge('정', '#1E5149')} ${mainManager}` : '', subManager ? `${createBadge('부', '#9CA3AF')} ${subManager}` : ''].filter(v => v !== '').join(' / ');
const ipInfo = [asset.IP주소, asset.IP2].filter(v => v).join(' / ');
const cpuRam = [asset.CPU, asset.RAM].filter(v => v).join(' / ');
const storage = [asset.SSD1, asset.SSD2].filter(v => v).join(' / ');
tr.innerHTML = `
<td>${idx+1}</td>
<td>${asset.}</td>
<td>${asset.||''}</td>
<td>${asset.}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${formatInline(asset.)}</td>
<td>${managerHtml}</td>
<td>${formatInline(ipInfo)}</td>
<td>${asset.||''}</td>
<td>${asset.OS||''}</td>
<td>${formatInline(cpuRam)}</td>
<td>${formatInline(storage)}</td>
<td><button class="btn btn-outline btn-sm">수정</button></td>
`;
tr.addEventListener('click', (e) => { if (!(e.target as HTMLElement).closest('button')) openHwModal(asset, 'view'); });
tbody.appendChild(tr);
});
};
document.getElementById('filter-keyword')?.addEventListener('input', updateTable);
document.getElementById('filter-corp')?.addEventListener('change', updateTable);
document.getElementById('filter-org-unit')?.addEventListener('change', updateTable);
document.getElementById('btn-reset-filters')?.addEventListener('click', () => {
(document.getElementById('filter-keyword') as HTMLInputElement).value = '';
(document.getElementById('filter-corp') as HTMLSelectElement).value = '';
(document.getElementById('filter-org-unit') as HTMLSelectElement).value = '';
updateTable();
});
updateTable();
}
document.getElementById('btn-add-server')?.addEventListener('click', () => {
const newServer: any = {
id: Math.random().toString(36).substring(2, 9),
type: '서버',
: 'HM',
: '전산팀',
: '사용중'
};
openHwModal(newServer, 'add');
});
}