FreeDATA/gui/src/components/chat_navbar.vue

183 lines
4.3 KiB
Vue
Raw Normal View History

2023-09-12 15:52:16 +00:00
<script setup lang="ts">
// @ts-nocheck
2023-10-03 13:15:17 +00:00
import { setActivePinia } from "pinia";
import pinia from "../store/index";
2023-09-12 15:52:16 +00:00
setActivePinia(pinia);
2023-10-03 13:15:17 +00:00
import { useStateStore } from "../store/stateStore.js";
2023-09-12 15:52:16 +00:00
const state = useStateStore(pinia);
2023-10-03 13:15:17 +00:00
import { useChatStore } from "../store/chatStore.js";
2023-09-14 20:45:29 +00:00
const chat = useChatStore(pinia);
2023-11-04 18:55:18 +00:00
import { startChatWithNewStation } from "../js/chatHandler";
2023-11-04 04:13:47 +00:00
import {
Chart as ChartJS,
CategoryScale,
LinearScale,
PointElement,
Title,
Tooltip,
Legend,
2023-10-03 13:15:17 +00:00
BarElement,
} from "chart.js";
2023-10-11 09:18:48 +00:00
2023-10-22 13:24:02 +00:00
import { Bar } from "vue-chartjs";
2023-10-03 13:15:17 +00:00
import { ref, computed } from "vue";
2023-10-22 08:12:00 +00:00
import annotationPlugin from "chartjs-plugin-annotation";
2023-10-11 09:18:48 +00:00
2023-10-22 08:12:00 +00:00
const newChatCall = ref(null);
ChartJS.register(
CategoryScale,
LinearScale,
PointElement,
Title,
Tooltip,
Legend,
2023-10-03 13:15:17 +00:00
BarElement,
2023-10-22 08:12:00 +00:00
annotationPlugin,
2023-10-03 13:15:17 +00:00
);
var beaconHistogramOptions = {
type: "bar",
bezierCurve: false, //remove curves from your plot
scaleShowLabels: false, //remove labels
tooltipEvents: [], //remove trigger from tooltips so they will'nt be show
pointDot: false, //remove the points markers
scaleShowGridLines: true, //set to false to remove the grids background
maintainAspectRatio: true,
plugins: {
legend: {
display: false,
},
2023-10-11 09:18:48 +00:00
annotation: {
annotations: [
{
2023-10-22 08:12:00 +00:00
type: "line",
mode: "horizontal",
scaleID: "y",
2023-10-11 09:18:48 +00:00
value: 0,
2023-10-22 08:12:00 +00:00
borderColor: "darkgrey", // Set the color to dark grey for the zero line
2023-10-16 16:44:09 +00:00
borderWidth: 0.5, // Set the line width
2023-10-22 08:12:00 +00:00
},
2023-10-11 09:18:48 +00:00
],
},
2023-10-03 13:15:17 +00:00
},
scales: {
x: {
position: "bottom",
display: false,
min: -10,
max: 15,
ticks: {
display: false,
},
},
y: {
display: false,
min: -5,
max: 10,
ticks: {
display: false,
},
2023-10-03 13:15:17 +00:00
},
},
};
const beaconHistogramData = computed(() => ({
2023-10-03 13:15:17 +00:00
labels: chat.beaconLabelArray,
datasets: [
2023-10-22 08:12:00 +00:00
{
data: chat.beaconDataArray,
tension: 0.1,
borderColor: "rgb(0, 255, 0)",
backgroundColor: function (context) {
var value = context.dataset.data[context.dataIndex];
return value >= 0 ? "green" : "red";
},
2023-10-11 09:18:48 +00:00
},
2023-10-03 13:15:17 +00:00
],
}));
2023-10-22 13:44:05 +00:00
function newChat() {
2023-10-16 01:03:12 +00:00
let callsign = this.newChatCall.value;
callsign = callsign.toUpperCase().trim();
if (callsign === "") return;
2023-11-18 16:12:05 +00:00
startChatWithNewStation(callsign);
2023-11-04 04:13:47 +00:00
//updateAllChat(false);
2023-10-22 08:12:00 +00:00
this.newChatCall.value = "";
}
2023-10-22 08:12:00 +00:00
function syncWithModem() {
getRxBuffer();
}
2023-09-12 15:52:16 +00:00
</script>
<template>
2023-10-03 13:15:17 +00:00
<nav class="navbar bg-body-tertiary border-bottom">
<div class="container">
<div class="row w-100">
2023-10-19 14:54:24 +00:00
<div class="col-3 p-0 me-2">
<div class="input-group bottom-0 m-0 ms-1">
2023-10-03 13:15:17 +00:00
<input
2023-10-19 14:54:24 +00:00
class="form-control"
2023-10-03 13:15:17 +00:00
maxlength="9"
style="text-transform: uppercase"
2023-10-19 14:54:24 +00:00
placeholder="callsign"
2023-10-16 01:03:12 +00:00
@keypress.enter="newChat()"
2023-10-22 08:12:00 +00:00
ref="newChatCall"
2023-10-03 13:15:17 +00:00
/>
<button
2023-10-19 14:54:24 +00:00
class="btn btn-sm btn-outline-success"
2023-10-03 13:15:17 +00:00
id="createNewChatButton"
type="button"
title="Start a new chat (enter dx call sign first)"
@click="newChat()"
>
new chat
<i class="bi bi-pencil-square" style="font-size: 1.2rem"></i>
</button>
</div>
</div>
<div class="col-5 ms-2 p-0">
2023-10-03 13:15:17 +00:00
<!-- right side of chat nav bar-->
2023-10-11 09:18:48 +00:00
2023-10-22 08:12:00 +00:00
<div class="input-group mb-0 p-0 w-50">
<button type="button" class="btn btn-outline-secondary" disabled>
Beacons
</button>
2023-10-11 09:18:48 +00:00
2023-10-22 08:12:00 +00:00
<div
class="form-floating border border-secondary-subtle border-1 rounded-end"
>
<Bar
:data="beaconHistogramData"
:options="beaconHistogramOptions"
width="300"
height="50"
/>
</div>
</div>
</div>
2023-10-11 09:18:48 +00:00
<div class="col-2 ms-2 p-0">
2023-10-22 08:12:00 +00:00
<div class="input-group mb-0 p-0">
<button
type="button"
class="btn btn-outline-secondary"
@click="syncWithModem()"
>
Modem Sync {{ state.rx_buffer_length }}
2023-10-22 08:12:00 +00:00
</button>
</div>
</div>
2023-10-03 13:15:17 +00:00
</div>
</div>
</nav>
2023-09-12 15:52:16 +00:00
</template>