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