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
996e2b4200
commit
ca789cfcdc
|
@ -5,7 +5,6 @@ setActivePinia(pinia);
|
||||||
|
|
||||||
import { useStateStore } from "../../store/stateStore.js";
|
import { useStateStore } from "../../store/stateStore.js";
|
||||||
const state = useStateStore(pinia);
|
const state = useStateStore(pinia);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="card w-100 h-100">
|
<div class="card w-100 h-100">
|
||||||
|
@ -29,7 +28,6 @@ const state = useStateStore(pinia);
|
||||||
>Tune</a
|
>Tune</a
|
||||||
>
|
>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -5,7 +5,6 @@ setActivePinia(pinia);
|
||||||
|
|
||||||
import { useStateStore } from "../store/stateStore.js";
|
import { useStateStore } from "../store/stateStore.js";
|
||||||
const state = useStateStore(pinia);
|
const state = useStateStore(pinia);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div class="card mb-1">
|
<div class="card mb-1">
|
||||||
|
@ -28,7 +27,6 @@ const state = useStateStore(pinia);
|
||||||
>
|
>
|
||||||
Tune
|
Tune
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-1 text-end">
|
<div class="col-1 text-end">
|
||||||
<button
|
<button
|
||||||
|
|
|
@ -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: ${ev.type}, Session ID: ${ev['arq-transfer-outbound'].session_id}, DXCall: ${ev['arq-transfer-outbound'].dxcall}, Total Bytes: ${ev['arq-transfer-outbound'].total_bytes}, State: ${ev['arq-transfer-outbound'].state}`;
|
message = `Type: ${ev.type}, Session ID: ${ev["arq-transfer-outbound"].session_id}, DXCall: ${ev["arq-transfer-outbound"].dxcall}, Total Bytes: ${ev["arq-transfer-outbound"].total_bytes}, State: ${ev["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: ${ev.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: ${ev.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: ${ev.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: ${ev.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: ${ev.type}, Session ID: ${ev['arq-transfer-outbound'].session_id}, DXCall: ${ev['arq-transfer-outbound'].dxcall}, Total Bytes: ${ev['arq-transfer-outbound'].total_bytes}, Success: ${ev['arq-transfer-outbound'].success ? 'Yes' : 'No'}, State: ${ev['arq-transfer-outbound'].state}, Data: ${ev['arq-transfer-outbound'].data ? 'Available' : 'Not Available'}`;
|
message = `Type: ${ev.type}, Session ID: ${
|
||||||
displayToast("danger", "bi-x-octagon", message, 5000);
|
ev["arq-transfer-outbound"].session_id
|
||||||
return
|
}, DXCall: ${ev["arq-transfer-outbound"].dxcall}, Total Bytes: ${
|
||||||
}
|
ev["arq-transfer-outbound"].total_bytes
|
||||||
|
}, Success: ${
|
||||||
|
ev["arq-transfer-outbound"].success ? "Yes" : "No"
|
||||||
|
}, State: ${ev["arq-transfer-outbound"].state}, Data: ${
|
||||||
|
ev["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: ${ev.type}, Session ID: ${ev['arq-transfer-outbound'].session_id}, DXCall: ${ev['arq-transfer-outbound'].dxcall}, State: ${ev['arq-transfer-outbound'].state}`;
|
message = `Type: ${ev.type}, Session ID: ${ev["arq-transfer-outbound"].session_id}, DXCall: ${ev["arq-transfer-outbound"].dxcall}, State: ${ev["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: ${ev.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: ${ev.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: ${ev.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: ${ev.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
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ function connect(endpoint, dispatcher) {
|
||||||
// handle data
|
// handle data
|
||||||
socket.addEventListener("message", function (event) {
|
socket.addEventListener("message", function (event) {
|
||||||
dispatcher(event.data);
|
dispatcher(event.data);
|
||||||
return
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle errors
|
// handle errors
|
||||||
|
|
Loading…
Reference in a new issue