From d6d4996245c91a33a6618bc749dfeaba40762441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9B=90=ED=98=95?= <147372294+blissyou@users.noreply.github.com> Date: Tue, 22 Jul 2025 09:07:33 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=97=85=EB=A1=9C=EB=93=9C=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20dom=EC=97=90=20=EB=82=A8=EC=95=84=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/static/index.html | 58 ++++++++++++++++++++++++---- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 811799d..9bce8c2 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -742,29 +742,27 @@ // Device 파일 업로드 // 모든 파일 업로드 래퍼 섹션을 가져옵니다. fileUploadWrappersDevice.forEach(wrapper => { + // 데이터 초기화 함수 정의 + // 현재 래퍼 내에서 input[type="file"]과 버튼을 찾습니다. const uploadDeviceFileInput = wrapper.querySelector('.upload-input-device'); const selectDeviceFileBtn = wrapper.querySelector('.select-file-btn-device'); - // 해당 래퍼의 data 속성들을 가져옵니다. const expectedDeviceFileName = wrapper.dataset.expectedFilename; const uploadDeviceUrl = wrapper.dataset.uploadUrl; const getDeviceUrl = wrapper.dataset.getUrl; const DeviceFileType = wrapper.dataset.fileType; - // null 체크 (요소가 존재하지 않을 수도 있는 경우를 대비) if (!uploadDeviceFileInput || !selectDeviceFileBtn) { console.warn(`File upload elements not found in wrapper for type: ${DeviceFileType}`); return; } - // "파일 선택" 버튼 클릭 시 숨겨진 input[type="file"] 클릭 이벤트 발생 selectDeviceFileBtn.addEventListener('click', () => { - uploadDeviceFileInput.value = ''; // 이전에 선택된 파일 초기화 + uploadDeviceFileInput.value = ''; uploadDeviceFileInput.click(); }); - // 파일 선택 시 (change 이벤트 발생) 바로 업로드 로직 시작 uploadDeviceFileInput.addEventListener('change', async (event) => { if (event.target.files.length === 0) { return; @@ -778,14 +776,15 @@ const DeviceFileContent = e.target.result; const jsonData = JSON.parse(DeviceFileContent); + clearAllInputs(); + const data = getInitialData(); loadFromData(jsonData); - console.log(`Loaded ${DeviceFileType} data from local file`, jsonData); - - uploadDeviceFileInput.value = ''; + console.log(`Loaded ${DeviceFileType} data from local file`, jsonData); } catch (error) { console.error(`Error uploading file (${DeviceFileType}):`, error); alert(`Error uploading file: ${error.message} (${DeviceFileType})`); + } finally { uploadDeviceFileInput.value = ''; } }; @@ -1224,6 +1223,49 @@ //ssid 행 추가 버튼 document.getElementById('add-ssid').addEventListener('click', addSsidRow); + function clearAllInputs() { + // 모든 input[type="text"], [type="number"], [type="password"] 등 초기화 + document.querySelectorAll('input').forEach(input => { + if (input.type === 'checkbox' || input.type === 'radio') { + input.checked = false; + } else { + input.value = ''; + } + }); + + // 모든 select 초기화 + document.querySelectorAll('select').forEach(select => { + select.selectedIndex = 0; + }); + + // textarea 초기화 (필요 시) + document.querySelectorAll('textarea').forEach(textarea => { + textarea.value = ''; + }); + + // 동적 SSID 목록 등도 비워야 한다면 + const ssidList = document.getElementById('ssid-list'); + if (ssidList) ssidList.innerHTML = ''; + } + + function getInitialData(){ + return { + wifi_static: '', wifi_ip: '', wifi_netmask: '', wifi_gateway: '', wifi_dns1: '', wifi_dns2: '', + eth_ip: '', eth_netmask: '', eth_gateway: '', + protocol_server_ip: '', protocol_server_port: null, + update_server_ip: '', update_server_port: null, + rtcm_server_ip: '', rtcm_server_port: null, + opc_ua_server_ip: '', opc_ua_server_port: null, + modbus_server_ip: '', modbus_server_port: null, + can_bus_type: '', can_baudrate: null, + rs485_mode: '', rs485_baudrate: null, rs485_data_bits: null, + rs485_parity: '', rs485_stop_bits: null, + imu_remap_x: '', imu_remap_y: '', imu_remap_z: '', + imu_remap_x_sign: '', imu_remap_y_sign: '', imu_remap_z_sign: '', + lte_ip: '', lte_netmask: '', lte_gateway: '', lte_port: null, + WIFI_SSID: [{wifi_ssid: '', wifi_password: '', wifi_security: 'none'}], + }; + } /*-----device input데이터 받는 함수------*/ function collectDeviceData() { const res = { ...data };