mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
[CodeFactor] Apply fixes
This commit is contained in:
parent
27fc465a3a
commit
79130edbe9
1 changed files with 80 additions and 71 deletions
|
@ -24,10 +24,7 @@ export function connectionFailed(endpoint, event) {
|
||||||
export function stateDispatcher(data) {
|
export function stateDispatcher(data) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
if (
|
if (data["type"] == "state-change" || data["type"] == "state") {
|
||||||
data["type"] == "state-change" ||
|
|
||||||
data["type"] == "state"
|
|
||||||
) {
|
|
||||||
stateStore.channel_busy = data["channel_busy"];
|
stateStore.channel_busy = data["channel_busy"];
|
||||||
stateStore.is_codec2_traffic = data["is_codec2_traffic"];
|
stateStore.is_codec2_traffic = data["is_codec2_traffic"];
|
||||||
stateStore.is_modem_running = data["is_modem_running"];
|
stateStore.is_modem_running = data["is_modem_running"];
|
||||||
|
@ -43,11 +40,9 @@ export function stateDispatcher(data) {
|
||||||
//Reverse entries so most recent is first
|
//Reverse entries so most recent is first
|
||||||
stateStore.activities = Object.entries(data["activities"]).reverse();
|
stateStore.activities = Object.entries(data["activities"]).reverse();
|
||||||
build_HSL();
|
build_HSL();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function eventDispatcher(data) {
|
export function eventDispatcher(data) {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
console.info(data);
|
console.info(data);
|
||||||
|
@ -66,92 +61,106 @@ export function eventDispatcher(data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var message = ''
|
var message = "";
|
||||||
|
|
||||||
switch (data["type"]) {
|
switch (data["type"]) {
|
||||||
case "hello-client":
|
case "hello-client":
|
||||||
message = "Connected to server";
|
message = "Connected to server";
|
||||||
displayToast("success", "bi-ethernet", message, 5000);
|
displayToast("success", "bi-ethernet", message, 5000);
|
||||||
stateStore.modem_connection = "connected";
|
stateStore.modem_connection = "connected";
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case "arq":
|
case "arq":
|
||||||
if (data['arq-transfer-outbound']) {
|
if (data["arq-transfer-outbound"]) {
|
||||||
switch (data["arq-transfer-outbound"].state) {
|
switch (data["arq-transfer-outbound"].state) {
|
||||||
case "NEW":
|
case "NEW":
|
||||||
message = `Type: ${data.type}, Session ID: ${data['arq-transfer-outbound'].session_id}, DXCall: ${data['arq-transfer-outbound'].dxcall}, Total Bytes: ${data['arq-transfer-outbound'].total_bytes}, State: ${data['arq-transfer-outbound'].state}`;
|
message = `Type: ${data.type}, Session ID: ${data["arq-transfer-outbound"].session_id}, DXCall: ${data["arq-transfer-outbound"].dxcall}, Total Bytes: ${data["arq-transfer-outbound"].total_bytes}, State: ${data["arq-transfer-outbound"].state}`;
|
||||||
displayToast("success", "bi-check-circle", message, 5000);
|
displayToast("success", "bi-check-circle", message, 5000);
|
||||||
return
|
return;
|
||||||
case "OPEN_SENT":
|
case "OPEN_SENT":
|
||||||
console.log("state OPEN_SENT needs to be implemented")
|
console.log("state OPEN_SENT needs to be implemented");
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "INFO_SENT":
|
case "INFO_SENT":
|
||||||
console.log("state INFO_SENT needs to be implemented")
|
console.log("state INFO_SENT needs to be implemented");
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "BURST_SENT":
|
case "BURST_SENT":
|
||||||
message = `Type: ${data.type}, Session ID: ${data['arq-transfer-outbound'].session_id}, DXCall: ${data['arq-transfer-outbound'].dxcall}, Received Bytes: ${data['arq-transfer-outbound'].received_bytes}/${data['arq-transfer-outbound'].total_bytes}, State: ${data['arq-transfer-outbound'].state}`;
|
message = `Type: ${data.type}, Session ID: ${data["arq-transfer-outbound"].session_id}, DXCall: ${data["arq-transfer-outbound"].dxcall}, Received Bytes: ${data["arq-transfer-outbound"].received_bytes}/${data["arq-transfer-outbound"].total_bytes}, State: ${data["arq-transfer-outbound"].state}`;
|
||||||
displayToast("info", "bi-info-circle", message, 5000);
|
displayToast("info", "bi-info-circle", message, 5000);
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "ABORTING":
|
case "ABORTING":
|
||||||
console.log("state ABORTING needs to be implemented")
|
console.log("state ABORTING needs to be implemented");
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "ABORTED":
|
case "ABORTED":
|
||||||
message = `Type: ${data.type}, Session ID: ${data['arq-transfer-outbound'].session_id}, DXCall: ${data['arq-transfer-outbound'].dxcall}, Total Bytes: ${data['arq-transfer-outbound'].total_bytes}, Success: ${data['arq-transfer-outbound'].success ? 'Yes' : 'No'}, State: ${data['arq-transfer-outbound'].state}, Data: ${data['arq-transfer-outbound'].data ? 'Available' : 'Not Available'}`;
|
message = `Type: ${data.type}, Session ID: ${
|
||||||
displayToast("warning", "bi-exclamation-triangle", message, 5000);
|
data["arq-transfer-outbound"].session_id
|
||||||
return
|
}, DXCall: ${data["arq-transfer-outbound"].dxcall}, Total Bytes: ${
|
||||||
|
data["arq-transfer-outbound"].total_bytes
|
||||||
|
}, Success: ${
|
||||||
|
data["arq-transfer-outbound"].success ? "Yes" : "No"
|
||||||
|
}, State: ${data["arq-transfer-outbound"].state}, Data: ${
|
||||||
|
data["arq-transfer-outbound"].data ? "Available" : "Not Available"
|
||||||
|
}`;
|
||||||
|
displayToast("warning", "bi-exclamation-triangle", message, 5000);
|
||||||
|
return;
|
||||||
|
|
||||||
case "FAILED":
|
case "FAILED":
|
||||||
message = `Type: ${data.type}, Session ID: ${data['arq-transfer-outbound'].session_id}, DXCall: ${data['arq-transfer-outbound'].dxcall}, Total Bytes: ${data['arq-transfer-outbound'].total_bytes}, Success: ${data['arq-transfer-outbound'].success ? 'Yes' : 'No'}, State: ${data['arq-transfer-outbound'].state}, Data: ${data['arq-transfer-outbound'].data ? 'Available' : 'Not Available'}`;
|
message = `Type: ${data.type}, Session ID: ${
|
||||||
displayToast("danger", "bi-x-octagon", message, 5000);
|
data["arq-transfer-outbound"].session_id
|
||||||
return
|
}, DXCall: ${data["arq-transfer-outbound"].dxcall}, Total Bytes: ${
|
||||||
}
|
data["arq-transfer-outbound"].total_bytes
|
||||||
|
}, Success: ${
|
||||||
|
data["arq-transfer-outbound"].success ? "Yes" : "No"
|
||||||
|
}, State: ${data["arq-transfer-outbound"].state}, Data: ${
|
||||||
|
data["arq-transfer-outbound"].data ? "Available" : "Not Available"
|
||||||
|
}`;
|
||||||
|
displayToast("danger", "bi-x-octagon", message, 5000);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (data['arq-transfer-inbound']) {
|
if (data["arq-transfer-inbound"]) {
|
||||||
switch (data["arq-transfer-inbound"].state) {
|
switch (data["arq-transfer-inbound"].state) {
|
||||||
case "NEW":
|
case "NEW":
|
||||||
message = `Type: ${data.type}, Session ID: ${data['arq-transfer-outbound'].session_id}, DXCall: ${data['arq-transfer-outbound'].dxcall}, State: ${data['arq-transfer-outbound'].state}`;
|
message = `Type: ${data.type}, Session ID: ${data["arq-transfer-outbound"].session_id}, DXCall: ${data["arq-transfer-outbound"].dxcall}, State: ${data["arq-transfer-outbound"].state}`;
|
||||||
displayToast("info", "bi-info-circle", message, 5000);
|
displayToast("info", "bi-info-circle", message, 5000);
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "OPEN_ACK_SENT":
|
case "OPEN_ACK_SENT":
|
||||||
message = `Session ID: ${data['arq-transfer-inbound'].session_id}, DXCall: ${data['arq-transfer-inbound'].dxcall}, Total Bytes: ${data['arq-transfer-inbound'].total_bytes}, State: ${data['arq-transfer-inbound'].state}`;
|
message = `Session ID: ${data["arq-transfer-inbound"].session_id}, DXCall: ${data["arq-transfer-inbound"].dxcall}, Total Bytes: ${data["arq-transfer-inbound"].total_bytes}, State: ${data["arq-transfer-inbound"].state}`;
|
||||||
displayToast("info", "bi-arrow-left-right", message, 5000);
|
displayToast("info", "bi-arrow-left-right", message, 5000);
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "INFO_ACK_SENT":
|
case "INFO_ACK_SENT":
|
||||||
message = `Type: ${data.type}, Session ID: ${data['arq-transfer-inbound'].session_id}, DXCall: ${data['arq-transfer-inbound'].dxcall}, Received Bytes: ${data['arq-transfer-inbound'].received_bytes}/${data['arq-transfer-inbound'].total_bytes}, State: ${data['arq-transfer-inbound'].state}`;
|
message = `Type: ${data.type}, Session ID: ${data["arq-transfer-inbound"].session_id}, DXCall: ${data["arq-transfer-inbound"].dxcall}, Received Bytes: ${data["arq-transfer-inbound"].received_bytes}/${data["arq-transfer-inbound"].total_bytes}, State: ${data["arq-transfer-inbound"].state}`;
|
||||||
displayToast("info", "bi-info-circle", message, 5000);
|
displayToast("info", "bi-info-circle", message, 5000);
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "BURST_REPLY_SENT":
|
case "BURST_REPLY_SENT":
|
||||||
console.log("state BURST_REPLY_SENT needs to be implemented")
|
console.log("state BURST_REPLY_SENT needs to be implemented");
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "ENDED":
|
case "ENDED":
|
||||||
console.log("state ENDED needs to be implemented")
|
console.log("state ENDED needs to be implemented");
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "ABORTED":
|
case "ABORTED":
|
||||||
console.log("state ABORTED needs to be implemented")
|
console.log("state ABORTED needs to be implemented");
|
||||||
return
|
return;
|
||||||
|
|
||||||
case "FAILED":
|
case "FAILED":
|
||||||
message = `Type: ${data.type}, Session ID: ${data['arq-transfer-outbound'].session_id}, DXCall: ${data['arq-transfer-outbound'].dxcall}, Received Bytes: ${data['arq-transfer-outbound'].received_bytes}/${data['arq-transfer-outbound'].total_bytes}, State: ${data['arq-transfer-outbound'].state}`;
|
message = `Type: ${data.type}, Session ID: ${data["arq-transfer-outbound"].session_id}, DXCall: ${data["arq-transfer-outbound"].dxcall}, Received Bytes: ${data["arq-transfer-outbound"].received_bytes}/${data["arq-transfer-outbound"].total_bytes}, State: ${data["arq-transfer-outbound"].state}`;
|
||||||
displayToast("info", "bi-info-circle", message, 5000);
|
displayToast("info", "bi-info-circle", message, 5000);
|
||||||
return
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function build_HSL() {
|
function build_HSL() {
|
||||||
//Use data from activities to build HSL list
|
//Use data from activities to build HSL list
|
||||||
for (let i = 0; i < stateStore.activities.length; i++) {
|
for (let i = 0; i < stateStore.activities.length; i++) {
|
||||||
|
@ -186,4 +195,4 @@ function build_HSL() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stateStore.heard_stations.sort((a, b) => b.timestamp - a.timestamp); // b - a for reverse sort
|
stateStore.heard_stations.sort((a, b) => b.timestamp - a.timestamp); // b - a for reverse sort
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue