fix: 원격접속 자산 데이터 매핑 보완
Some checks failed
ITAM Code Check / build-and-config-check (push) Successful in 20s
ITAM Docker Build Check / docker-build-check (push) Failing after 22s

This commit is contained in:
2026-06-19 18:03:58 +09:00
parent 9735344f37
commit 7b631ab858
4 changed files with 124 additions and 0 deletions

View File

@@ -45,6 +45,63 @@ export async function loadMasterDataFromDB() {
const data = await response.json();
// DB의 쪼개진 asset_remote 데이터로부터 가상 대표 속성(IP, MAC, 원격도구)을 주입해주는 전처리 함수
const preprocessAssets = (assets: any[]) => {
if (!Array.isArray(assets)) return;
assets.forEach((asset: any) => {
let ip = '';
let mac = '';
let remoteTool = '';
let remoteId = '';
let remotePw = '';
let rems: any[] = [];
try {
rems = asset.remotes ? (typeof asset.remotes === 'string' ? JSON.parse(asset.remotes) : asset.remotes) : [];
} catch(e) {}
if (Array.isArray(rems)) {
rems.forEach((r: any) => {
if (r.type === 'IP') {
if (!ip) ip = r.val1 || '';
if (r.val2) {
if (String(r.val2).trim().startsWith('{')) {
try {
const parsed = JSON.parse(r.val2);
remoteTool = r.name || '원격접속';
remoteId = parsed.id || '';
remotePw = parsed.pw || '';
} catch(e) {}
} else {
if (!mac) mac = r.val2 || '';
}
}
} else if (r.type === 'MAC') {
if (!mac) mac = r.val1 || '';
} else if (r.type === 'REMOTE') {
if (!remoteTool) remoteTool = r.name || '';
if (!remoteId) remoteId = r.val1 || '';
if (!remotePw) remotePw = r.val2 || '';
}
});
}
// 최상위 가상 속성 바인딩 (목록 및 위치보기 뷰어 매핑용)
asset.ip_address = ip;
asset.mac_address = mac;
asset.remote_tool = remoteTool;
asset.remote_id = remoteId;
asset.remote_pw = remotePw;
});
};
if (data) {
const keys = ['pc', 'server', 'storage', 'network', 'survey', 'equipment', 'officeSupplies'];
keys.forEach(k => {
if (data[k]) preprocessAssets(data[k]);
});
}
// 전역 상태 업데이트
state.masterData = {
...state.masterData,