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 };