diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html
index 1bd9a55..c6d227d 100644
--- a/src/main/resources/static/index.html
+++ b/src/main/resources/static/index.html
@@ -239,7 +239,6 @@
@@ -281,12 +280,12 @@
-
IP
- SUBNET
-
@@ -313,8 +312,8 @@
-
-
+
+
@@ -332,10 +331,6 @@
class="colon">:
GATEWAY:
- SERVER IP:
- SERVER PORT:
@@ -450,8 +445,8 @@
-
-
+
+
@@ -588,8 +583,8 @@
-
-
+
+
@@ -677,8 +672,8 @@
-
-
+
+
@@ -759,8 +754,8 @@
-
-
+
+
@@ -834,8 +829,8 @@
-
-
+
+
@@ -1010,14 +1005,7 @@
}
}
- /* (A) 고정 data 객체 그대로 저장 */
- document.getElementById('downloadDeviceBtn')?.addEventListener('click', () => {
- downloadDeviceJson(collectData(data));
- });
- document.getElementById('downloadProtocolBtn')?.addEventListener('click', () => {
- downloadProtocolJson(collectConfigData(configData));
- })
function showPage(pageName) {
Object.values(pages).forEach(p => p.style.display = 'none');
@@ -1068,7 +1056,7 @@
document.getElementById('delete-ssid').addEventListener('click', () => {
if (ssidList.children.length > 1) {
ssidList.removeChild(ssidList.lastElementChild);
- } else if (ssidList.children.length == 1) {
+ } else if (ssidList.children.length === 1) {
const firstRow = ssidList.firstElementChild;
firstRow.querySelector('.ssid-name').value = '';
firstRow.querySelector('.ssid-pw').value = '';
@@ -2066,192 +2054,48 @@
toggleProtocolMenus();
}
- document.querySelectorAll('.js-save').forEach(btn=>btn.addEventListener('click', () => {saveToConfig()}))
- document.getElementById('loadDeviceBtn_ssid')?.addEventListener('click', () => {
- fetch('http://localhost:8080/setting/get-device')
- .then(res => {
- if (!res.ok) {
- console.error(`HTTP error! status: ${res.status}`);
- throw new Error('Device file not found or server error');
- }
- return res.json();
- })
- .then(({body}) => {
- loadFromData(body);
- alert('Device 설정 파일 로드 완료');
- })
- .catch(error => {
- console.error('Device 설정 파일 로드 중 오류 발생:', error);
- alert('Device 설정 파일 로드 실패! 기본값으로 시작합니다.');
- loadFromData(data); // 오류 발생 시 data의 초기값으로 UI 초기화
- });
- });
-
- document.getElementById('loadDeviceBtn_network')?.addEventListener('click', () => {
- fetch('http://localhost:8080/setting/get-device')
- .then(res => {
- if (!res.ok) {
- console.error(`HTTP error! status: ${res.status}`);
- throw new Error('Device file not found or server error');
- }
- return res.json();
- })
- .then(({body}) => {
- loadFromData(body);
- alert('Device 설정 파일 로드 완료');
- })
- .catch(error => {
- console.error('Device 설정 파일 로드 중 오류 발생:', error);
- alert('Device 설정 파일 로드 실패! 기본값으로 시작합니다.');
- loadFromData(data); // 오류 발생 시 data의 초기값으로 UI 초기화
- });
- });
-
- document.getElementById('loadDeviceBtn_io')?.addEventListener('click', () => {
- fetch('http://localhost:8080/setting/get-device')
- .then(res => {
- if (!res.ok) {
- console.error(`HTTP error! status: ${res.status}`);
- throw new Error('Device file not found or server error');
- }
- return res.json();
- })
- .then(deviceJsonData => {
- loadFromData(deviceJsonData);
- alert('Device 설정 파일 로드 완료');
- })
- .catch(error => {
- console.error('Device 설정 파일 로드 중 오류 발생:', error);
- alert('Device 설정 파일 로드 실패! 기본값으로 시작합니다.');
- loadFromData(data); // 오류 발생 시 data의 초기값으로 UI 초기화
- });
- });
-
-
- document.getElementById('saveDeviceBtn_ssid').addEventListener('click', () => {
- fetch('http://localhost:8080/setting/device', {
- method: 'POST',
- headers: {'Content-Type': 'application/json'},
- body: JSON.stringify(collectData())
- })
- .then(res => {
- if (res.ok) {
- alert('Device config successfully');
- } else {
- alert('Device config failed: ' + res.statusText);
- console.error('Device config failed:', res); // 응답 객체 자체를 로깅
- }
- })
- .catch(error => {
- console.error('Device config failed::', error); // 네트워크 오류 로깅
- alert('Device config failed:');
- });
- });
-
- document.getElementById('saveDeviceBtn_network').addEventListener('click', () => {
- fetch('http://localhost:8080/setting/device', {
+ function saveToConfig() {
+ fetch('http://localhost:8080/setting/device',{
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(collectData())
- })
- .then(res => {
- if (res.ok) {
- alert('Device config successfully');
- } else {
- alert('Device config failed: ' + res.statusText);
- console.error('Device config failed:', res); // 응답 객체 자체를 로깅
- }
- })
- .catch(error => {
- console.error('Device config failed::', error); // 네트워크 오류 로깅
- alert('Device config failed:');
- });
- });
-
- document.getElementById('saveDeviceBtn_io').addEventListener('click', () => {
- fetch('http://localhost:8080/setting/device', {
- method: 'POST',
- headers: {'Content-Type': 'application/json'},
- body: JSON.stringify(collectData())
- })
- .then(res => {
- if (res.ok) {
- alert('Device config successfully');
- } else {
- alert('Device config failed: ' + res.statusText);
- console.error('Device config failed:', res); // 응답 객체 자체를 로깅
- }
- })
- .catch(error => {
- console.error('Device config failed::', error); // 네트워크 오류 로깅
- alert('Device config failed:');
- });
- });
-
+ }).then(res => {
+ if(!res.ok) {
+ alert('전송 실패')
+ }
+ }).catch(()=>{
+ alert('device 설정 전송 중 통신 오류 발생');
+ });
- document.getElementById('saveProtocolBtn').addEventListener('click', () => {
- console.log('버튼 클릭 됨');
- console.log(collectConfigData());
fetch('http://localhost:8080/setting/protocol', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(collectConfigData())
- })
- .then(res => {
- if (res.ok) {
- alert('Register 설정 전송 완료');
- } else {
+ }).then(res => {
+ if (!res.ok) {
alert('Register 설정 전송 실패: ' + res.statusText);
- console.error('Register 설정 전송 실패:', res); // 응답 객체 자체를 로깅
}
})
.catch(error => {
console.error('Register 설정 전송 중 오류 발생:', error); // 네트워크 오류 로깅
alert('Register 설정 전송 중 통신 오류 발생');
- });
- });
-
- document.getElementById('saveModbusBtn').addEventListener('click', () => {
- console.log('버튼 클릭 됨');
- fetch('http://localhost:8080/setting/protocol', {
- method: 'POST',
- headers: {'Content-Type': 'application/json'},
- body: JSON.stringify(collectConfigData())
+ }).finally(()=>{
+ alert('저장 완료');
})
- .then(res => {
- if (res.ok) {
- alert('Register 설정 전송 완료');
- } else {
- alert('Register 설정 전송 실패: ' + res.statusText);
- console.error('Register 설정 전송 실패:', res); // 응답 객체 자체를 로깅
- }
- })
- .catch(error => {
- console.error('Register 설정 전송 중 오류 발생:', error); // 네트워크 오류 로깅
- alert('Register 설정 전송 중 통신 오류 발생');
- });
- });
+ }
+
+
+ document.querySelectorAll('.save-file').forEach(btn=>btn.addEventListener('click', () => {saveToConfig()}))
+
+
+ document.querySelectorAll('.download-device-file').forEach(btn=>{btn.addEventListener('click', () => {
+ downloadDeviceJson(collectData(data));
+ })})
+
+ document.querySelectorAll('.download-protocol-file').forEach(btn=>{btn.addEventListener('click', () => {
+ downloadProtocolJson(collectData(data));
+ })})
- document.getElementById('saveOpcUaFileBtn').addEventListener('click', () => {
- console.log('버튼 클릭 됨');
- fetch('http://localhost:8080/setting/protocol', {
- method: 'POST',
- headers: {'Content-Type': 'application/json'},
- body: JSON.stringify(collectConfigData())
- })
- .then(res => {
- if (res.ok) {
- alert('Register 설정 전송 완료');
- } else {
- alert('Register 설정 전송 실패: ' + res.statusText);
- console.error('Register 설정 전송 실패:', res); // 응답 객체 자체를 로깅
- }
- })
- .catch(error => {
- console.error('Register 설정 전송 중 오류 발생:', error); // 네트워크 오류 로깅
- alert('Register 설정 전송 중 통신 오류 발생');
- });
- });
document.getElementById('reg_can_input')?.addEventListener('change', toggleProtocolMenus);//--------------------------------
@@ -2280,23 +2124,6 @@
document.getElementById('can_mask_input').value = tr.querySelector('.can-mask-display').textContent;
});
});
-
- document.getElementById('saveCanBtn').addEventListener('click', () => {
- fetch('http://localhost:8080/setting/protocol', {
- method: 'POST',
- headers: {'Content-Type': 'application/json'},
- body: JSON.stringify(collectConfigData())
- })
- .then(res => {
- if (res.ok) {
- alert('Register 설정 전송 완료');
- } else {
- alert('Register 설정 전송 실패: ' + res.statusText);
- }
- });
- });
-
-