Skip to content

Commit

Permalink
update position tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
liamcottle authored and KomelT committed Aug 29, 2024
1 parent 330b1e2 commit 793b124
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions api/src/routes/position-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ express.get("/api/v1/nodes/:nodeId/position-history", async (req, res) => {

positions.forEach((position) => {
positionHistory.push({
id: position.id,
node_id: position.node_id,
type: "position",
latitude: position.latitude,
longitude: position.longitude,
altitude: position.altitude,
Expand All @@ -69,6 +71,7 @@ express.get("/api/v1/nodes/:nodeId/position-history", async (req, res) => {
mapReports.forEach((mapReport) => {
positionHistory.push({
node_id: mapReport.node_id,
type: "map_report",
latitude: mapReport.latitude,
longitude: mapReport.longitude,
altitude: mapReport.altitude,
Expand Down
20 changes: 16 additions & 4 deletions app/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5036,14 +5036,26 @@ <h2 class="font-bold">
]);

let tooltip = "";
tooltip += `Position: ${positionHistory.latitude}, ${positionHistory.longitude}</br>`;
if (positionHistory.type === "position") {
tooltip += `<b>Position</b>`;
} else if (positionHistory.type === "map_report") {
tooltip += `<b>Map Report</b>`;
}
tooltip += `<br/>[${escapeString(node.short_name)}] ${escapeString(
node.long_name
)}`;
tooltip += `<br/>${positionHistory.latitude}, ${positionHistory.longitude}`;
tooltip += `<br/>Heard on: ${moment(
new Date(positionHistory.created_at)
).format("DD/MM/YYYY hh:mm A")}`;

// add gateway info if available
if (positionHistory.gateway_id) {
const gatewayNode = findNodeById(positionHistory.gateway_id);
if (gatewayNode) {
tooltip += `Heard by: <a href="javascript:void(0);" onclick="goToNode(${gatewayNode.node_id})">[${gatewayNode.short_name}] ${gatewayNode.long_name}</a>`;
}
const gatewayNodeInfo = gatewayNode
? `[${gatewayNode.short_name}] ${gatewayNode.long_name}`
: "???";
tooltip += `<br/>Heard by: <a href="javascript:void(0);" onclick="goToNode(${positionHistory.gateway_id})">${gatewayNodeInfo}</a>`;
}

// create position history marker
Expand Down

0 comments on commit 793b124

Please sign in to comment.