Add support for per-station timeoutLength/lowVoltage
This commit is contained in:
parent
2feabd4d87
commit
e14904e59b
@ -24,11 +24,12 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, watch } from 'vue';
|
import { ref, computed, watch } from 'vue';
|
||||||
|
import parseDuration from 'parse-duration';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
callsign: String,
|
callsign: String,
|
||||||
tactical: String,
|
tactical: String,
|
||||||
timeoutLength: Number,
|
timeoutLength: String,
|
||||||
lowVoltage: Number,
|
lowVoltage: Number,
|
||||||
finishedReplay: Boolean,
|
finishedReplay: Boolean,
|
||||||
messages: Array,
|
messages: Array,
|
||||||
@ -48,6 +49,10 @@ function formatTime(time, isDuration = false) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const timeoutLengthMs = computed(() => {
|
||||||
|
return parseDuration(props.timeoutLength);
|
||||||
|
});
|
||||||
|
|
||||||
function prettyDuration(duration) {
|
function prettyDuration(duration) {
|
||||||
let date = new Date(duration);
|
let date = new Date(duration);
|
||||||
return [
|
return [
|
||||||
@ -74,7 +79,8 @@ const timedOut = computed(() => {
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
props.now.getTime() - stationStatus.value.lastHeard > props.timeoutLength
|
props.now.getTime() - stationStatus.value.lastHeard >
|
||||||
|
timeoutLengthMs.value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -131,12 +137,12 @@ watch(timedOut, (newVal) => {
|
|||||||
if (newVal) {
|
if (newVal) {
|
||||||
notify(
|
notify(
|
||||||
`${tacticalAndOrCall.value} has not been heard for over ${prettyDuration(
|
`${tacticalAndOrCall.value} has not been heard for over ${prettyDuration(
|
||||||
props.timeoutLength
|
timeoutLengthMs.value
|
||||||
)}!`,
|
)}!`,
|
||||||
`Last Heard: ${formatTime(
|
`Last Heard: ${formatTime(
|
||||||
stationStatus.value.lastHeard
|
stationStatus.value.lastHeard
|
||||||
)} (${prettyDuration(
|
)} (${prettyDuration(
|
||||||
props.now.value - stationStatus.value.lastHeard
|
props.now.getTime() - stationStatus.value.lastHeard
|
||||||
)} ago!)`
|
)} ago!)`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,10 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<StationRow
|
<StationRow
|
||||||
v-for="(tactical, callsign) in trackedStations"
|
v-for="(stationProps, callsign) in trackedStations"
|
||||||
:key="callsign"
|
:key="callsign"
|
||||||
:callsign="callsign"
|
:callsign="callsign"
|
||||||
:tactical="tactical"
|
v-bind="{ ...config.default, ...stationProps }"
|
||||||
:lowVoltage="config.lowVoltage"
|
|
||||||
:timeoutLength="parseDuration(config.timeoutLength)"
|
|
||||||
:finishedReplay="finishedReplay"
|
:finishedReplay="finishedReplay"
|
||||||
:messages="messagesFromStation[callsign] || []"
|
:messages="messagesFromStation[callsign] || []"
|
||||||
:now="now"
|
:now="now"
|
||||||
@ -39,7 +37,6 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import APRSParser from 'aprs-parser/lib/APRSParser';
|
import APRSParser from 'aprs-parser/lib/APRSParser';
|
||||||
import parseDuration from 'parse-duration';
|
|
||||||
|
|
||||||
import StationRow from './StationRow.vue';
|
import StationRow from './StationRow.vue';
|
||||||
import config from './status_config.yaml';
|
import config from './status_config.yaml';
|
||||||
@ -50,9 +47,25 @@ const finishedReplay = ref(false);
|
|||||||
const messages = ref([]);
|
const messages = ref([]);
|
||||||
const messagesFromStation = ref({});
|
const messagesFromStation = ref({});
|
||||||
const now = ref(new Date());
|
const now = ref(new Date());
|
||||||
const trackedStations = ref(config.trackedStations);
|
const trackedStations = ref(normalizeConfigStations());
|
||||||
const canNotify = ref(Notification.permission === 'granted');
|
const canNotify = ref(Notification.permission === 'granted');
|
||||||
|
|
||||||
|
function normalizeConfigStations() {
|
||||||
|
return [...Object.entries(config.trackedStations)]
|
||||||
|
.map(([callsign, tacticalOrProps]) => {
|
||||||
|
if (typeof tacticalOrProps === 'string') {
|
||||||
|
return [callsign, { tactical: tacticalOrProps }];
|
||||||
|
} else {
|
||||||
|
return [callsign, tacticalOrProps];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.reduce((acc, [callsign, props]) => {
|
||||||
|
console.log(callsign, props);
|
||||||
|
acc[callsign] = props;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// Connect to websocket aprs stream
|
// Connect to websocket aprs stream
|
||||||
connectToStream();
|
connectToStream();
|
||||||
@ -103,7 +116,7 @@ function handleMessage(packet) {
|
|||||||
message.data.text.split(';').map((tac_assoc) => {
|
message.data.text.split(';').map((tac_assoc) => {
|
||||||
let [call, tac] = tac_assoc.split('=', 2);
|
let [call, tac] = tac_assoc.split('=', 2);
|
||||||
if (tac) {
|
if (tac) {
|
||||||
trackedStations.value[call] = tac;
|
trackedStations.value[call].tactical = tac;
|
||||||
} else {
|
} else {
|
||||||
delete trackedStations.value[call];
|
delete trackedStations.value[call];
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,31 @@
|
|||||||
timeoutLength: 10 minutes
|
|
||||||
lowVoltage: 11.9
|
|
||||||
|
|
||||||
TACTICAL_whitelist:
|
TACTICAL_whitelist:
|
||||||
- KC1GDW-7
|
- KC1GDW-7
|
||||||
- W1FN
|
- W1FN
|
||||||
|
|
||||||
|
default:
|
||||||
|
timeoutLength: 10 minutes
|
||||||
|
lowVoltage: 11.9
|
||||||
|
|
||||||
trackedStations:
|
trackedStations:
|
||||||
# Digis/iGates
|
# Digis/iGates
|
||||||
W1FN-1: Moose Mt
|
W1FN-1:
|
||||||
W1FN-5: Hanover
|
tactical: Moose Mt
|
||||||
W1FN-9: Bath
|
timeoutLength: 25 minutes
|
||||||
N1GMC-1: Dame Hill Rd, Orford
|
W1FN-5:
|
||||||
N1GMC-2: Sunday Mt, Orford
|
tactical: Hanover
|
||||||
KB1FDA-1: Corinth
|
timeoutLength: 25 minutes
|
||||||
|
W1FN-9:
|
||||||
|
tactical: Bath
|
||||||
|
timeoutLength: 25 minutes
|
||||||
|
N1GMC-1:
|
||||||
|
tactical: Dame Hill Rd, Orford
|
||||||
|
timeoutLength: 25 minutes
|
||||||
|
N1GMC-2:
|
||||||
|
tactical: Sunday Mt, Orford
|
||||||
|
timeoutLength: 25 minutes
|
||||||
|
KB1FDA-1:
|
||||||
|
tactical: Corinth
|
||||||
|
timeoutLength: 25 minutes
|
||||||
|
|
||||||
# Vehicles
|
# Vehicles
|
||||||
K1EHZ-10: Recovery
|
K1EHZ-10: Recovery
|
||||||
|
Loading…
Reference in New Issue
Block a user