Add/apply .prettierrc and .editorconfig
This commit is contained in:
parent
dcb034dc10
commit
6f0a537a06
9
.editorconfig
Normal file
9
.editorconfig
Normal file
@ -0,0 +1,9 @@
|
||||
# EditorConfig is awesome: https://EditorConfig.org
|
||||
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
3
.prettierrc
Normal file
3
.prettierrc
Normal file
@ -0,0 +1,3 @@
|
||||
trailingComma: es5
|
||||
singleQuote: true
|
||||
jsxBracketSameLine: true
|
89
src/Map.vue
89
src/Map.vue
@ -83,32 +83,32 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from "vue";
|
||||
import Vue from 'vue';
|
||||
|
||||
import { APRSParser } from "aprs-parser";
|
||||
import distinctColors from "distinct-colors";
|
||||
import { APRSParser } from 'aprs-parser';
|
||||
import distinctColors from 'distinct-colors';
|
||||
|
||||
import VueLayers from "vuelayers";
|
||||
import { createStyle, createLineGeom } from "vuelayers/lib/ol-ext";
|
||||
import { Control } from "ol/control";
|
||||
import { GPX } from "ol/format";
|
||||
import VueLayers from 'vuelayers';
|
||||
import { createStyle, createLineGeom } from 'vuelayers/lib/ol-ext';
|
||||
import { Control } from 'ol/control';
|
||||
import { GPX } from 'ol/format';
|
||||
|
||||
import "vuelayers/lib/style.css";
|
||||
import 'vuelayers/lib/style.css';
|
||||
|
||||
Vue.use(VueLayers);
|
||||
|
||||
import route_data from "gpx/*.gpx";
|
||||
import { readFileSync } from "fs";
|
||||
const packetLog = readFileSync(__dirname + "/../IS_packets.txt", "utf-8");
|
||||
import route_data from 'gpx/*.gpx';
|
||||
import { readFileSync } from 'fs';
|
||||
const packetLog = readFileSync(__dirname + '/../IS_packets.txt', 'utf-8');
|
||||
|
||||
function parsePackets(packetLog) {
|
||||
let parser = new APRSParser();
|
||||
return (
|
||||
packetLog
|
||||
.trim()
|
||||
.split("\n")
|
||||
.split('\n')
|
||||
// parse to Date and APRS packet
|
||||
.map(line => {
|
||||
.map((line) => {
|
||||
let packet = parser.parse(line.slice(29));
|
||||
packet.date = new Date(line.slice(0, 18));
|
||||
return packet;
|
||||
@ -120,7 +120,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
packets: parsePackets(packetLog),
|
||||
routes: route_data
|
||||
routes: route_data,
|
||||
};
|
||||
},
|
||||
|
||||
@ -130,23 +130,18 @@ export default {
|
||||
},
|
||||
|
||||
packetsToStationPathPoints(packets) {
|
||||
return packets.map(packet => [
|
||||
return packets.map((packet) => [
|
||||
packet.data.longitude,
|
||||
packet.data.latitude
|
||||
packet.data.latitude,
|
||||
]);
|
||||
},
|
||||
|
||||
pathToString(path) {
|
||||
return path
|
||||
.filter(
|
||||
station => !station.call.match(/WIDE[12]|qA?|UV[123]|.*\*$|UNCAN/)
|
||||
(station) => !station.call.match(/WIDE[12]|qA?|UV[123]|.*\*$|UNCAN/)
|
||||
)
|
||||
.map(station =>
|
||||
station
|
||||
.toString()
|
||||
.trim()
|
||||
.replace(/\*$/, "")
|
||||
);
|
||||
.map((station) => station.toString().trim().replace(/\*$/, ''));
|
||||
},
|
||||
|
||||
groupByCall(acc, packet) {
|
||||
@ -160,7 +155,7 @@ export default {
|
||||
if (digi in this.digiColors) {
|
||||
return this.digiColors[digi].hex();
|
||||
} else {
|
||||
return "#000000";
|
||||
return '#000000';
|
||||
}
|
||||
},
|
||||
|
||||
@ -171,7 +166,7 @@ export default {
|
||||
feature
|
||||
.getGeometry()
|
||||
.getLineStrings()
|
||||
.forEach(ls => {
|
||||
.forEach((ls) => {
|
||||
let path = paths.shift().slice(0);
|
||||
ls.forEachSegment((start, end) => {
|
||||
let color = this.colorForDigi(path.shift());
|
||||
@ -180,14 +175,14 @@ export default {
|
||||
createStyle({
|
||||
geom: createLineGeom([start, end]),
|
||||
strokeColor: color,
|
||||
strokeWidth: 2
|
||||
strokeWidth: 2,
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
return styles;
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
@ -195,12 +190,12 @@ export default {
|
||||
return (
|
||||
this.packets
|
||||
.filter(
|
||||
packet =>
|
||||
packet.date > new Date("2018-07-13") &&
|
||||
packet.date < new Date("2018-07-14")
|
||||
(packet) =>
|
||||
packet.date > new Date('2018-07-13') &&
|
||||
packet.date < new Date('2018-07-14')
|
||||
)
|
||||
// filter to just positional data
|
||||
.filter(packet => "data" in packet && "latitude" in packet.data)
|
||||
.filter((packet) => 'data' in packet && 'latitude' in packet.data)
|
||||
);
|
||||
},
|
||||
|
||||
@ -212,16 +207,16 @@ export default {
|
||||
digis() {
|
||||
let digiCalls = new Set(
|
||||
this.packets
|
||||
.map(packet => this.pathToString(packet.via))
|
||||
.map((packet) => this.pathToString(packet.via))
|
||||
.reduce((acc, stations) => acc.concat(stations))
|
||||
);
|
||||
|
||||
return (
|
||||
this.packets
|
||||
// filter to digis
|
||||
.filter(packet => digiCalls.has(packet.from.toString().trim()))
|
||||
.filter((packet) => digiCalls.has(packet.from.toString().trim()))
|
||||
// filter to just positional data
|
||||
.filter(packet => "data" in packet && "latitude" in packet.data)
|
||||
.filter((packet) => 'data' in packet && 'latitude' in packet.data)
|
||||
// group by call
|
||||
.reduce(this.groupByCall, {})
|
||||
);
|
||||
@ -238,26 +233,26 @@ export default {
|
||||
packetPathsGeoJSON() {
|
||||
let digiPos = { ...this.digiPos }; // localize for performance
|
||||
return Object.entries(this.stationPaths).map(([station, packets]) => {
|
||||
let lines = packets.map(packet => {
|
||||
let lines = packets.map((packet) => {
|
||||
let path = this.pathToString(packet.via);
|
||||
return {
|
||||
// first point in path is originating station
|
||||
coords: [
|
||||
[packet.data.longitude, packet.data.latitude],
|
||||
...path.map(hop => digiPos[hop] || [0, 0])
|
||||
...path.map((hop) => digiPos[hop] || [0, 0]),
|
||||
],
|
||||
path: path
|
||||
path: path,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
type: "Feature",
|
||||
type: 'Feature',
|
||||
id: station,
|
||||
geometry: {
|
||||
type: "MultiLineString",
|
||||
coordinates: lines.map(p => p.coords)
|
||||
type: 'MultiLineString',
|
||||
coordinates: lines.map((p) => p.coords),
|
||||
},
|
||||
properties: { paths: lines.map(p => p.path) }
|
||||
properties: { paths: lines.map((p) => p.path) },
|
||||
};
|
||||
});
|
||||
},
|
||||
@ -266,7 +261,7 @@ export default {
|
||||
return distinctColors({
|
||||
count: Object.keys(this.stationPaths).length,
|
||||
lightMin: 20,
|
||||
lightMax: 80
|
||||
lightMax: 80,
|
||||
});
|
||||
},
|
||||
|
||||
@ -274,14 +269,14 @@ export default {
|
||||
let colors = distinctColors({
|
||||
count: Object.keys(this.digis).length,
|
||||
lightMin: 20,
|
||||
lightMax: 80
|
||||
lightMax: 80,
|
||||
});
|
||||
return Object.keys(this.digis).reduce((acc, callsign, index) => {
|
||||
acc[callsign] = colors[index];
|
||||
return acc;
|
||||
}, {});
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -325,11 +320,11 @@ body {
|
||||
}
|
||||
|
||||
.expand + span::before {
|
||||
content: "\25B6";
|
||||
content: '\25B6';
|
||||
}
|
||||
|
||||
.expand:checked + span::before {
|
||||
content: "\25BC";
|
||||
content: '\25BC';
|
||||
}
|
||||
|
||||
.expand ~ .collapsible-content {
|
||||
|
@ -6,8 +6,8 @@
|
||||
<td>{{ formatTime(now - status.lastHeard, true) }}</td>
|
||||
<td>{{ formatTime(Math.round(status.avgDelta), true) }}</td>
|
||||
<td>{{ status.lastMicE }}</td>
|
||||
<td>{{ status.lastVoltage || "" }}</td>
|
||||
<td>{{ status.lastTemperature || "" }}</td>
|
||||
<td>{{ status.lastVoltage || '' }}</td>
|
||||
<td>{{ status.lastTemperature || '' }}</td>
|
||||
<td>{{ status.lastComment }}</td>
|
||||
</template>
|
||||
<template v-else>
|
||||
@ -23,10 +23,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import config from "./status_config.yaml";
|
||||
import config from './status_config.yaml';
|
||||
|
||||
export default {
|
||||
name: "StationRow",
|
||||
name: 'StationRow',
|
||||
props: { callsign: String, tactical: String, messages: Array, now: Date },
|
||||
|
||||
data() {
|
||||
@ -35,8 +35,8 @@ export default {
|
||||
lastHeard: null,
|
||||
delta: null,
|
||||
lastVoltage: null,
|
||||
lastTemperature: null
|
||||
}
|
||||
lastTemperature: null,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
@ -47,8 +47,8 @@ export default {
|
||||
|
||||
formatTime(time, isDuration = false) {
|
||||
return new Date(time).toLocaleTimeString(
|
||||
"en-GB",
|
||||
isDuration ? { timeZone: "UTC" } : {}
|
||||
'en-GB',
|
||||
isDuration ? { timeZone: 'UTC' } : {}
|
||||
);
|
||||
},
|
||||
|
||||
@ -59,13 +59,13 @@ export default {
|
||||
hours: date.getUTCHours(),
|
||||
minutes: date.getUTCMinutes(),
|
||||
seconds: date.getUTCSeconds(),
|
||||
milliseconds: date.getUTCMilliseconds()
|
||||
})
|
||||
milliseconds: date.getUTCMilliseconds(),
|
||||
}),
|
||||
]
|
||||
.filter(([suffix, num]) => num > 0)
|
||||
.map(([suffix, num]) => num + " " + suffix)
|
||||
.join(" ");
|
||||
}
|
||||
.map(([suffix, num]) => num + ' ' + suffix)
|
||||
.join(' ');
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
@ -80,8 +80,8 @@ export default {
|
||||
let delta = message.date.getTime() - arr[idx - 1].date.getTime();
|
||||
acc.avgDelta = (acc.avgDelta * (idx - 1) + delta) / idx;
|
||||
}
|
||||
if ("data" in message) {
|
||||
if ("analog" in message.data) {
|
||||
if ('data' in message) {
|
||||
if ('analog' in message.data) {
|
||||
acc.lastVoltage = message.data.analog[0] / 10;
|
||||
acc.lastTemperature = message.data.analog[1];
|
||||
}
|
||||
@ -115,7 +115,7 @@ export default {
|
||||
)} (${this.prettyDuration(this.now - this.status.lastHeard)} ago!)`
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
@ -138,8 +138,8 @@ export default {
|
||||
return (
|
||||
this.status.lastVoltage && this.status.lastVoltage < config.lowVoltage
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
@ -26,14 +26,14 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import aprs from "aprs-parser";
|
||||
import aprs from 'aprs-parser';
|
||||
|
||||
import StationRow from "./StationRow.vue";
|
||||
import StationRow from './StationRow.vue';
|
||||
|
||||
import config from "./status_config.yaml";
|
||||
import config from './status_config.yaml';
|
||||
|
||||
export default {
|
||||
name: "StationStatus",
|
||||
name: 'StationStatus',
|
||||
components: { StationRow },
|
||||
data() {
|
||||
return {
|
||||
@ -42,16 +42,16 @@ export default {
|
||||
messages: [],
|
||||
messagesFromStation: {},
|
||||
now: new Date(),
|
||||
trackedStations: config.trackedStations
|
||||
trackedStations: config.trackedStations,
|
||||
};
|
||||
},
|
||||
|
||||
mounted() {
|
||||
// request notification permissions
|
||||
if (Notification.permission !== "granted") {
|
||||
Notification.requestPermission(permission => {
|
||||
if (permission === "granted") {
|
||||
new Notification("Test notification", { body: "whatever" });
|
||||
if (Notification.permission !== 'granted') {
|
||||
Notification.requestPermission((permission) => {
|
||||
if (permission === 'granted') {
|
||||
new Notification('Test notification', { body: 'whatever' });
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -65,7 +65,7 @@ export default {
|
||||
|
||||
methods: {
|
||||
connectToStream() {
|
||||
this.aprsStream = new WebSocket("ws://localhost:4321");
|
||||
this.aprsStream = new WebSocket('ws://localhost:4321');
|
||||
this.aprsStream.onclose = () => {
|
||||
// Try to reconnect every 5 seconds
|
||||
let interval = window.setTimeout(() => {
|
||||
@ -73,7 +73,7 @@ export default {
|
||||
this.connectToStream();
|
||||
}, 5000);
|
||||
};
|
||||
this.aprsStream.onmessage = event =>
|
||||
this.aprsStream.onmessage = (event) =>
|
||||
this.handleMessage(JSON.parse(event.data));
|
||||
},
|
||||
|
||||
@ -95,11 +95,11 @@ export default {
|
||||
if (
|
||||
message.data &&
|
||||
message.data.addressee &&
|
||||
message.data.addressee.call === "TACTICAL" &&
|
||||
message.data.addressee.call === 'TACTICAL' &&
|
||||
config.TACTICAL_whitelist.includes(message.from.toString())
|
||||
) {
|
||||
message.data.text.split(";").map(tac_assoc => {
|
||||
let [call, tac] = tac_assoc.split("=", 2);
|
||||
message.data.text.split(';').map((tac_assoc) => {
|
||||
let [call, tac] = tac_assoc.split('=', 2);
|
||||
if (tac) {
|
||||
this.trackedStations[call] = tac;
|
||||
} else {
|
||||
@ -107,8 +107,8 @@ export default {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@ -132,7 +132,7 @@ table th {
|
||||
/* border magic for sticky header */
|
||||
/* https://stackoverflow.com/questions/50361698/border-style-do-not-work-with-sticky-position-element */
|
||||
th::before {
|
||||
content: "";
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
@ -142,7 +142,7 @@ th::before {
|
||||
top: 1px;
|
||||
}
|
||||
th::after {
|
||||
content: "";
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
|
@ -1,5 +1,5 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta charset="UTF-8" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
@ -3,5 +3,5 @@ import App from './StatusScreen.vue';
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
render: h => h(App),
|
||||
render: (h) => h(App),
|
||||
});
|
||||
|
@ -1,41 +1,41 @@
|
||||
const WebSocket = require("ws");
|
||||
const net = require("net");
|
||||
const fs = require("fs");
|
||||
const WebSocket = require('ws');
|
||||
const net = require('net');
|
||||
const fs = require('fs');
|
||||
|
||||
const client = new net.Socket();
|
||||
const wss = new WebSocket.Server({ host: "127.0.0.1", port: 4321 });
|
||||
const wss = new WebSocket.Server({ host: '127.0.0.1', port: 4321 });
|
||||
|
||||
wss.broadcast = function (data) {
|
||||
wss.clients.forEach(client => {
|
||||
wss.clients.forEach((client) => {
|
||||
if (client.readyState === WebSocket.OPEN) {
|
||||
client.send(data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
client.connect(14580, "rotate.aprs2.net", () =>
|
||||
client.write("user KC1GDW pass -1 filter r/43.90/-72.15/75\r\n")
|
||||
client.connect(14580, 'rotate.aprs2.net', () =>
|
||||
client.write('user KC1GDW pass -1 filter r/43.90/-72.15/75\r\n')
|
||||
);
|
||||
|
||||
function datestamp(date) {
|
||||
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
||||
}
|
||||
|
||||
client.on("data", function(data) {
|
||||
let str = data.toString("utf8").replace(/^\s+|\s+$/g, "");
|
||||
client.on('data', function (data) {
|
||||
let str = data.toString('utf8').replace(/^\s+|\s+$/g, '');
|
||||
console.log(str);
|
||||
|
||||
// strip whitespace, then handle multiple APRS packets per TCP packet
|
||||
str.split("\r\n").forEach(packet => {
|
||||
if (!packet.startsWith("#")) {
|
||||
str.split('\r\n').forEach((packet) => {
|
||||
if (!packet.startsWith('#')) {
|
||||
// ignore comments
|
||||
let date = new Date();
|
||||
// create log dir if it doesn't exist
|
||||
if (!fs.existsSync("log")) fs.mkdirSync("log");
|
||||
if (!fs.existsSync('log')) fs.mkdirSync('log');
|
||||
fs.appendFile(
|
||||
`log/log${datestamp(date)}.json`,
|
||||
JSON.stringify([date, packet]) + "\n",
|
||||
err => {
|
||||
JSON.stringify([date, packet]) + '\n',
|
||||
(err) => {
|
||||
if (err) throw err;
|
||||
}
|
||||
);
|
||||
@ -44,14 +44,14 @@ client.on("data", function(data) {
|
||||
});
|
||||
});
|
||||
|
||||
wss.on("connection", ws => {
|
||||
wss.on('connection', (ws) => {
|
||||
let date = new Date();
|
||||
let filename = `log/log${datestamp(date)}.json`;
|
||||
|
||||
if (fs.existsSync(filename)) {
|
||||
fs.readFileSync(filename)
|
||||
.toString()
|
||||
.split("\n")
|
||||
.forEach(line => ws.send(line));
|
||||
.split('\n')
|
||||
.forEach((line) => ws.send(line));
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user