bugfix + output fix
parent
aa9e68b96d
commit
e25db0b419
|
|
@ -86,6 +86,7 @@ button:hover {
|
|||
height: 90vh;
|
||||
max-height: 90vh;
|
||||
width: 30%;
|
||||
max-width: 30%;
|
||||
border-radius: 4px;
|
||||
padding: 10px;
|
||||
overflow-y: scroll;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
$(window).ready(function () {
|
||||
var isConnected = false;
|
||||
var apiIsAlive = true;
|
||||
var apiIsAlive = false;
|
||||
// TODO: change to valid url
|
||||
var apiServer = "http://localhost:8080";
|
||||
|
||||
|
|
@ -53,6 +53,8 @@ $(window).ready(function () {
|
|||
}
|
||||
|
||||
const fabric = new PacketFabric();
|
||||
let hello_check = fabric.new_hello();
|
||||
queryConstructor(hello_check);
|
||||
|
||||
function dataConstructor(packet){
|
||||
switch (packet.type) {
|
||||
|
|
@ -86,7 +88,7 @@ $(window).ready(function () {
|
|||
apiIsAlive = status;
|
||||
return status ?
|
||||
ok_msg_conn(`API-Server is running. Connection established`)
|
||||
: err_msg_conn(`API-Server unreachable. Error: ${JSON.stringify(er)}`);
|
||||
: err_msg_conn(`API-Server unreachable. Error: ${er.statusText}. Status : ${er.status}`);
|
||||
case 'close':
|
||||
isConnected = status ? false : isConnected;
|
||||
if (status) {
|
||||
|
|
@ -98,7 +100,7 @@ $(window).ready(function () {
|
|||
}
|
||||
return status ?
|
||||
ok_msg_conn(`Connection closed`)
|
||||
: err_msg_conn(`Cannot close connection. Error: ${JSON.stringify(er)}`);
|
||||
: err_msg_conn(`Cannot close connection. Error: ${er.statusText}. Status : ${er.status}`);
|
||||
case 'connect':
|
||||
isConnected = status ? true : isConnected;
|
||||
if (status) {
|
||||
|
|
@ -113,7 +115,7 @@ $(window).ready(function () {
|
|||
}
|
||||
return status ?
|
||||
ok_msg_conn(`Successfully connected to PLD ${packet.ip}:${packet.port}`)
|
||||
: err_msg_conn(`Cannot open web-socket with ${packet.ip}:${packet.port}. Error: ${JSON.stringify(er)}`);
|
||||
: err_msg_conn(`Cannot open web-socket with ${packet.ip}:${packet.port}. Error: ${er.statusText}. Status : ${er.status}`);
|
||||
case 'send':
|
||||
if (status) {
|
||||
valid('address');
|
||||
|
|
@ -126,7 +128,7 @@ $(window).ready(function () {
|
|||
}
|
||||
return status ?
|
||||
ok_msg_conn(`Successfully sent data to ${packet.register_address}`)
|
||||
: err_msg_conn(`Cannot send data to ${packet.register_address}. Error: ${JSON.stringify(er)}`);
|
||||
: err_msg_conn(`Cannot send data to ${packet.register_address}. Error: ${er.statusText}. Status : ${er.status}`);
|
||||
default:
|
||||
return packet
|
||||
}
|
||||
|
|
@ -150,9 +152,11 @@ $(window).ready(function () {
|
|||
|
||||
$('#connect-btn').click(function() {
|
||||
if (!apiIsAlive) {
|
||||
err_msg_conn("Cannot work without API-Server. Check its health...");
|
||||
if (!hello_api()) {
|
||||
err_msg_conn("Cannot work without API-Server. Check it health...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isConnected) {
|
||||
let packet = fabric.new_close();
|
||||
|
|
@ -174,9 +178,11 @@ $(window).ready(function () {
|
|||
|
||||
$('#send-btn').click(() => {
|
||||
if (!apiIsAlive) {
|
||||
if (!hello_api()) {
|
||||
err_msg_conn("Cannot work without API-Server. Check it health...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
const address = document.getElementById('address').value;
|
||||
const data = document.getElementById('data').value;
|
||||
// wr or rd
|
||||
|
|
@ -203,6 +209,11 @@ $(window).ready(function () {
|
|||
}
|
||||
});
|
||||
|
||||
function hello_api() {
|
||||
let packet = fabric.new_hello;
|
||||
return queryConstructor(packet);
|
||||
}
|
||||
|
||||
function valid(id) {
|
||||
var obj = document.getElementById(id).classList;
|
||||
if (obj.contains('invalid-args')) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue