Browse Source

consolelog삭제

v2
gudae01 1 year ago
parent
commit
95b929eeb9
  1. 72
      src/main/resources/static/index.html

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

@ -759,11 +759,10 @@
const deviceData = await deviceResponse.json(); const deviceData = await deviceResponse.json();
if (deviceData && deviceData.body) { if (deviceData && deviceData.body) {
loadFromData(deviceData.body); loadFromData(deviceData.body);
console.log('Device 설정 자동 로드 완료');
} }
} }
} catch (error) { } catch (error) {
console.log('Device 설정 파일이 없거나 로드 실패, 기본값 사용:', error.message); alert('Device configuration file missing or loading failed');
} }
try { try {
@ -773,12 +772,10 @@
const protocolData = await protocolResponse.json(); const protocolData = await protocolResponse.json();
if (protocolData && protocolData.body) { if (protocolData && protocolData.body) {
loadFromRegisterJson(protocolData.body); loadFromRegisterJson(protocolData.body);
console.log('Protocol 설정 자동 로드 완료');
} }
} }
} catch (error) { } catch (error) {
console.log('Protocol 설정 파일이 없거나 로드 실패, 기본값 사용:', error.message); alert('Protocol configuration file missing or loading failed'); }
}
} }
@ -1238,7 +1235,7 @@
// 파일명 검증 (data-expected-filename 사용) // 파일명 검증 (data-expected-filename 사용)
if (DeviceFileName !== expectedDeviceFileName){ if (DeviceFileName !== expectedDeviceFileName){
alert(`잘못된 파일입니다. '${expectedDeviceFileName}' 파일을 선택해주세요. 현재 파일: ${DeviceFileName} `); alert(`Invalid file.'${expectedDeviceFileName}' Please select a file. Current file: ${DeviceFileName} `);
uploadDeviceFileInput.value = ''; // 잘못된 파일 선택 시 input 초기화 uploadDeviceFileInput.value = ''; // 잘못된 파일 선택 시 input 초기화
return; return;
} }
@ -1250,16 +1247,6 @@
const DeviceFileContent = e.target.result; const DeviceFileContent = e.target.result;
const jsonData = JSON.parse(DeviceFileContent); const jsonData = JSON.parse(DeviceFileContent);
// JSON 내용 유효성 검증
// 모든 파일이 Register 설정이라면 isValidRegisterConfig를 그대로 사용
// 만약 파일 타입에 따라 다른 유효성 검사가 필요하다면,
// 여기에 조건부 로직을 추가해야 합니다.
// if (!isValidDeviceConfig(jsonData)){ // 예를 들어, isValidModbusConfig(jsonData) 등
// alert(`선택된 파일의 내용이 유효한 ${DeviceFileType} 설정 파일 형식이 아닙니다.`);
// uploadDeviceFileInput.value = '';
// return;
// }
// 백엔드 저장 API 호출 (data-upload-url 사용) // 백엔드 저장 API 호출 (data-upload-url 사용)
const response = await fetch(uploadDeviceUrl, { const response = await fetch(uploadDeviceUrl, {
method: 'POST', method: 'POST',
@ -1271,13 +1258,13 @@
if (!response.ok) { if (!response.ok) {
const errorText = await response.text(); const errorText = await response.text();
throw new Error(`파일 업로드 실패: ${response.status} ${response.statusText} - ${errorText}`); throw new Error(`File upload failed: ${response.status} ${response.statusText} - ${errorText}`);
} }
const result = await response.json(); const result = await response.json();
if (result.result && result.result.result_code === 200) { if (result.result && result.result.result_code === 200) {
alert(`파일이 Device에 성공적으로 업로드되었습니다! (${DeviceFileType})`); alert(`File uploaded to Device successfully (${DeviceFileType})`);
console.log(`Upload successful for ${DeviceFileType}:`, result); console.log(`Upload successful for ${DeviceFileType}:`, result);
// 업로드 성공 후 최신 데이터를 Device에서 다시 불러와 UI 업데이트 (data-get-url 사용) // 업로드 성공 후 최신 데이터를 Device에서 다시 불러와 UI 업데이트 (data-get-url 사용)
@ -1292,28 +1279,28 @@
loadFromData(apiResponseData.body); loadFromData(apiResponseData.body);
console.log(`UI updated with newly uploaded ${DeviceFileType} data.`); console.log(`UI updated with newly uploaded ${DeviceFileType} data.`);
} else { } else {
console.warn(`업로드 후 ${DeviceFileType} 데이터 재로드 실패: 응답 body 없음`); console.warn(`Failed to reload ${DeviceFileType} data after upload: no response body`);
} }
}) })
.catch(err => console.error(`업로드 후 ${DeviceFileType} 데이터 재로드 중 오류 발생:`, err)); .catch(err => console.error(`Error reloading ${DeviceFileType} data after upload:`, err));
uploadDeviceFileInput.value = ''; // input 초기화 (다음 업로드 위함) uploadDeviceFileInput.value = ''; // input 초기화 (다음 업로드 위함)
} else { } else {
alert(`파일 업로드 실패: ${result.result ? result.result.result_message : '알 수 없는 오류'} (${DeviceFileType})`); alert(`File upload failed: ${result.result ? result.result.result_message : 'Unknown error'} (${DeviceFileType})`);
console.error(`Upload failed for ${DeviceFileType} with backend error:`, result); console.error(`Upload failed for ${DeviceFileType} with backend error:`, result);
uploadDeviceFileInput.value = ''; uploadDeviceFileInput.value = '';
} }
} catch (error) { } catch (error) {
console.error(`파일 업로드 중 오류 발생 (${DeviceFileType}):`, error); console.error(`Error uploading file (${DeviceFileType}):`, error);
alert(`파일 업로드 중 오류 발생: ${error.message} (${DeviceFileType})`); alert(`Error uploading file: ${error.message} (${DeviceFileType})`);
uploadDeviceFileInput.value = ''; uploadDeviceFileInput.value = '';
} }
}; };
reader.onerror = () => { reader.onerror = () => {
alert(`파일을 읽는 도중 오류가 발생했습니다. (${DeviceFileType})`); alert(`An error occurred while reading the file. (${DeviceFileType})`);
console.error(`FileReader error for ${DeviceFileType}:`, reader.error); console.error(`FileReader error for ${DeviceFileType}:`, reader.error);
uploadDeviceFileInput.value = ''; uploadDeviceFileInput.value = '';
}; };
@ -1360,7 +1347,7 @@
// 파일명 검증 (data-expected-filename 사용) // 파일명 검증 (data-expected-filename 사용)
if (fileName !== expectedFileName){ if (fileName !== expectedFileName){
alert(`잘못된 파일입니다. '${expectedFileName}' 파일을 선택해주세요. 현재 파일: ${fileName} `); alert(`Invalid file. '${expectedFileName}' Please select a file. Current file: ${fileName} `);
uploadFileInput.value = ''; // 잘못된 파일 선택 시 input 초기화 uploadFileInput.value = ''; // 잘못된 파일 선택 시 input 초기화
return; return;
} }
@ -1377,7 +1364,7 @@
// 만약 파일 타입에 따라 다른 유효성 검사가 필요하다면, // 만약 파일 타입에 따라 다른 유효성 검사가 필요하다면,
// 여기에 조건부 로직을 추가해야 합니다. // 여기에 조건부 로직을 추가해야 합니다.
if (!isValidRegisterConfig(jsonData)){ // 예를 들어, isValidModbusConfig(jsonData) 등 if (!isValidRegisterConfig(jsonData)){ // 예를 들어, isValidModbusConfig(jsonData) 등
alert(`선택된 파일의 내용이 유효한 ${fileType} 설정 파일 형식이 아닙니다.`); alert(`The contents of the selected file are not in a valid ${fileType} setting file format.`);
uploadFileInput.value = ''; uploadFileInput.value = '';
return; return;
} }
@ -1393,13 +1380,13 @@
if (!response.ok) { if (!response.ok) {
const errorText = await response.text(); const errorText = await response.text();
throw new Error(`파일 업로드 실패: ${response.status} ${response.statusText} - ${errorText}`); throw new Error(`File upload failed: ${response.status} ${response.statusText} - ${errorText}`);
} }
const result = await response.json(); const result = await response.json();
if (result.result && result.result.result_code === 200) { if (result.result && result.result.result_code === 200) {
alert(`파일이 Device에 성공적으로 업로드되었습니다! (${fileType})`); alert(`File uploaded to Device successfully (${fileType})`);
console.log(`Upload successful for ${fileType}:`, result); console.log(`Upload successful for ${fileType}:`, result);
// 업로드 성공 후 최신 데이터를 Device에서 다시 불러와 UI 업데이트 (data-get-url 사용) // 업로드 성공 후 최신 데이터를 Device에서 다시 불러와 UI 업데이트 (data-get-url 사용)
@ -1414,7 +1401,7 @@
loadFromRegisterJson(apiResponseData.body); loadFromRegisterJson(apiResponseData.body);
console.log(`UI updated with newly uploaded ${fileType} data.`); console.log(`UI updated with newly uploaded ${fileType} data.`);
} else { } else {
console.warn(`업로드 후 ${fileType} 데이터 재로드 실패: 응답 body 없음`); console.warn(`Failed to reload ${fileType} data after upload: no response body`);
} }
}) })
.catch(err => console.error(`업로드 후 ${fileType} 데이터 재로드 중 오류 발생:`, err)); .catch(err => console.error(`업로드 후 ${fileType} 데이터 재로드 중 오류 발생:`, err));
@ -1422,21 +1409,19 @@
uploadFileInput.value = ''; // input 초기화 (다음 업로드 위함) uploadFileInput.value = ''; // input 초기화 (다음 업로드 위함)
} else { } else {
alert(`파일 업로드 실패: ${result.result ? result.result.result_message : '알 수 없는 오류'} (${fileType})`); alert(`File upload failed: ${result.result?result.result_message: 'unknown error'} (${fileType})`);
console.error(`Upload failed for ${fileType} with backend error:`, result); console.error(`Upload failed for ${fileType} with backend error:`, result);
uploadFileInput.value = ''; uploadFileInput.value = '';
} }
} catch (error) { } catch (error) {
console.error(`파일 업로드 중 오류 발생 (${fileType}):`, error); alert(`Error uploading file: ${error.message} (${fileType})`);
alert(`파일 업로드 중 오류 발생: ${error.message} (${fileType})`);
uploadFileInput.value = ''; uploadFileInput.value = '';
} }
}; };
reader.onerror = () => { reader.onerror = () => {
alert(`파일을 읽는 도중 오류가 발생했습니다. (${fileType})`); alert(`An error occurred while reading the file. (${fileType})`);
console.error(`FileReader error for ${fileType}:`, reader.error);
uploadFileInput.value = ''; uploadFileInput.value = '';
}; };
@ -1704,7 +1689,7 @@
} }
document.getElementById('modbus_modify_btn').onclick = function () { document.getElementById('modbus_modify_btn').onclick = function () {
if (!selectedRow) return alert('수정할 행을 선택하세요!'); if (!selectedRow) return alert('Please select the row you want to modify');
selectedRow.querySelector('.field-display').textContent = document.getElementById('modbus_field_input').value; selectedRow.querySelector('.field-display').textContent = document.getElementById('modbus_field_input').value;
selectedRow.querySelector('.addr-display').textContent = document.getElementById('modbus_addr_input').value; selectedRow.querySelector('.addr-display').textContent = document.getElementById('modbus_addr_input').value;
selectedRow.querySelector('.idt-display').textContent = document.getElementById('modbus_idt_input').value; selectedRow.querySelector('.idt-display').textContent = document.getElementById('modbus_idt_input').value;
@ -1717,7 +1702,7 @@
// 삭제 버튼 // 삭제 버튼
document.getElementById('modbus_delete_btn').onclick = function () { document.getElementById('modbus_delete_btn').onclick = function () {
if (!selectedRow) return alert('삭제할 행을 선택하세요!'); if (!selectedRow) return alert('Select the row you want to delete');
const list = document.getElementById('modbus-field-list'); const list = document.getElementById('modbus-field-list');
selectedRow.remove(); selectedRow.remove();
selectedRow = null; selectedRow = null;
@ -1763,7 +1748,7 @@
} }
document.getElementById('opcua_modify_btn').onclick = function () { document.getElementById('opcua_modify_btn').onclick = function () {
if (!selectedRow) return alert('수정할 행을 선택하세요!'); if (!selectedRow) return alert('Please select the row you want to modify');
selectedRow.querySelector('.opcua-field-display').textContent = document.getElementById('opcua_field_input').value; selectedRow.querySelector('.opcua-field-display').textContent = document.getElementById('opcua_field_input').value;
selectedRow.querySelector('.opcua-addr-display').textContent = document.getElementById('opcua_addr_input').value; selectedRow.querySelector('.opcua-addr-display').textContent = document.getElementById('opcua_addr_input').value;
selectedRow.querySelector('.opcua-ns-display').textContent = document.getElementById('opcua_ns_input').value; selectedRow.querySelector('.opcua-ns-display').textContent = document.getElementById('opcua_ns_input').value;
@ -1776,7 +1761,7 @@
// 삭제 버튼 // 삭제 버튼
document.getElementById('opcua_delete_btn').onclick = function () { document.getElementById('opcua_delete_btn').onclick = function () {
if (!selectedRow) return alert('삭제할 행을 선택하세요!'); if (!selectedRow) return alert('Select the row you want to delete');
const list = document.getElementById('opcua-field-list'); const list = document.getElementById('opcua-field-list');
selectedRow.remove(); selectedRow.remove();
selectedRow = null; selectedRow = null;
@ -1811,7 +1796,7 @@
document.getElementById('can_mask_input').value = ''; document.getElementById('can_mask_input').value = '';
}); });
document.getElementById('can_modify_btn').onclick = function () { document.getElementById('can_modify_btn').onclick = function () {
if (!selectedRow) return alert('수정할 행을 선택하세요!'); if (!selectedRow) return alert('Please select the row you want to modify');
selectedRow.querySelector('.can-field-display').textContent = document.getElementById('can_field_input').value; selectedRow.querySelector('.can-field-display').textContent = document.getElementById('can_field_input').value;
selectedRow.querySelector('.can-id-display').textContent = document.getElementById('can_id_input').value; selectedRow.querySelector('.can-id-display').textContent = document.getElementById('can_id_input').value;
selectedRow.querySelector('.can-odt-display').textContent = document.getElementById('can_odt_input').value; selectedRow.querySelector('.can-odt-display').textContent = document.getElementById('can_odt_input').value;
@ -1821,7 +1806,7 @@
selectedRow.querySelector('.can-mask-display').textContent = document.getElementById('can_mask_input').value; selectedRow.querySelector('.can-mask-display').textContent = document.getElementById('can_mask_input').value;
}; };
document.getElementById('can_delete_btn').onclick = function () { document.getElementById('can_delete_btn').onclick = function () {
if (!selectedRow) return alert('삭제할 행을 선택하세요!'); if (!selectedRow) return alert('Select the row you want to delete');
const list = document.getElementById('can-field-list'); const list = document.getElementById('can-field-list');
selectedRow.remove(); selectedRow.remove();
selectedRow = null; selectedRow = null;
@ -1832,7 +1817,6 @@
regProtocolSelect = document.getElementById('reg_protocol'); regProtocolSelect = document.getElementById('reg_protocol');
if (regProtocolSelect) { if (regProtocolSelect) {
regProtocolSelect.addEventListener('change', () => { regProtocolSelect.addEventListener('change', () => {
console.log('regProtocolSelect 변경 감지', regProtocolSelect.value);
toggleProtocolMenus(); toggleProtocolMenus();
}); });
@ -1844,7 +1828,7 @@
const protocolData = collectConfigData(); const protocolData = collectConfigData();
if (!isValidRegisterConfig(protocolData)) { if (!isValidRegisterConfig(protocolData)) {
alert("현재 Register 설정이 유효하지 않습니다. 저장할 수 없습니다. 콘솔을 확인하세요."); alert("Register settings are currently invalid. Cannot be saved.");
return; return;
} }
@ -1868,11 +1852,11 @@
alert('saved successfully'); alert('saved successfully');
} else { } else {
alert('save failure'); alert('save failure');
console.error('device 응답:', res1.status, 'protocol 응답:', res2.status); console.error('device response:', res1.status, 'protocol response:', res2.status);
} }
}) })
.catch(err => { .catch(err => {
console.error('전송 중 오류 발생:', err); console.error('Error during transfer:', err);
alert('save failure'); alert('save failure');
}); });
} }

Loading…
Cancel
Save