gudae01 1 year ago
parent
commit
1bce706df7
  1. 4
      src/main/java/org/mobidgim/mobidigimproject/service/SettingService.java
  2. 88
      src/main/resources/static/index.html

4
src/main/java/org/mobidgim/mobidigimproject/service/SettingService.java

@ -32,7 +32,7 @@ public class SettingService {
private final ObjectMapper mapper; private final ObjectMapper mapper;
private static final String DEFAULT_DEVICE_FILENAME = "deviceConfig.json"; private static final String DEFAULT_DEVICE_FILENAME = "deviceConfig.json";
private static final String DEFAULT_PROTOCOL_FILENAME = "protocolConfig.json"; private static final String DEFAULT_PROTOCOL_FILENAME = "protocolConfig.json";
private static final String TEMP_DIRECTORY = "./temp"; private static final String TEMP_DIRECTORY = System.getProperty("user.home") + "/config";
@Autowired @Autowired
public SettingService(ObjectMapper mapper) { public SettingService(ObjectMapper mapper) {
@ -61,7 +61,7 @@ public class SettingService {
ensureDirectoryExists(); ensureDirectoryExists();
String filePath = TEMP_DIRECTORY + "/" + filename; String filePath = TEMP_DIRECTORY + "/" + filename;
Files.createDirectory(Paths.get(filePath)); Files.write(Paths.get(filePath), json.getBytes(StandardCharsets.UTF_8));
} }
// Device 파일 읽기 (기본 파일명 사용) // Device 파일 읽기 (기본 파일명 사용)

88
src/main/resources/static/index.html

@ -776,8 +776,6 @@
const DeviceFileContent = e.target.result; const DeviceFileContent = e.target.result;
const jsonData = JSON.parse(DeviceFileContent); const jsonData = JSON.parse(DeviceFileContent);
clearAllInputs();
const data = getInitialData();
loadFromData(jsonData); loadFromData(jsonData);
console.log(`Loaded ${DeviceFileType} data from local file`, jsonData); console.log(`Loaded ${DeviceFileType} data from local file`, jsonData);
@ -1223,49 +1221,49 @@
//ssid 행 추가 버튼 //ssid 행 추가 버튼
document.getElementById('add-ssid').addEventListener('click', addSsidRow); document.getElementById('add-ssid').addEventListener('click', addSsidRow);
function clearAllInputs() { // function clearAllInputs() {
// 모든 input[type="text"], [type="number"], [type="password"] 등 초기화 // // 모든 input[type="text"], [type="number"], [type="password"] 등 초기화
document.querySelectorAll('input').forEach(input => { // document.querySelectorAll('input').forEach(input => {
if (input.type === 'checkbox' || input.type === 'radio') { // if (input.type === 'checkbox' || input.type === 'radio') {
input.checked = false; // input.checked = false;
} else { // } else {
input.value = ''; // input.value = '';
} // }
}); // });
//
// 모든 select 초기화 // // 모든 select 초기화
document.querySelectorAll('select').forEach(select => { // document.querySelectorAll('select').forEach(select => {
select.selectedIndex = 0; // select.selectedIndex = 0;
}); // });
//
// textarea 초기화 (필요 시) // // textarea 초기화 (필요 시)
document.querySelectorAll('textarea').forEach(textarea => { // document.querySelectorAll('textarea').forEach(textarea => {
textarea.value = ''; // textarea.value = '';
}); // });
//
// 동적 SSID 목록 등도 비워야 한다면 // // 동적 SSID 목록 등도 비워야 한다면
const ssidList = document.getElementById('ssid-list'); // const ssidList = document.getElementById('ssid-list');
if (ssidList) ssidList.innerHTML = ''; // if (ssidList) ssidList.innerHTML = '';
} // }
//
function getInitialData(){ // function getInitialData(){
return { // return {
wifi_static: '', wifi_ip: '', wifi_netmask: '', wifi_gateway: '', wifi_dns1: '', wifi_dns2: '', // wifi_static: '', wifi_ip: '', wifi_netmask: '', wifi_gateway: '', wifi_dns1: '', wifi_dns2: '',
eth_ip: '', eth_netmask: '', eth_gateway: '', // eth_ip: '', eth_netmask: '', eth_gateway: '',
protocol_server_ip: '', protocol_server_port: null, // protocol_server_ip: '', protocol_server_port: null,
update_server_ip: '', update_server_port: null, // update_server_ip: '', update_server_port: null,
rtcm_server_ip: '', rtcm_server_port: null, // rtcm_server_ip: '', rtcm_server_port: null,
opc_ua_server_ip: '', opc_ua_server_port: null, // opc_ua_server_ip: '', opc_ua_server_port: null,
modbus_server_ip: '', modbus_server_port: null, // modbus_server_ip: '', modbus_server_port: null,
can_bus_type: '', can_baudrate: null, // can_bus_type: '', can_baudrate: null,
rs485_mode: '', rs485_baudrate: null, rs485_data_bits: null, // rs485_mode: '', rs485_baudrate: null, rs485_data_bits: null,
rs485_parity: '', rs485_stop_bits: null, // rs485_parity: '', rs485_stop_bits: null,
imu_remap_x: '', imu_remap_y: '', imu_remap_z: '', // imu_remap_x: '', imu_remap_y: '', imu_remap_z: '',
imu_remap_x_sign: '', imu_remap_y_sign: '', imu_remap_z_sign: '', // imu_remap_x_sign: '', imu_remap_y_sign: '', imu_remap_z_sign: '',
lte_ip: '', lte_netmask: '', lte_gateway: '', lte_port: null, // lte_ip: '', lte_netmask: '', lte_gateway: '', lte_port: null,
WIFI_SSID: [{wifi_ssid: '', wifi_password: '', wifi_security: 'none'}], // WIFI_SSID: [{wifi_ssid: '', wifi_password: '', wifi_security: 'none'}],
}; // };
} // }
/*-----device input데이터 받는 함수------*/ /*-----device input데이터 받는 함수------*/
function collectDeviceData() { function collectDeviceData() {
const res = { ...data }; const res = { ...data };

Loading…
Cancel
Save