Browse Source

오류 수정

v2
gudae01 1 year ago
parent
commit
e5ca3ea1f0
  1. 100
      src/main/resources/static/index.html

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

@ -55,7 +55,6 @@
<div id="ssid-list"></div> <div id="ssid-list"></div>
<button id="add-ssid" class="icon-button" title="add SSID"></button> <button id="add-ssid" class="icon-button" title="add SSID"></button>
<button id="delete-ssid" class="icon-button" title="delete SSID"></button>
</div> </div>
<div class="actions"> <div class="actions">
<div class="file-upload-wrapper-device" <div class="file-upload-wrapper-device"
@ -170,7 +169,7 @@
</select></div> </select></div>
<div class="io-row"><span class="label-inline">Parity</span><span <div class="io-row"><span class="label-inline">Parity</span><span
class="colon">:</span><select id="rs485_parity"> class="colon">:</span><select id="rs485_parity">
<option value="no">NONE</option> <option value="">NONE</option>
<option value="odd">ODD</option> <option value="odd">ODD</option>
<option value="even">EVEN</option> <option value="even">EVEN</option>
</select></div> </select></div>
@ -495,8 +494,8 @@
<td><span class="opcua-odt-display"></span></td> <td><span class="opcua-odt-display"></span></td>
<td><span class="opcua-dv-display"></span></td> <td><span class="opcua-dv-display"></span></td>
<td><span class="opcua-shift-display"></span></td> <td><span class="opcua-shift-display"></span></td>
<td><span class="opcua-mask-display"></span></td>
<td><span class="opcua-expr-display"></span></td> <td><span class="opcua-expr-display"></span></td>
<td><span class="opcua-mask-display"></span></td>
</tr> </tr>
</template> </template>
@ -575,8 +574,8 @@
<td><span class="can-odt-display"></span></td> <td><span class="can-odt-display"></span></td>
<td><span class="can-dv-display"></span></td> <td><span class="can-dv-display"></span></td>
<td><span class="can-shift-display"></span></td> <td><span class="can-shift-display"></span></td>
<td><span class="can-mask-display"></span></td>
<td><span class="can-expr-display"></span></td> <td><span class="can-expr-display"></span></td>
<td><span class="can-mask-display"></span></td>
</tr> </tr>
</template> </template>
@ -613,7 +612,7 @@
<option value="boolean">boolean</option> <option value="boolean">boolean</option>
<option value="string">string</option> <option value="string">string</option>
</select> </select>
<label>dv</label> <label>dv(Default Value)</label>
<input type="text" id="can_dv_input" placeholder="Enter default value"> <input type="text" id="can_dv_input" placeholder="Enter default value">
<label>shift</label> <label>shift</label>
<input type="text" id="can_shift_input" placeholder="Enter shift value"> <input type="text" id="can_shift_input" placeholder="Enter shift value">
@ -734,6 +733,7 @@
const opcUaAddBtn = document.getElementById('opcua_add_btn'); const opcUaAddBtn = document.getElementById('opcua_add_btn');
const opcUaFieldList = document.getElementById('opcua-field-list'); const opcUaFieldList = document.getElementById('opcua-field-list');
const opcUaRowTemplate = document.getElementById('opcua-row-template'); const opcUaRowTemplate = document.getElementById('opcua-row-template');
const canRowTemplate = document.getElementById('can-row-template');
const canFieldList = document.getElementById('can-field-list'); const canFieldList = document.getElementById('can-field-list');
// 페이지 로드 시 자동으로 JSON 파일들 로드 // 페이지 로드 시 자동으로 JSON 파일들 로드
@ -790,12 +790,6 @@
} }
}; };
reader.onerror = () => {
alert(`An error occurred while reading the file. (${DeviceFileType})`);
console.error(`FileReader error for ${DeviceFileType}:`, reader.error);
uploadDeviceFileInput.value = '';
};
reader.readAsText(selectedDeviceFile); reader.readAsText(selectedDeviceFile);
}); });
}); });
@ -854,11 +848,6 @@
uploadFileInput.value = ''; uploadFileInput.value = '';
} }
}; };
reader.onerror = () => {
alert(`An error occurred while reading the file. (${fileType})`);
uploadFileInput.value = '';
};
reader.readAsText(selectedFile); reader.readAsText(selectedFile);
}); });
}); });
@ -934,6 +923,32 @@
} }
} }
/*---can 테이블에 행 추가 로직---*/
document.getElementById('can-field-list').addEventListener('click', function (e) {
let tr = e.target.closest('tr');
if (!tr) return;
Array.from(this.children).forEach(row => row.classList.remove('selected-row'));
tr.classList.add('selected-row');
selectedRow = tr;
document.getElementById('can_field_input').value = tr.querySelector('.can-field-display').textContent;
document.getElementById('can_id_input').value = tr.querySelector('.can-id-display').textContent;
document.getElementById('can_odt_input').value = tr.querySelector('.can-odt-display').textContent;
document.getElementById('can_dv_input').value = tr.querySelector('.can-dv-display').textContent;
document.getElementById('can_shift_input').value = tr.querySelector('.can-shift-display').textContent;
document.getElementById('can_expr_input').value = tr.querySelector('.can-expr-display').textContent;
document.getElementById('can_mask_input').value = tr.querySelector('.can-mask-display').textContent;
});
// 처음에 행이 없으면 빈 행을 하나 추가
if (canFieldList.children.length === 0) {
const canRowTemplate = document.getElementById('can-row-template');
if (canRowTemplate) {
const newRow = canRowTemplate.content.cloneNode(true);
opcUaList.appendChild(newRow);
}
}
modbusAddBtn.addEventListener('click', () => { modbusAddBtn.addEventListener('click', () => {
const field = document.getElementById('modbus_field_input').value; const field = document.getElementById('modbus_field_input').value;
const addr = document.getElementById('modbus_addr_input').value; const addr = document.getElementById('modbus_addr_input').value;
@ -1042,14 +1057,14 @@
} }
// 입력 필드 초기화 // 입력 필드 초기화
document.getElementById('modbus_field_input').value = ''; document.getElementById('opcua_field_input').value = '';
document.getElementById('modbus_addr_input').value = ''; document.getElementById('opcua_addr_input').value = '';
document.getElementById('modbus_idt_input').value = ''; document.getElementById('opcua_ns_input').value = '';
document.getElementById('modbus_odt_input').value = ''; document.getElementById('opcua_odt_input').value = '';
document.getElementById('modbus_dv_input').value = ''; document.getElementById('opcua_dv_input').value = '';
document.getElementById('modbus_shift_input').value = ''; document.getElementById('opcua_shift_input').value = '';
document.getElementById('modbus_expr_input').value = ''; document.getElementById('opcua_expr_input').value = '';
document.getElementById('modbus_mask_input').value = ''; document.getElementById('opcua_mask_input').value = '';
}); });
@ -1093,15 +1108,32 @@
const expr = document.getElementById('can_expr_input').value; const expr = document.getElementById('can_expr_input').value;
const mask = document.getElementById('can_mask_input').value; const mask = document.getElementById('can_mask_input').value;
const canRowTemplate = document.getElementById('can-row-template'); const canRowTemplate = document.getElementById('can-row-template');
const newRow = canRowTemplate.content.cloneNode(true); const firstRow = canFieldList.querySelector('tr');
newRow.querySelector('.can-field-display').textContent = field;
newRow.querySelector('.can-id-display').textContent = id; // 첫 행이 비어있다면 그 자리에 값을 넣기
newRow.querySelector('.can-odt-display').textContent = odt; if (firstRow && firstRow.querySelector('.can-field-display').textContent.trim() === '') {
newRow.querySelector('.can-dv-display').textContent = dv; firstRow.querySelector('.can-field-display').textContent = field;
newRow.querySelector('.can-shift-display').textContent = shift; firstRow.querySelector('.can-id-display').textContent = id;
newRow.querySelector('.can-expr-display').textContent = expr; firstRow.querySelector('.can-odt-display').textContent = odt;
newRow.querySelector('.can-mask-display').textContent = mask; firstRow.querySelector('.can-dv-display').textContent = dv;
canFieldList.appendChild(newRow); firstRow.querySelector('.can-shift-display').textContent = shift;
firstRow.querySelector('.can-expr-display').textContent = expr;
firstRow.querySelector('.can-mask-display').textContent = mask;
} else {
// 새로운 행을 추가
const newRow = canRowTemplate.content.cloneNode(true);
newRow.querySelector('.can-field-display').textContent = field;
newRow.querySelector('.can-id-display').textContent = id;
newRow.querySelector('.can-odt-display').textContent = odt;
newRow.querySelector('.can-dv-display').textContent = dv;
newRow.querySelector('.can-shift-display').textContent = shift;
newRow.querySelector('.can-expr-display').textContent = expr;
newRow.querySelector('.can-mask-display').textContent = mask;
canFieldList.appendChild(newRow);
}
// 입력 필드 초기화
document.getElementById('can_field_input').value = ''; document.getElementById('can_field_input').value = '';
document.getElementById('can_id_input').value = ''; document.getElementById('can_id_input').value = '';
document.getElementById('can_odt_input').value = ''; document.getElementById('can_odt_input').value = '';
@ -1424,7 +1456,7 @@
console.warn(`Protocol load failed: HTTP ${protocolResponse.status}`); console.warn(`Protocol load failed: HTTP ${protocolResponse.status}`);
} }
} catch (error) { } catch (error) {
console.error('Protocol load failed:', error.message); console.error('./Protocol load failed:', error.message);
} }
} }
/*-----------------------------------------------------*/ /*-----------------------------------------------------*/

Loading…
Cancel
Save