add webapp, move frontend to webapp folder

This commit is contained in:
2025-04-15 15:33:08 -04:00
parent f97b3b5185
commit 196063c23b
93 changed files with 2162 additions and 0 deletions

View File

@ -0,0 +1,33 @@
<script setup>
import { state } from '../store.js';
import { lastSeenAnnouncementId, CURRENT_ANNOUNCEMENT_ID } from '../config.js';
function dismissAnnouncement() {
if (lastSeenAnnouncementId.value != CURRENT_ANNOUNCEMENT_ID) {
lastSeenAnnouncementId.value = CURRENT_ANNOUNCEMENT_ID;
}
state.announcementVisible = false;
}
</script>
<template>
<!-- announcement -->
<div v-if="state.announcementVisible" class="flex bg-yellow-300 p-2 border-gray-300 border-b">
<!-- info -->
<div class="my-auto leading-tight">
<div class="font-bold">Service Announcement</div>
<div class="text-sm">
<span>Changes were made to mqtt.meshtastic.org. Uplink your nodes to <button @click="state.infoModalVisible = true" type="button" class="link">our MQTT server</button> to continue showing on this map.</span>
</div>
</div>
<!-- action buttons -->
<div class="flex my-auto ml-auto mr-0 sm:mr-2">
<a @click="dismissAnnouncement" href="javascript:void(0)" class="rounded-full">
<div class="bg-white hover:bg-gray-100 p-2 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12" />
</svg>
</div>
</a>
</div>
</div>
</template>

View File

@ -0,0 +1,88 @@
<script setup>
import axios from 'axios';
import { state } from '../store.js';
import { buildPath } from '../utils.js';
import { ref, onMounted } from 'vue';
const hardwareModelStats = ref([]);
onMounted(() => {
axios.get(buildPath('/api/v1/stats/hardware-models')).then((response) => {
hardwareModelStats.value = response.data.hardware_model_stats;
}).catch((error) => {
// do nothing
});
});
</script>
<template>
<!-- hardware models sidebar -->
<div class="relative z-sidebar" role="dialog" aria-modal="true">
<!-- overlay -->
<transition
enter-active-class="transition-opacity duration-300 ease-linear"
enter-from-class="opacity-0"
enter-to-class="opacity-100"
leave-active-class="transition-opacity duration-300 ease-linear"
leave-from-class="opacity-100"
leave-to-class="opacity-0">
<div v-show="state.hardwareStatsVisible" @click="state.hardwareStatsVisible = !state.hardwareStatsVisible" class="fixed inset-0 bg-gray-900/75"></div>
</transition>
<!-- sidebar -->
<transition
enter-active-class="transition duration-300 ease-in-out transform"
enter-from-class="-translate-x-full"
enter-to-class="translate-x-0"
leave-active-class="transition duration-300 ease-in-out transform"
leave-from-class="translate-x-0"
leave-to-class="-translate-x-full">
<div v-show="state.hardwareStatsVisible" class="fixed top-0 left-0 bottom-0">
<div class="w-screen h-full max-w-md overflow-hidden">
<div class="flex h-full flex-col bg-white shadow-xl">
<!-- slideover header -->
<div class="p-2 border-b border-gray-200 shadow-sm">
<div class="flex items-start justify-between">
<div>
<h2 class="font-bold">Meshtastic Devices</h2>
<h3 class="text-sm">Ordered by most popular</h3>
</div>
<div class="my-auto ml-3 flex h-7 items-center">
<a href="javascript:void(0)" class="rounded-full" @click="state.hardwareStatsVisible = false">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M18 6l-12 12"></path>
<path d="M6 6l12 12"></path>
</svg>
</div>
</a>
</div>
</div>
</div>
<!-- list of hardware models -->
<ul role="list" class="flex-1 divide-y divide-gray-200 overflow-y-auto">
<li v-for="hardwareModel of hardwareModelStats">
<div class="group relative flex items-center">
<a href="#" class="block flex-1 px-4 py-2">
<div class="absolute inset-0 group-hover:bg-gray-100" aria-hidden="true"></div>
<div class="relative flex min-w-0 flex-1 items-center">
<span class="relative inline-block flex-shrink-0 mr-4">
<img class="h-20 w-20 rounded-sm object-contain" :src="`/images/devices/${hardwareModel.hardware_model_name}.png`" alt="" onerror="if(this.src != '/images/no_image.png') this.src = '/images/no_image.png';">
</span>
<div class="truncate">
<p class="truncate text-sm font-medium text-gray-900">{{ hardwareModel.hardware_model_name }}</p>
<p class="truncate text-sm text-gray-500">{{ hardwareModel.count }} nodes on the map</p>
</div>
</div>
</a>
</div>
</li>
</ul>
</div>
</div>
</div>
</transition>
</div>
</template>

View File

@ -0,0 +1,141 @@
<script setup>
const emit = defineEmits(['reload', 'randomNode', 'searchClick']);
import { ref } from 'vue';
import { state, searchedNodes } from '../store.js';
import { getNodeColor, getNodeTextColor } from '../utils.js';
</script>
<template>
<div class="flex bg-white p-2 border-gray-300 border-b h-16">
<!-- close mobile search button -->
<div v-if="state.mobileSearchVisible" class="my-auto">
<a @click="state.mobileSearchVisible = false" href="javascript:void(0)" class="rounded-full">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18" />
</svg>
</div>
</a>
</div>
<!-- icon -->
<div v-if="!state.mobileSearchVisible" class="hidden sm:block my-auto mr-3">
<img class="w-10 h-10 rounded" src="/images/icon.png"/>
</div>
<!-- app info -->
<div v-if="!state.mobileSearchVisible" class="my-auto leading-tight">
<div class="font-bold">CT Mesh Map</div>
<div class="text-sm">
Created by <a class="link" target="_blank" href="https://liamcottle.com">Liam Cottle</a>
</div>
</div>
<!-- search bar -->
<div class="mx-3 flex-1 relative" :class="{ 'hidden lg:block': !state.mobileSearchVisible }">
<input v-model="state.searchText" type="text" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" :placeholder="`Search ${state.nodes.length} nodes...`">
<div v-if="state.searchText !== ''" class="absolute z-search bg-white w-full border border-gray-200 rounded-lg shadow-md mt-1 overflow-y-scroll max-h-80 divide-y divide-gray-200">
<template v-if="searchedNodes.length > 0">
<div @click="$emit('searchClick', node)" class="flex space-x-2 p-2 hover:bg-gray-100 cursor-pointer" v-for="node of searchedNodes">
<div>
<div class="flex rounded-full h-12 w-12 text-white shadow" :style="{backgroundColor: getNodeColor(node.node_id)}" :class="[ `text-[${getNodeTextColor(node.node_id)}]` ]">
<div class="mx-auto my-auto drop-shadow-sm">{{ node.short_name }}</div>
</div>
</div>
<div>
<div class="text-gray-900" :class="{ 'text-red-500': node.latitude == null || node.longitude == null }">{{ node.long_name !== '' ? node.long_name : "-" }}</div>
<div class="flex space-x-1 text-sm text-gray-700">
<div>{{ node.node_id_hex }} / {{ node.node_id }}</div>
</div>
</div>
</div>
<div v-if="searchedNodes.length === 500" class="text-gray-500 text-sm px-2 py-1">
Only the first 500 results are shown.
</div>
</template>
<template v-else>
<div class="p-2">
No results found...
</div>
</template>
</div>
</div>
<!-- header action buttons -->
<div v-if="!state.mobileSearchVisible" class="flex my-auto ml-auto mr-0 sm:mr-2 space-x-1 sm:space-x-2">
<a @click="state.infoModalVisible = !state.infoModalVisible" href="javascript:void(0)" class="tooltip rounded-full">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="m11.25 11.25.041-.02a.75.75 0 0 1 1.063.852l-.708 2.836a.75.75 0 0 0 1.063.853l.041-.021M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Zm-9-3.75h.008v.008H12V8.25Z" />
</svg>
</div>
<div class="hidden sm:block">
<span class="tooltip-text">About</span>
</div>
</a>
<a @click="state.mobileSearchVisible = true" href="javascript:void(0)" class="tooltip rounded-full block lg:hidden">
<div id="search-button" class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M10 10m-7 0a7 7 0 1 0 14 0a7 7 0 1 0 -14 0"></path>
<path d="M21 21l-6 -6"></path>
</svg>
</div>
<div class="hidden sm:block">
<span class="tooltip-text">Search</span>
</div>
</a>
<a @click="state.hardwareStatsVisible = !state.hardwareStatsVisible" href="javascript:void(0)" class="tooltip rounded-full hidden sm:block">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 1.5H8.25A2.25 2.25 0 0 0 6 3.75v16.5a2.25 2.25 0 0 0 2.25 2.25h7.5A2.25 2.25 0 0 0 18 20.25V3.75a2.25 2.25 0 0 0-2.25-2.25H13.5m-3 0V3h3V1.5m-3 0h3m-3 18.75h3" />
</svg>
</div>
<div class="hidden sm:block">
<span class="tooltip-text">Devices</span>
</div>
</a>
<a href="#" class="tooltip rounded-full hidden lg:block" @click="$emit('randomNode')">
<div id="random-button" class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M18 4l3 3l-3 3"></path>
<path d="M18 20l3 -3l-3 -3"></path>
<path d="M3 7h3a5 5 0 0 1 5 5a5 5 0 0 0 5 5h5"></path>
<path d="M21 7h-5a4.978 4.978 0 0 0 -3 1m-4 8a4.984 4.984 0 0 1 -3 1h-3"></path>
</svg>
</div>
<div class="hidden sm:block">
<span class="tooltip-text">Random</span>
</div>
</a>
<a @click="state.settingsVisible = !state.settingsVisible" href="javascript:void(0)" class="tooltip rounded-full">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.24.437-.613.43-.991a6.932 6.932 0 0 1 0-.255c.007-.38-.138-.751-.43-.992l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.28Z" />
<path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
</svg>
</div>
<div class="hidden sm:block">
<span class="tooltip-text">Settings</span>
</div>
</a>
<a href="#" class="tooltip rounded-full" @click="$emit('reload')">
<div id="reload-button" class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full" :class="{'animate-spin': state.loading}">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M19.933 13.041a8 8 0 1 1 -9.925 -8.788c3.899 -1 7.935 1.007 9.425 4.747"></path>
<path d="M20 4v5h-5"></path>
</svg>
</div>
<div class="hidden sm:block">
<span class="tooltip-text">Reload</span>
</div>
</a>
</div>
</div>
</template>

View File

@ -0,0 +1,193 @@
<script setup>
import { state } from '../store.js';
import { hasSeenInfoModal } from '../config.js';
function dismissInfoModal() {
if (hasSeenInfoModal.value === false) {
hasSeenInfoModal.value = true;
}
state.infoModalVisible = false;
}
</script>
<template>
<!-- info modal -> InfoModal -->
<div class="relative z-sidebar">
<!-- overlay -->
<transition
enter-active-class="transition-opacity duration-300 ease-linear"
enter-from-class="opacity-0"
enter-to-class="opacity-100"
leave-active-class="transition-opacity duration-300 ease-linear"
leave-from-class="opacity-100"
leave-to-class="opacity-0">
<div v-show="state.infoModalVisible" @click="dismissInfoModal" class="fixed inset-0 bg-gray-900/75"></div>
</transition>
<!-- modal -->
<transition
enter-active-class="transition duration-300 ease-in-out transform"
enter-from-class="translate-y-full"
enter-to-class="translate-y-0"
leave-active-class="transition duration-300 ease-in-out transform"
leave-from-class="translate-y-0"
leave-to-class="translate-y-full">
<div @click="dismissInfoModal" v-show="state.infoModalVisible" class="fixed left-0 right-0 top-0 bottom-0 lg:pointer-events-none">
<div class="flex w-full h-full overflow-y-auto p-4">
<div @click.stop class="mx-auto my-auto w-full max-w-2xl flex-col bg-white shadow-xl rounded-xl p-2 lg:pointer-events-auto">
<div class="relative flex">
<!-- close button -->
<div class="absolute top-0 right-0">
<div class="h-7">
<a href="javascript:void(0)" class="rounded-full" @click="dismissInfoModal">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M18 6l-12 12"></path>
<path d="M6 6l12 12"></path>
</svg>
</div>
</a>
</div>
</div>
<!-- content -->
<div class="flex flex-col w-full py-2 space-y-2">
<!-- app info -->
<div class="w-full mx-auto text-center">
<img src="/images/icon.png" class="mx-auto w-16 h-16 rounded mb-1"/>
<h1 class="font-bold">CT Mesh Map</h1>
<h2>Created by <a class="link" target="_blank" href="https://liamcottle.com">Liam Cottle</a></h2>
<div class="w-full mx-auto text-center space-x-1 mt-2">
<a target="_blank" href="https://twitter.com/liamcottle" title="Twitter" class="raise inline-flex items-center p-1.5 border border-transparent text-xs font-medium rounded-full shadow-sm text-white bg-[#1da1f2] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[#1da1f2]">
<svg role="img" class="w-4 h-4" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor" d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"></path>
</svg>
</a>
<a target="_blank" href="https://github.com/liamcottle/meshtastic-map" title="GitHub" class="raise inline-flex items-center p-1.5 border border-transparent text-xs font-medium rounded-full shadow-sm text-white bg-[#333333] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[#333333]">
<svg role="img" class="w-4 h-4" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor" d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"></path>
</svg>
</a>
<a target="_blank" href="https://discord.gg/K55zeZyHKK" title="Discord" class="raise inline-flex items-center p-1.5 border border-transparent text-xs font-medium rounded-full shadow-sm text-white bg-[#5865f2] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[#5865f2]">
<svg role="img" class="w-4 h-4" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path fill="currentColor" d="M20.317 4.3698a19.7913 19.7913 0 00-4.8851-1.5152.0741.0741 0 00-.0785.0371c-.211.3753-.4447.8648-.6083 1.2495-1.8447-.2762-3.68-.2762-5.4868 0-.1636-.3933-.4058-.8742-.6177-1.2495a.077.077 0 00-.0785-.037 19.7363 19.7363 0 00-4.8852 1.515.0699.0699 0 00-.0321.0277C.5334 9.0458-.319 13.5799.0992 18.0578a.0824.0824 0 00.0312.0561c2.0528 1.5076 4.0413 2.4228 5.9929 3.0294a.0777.0777 0 00.0842-.0276c.4616-.6304.8731-1.2952 1.226-1.9942a.076.076 0 00-.0416-.1057c-.6528-.2476-1.2743-.5495-1.8722-.8923a.077.077 0 01-.0076-.1277c.1258-.0943.2517-.1923.3718-.2914a.0743.0743 0 01.0776-.0105c3.9278 1.7933 8.18 1.7933 12.0614 0a.0739.0739 0 01.0785.0095c.1202.099.246.1981.3728.2924a.077.077 0 01-.0066.1276 12.2986 12.2986 0 01-1.873.8914.0766.0766 0 00-.0407.1067c.3604.698.7719 1.3628 1.225 1.9932a.076.076 0 00.0842.0286c1.961-.6067 3.9495-1.5219 6.0023-3.0294a.077.077 0 00.0313-.0552c.5004-5.177-.8382-9.6739-3.5485-13.6604a.061.061 0 00-.0312-.0286zM8.02 15.3312c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9555-2.4189 2.157-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.9555 2.4189-2.1569 2.4189zm7.9748 0c-1.1825 0-2.1569-1.0857-2.1569-2.419 0-1.3332.9554-2.4189 2.1569-2.4189 1.2108 0 2.1757 1.0952 2.1568 2.419 0 1.3332-.946 2.4189-2.1568 2.4189Z"></path>
</svg>
</a>
<a target="_blank" href="https://paypal.me/liamcarncottle" title="PayPal" class="raise inline-flex items-center p-1.5 border border-transparent text-xs font-medium rounded-full shadow-sm text-white bg-[#0070ba] focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-[#0070ba]">
<svg role="img" class="w-4 h-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 48 48">
<path fill="#fff" fill-opacity=".45" d="M16.13 39.115H8.367a1.041 1.041 0 0 1-1.026-1.2l5.234-33.176a1.279 1.279 0 0 1 1.261-1.079h13.335c6.315 0 10.909 4.592 10.8 10.157 3.735 1.95 5.915 5.91 5.234 10.247a12.548 12.548 0 0 1-12.39 10.62H26.89a1.275 1.275 0 0 0-1.261 1.08L23.87 46.9a1.276 1.276 0 0 1-1.262 1.079H15.94a1.04 1.04 0 0 1-1.026-1.199l1.215-7.664v-.002Z"></path>
<path fill="#fff" fill-opacity=".45" d="M37.973 13.817a11.668 11.668 0 0 0-5.441-1.294H21.414a1.277 1.277 0 0 0-1.261 1.08l-2.098 13.293.006-.035a1.28 1.28 0 0 1 1.256-1.042h6.144a12.553 12.553 0 0 0 12.39-10.62c.071-.457.113-.92.122-1.382Z"></path>
<path fill="#fff" d="M16.133 39.115H8.368a1.041 1.041 0 0 1-1.026-1.2l5.234-33.176a1.279 1.279 0 0 1 1.261-1.079h13.335c6.315 0 10.909 4.592 10.801 10.157a11.67 11.67 0 0 0-5.441-1.294H21.414a1.277 1.277 0 0 0-1.261 1.08l-2.098 13.293.006-.035-1.928 12.254Z"></path>
</svg>
</a>
<a target="_blank" href="https://liamcottle.com/contact" title="Email" class="raise inline-flex items-center p-1.5 border border-transparent text-xs font-medium rounded-full shadow-sm text-white bg-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path>
</svg>
</a>
</div>
</div>
<!-- welcome -->
<div class="bg-green-100 rounded p-2 border border-green-200">
A map of Meshtastic nodes on the CT Mesh heard via MQTT.
</div>
<!-- features -->
<div>
<div class="font-bold mb-2">Features</div>
<div class="bg-gray-100 rounded p-2 border border-gray-200">
<ul class="list-disc list-inside">
<li>The map shows nodes that have sent a valid position to MQTT.</li>
<li>Position packets must be unencrypted, or encrypted with the default key.</li>
<li>Use the search bar to find nodes by ID or name.</li>
<li>Hover over nodes (on desktop) to see basic details.</li>
<li>Click a node to see info such as telemetry graphs and traceroutes.</li>
<li>Use the top right layers panel to show neighbours and waypoints.</li>
<li>Use the settings button to configure the map to your liking.</li>
<li>Have a feature request, or found a bug? <a class="link" target="_blank" href="https://github.com/liamcottle/meshtastic-map">Open an issue</a> on GitHub.</li>
</ul>
</div>
</div>
<!-- faq -->
<div>
<div class="font-bold mb-2">FAQ</div>
<div class="space-y-2">
<div class="bg-gray-100 rounded p-2 border border-gray-200">
<div class="font-semibold">How do I add my node to the map?</div>
<div>Your node, or a node that hears your node must uplink to our MQTT server.</div>
<div>Your position packet must be unencrypted, or encrypted with the default key.</div>
<div>If your node has v2.5 firmware or newer, you must enable "OK to MQTT".</div>
<div>Use the MQTT server details below to uplink to this map.</div>
</div>
<div class="bg-gray-100 rounded p-2 border border-gray-200">
<div class="font-semibold">What MQTT server should I use?</div>
<ul class="list-disc list-inside">
<div>Specific nodes on the CT Mesh will report to this map, so there's nothing you need to do aside from enabling the following under LoRa configuration:</div>
<li>Ignore MQTT: Disabled</li>
<li>OK to MQTT: Enabled</li>
</ul>
<div>Important: without this configuration, your node may not show up on the map.</div>
<div>If you are out of range of a designated MQTT-connected node and have a site that would be a good MQTT gateway, contact us in the <a target="_blank" href="https://discord.gg/m4F328as3K" class="link">CT Mesh Discord</a>.</div>
</div>
<div class="bg-gray-100 rounded p-2 border border-gray-200">
<div class="font-semibold">How do I remove my node from the map?</div>
<div>Nodes that have not been heard for 7 days are automatically removed.</div>
<div>Disable position reporting in your node to prevent it coming back.</div>
<div>Use custom encryption keys so the public can't see your position data.</div>
<div>If your node has v2.5 firmware or newer, we ignore packets if "OK to MQTT" is disabled.</div>
<div>To have your node removed now, please contact us in the <a target="_blank" href="https://discord.gg/m4F328as3K" class="link">CT Mesh Discord</a>.</div>
</div>
<div class="bg-gray-100 rounded p-2 border border-gray-200">
<div class="font-semibold">How do I see neighbours a node heard?</div>
<div>Open the top right layers panel and enable neighbours.</div>
<div>Some neighbours are from MQTT, this is patched in latest firmware.</div>
</div>
<div class="bg-gray-100 rounded p-2 border border-gray-200">
<div class="font-semibold">Why is my node showing up in the wrong place?</div>
<div>This public map obfuscates your position packets for v2.4 firmware and older.</div>
<div>Nodes on v2.4 and older have their positions obfuscated to 2 decimal places.</div>
<div>Nodes on v2.5 and newer, with "OK to MQTT" enabled, will show positions with your configured precision.</div>
<div>Nodes on v2.5 and newer, with "OK to MQTT" disabled, will not update their positions.</div>
</div>
</div>
</div>
<!-- legal -->
<div>
<div class="font-bold mb-2">Legal</div>
<div class="bg-gray-100 rounded p-2 border border-gray-200">
<div>This project is not affiliated with or endorsed by the <a class="link" target="_blank" href="https://meshtastic.org">Meshtastic</a> project.</div>
<div>The Meshtastic logo is the trademark of Meshtastic LLC.</div>
<div>Map tiles provided by <a class="link" target="_blank" href="https://www.openstreetmap.org/copyright">OpenStreetMap</a></div>
</div>
</div>
<!-- dismiss button -->
<div class="mx-auto">
<a href="javascript:void(0)" @click="dismissInfoModal">
<div class="bg-gray-200 hover:bg-gray-300 px-6 py-2 rounded-md shadow">
Dismiss
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</transition>
</div>
</template>

View File

@ -0,0 +1,287 @@
<script setup>
import axios from 'axios';
import moment from 'moment';
import { Chart } from 'chart.js';
import 'chartjs-adapter-moment';
import { onMounted, useTemplateRef, ref, watch } from 'vue';
import { state } from '../store.js';
import { environmentMetricsTimeRange, powerMetricsTimeRange, deviceMetricsTimeRange } from '../config.js';
import DeviceMetricsChart from './NodeInfo/DeviceMetricsChart.vue';
import PowerMetricsChart from './NodeInfo/PowerMetricsChart.vue';
import EnvironmentMetricsChart from './NodeInfo/EnvironmentMetricsChart.vue';
import LoraConfig from './NodeInfo/LoraConfig.vue';
import NodeDetails from './NodeInfo/NodeDetails.vue';
import MqttHistory from './NodeInfo/MqttHistory.vue';
import OtherInfo from './NodeInfo/OtherInfo.vue';
import Share from './NodeInfo/Share.vue';
import Traceroutes from './NodeInfo/Traceroutes.vue';
import Position from './NodeInfo/Position.vue';
import { getNodeColor, getNodeTextColor, copyShareLinkForNode, getTimeSpan, buildPath } from '../utils.js';
const emit = defineEmits(['showPositionHistory']);
function showPositionHistory(id) {
emit('showPositionHistory', id);
}
function showTraceRoute(traceroute) {
emit('showTraceRoute', traceroute);
state.selectedTraceRoute = traceroute;
}
// find node marker by id
function findNodeMarkerById(id) {
return state.nodeMarkers[id] ?? null;
}
function loadNode(nodeId) {
loadNodeMqttMetrics(nodeId);
loadNodeTraceroutes(nodeId);
loadNodeDeviceMetrics(nodeId);
loadNodeEnvironmentMetrics(nodeId);
loadNodePowerMetrics(nodeId);
}
function loadNodeMqttMetrics(nodeId) {
state.selectedNodeMqttMetrics = [];
axios.get(buildPath(`/api/v1/nodes/${nodeId}/mqtt-metrics`)).then((response) => {
state.selectedNodeMqttMetrics = response.data.mqtt_metrics;
}).catch(() => {
// do nothing
});
}
function loadNodeTraceroutes(nodeId) {
state.selectedNodeTraceroutes = [];
axios.get(buildPath(`/api/v1/nodes/${nodeId}/traceroutes`), {
params: {
count: 5,
},
}).then((response) => {
state.selectedNodeTraceroutes = response.data.traceroutes;
}).catch(() => {
// do nothing
});
}
function loadNodeDeviceMetrics(nodeId) {
const time = getTimeSpan(deviceMetricsTimeRange.value).amount
const timeFrom = new Date().getTime() - (time * 1000);
axios.get(buildPath(`/api/v1/nodes/${nodeId}/device-metrics`), {
params: {
time_from: timeFrom,
},
}).then((response) => {
// reverse response, as it's newest to oldest, but we want oldest to newest
state.selectedNodeDeviceMetrics = response.data.device_metrics.reverse();
}).catch(() => {
state.selectedNodeDeviceMetrics = [];
});
}
function loadNodeEnvironmentMetrics(nodeId) {
const time = getTimeSpan(environmentMetricsTimeRange.value).amount
const timeFrom = new Date().getTime() - (time * 1000);
axios.get(buildPath(`/api/v1/nodes/${nodeId}/environment-metrics`), {
params: {
time_from: timeFrom,
},
}).then((response) => {
// reverse response, as it's newest to oldest, but we want oldest to newest
state.selectedNodeEnvironmentMetrics = response.data.environment_metrics.reverse();
}).catch(() => {
state.selectedNodeEnvironmentMetrics = [];
});
}
function loadNodePowerMetrics(nodeId) {
const time = getTimeSpan(powerMetricsTimeRange.value).amount
const timeFrom = new Date().getTime() - (time * 1000);
axios.get(buildPath(`/api/v1/nodes/${nodeId}/power-metrics`), {
params: {
time_from: timeFrom,
},
}).then((response) => {
// reverse response, as it's newest to oldest, but we want oldest to newest
state.selectedNodePowerMetrics = response.data.power_metrics.reverse();
}).catch(() => {
state.selectedNodePowerMetrics = [];
});
}
watch(
() => state.selectedNode,
(newValue) => {
if (newValue) {
loadNode(newValue.node_id)
}
}, {deep: true}
)
watch(
() => deviceMetricsTimeRange.value,
(newValue) => {
loadNodeDeviceMetrics(state.selectedNode.node_id)
}
)
watch(
() => powerMetricsTimeRange.value,
(newValue) => {
loadNodePowerMetrics(state.selectedNode.node_id)
}
)
watch(
() => environmentMetricsTimeRange.value,
(newValue) => {
loadNodeEnvironmentMetrics(state.selectedNode.node_id)
}
)
</script>
<template>
<div class="relative z-sidebar" role="dialog" aria-modal="true">
<!-- overlay -->
<transition
enter-active-class="transition-opacity duration-300 ease-linear"
enter-from-class="opacity-0"
enter-to-class="opacity-100"
leave-active-class="transition-opacity duration-300 ease-linear"
leave-from-class="opacity-100"
leave-to-class="opacity-0">
<div v-show="state.selectedNode != null" @click="state.selectedNode = null" class="fixed inset-0 bg-gray-900/75"></div>
</transition>
<!-- sidebar -->
<transition
enter-active-class="transition duration-300 ease-in-out transform"
enter-from-class="-translate-x-full"
enter-to-class="translate-x-0"
leave-active-class="transition duration-300 ease-in-out transform"
leave-from-class="translate-x-0"
leave-to-class="-translate-x-full">
<div v-show="state.selectedNode != null" class="fixed top-0 left-0 bottom-0">
<div v-if="state.selectedNode != null" class="w-screen h-full max-w-md overflow-hidden">
<div class="flex h-full flex-col bg-white shadow-xl">
<!-- slideover header -->
<div class="p-2 border-b border-gray-200 shadow-sm">
<div class="flex">
<div class="my-auto mr-2">
<div class="flex rounded-full h-12 w-12 text-white shadow-sm" :style="{backgroundColor: getNodeColor(state.selectedNode.node_id)}" :class="[ `text-[${getNodeTextColor(state.selectedNode.node_id)}]` ]">
<div class="mx-auto my-auto drop-shadow-sm">{{ state.selectedNode.short_name }}</div>
</div>
</div>
<div class="my-auto mr-auto">
<h2 class="font-bold">Node Info</h2>
<h3 class="text-sm">{{ state.selectedNode.long_name }}</h3>
</div>
<div class="my-auto ml-2 flex h-7 items-center space-x-2">
<a href="javascript:void(0)" class="rounded-full" @click="copyShareLinkForNode(state.selectedNode.node_id)">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 256 256" class="size-6">
<path d="M216,112v96a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V112A16,16,0,0,1,56,96H80a8,8,0,0,1,0,16H56v96H200V112H176a8,8,0,0,1,0-16h24A16,16,0,0,1,216,112ZM93.66,69.66,120,43.31V136a8,8,0,0,0,16,0V43.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,69.66Z"></path>
</svg>
</div>
</a>
<a href="javascript:void(0)" class="rounded-full" @click="state.selectedNode = null">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M18 6l-12 12"></path>
<path d="M6 6l12 12"></path>
</svg>
</div>
</a>
</div>
</div>
</div>
<div class="overflow-y-auto">
<!-- no position banner -->
<div v-if="findNodeMarkerById(state.selectedNode.node_id) == null" class="flex bg-orange-500 text-white p-2">
<div class="my-auto mr-2">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="size-6">
<path fill-rule="evenodd" d="m11.54 22.351.07.04.028.016a.76.76 0 0 0 .723 0l.028-.015.071-.041a16.975 16.975 0 0 0 1.144-.742 19.58 19.58 0 0 0 2.683-2.282c1.944-1.99 3.963-4.98 3.963-8.827a8.25 8.25 0 0 0-16.5 0c0 3.846 2.02 6.837 3.963 8.827a19.58 19.58 0 0 0 2.682 2.282 16.975 16.975 0 0 0 1.145.742ZM12 13.5a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z" clip-rule="evenodd" />
</svg>
</div>
<div class="my-auto">This node has not reported a position.</div>
</div>
<div class="flex flex-col my-2">
<div class="mx-auto">
<img class="h-48 w-48 rounded object-contain" :src="`/images/devices/${state.selectedNode.hardware_model_name}.png`" alt="" onerror="if(this.src != '/images/no_image.png') this.src = '/images/no_image.png';">
</div>
</div>
<!-- action buttons -->
<div class="flex space-x-6 p-2 justify-center">
<!-- sent messages -->
<a target="_blank" :href="`/api/v1/text-messages/embed?from=${state.selectedNode.node_id}`" class="flex flex-col" title="Messages sent from this Node">
<div class="flex mx-auto mb-1">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="m15 11.25-3-3m0 0-3 3m3-3v7.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
</div>
</div>
<div class="mx-auto text-sm font-medium text-gray-900">Sent Msgs</div>
</a>
<!-- received messages -->
<a target="_blank" :href="`/api/v1/text-messages/embed?to=${state.selectedNode.node_id}`" class="flex flex-col" title="Messages sent to this Node">
<div class="flex mx-auto mb-1">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="m9 12.75 3 3m0 0 3-3m-3 3v-7.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
</svg>
</div>
</div>
<div class="mx-auto text-sm font-medium text-gray-900">Received Msgs</div>
</a>
<!-- gated messages -->
<a target="_blank" :href="`/api/v1/text-messages/embed?gateway_id=${state.selectedNode.node_id}`" class="flex flex-col" title="Messages gated to MQTT by this Node">
<div class="flex mx-auto mb-1">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418" />
</svg>
</div>
</div>
<div class="mx-auto text-sm font-medium text-gray-900">Gated Msgs</div>
</a>
</div>
<!-- details -->
<NodeDetails :node="state.selectedNode"/>
<!-- lora config -->
<LoraConfig :node="state.selectedNode"/>
<!-- position -->
<Position @show-position-history="showPositionHistory" :node="state.selectedNode"/>
<!-- device metrics -->
<DeviceMetricsChart :node="state.selectedNode"/>
<!-- environment metrics -->
<EnvironmentMetricsChart :node="state.selectedNode"/>
<!-- power metrics -->
<PowerMetricsChart/>
<!-- mqtt -->
<MqttHistory />
<!-- traceroutes -->
<Traceroutes @show-trace-route="showTraceRoute"/>
<!-- other -->
<OtherInfo :node="state.selectedNode"/>
<!-- share -->
<Share :node="state.selectedNode"/>
</div>
</div>
</div>
</div>
</transition>
</div>
</template>

View File

@ -0,0 +1,207 @@
<script setup>
const props = defineProps(['node']);
import axios from 'axios';
import moment from 'moment';
import { Chart, TimeScale, LinearScale, LineController, Tooltip, Legend, PointElement, LineElement } from 'chart.js';
import 'chartjs-adapter-moment';
import { onMounted, useTemplateRef, watch } from 'vue';
import { state } from '../../store.js';
import { deviceMetricsTimeRange } from '../../config.js';
import { formatUptimeSeconds, getTimeSpans } from '../../utils.js';
import { useStorage } from '@vueuse/core';
const deviceMetricsChartEl = useTemplateRef('device-metrics-chart');
function initChart() {
// destroy existing chart
const existingChart = Chart.getChart(deviceMetricsChartEl.value);
if (existingChart != null) {
existingChart.destroy();
}
// create chart data
const labels = [];
const batteryMetrics = [];
const channelUtilizationMetrics = [];
const airUtilTxMetrics = [];
for(const deviceMetric of state.selectedNodeDeviceMetrics) {
labels.push(moment(deviceMetric.created_at));
batteryMetrics.push(deviceMetric.battery_level);
channelUtilizationMetrics.push(deviceMetric.channel_utilization);
airUtilTxMetrics.push(deviceMetric.air_util_tx);
}
// create chart
new Chart(deviceMetricsChartEl.value, {
type: 'line',
data: {
labels: labels,
datasets: [
{
label: 'Battery Level',
borderColor: '#3b82f6',
backgroundColor: '#3b82f6',
pointStyle: false, // no points
fill: false,
data: batteryMetrics,
},
{
label: 'Channel Util',
borderColor: '#22c55e',
backgroundColor: '#22c55e',
showLine: false, // no lines between points
fill: false,
data: channelUtilizationMetrics,
},
{
label: 'Air Util TX',
borderColor: '#f97316',
backgroundColor: '#f97316',
showLine: false, // no lines between points
fill: false,
data: airUtilTxMetrics,
},
],
},
options: {
responsive: true,
borderWidth: 2,
elements: {
point: {
radius: 2,
},
},
scales: {
x: {
position: 'top',
type: 'time',
time: {
unit: 'day',
displayFormats: {
day: 'MMM DD', // Jan 01
},
},
},
y: {
min: 0,
max: 101, // 101 is "Plugged In", need to include for tooltip to work
ticks: {
callback: (label) => `${label}%`,
},
},
},
plugins: {
legend: {
display: false,
},
tooltip: {
mode: "index",
intersect: false,
callbacks: {
label: (item) => {
return `${item.dataset.label}: ${item.formattedValue}%`;
},
},
},
},
},
});
}
watch(
() => state.selectedNodeDeviceMetrics,
(newValue) => {
if (newValue !== []) {
initChart()
}
}, {deep: true}
)
onMounted(() => {
Chart.register(TimeScale, LinearScale, LineController, Tooltip, Legend, PointElement, LineElement)
})
</script>
<template>
<!-- device metrics -->
<div>
<div class="flex bg-gray-200 p-2 font-semibold">
<div class="my-auto">Device Metrics</div>
<div class="my-auto ml-auto">
<select v-model="deviceMetricsTimeRange" class="block w-full rounded-md border-0 py-0.5 pl-2 pr-8 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-500 sm:text-sm sm:leading-6">
<option v-for="(range, index) in getTimeSpans()" :value="index">{{ range.name }}</option>
</select>
</div>
</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<!-- device metrics chart -->
<li>
<div class="px-4 py-2">
<div class="w-full">
<canvas id="deviceMetricsChart" style="height:150px;" ref="device-metrics-chart"></canvas>
<div class="flex">
<div class="mx-auto flex space-x-2">
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-blue-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Battery Level</div>
</div>
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-green-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Channel Utilization</div>
</div>
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-orange-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Air Util TX</div>
</div>
</div>
</div>
</div>
</div>
</li>
<!-- battery level -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Battery Level</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.battery_level">
<span v-if="props.node.battery_level > 100">Plugged In</span>
<span v-else>{{ props.node.battery_level }}%</span>
</span>
<span v-else>???</span>
</div>
</li>
<!-- voltage -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Voltage</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.voltage">{{ Number(props.node.voltage).toFixed(2) }}V</span>
<span v-else>???</span>
</div>
</li>
<!-- channel utilization -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Channel Utilization</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.channel_utilization">{{ Number(props.node.channel_utilization).toFixed(2) }}%</span>
<span v-else>???</span>
</div>
</li>
<!-- air util tx -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Air Util Tx</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.air_util_tx">{{ Number(props.node.air_util_tx).toFixed(2) }}%</span>
<span v-else>???</span>
</div>
</li>
<!-- air util tx -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Uptime</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.uptime_seconds">{{ formatUptimeSeconds(props.node.uptime_seconds) }}</span>
<span v-else>???</span>
</div>
</li>
</ul>
</div>
</template>

View File

@ -0,0 +1,202 @@
<script setup>
const props = defineProps(['node']);
import axios from 'axios';
import moment from 'moment';
import { Chart, TimeScale, LinearScale, LineController, Tooltip, Legend, PointElement, LineElement } from 'chart.js';
import 'chartjs-adapter-moment';
import { onMounted, useTemplateRef, watch } from 'vue';
import { state } from '../../store.js';
import { environmentMetricsTimeRange } from '../../config.js';
import { formatTemperature, getTimeSpans } from '../../utils.js';
const environmentMetricsChartEl = useTemplateRef('environment-metrics-chart');
function initChart() {
// destroy existing chart
const existingChart = Chart.getChart(environmentMetricsChartEl.value);
if (existingChart != null) {
existingChart.destroy();
}
// create chart data
const labels = [];
const temperatureMetrics = [];
const relativeHumidityMetrics = [];
const barometricPressureMetrics = [];
for(const deviceMetric of state.selectedNodeEnvironmentMetrics){
labels.push(moment(deviceMetric.created_at));
temperatureMetrics.push(deviceMetric.temperature);
relativeHumidityMetrics.push(deviceMetric.relative_humidity);
barometricPressureMetrics.push(deviceMetric.barometric_pressure);
}
// create chart
new Chart(environmentMetricsChartEl.value, {
type: 'line',
data: {
labels: labels,
datasets: [
{
label: 'Temperature',
suffix: 'ºC',
borderColor: '#3b82f6',
backgroundColor: '#3b82f6',
pointStyle: false, // no points
fill: false,
data: temperatureMetrics,
yAxisID: 'y',
},
{
label: 'Humidity',
suffix: '%',
borderColor: '#22c55e',
backgroundColor: '#22c55e',
pointStyle: false, // no points
fill: false,
data: relativeHumidityMetrics,
yAxisID: 'y',
},
{
label: 'Pressure',
suffix: 'hPa',
borderColor: '#f97316',
backgroundColor: '#f97316',
pointStyle: false, // no points
fill: false,
data: barometricPressureMetrics,
yAxisID: 'y1',
},
],
},
options: {
responsive: true,
borderWidth: 2,
spanGaps: 1000 * 60 * 60 * 3, // only show lines between metrics with a 3 hour or less gap
elements: {
point: {
radius: 2,
},
},
scales: {
x: {
position: 'top',
type: 'time',
time: {
unit: 'day',
displayFormats: {
day: 'MMM DD', // Jan 01
},
},
},
y: {
min: -20,
max: 100,
},
y1: {
min: 800,
max: 1100,
ticks: {
stepSize: 10,
callback: (label) => `${label} hPa`,
},
position: 'right',
grid: {
drawOnChartArea: false, // only want the grid lines for one axis to show up
},
},
},
plugins: {
legend: {
display: false,
},
tooltip: {
mode: "index",
intersect: false,
callbacks: {
label: (item) => {
return `${item.dataset.label}: ${item.formattedValue}${item.dataset.suffix}`;
},
},
},
},
}
});
}
watch(
() => state.selectedNodeEnvironmentMetrics,
(newValue) => {
if (newValue !== []) {
initChart()
}
}, {deep: true}
)
onMounted(() => {
Chart.register(TimeScale, LinearScale, LineController, Tooltip, Legend, PointElement, LineElement)
})
</script>
<template>
<div>
<div class="flex bg-gray-200 p-2 font-semibold">
<div class="my-auto">Environment Metrics</div>
<div class="my-auto ml-auto">
<select v-model="environmentMetricsTimeRange" class="block w-full rounded-md border-0 py-0.5 pl-2 pr-8 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-500 sm:text-sm sm:leading-6">
<option v-for="(range, index) in getTimeSpans()" :value="index">{{ range.name }}</option>
</select>
</div>
</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<!-- environment metrics chart -->
<li>
<div class="px-4 py-2">
<div class="w-full">
<canvas id="environmentMetricsChart" style="height:150px;" ref="environment-metrics-chart"></canvas>
<div class="flex">
<div class="mx-auto flex space-x-2">
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-blue-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Temperature</div>
</div>
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-green-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Humidity</div>
</div>
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-orange-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Pressure</div>
</div>
</div>
</div>
</div>
</div>
</li>
<!-- temperature -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Temperature</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.temperature">{{ formatTemperature(props.node.temperature) }}</span>
<span v-else>???</span>
</div>
</li>
<!-- relative humidity -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Relative Humidity</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.relative_humidity">{{ Number(props.node.relative_humidity).toFixed(0) }}%</span>
<span v-else>???</span>
</div>
</li>
<!-- barometric pressure -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Barometric Pressure</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.barometric_pressure">{{ Number(props.node.barometric_pressure).toFixed(1) }}hPa</span>
<span v-else>???</span>
</div>
</li>
</ul>
</div>
</template>

View File

@ -0,0 +1,40 @@
<script setup>
import { getRegionFrequencyRange } from '../../utils.js';
const props = defineProps(['node']);
</script>
<template>
<!-- lora config -->
<div>
<div class="bg-gray-200 p-2 font-semibold">LoRa Config</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<!-- region -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Region</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.region_name">{{ props.node.region_name }} ({{ getRegionFrequencyRange(props.node.region_name) }})</span>
<span v-else>???</span>
</div>
</li>
<!-- modem preset -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Modem Preset</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.modem_preset_name">{{ props.node.modem_preset_name }}</span>
<span v-else>???</span>
</div>
</li>
<!-- has default channel -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Has Default Channel</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.has_default_channel != null">{{ props.node.has_default_channel ? "Yes" : "No" }}</span>
<span v-else>???</span>
</div>
</li>
</ul>
</div>
</template>

View File

@ -0,0 +1,41 @@
<script setup>
import { state } from '../../store.js';
import moment from 'moment';
</script>
<template>
<div>
<div class="bg-gray-200 p-2">
<div class="font-semibold">MQTT</div>
<div class="text-sm text-gray-600">Topics this node sent packets to</div>
</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<template v-if="state.selectedNodeMqttMetrics.length > 0">
<li v-for="mqttMetric of state.selectedNodeMqttMetrics">
<div class="relative flex items-center">
<div class="block flex-1 px-4 py-2">
<div class="relative flex min-w-0 flex-1 items-center">
<div class="truncate">
<p class="truncate text-sm font-medium text-gray-900">{{ mqttMetric.mqtt_topic }}</p>
<div class="text-sm text-gray-700">Last packet {{ moment(new Date(mqttMetric.last_packet_at)).fromNow() }}</div>
</div>
</div>
</div>
</div>
</li>
</template>
<template v-else>
<li>
<div class="relative flex items-center">
<div class="block flex-1 px-4 py-2">
<div class="relative flex min-w-0 flex-1 items-center">
<div class="truncate">
<div class="text-sm text-gray-700">No packets seen on MQTT</div>
</div>
</div>
</div>
</div>
</li>
</template>
</ul>
</div>
</template>

View File

@ -0,0 +1,45 @@
<script setup>
const props = defineProps(['node']);
</script>
<template>
<div>
<div class="bg-gray-200 p-2 font-semibold">Details</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<!-- id -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">ID</div>
<div class="ml-auto text-sm text-gray-700">{{ props.node.node_id }}</div>
</li>
<!-- hex id -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Hex ID</div>
<div class="ml-auto text-sm text-gray-700">{{ props.node.node_id_hex }}</div>
</li>
<!-- role -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Role</div>
<div class="ml-auto text-sm text-gray-700">{{ props.node.role_name }}</div>
</li>
<!-- hardware -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Hardware</div>
<div class="ml-auto text-sm text-gray-700">{{ props.node.hardware_model_name }}</div>
</li>
<!-- firmware version -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Firmware</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.firmware_version">{{ props.node.firmware_version }}</span>
<span v-else>???</span>
</div>
</li>
</ul>
</div>
</template>

View File

@ -0,0 +1,40 @@
<script setup>
const props = defineProps(['node']);
import moment from 'moment';
</script>
<template>
<div>
<div class="bg-gray-200 p-2 font-semibold">Other</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<!-- first seen -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">First Seen</div>
<div class="ml-auto text-sm text-gray-700">{{ moment(new Date(props.node.created_at)).fromNow() }}</div>
</li>
<!-- last seen -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Last Seen</div>
<div class="ml-auto text-sm text-gray-700">{{ moment(new Date(props.node.updated_at)).fromNow() }}</div>
</li>
<!-- neighbours updated -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Neighbours Updated</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.neighbours_updated_at">{{ moment(new Date(props.node.neighbours_updated_at)).fromNow() }}</span>
<span v-else>???</span>
</div>
</li>
<!-- position updated -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Position Updated</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.position_updated_at">{{ moment(new Date(props.node.position_updated_at)).fromNow() }}</span>
<span v-else>???</span>
</div>
</li>
</ul>
</div>
</template>

View File

@ -0,0 +1,34 @@
<script setup>
const props = defineProps(['node']);
const emit = defineEmits(['showPositionHistory']);
</script>
<template>
<div>
<div @click.stop class="flex bg-gray-200 p-2 font-semibold">
<div class="my-auto">Position</div>
<div class="ml-auto">
<button @click="$emit('showPositionHistory', props.node.node_id)" type="button" class="rounded-sm bg-white px-2 py-1 text-sm font-semibold text-gray-900 shadow-xs ring-1 ring-inset ring-gray-300 hover:bg-gray-50">
Show History
</button>
</div>
</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<!-- position -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Lat/Long</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.latitude && props.node.longitude">{{ props.node.latitude }}, {{ props.node.longitude }}</span>
<span v-else>???</span>
</div>
</li>
<!-- altitude -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Altitude</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="props.node.altitude">{{ props.node.altitude }}m</span>
<span v-else>???</span>
</div>
</li>
</ul>
</div>
</template>

View File

@ -0,0 +1,251 @@
<script setup>
import axios from 'axios';
import moment from 'moment';
import { Chart, TimeScale, LinearScale, LineController, Tooltip, Legend, PointElement, LineElement } from 'chart.js';
import 'chartjs-adapter-moment';
import { onMounted, useTemplateRef, watch } from 'vue';
import { state, selectedNodeLatestPowerMetric } from '../../store.js';
import { powerMetricsTimeRange } from '../../config.js';
import { getTimeSpans } from '../../utils.js';
const powerMetricsChartEl = useTemplateRef('power-metrics-chart');
function initChart() {
// destroy existing chart
const existingChart = Chart.getChart(powerMetricsChartEl.value);
if (existingChart != null) {
existingChart.destroy();
}
// create chart data
const labels = [];
const channel1VoltageReadings = [];
const channel2VoltageReadings = [];
const channel3VoltageReadings = [];
const channel1CurrentReadings = [];
const channel2CurrentReadings = [];
const channel3CurrentReadings = [];
for(const powerMetric of state.selectedNodePowerMetrics) {
labels.push(moment(powerMetric.created_at));
channel1VoltageReadings.push(powerMetric.ch1_voltage);
channel2VoltageReadings.push(powerMetric.ch2_voltage);
channel3VoltageReadings.push(powerMetric.ch3_voltage);
channel1CurrentReadings.push(powerMetric.ch1_current);
channel2CurrentReadings.push(powerMetric.ch2_current);
channel3CurrentReadings.push(powerMetric.ch3_current);
}
// create chart
new Chart(powerMetricsChartEl.value, {
type: 'line',
data: {
labels: labels,
datasets: [
{
label: 'Ch1 Voltage',
suffix: "V",
borderColor: '#3b82f6',
backgroundColor: '#3b82f6',
pointStyle: false, // no points
fill: false,
data: channel1VoltageReadings,
yAxisID: 'y',
},
{
label: 'Ch2 Voltage',
suffix: "V",
borderColor: '#22c55e',
backgroundColor: '#22c55e',
pointStyle: false, // no points
fill: false,
data: channel2VoltageReadings,
yAxisID: 'y',
},
{
label: 'Ch3 Voltage',
suffix: "V",
borderColor: '#f97316',
backgroundColor: '#f97316',
pointStyle: false, // no points
fill: false,
data: channel3VoltageReadings,
yAxisID: 'y',
},
{
label: 'Ch1 Current',
suffix: "mA",
borderColor: '#93c5fd',
backgroundColor: '#93c5fd',
pointStyle: false, // no points
fill: false,
data: channel1CurrentReadings,
yAxisID: 'y1',
},
{
label: 'Ch2 Current',
suffix: "mA",
borderColor: '#86efac',
backgroundColor: '#86efac',
pointStyle: false, // no points
fill: false,
data: channel2CurrentReadings,
yAxisID: 'y1',
},
{
label: 'Ch3 Current',
suffix: "mA",
borderColor: '#fdba74',
backgroundColor: '#fdba74',
pointStyle: false, // no points
fill: false,
data: channel3CurrentReadings,
yAxisID: 'y1',
},
],
},
options: {
responsive: true,
borderWidth: 2,
spanGaps: 1000 * 60 * 60 * 3, // only show lines between metrics with a 3 hour or less gap
elements: {
point: {
radius: 2,
},
},
scales: {
x: {
position: 'top',
type: 'time',
time: {
unit: 'day',
displayFormats: {
day: 'MMM DD', // Jan 01
},
},
},
y: {
min: 0,
max: 30,
ticks: {
callback: (label) => `${label}V`,
},
},
y1: {
min: -500,
max: 500,
ticks: {
stepSize: 50,
callback: (label) => `${label}mA`,
},
position: 'right',
grid: {
drawOnChartArea: false, // only want the grid lines for one axis to show up
},
},
},
plugins: {
legend: {
display: false,
},
tooltip: {
mode: "index",
intersect: false,
callbacks: {
label: (item) => {
return `${item.dataset.label}: ${item.formattedValue}${item.dataset.suffix}`;
},
},
},
},
}
});
}
watch(
() => state.selectedNodePowerMetrics,
(newValue) => {
if (newValue !== []) {
initChart()
}
}, {deep: true}
)
onMounted(() => {
Chart.register(TimeScale, LinearScale, LineController, Tooltip, Legend, PointElement, LineElement)
})
</script>
<template>
<!-- power metrics -->
<div>
<div class="flex bg-gray-200 p-2 font-semibold">
<div class="my-auto">Power Metrics</div>
<div class="my-auto ml-auto">
<select v-model="powerMetricsTimeRange" class="block w-full rounded-md border-0 py-0.5 pl-2 pr-8 text-gray-900 ring-1 ring-inset ring-gray-300 focus:ring-2 focus:ring-blue-500 sm:text-sm sm:leading-6">
<option v-for="(range, index) in getTimeSpans()" :value="index">{{ range.name }}</option>
</select>
</div>
</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<!-- power metrics chart -->
<li>
<div class="px-4 py-2">
<div class="w-full">
<canvas id="powerMetricsChart" style="height:150px;" ref="power-metrics-chart"></canvas>
<div class="flex">
<div class="mx-auto flex space-x-2">
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-blue-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Channel 1</div>
</div>
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-green-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Channel 2</div>
</div>
<div class="flex mx-auto">
<div class="my-auto w-2 h-2 bg-orange-500 rounded-full"></div>
<div class="my-auto ml-1 text-sm text-gray-500">Channel 3</div>
</div>
</div>
</div>
</div>
</div>
</li>
<!-- channel 1 -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Channel 1</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="selectedNodeLatestPowerMetric">
<span v-if="selectedNodeLatestPowerMetric?.ch1_voltage">{{ Number(selectedNodeLatestPowerMetric.ch1_voltage).toFixed(2) }}V</span>
<span v-else>???</span>
<span v-if="selectedNodeLatestPowerMetric?.ch1_current"> / {{ Number(selectedNodeLatestPowerMetric.ch1_current).toFixed(2) }}mA</span>
</span>
<span v-else>???</span>
</div>
</li>
<!-- channel 2 -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Channel 2</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="selectedNodeLatestPowerMetric">
<span v-if="selectedNodeLatestPowerMetric?.ch2_voltage">{{ Number(selectedNodeLatestPowerMetric.ch2_voltage).toFixed(2) }}V</span>
<span v-else>???</span>
<span v-if="selectedNodeLatestPowerMetric?.ch2_current"> / {{ Number(selectedNodeLatestPowerMetric.ch2_current).toFixed(2) }}mA</span>
</span>
<span v-else>???</span>
</div>
</li>
<!-- channel 3 -->
<li class="flex p-3">
<div class="text-sm font-medium text-gray-900">Channel 3</div>
<div class="ml-auto text-sm text-gray-700">
<span v-if="selectedNodeLatestPowerMetric">
<span v-if="selectedNodeLatestPowerMetric?.ch3_voltage">{{ Number(selectedNodeLatestPowerMetric.ch3_voltage).toFixed(2) }}V</span>
<span v-else>???</span>
<span v-if="selectedNodeLatestPowerMetric?.ch3_current"> / {{ Number(selectedNodeLatestPowerMetric.ch3_current).toFixed(2) }}mA</span>
</span>
<span v-else>???</span>
</div>
</li>
</ul>
</div>
</template>

View File

@ -0,0 +1,27 @@
<script setup>
const props = defineProps(['node']);
import { getShareLinkForNode, copyShareLinkForNode } from '../../utils.js';
</script>
<template>
<div>
<div class="flex bg-gray-200 p-2 font-semibold">
<div class="my-auto">Share Link</div>
<div class="ml-auto">
<button @click="copyShareLinkForNode(props.node.node_id)" type="button" class="rounded-sm bg-white px-2 py-1 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50">
Copy
</button>
</div>
</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<li>
<div class="relative flex items-center">
<div class="block flex-1 p-2">
<div class="flex space-x-2">
<input type="text" readonly class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" :value="getShareLinkForNode(props.node.node_id)">
</div>
</div>
</div>
</li>
</ul>
</div>
</template>

View File

@ -0,0 +1,42 @@
<script setup>
const emit = defineEmits(['showTraceRoute']);
import { state } from '../../store.js';
import { findNodeById } from '../../utils.js';
</script>
<template>
<div>
<div class="bg-gray-200 p-2">
<div class="font-semibold">Trace Routes</div>
<div class="text-sm text-gray-600">Only 5 most recent are shown</div>
</div>
<ul role="list" class="flex-1 divide-y divide-gray-200">
<template v-if="state.selectedNodeTraceroutes.length > 0">
<li @click="$emit('showTraceRoute', traceroute)" v-for="traceroute of state.selectedNodeTraceroutes">
<div class="relative flex items-center">
<div class="block flex-1 px-4 py-2">
<div class="relative flex min-w-0 flex-1 items-center">
<div>
<p class="text-sm text-gray-900"><span class="font-medium">{{ findNodeById(traceroute.to)?.long_name || '???' }}</span> to <span class="font-medium">{{ findNodeById(traceroute.from)?.long_name || '???' }}</span></p>
<div class="text-sm text-gray-700">{{ moment(new Date(traceroute.updated_at)).fromNow() }} - {{ traceroute.route.length }} hops {{ traceroute.channel_id ? `on ${traceroute.channel_id}` : '' }}</div>
</div>
</div>
</div>
</div>
</li>
</template>
<template v-else>
<li>
<div class="relative flex items-center">
<div class="block flex-1 px-4 py-2">
<div class="relative flex min-w-0 flex-1 items-center">
<div class="truncate">
<div class="text-sm text-gray-700">No traceroutes seen on MQTT</div>
</div>
</div>
</div>
</div>
</li>
</template>
</ul>
</div>
</template>

View File

@ -0,0 +1,47 @@
<script setup>
const emit = defineEmits(['dismiss']);
import { state } from '../store.js';
function dismissShowingNodeNeighbours() {
state.selectedNodeToShowNeighbours = null;
emit('dismiss');
}
</script>
<template>
<div class="relative z-sidebar" role="dialog" aria-modal="true">
<!-- sidebar -->
<transition
enter-active-class="transition duration-300 ease-in-out transform"
enter-from-class="translate-y-full"
enter-to-class="translate-y-0"
leave-active-class="transition duration-300 ease-in-out transform"
leave-from-class="translate-y-0"
leave-to-class="translate-y-full">
<div v-show="state.selectedNodeToShowNeighbours != null" class="fixed left-0 right-0 bottom-0">
<div v-if="state.selectedNodeToShowNeighbours != null" class="mx-auto w-screen max-w-md p-4">
<div class="flex h-full flex-col bg-white shadow-xl rounded-xl border">
<div class="p-2">
<div class="flex items-start justify-between">
<div>
<h2 class="font-bold">{{ state.selectedNodeToShowNeighbours.short_name }} Neighbours</h2>
<h3 v-if="state.selectedNodeToShowNeighboursType === 'weHeard'" class="text-sm">Nodes heard by {{ state.selectedNodeToShowNeighbours.short_name }}</h3>
<h3 v-if="state.selectedNodeToShowNeighboursType === 'theyHeard'" class="text-sm">Nodes that heard {{ state.selectedNodeToShowNeighbours.short_name }}</h3>
</div>
<div class="my-auto ml-3 flex h-7 items-center">
<a href="javascript:void(0)" class="rounded-full" @click="dismissShowingNodeNeighbours">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M18 6l-12 12"></path>
<path d="M6 6l12 12"></path>
</svg>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</transition>
</div>
</template>

View File

@ -0,0 +1,107 @@
<script setup>
const emit = defineEmits(['dismiss']);
import { state } from '../store.js';
import moment from 'moment';
function dismissShowingNodePositionHistory() {
state.selectedNodePositionHistory = [];
state.selectedNodeToShowPositionHistory = null;
state.positionHistoryModalExpanded = false;
emit('dismiss');
}
function onPositionHistoryQuickRangeClick(range) {
// update position history time range
switch(range){
case "1h": {
state.positionHistoryDateTimeFrom = moment().subtract(1, "hours").format('YYYY-MM-DDTHH:mm');
state.positionHistoryDateTimeTo = moment().format('YYYY-MM-DDTHH:mm');
break;
}
case "24h": {
state.positionHistoryDateTimeFrom = moment().subtract(24, "hours").format('YYYY-MM-DDTHH:mm');
state.positionHistoryDateTimeTo = moment().format('YYYY-MM-DDTHH:mm');
break;
}
case "7d": {
state.positionHistoryDateTimeFrom = moment().subtract(7, "days").format('YYYY-MM-DDTHH:mm');
state.positionHistoryDateTimeTo = moment().format('YYYY-MM-DDTHH:mm');
break;
}
}
}
</script>
<template>
<!-- node position history modal -->
<div class="relative z-sidebar" role="dialog" aria-modal="true">
<!-- sidebar -->
<transition
enter-active-class="transition duration-300 ease-in-out transform"
enter-from-class="translate-y-full"
enter-to-class="translate-y-0"
leave-active-class="transition duration-300 ease-in-out transform"
leave-from-class="translate-y-0"
leave-to-class="translate-y-full">
<div v-show="state.selectedNodeToShowPositionHistory != null" class="fixed left-0 right-0 bottom-0">
<div v-if="state.selectedNodeToShowPositionHistory != null" class="mx-auto w-screen max-w-md p-4">
<div class="flex h-full flex-col bg-white shadow-xl rounded-xl border">
<div>
<div class="flex p-2">
<div class="flex my-auto mr-3 space-x-2">
<a href="javascript:void(0)" @click="state.positionHistoryModalExpanded = !state.positionHistoryModalExpanded" class="rounded-full">
<div class="bg-gray-100 hover:bg-gray-200 p-1 rounded-full">
<svg v-if="state.positionHistoryModalExpanded" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
</svg>
<svg v-else xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-6">
<path stroke-linecap="round" stroke-linejoin="round" d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
</div>
</a>
</div>
<div class="my-auto mr-auto font-bold">{{ state.selectedNodeToShowPositionHistory.short_name }} Position History</div>
<div class="flex my-auto ml-3 space-x-2">
<a href="javascript:void(0)" class="rounded-full" @click="dismissShowingNodePositionHistory">
<div class="bg-gray-100 hover:bg-gray-200 p-1 rounded-full">
<svg class="size-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M18 6l-12 12"></path>
<path d="M6 6l12 12"></path>
</svg>
</div>
</a>
</div>
</div>
<div v-if="state.positionHistoryModalExpanded" class="divide-y border-t">
<!-- quick range -->
<div class="flex p-2 space-x-2">
<button @click="onPositionHistoryQuickRangeClick('1h')" type="button" class="w-full bg-gray-100 rounded border shadow px-2 py-1 text-sm hover:bg-gray-200 text-center">1 Hour</button>
<button @click="onPositionHistoryQuickRangeClick('24h')" type="button" class="w-full bg-gray-100 rounded border shadow px-2 py-1 text-sm hover:bg-gray-200 text-center">24 Hours</button>
<button @click="onPositionHistoryQuickRangeClick('7d')" type="button" class="w-full bg-gray-100 rounded border shadow px-2 py-1 text-sm hover:bg-gray-200 text-center">7 Days</button>
</div>
<!-- manual range -->
<div class="p-2 space-y-1">
<!-- from -->
<div class="flex items-center">
<label class="text-sm pr-1 min-w-12 text-right">From:</label>
<input v-model="state.positionHistoryDateTimeFrom" type="datetime-local" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-1">
</div>
<!-- to -->
<div class="flex items-center">
<label class="text-sm pr-1 min-w-12 text-right">To:</label>
<input v-model="state.positionHistoryDateTimeTo" type="datetime-local" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-1">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</transition>
</div>
</template>

View File

@ -0,0 +1,210 @@
<script setup>
import { state } from '../store.js';
import {
nodesMaxAge,
nodesDisconnectedAge,
nodesOfflineAge,
waypointsMaxAge,
neighboursMaxDistance,
goToNodeZoomLevel,
temperatureFormat,
autoUpdatePositionInUrl,
enableMapAnimations,
} from '../config.js';
</script>
<template>
<!-- settings sidebar -->
<div class="relative z-sidebar" role="dialog" aria-modal="true">
<!-- overlay -->
<transition
enter-active-class="transition-opacity duration-300 ease-linear"
enter-from-class="opacity-0"
enter-to-class="opacity-100"
leave-active-class="transition-opacity duration-300 ease-linear"
leave-from-class="opacity-100"
leave-to-class="opacity-0">
<div v-show="state.settingsVisible" @click="state.settingsVisible = !state.settingsVisible" class="fixed inset-0 bg-gray-900/75"></div>
</transition>
<!-- sidebar -->
<transition
enter-active-class="transition duration-300 ease-in-out transform"
enter-from-class="-translate-x-full"
enter-to-class="translate-x-0"
leave-active-class="transition duration-300 ease-in-out transform"
leave-from-class="translate-x-0"
leave-to-class="-translate-x-full">
<div v-show="state.settingsVisible" class="fixed top-0 left-0 bottom-0">
<div v-if="state.settingsVisible" class="w-screen h-full max-w-md overflow-hidden">
<div class="flex h-full flex-col bg-white shadow-xl">
<!-- slideover header -->
<div class="p-2 border-b border-gray-200 shadow-sm">
<div class="flex items-start justify-between">
<div>
<h2 class="font-bold">Settings</h2>
<h3 class="text-sm">Changes are only saved in this browser.</h3>
</div>
<div class="my-auto ml-3 flex h-7 items-center">
<a href="javascript:void(0)" class="rounded-full" @click="state.settingsVisible = false">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M18 6l-12 12"></path>
<path d="M6 6l12 12"></path>
</svg>
</div>
</a>
</div>
</div>
</div>
<div class="overflow-y-auto divide-y divide-gray-200">
<!-- configNodesMaxAgeInSeconds -->
<div class="p-2">
<label class="block text-sm font-medium text-gray-900">Nodes Max Age</label>
<div class="text-xs text-gray-600 mb-2">Nodes not updated within this time are hidden. Reload to update map.</div>
<select v-model="nodesMaxAge" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
<option :value="null">Show All</option>
<option value="900">15 minutes</option>
<option value="1800">30 minutes</option>
<option value="3600">1 hour</option>
<option value="10800">3 hours</option>
<option value="21600">6 hours</option>
<option value="43200">12 hours</option>
<option value="86400">24 hours</option>
<option value="172800">2 days</option>
<option value="259200">3 days</option>
<option value="345600">4 days</option>
<option value="432000">5 days</option>
<option value="518400">6 days</option>
<option value="604800">7 days</option>
</select>
</div>
<!-- configNodesDisconnectedAgeInSeconds -->
<div class="p-2">
<label class="block text-sm font-medium text-gray-900">Nodes Disconnected Age</label>
<div class="text-xs text-gray-600 mb-2">Nodes that have not uplinked to MQTT in this time will show as blue icons. Reload to update map.</div>
<select v-model="nodesDisconnectedAge" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
<option value="900">15 minutes</option>
<option value="1800">30 minutes</option>
<option value="2700">45 minutes</option>
<option value="3600">1 hour</option>
<option value="7200">2 hours</option>
<option value="10800">3 hours</option>
<option value="21600">6 hours</option>
<option value="43200">12 hours</option>
<option value="86400">24 hours</option>
<option value="172800">2 days</option>
<option value="259200">3 days</option>
<option value="345600">4 days</option>
<option value="432000">5 days</option>
<option value="518400">6 days</option>
<option value="604800">7 days</option>
</select>
</div>
<!-- configNodesOfflineAgeInSeconds -->
<div class="p-2">
<label class="block text-sm font-medium text-gray-900">Nodes Offline Age</label>
<div class="text-xs text-gray-600 mb-2">Nodes not updated within this time will show as red icons. Reload to update map.</div>
<select v-model="nodesOfflineAge" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
<option :value="null">Don't show as offline</option>
<option value="900">15 minutes</option>
<option value="1800">30 minutes</option>
<option value="2700">45 minutes</option>
<option value="3600">1 hour</option>
<option value="7200">2 hours</option>
<option value="10800">3 hours</option>
<option value="21600">6 hours</option>
<option value="43200">12 hours</option>
<option value="86400">24 hours</option>
<option value="172800">2 days</option>
<option value="259200">3 days</option>
<option value="345600">4 days</option>
<option value="432000">5 days</option>
<option value="518400">6 days</option>
<option value="604800">7 days</option>
</select>
</div>
<!-- configWaypointsMaxAgeInSeconds -->
<div class="p-2">
<label class="block text-sm font-medium text-gray-900">Waypoints Max Age</label>
<div class="text-xs text-gray-600 mb-2">Waypoints not updated within this time are hidden. Reload to update map.</div>
<select v-model="waypointsMaxAge" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
<option :value="null">Show All</option>
<option value="900">15 minutes</option>
<option value="1800">30 minutes</option>
<option value="3600">1 hour</option>
<option value="10800">3 hours</option>
<option value="21600">6 hours</option>
<option value="43200">12 hours</option>
<option value="86400">24 hours</option>
<option value="172800">2 days</option>
<option value="259200">3 days</option>
<option value="345600">4 days</option>
<option value="432000">5 days</option>
<option value="518400">6 days</option>
<option value="604800">7 days</option>
</select>
</div>
<!-- configNeighboursMaxDistanceInMeters -->
<div class="p-2">
<label class="block text-sm font-medium text-gray-900">Neighbours Max Distance (meters)</label>
<div class="text-xs text-gray-600 mb-2">Neighbours further than this are hidden. Reload to update map.</div>
<input type="number" v-model="neighboursMaxDistance" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
</div>
<!-- configZoomLevelGoToNode -->
<div class="p-2">
<label class="block text-sm font-medium text-gray-900">Zoom Level (go to node)</label>
<div class="text-xs text-gray-600 mb-2">How far to zoom map when navigating to a node.</div>
<input type="number" v-model="goToNodeZoomLevel" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
</div>
<!-- configTemperatureFormat -->
<div class="p-2">
<label class="block text-sm font-medium text-gray-900">Temperature Format</label>
<div class="text-xs text-gray-600 mb-2">Metrics will be shown in the selected format.</div>
<select v-model="temperatureFormat" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5">
<option value="celsius">Celsius (ºC)</option>
<option value="fahrenheit">Fahrenheit (ºF)</option>
</select>
</div>
<!-- configAutoUpdatePositionInUrl -->
<div class="p-2">
<div class="flex items-start">
<div class="flex items-center h-5">
<input type="checkbox" v-model="autoUpdatePositionInUrl" class="w-4 h-4 border border-gray-300 rounded-sm bg-gray-50 focus:ring-3 focus:ring-blue-300" required>
</div>
<label class="ml-2 text-sm font-medium text-gray-900">Auto Update Position in URL</label>
</div>
<div class="text-xs text-gray-600">Sets lat/lng/zoom as query parameters.</div>
</div>
<!-- configEnableMapAnimations -->
<div class="p-2">
<div class="flex items-start">
<div class="flex items-center h-5">
<input type="checkbox" v-model="enableMapAnimations" class="w-4 h-4 border border-gray-300 rounded-sm bg-gray-50 focus:ring-3 focus:ring-blue-300" required>
</div>
<label class="ml-2 text-sm font-medium text-gray-900">Enable Map Animations</label>
</div>
<div class="text-xs text-gray-600">Map will animate flying to nodes.</div>
</div>
</div>
</div>
</div>
</div>
</transition>
</div>
</template>

View File

@ -0,0 +1,154 @@
<script setup>
const emit = defineEmits(['goTo']);
import moment from 'moment';
import { state } from '../store.js';
import { getNodeColor, getNodeTextColor, findNodeById, findNodeMarkerById } from '../utils.js';
</script>
<template>
<div class="relative z-sidebar" role="dialog" aria-modal="true">
<!-- overlay -->
<transition
enter-active-class="transition-opacity duration-300 ease-linear"
enter-from-class="opacity-0"
enter-to-class="opacity-100"
leave-active-class="transition-opacity duration-300 ease-linear"
leave-from-class="opacity-100"
leave-to-class="opacity-0">
<div v-show="state.selectedTraceRoute != null" @click="state.selectedTraceRoute = null" class="fixed inset-0 bg-gray-900/75"></div>
</transition>
<!-- sidebar -->
<transition
enter-active-class="transition duration-300 ease-in-out transform"
enter-from-class="-translate-x-full"
enter-to-class="translate-x-0"
leave-active-class="transition duration-300 ease-in-out transform"
leave-from-class="translate-x-0"
leave-to-class="-translate-x-full">
<div v-show="state.selectedTraceRoute != null" class="fixed top-0 left-0 bottom-0">
<div v-if="state.selectedTraceRoute != null" class="w-screen h-full max-w-md overflow-hidden">
<div class="flex h-full flex-col bg-white shadow-xl">
<!-- slideover header -->
<div class="p-2 border-b border-gray-200 shadow-sm">
<div class="flex items-start justify-between">
<div>
<h2 class="font-bold">Traceroute #{{ state.selectedTraceRoute.id }}</h2>
<h3 class="text-sm">{{ moment(new Date(state.selectedTraceRoute.updated_at)).fromNow() }} - {{ state.selectedTraceRoute.route.length }} hops {{ state.selectedTraceRoute.channel_id ? `on ${state.selectedTraceRoute.channel_id}` : '' }}</h3>
</div>
<div class="my-auto ml-3 flex h-7 items-center">
<a href="javascript:void(0)" class="rounded-full" @click="state.selectedTraceRoute = null">
<div class="bg-gray-100 hover:bg-gray-200 p-2 rounded-full">
<svg class="w-6 h-6" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M18 6l-12 12"></path>
<path d="M6 6l12 12"></path>
</svg>
</div>
</a>
</div>
</div>
</div>
<div class="overflow-y-auto">
<!-- details -->
<div class="p-2">
<ul role="list" class="space-y-3">
<!-- node that initiated traceroute -->
<li @click="$emit('goTo', state.selectedTraceRoute.to)" class="relative flex gap-x-4">
<div class="absolute left-0 top-0 flex w-12 justify-center top-3 -bottom-3">
<div class="w-px bg-gray-200"></div>
</div>
<div class="my-auto relative flex flex-none items-center justify-center">
<div>
<div class="flex rounded-full h-12 w-12 text-white shadow-sm" :class="[ `bg-[${getNodeColor(state.selectedTraceRoute.to)}]`, `text-[${getNodeTextColor(state.selectedTraceRoute.to)}]` ]">
<div class="mx-auto my-auto drop-shadow-sm">{{ findNodeById(state.selectedTraceRoute.to)?.short_name ?? "?" }}</div>
</div>
</div>
</div>
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500">
<div class="font-medium text-gray-900">{{ findNodeById(state.selectedTraceRoute.to)?.long_name || '???' }}</div>
<div>Hex ID: !{{ Number(state.selectedTraceRoute.to).toString(16) }}</div>
<div>Started the traceroute</div>
</div>
</li>
<!-- middleman nodes -->
<li @click="$emit('goTo', route)" v-for="route of state.selectedTraceRoute.route" class="relative flex gap-x-4">
<div class="absolute left-0 top-0 flex w-12 justify-center -bottom-3">
<div class="w-px bg-gray-200"></div>
</div>
<div class="my-auto relative flex flex-none items-center justify-center">
<div>
<div class="flex rounded-full h-12 w-12 text-white shadow" :class="[ `bg-[${getNodeColor(route)}]`, `text-[${getNodeTextColor(route)}]` ]">
<div class="mx-auto my-auto drop-shadow-sm">{{ findNodeById(route)?.short_name ?? "?" }}</div>
</div>
</div>
</div>
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500">
<div class="font-medium text-gray-900">{{ findNodeById(route)?.long_name || '???' }}</div>
<div>Hex ID: !{{ Number(route).toString(16) }}</div>
<div>Forwarded the packet</div>
</div>
</li>
<!-- node that replied to traceroute -->
<li @click="$emit('goTo', state.selectedTraceRoute.from)" v-if="state.selectedTraceRoute.from" class="relative flex gap-x-4">
<div class="absolute left-0 top-0 flex w-12 justify-center -bottom-3">
<div class="w-px bg-gray-200"></div>
</div>
<div class="my-auto relative flex flex-none items-center justify-center">
<div>
<div class="flex rounded-full h-12 w-12 text-white shadow" :class="[ `bg-[${getNodeColor(state.selectedTraceRoute.from)}]`, `text-[${getNodeTextColor(state.selectedTraceRoute.from)}]` ]">
<div class="mx-auto my-auto drop-shadow-sm">{{ findNodeById(state.selectedTraceRoute.from)?.short_name ?? "?" }}</div>
</div>
</div>
</div>
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500">
<div class="font-medium text-gray-900">{{ findNodeById(state.selectedTraceRoute.from)?.long_name || '???' }}</div>
<div>Hex ID: !{{ Number(state.selectedTraceRoute.from).toString(16) }}</div>
<div>Replied to traceroute</div>
</div>
</li>
<!-- node that gated traceroute to mqtt -->
<li @click="$emit('goTo', state.selectedTraceRoute.gateway_id)" v-if="state.selectedTraceRoute.gateway_id" class="relative flex gap-x-4">
<div class="absolute left-0 top-0 flex w-12 justify-center h-6">
<div class="w-px bg-gray-200"></div>
</div>
<div class="my-auto relative flex flex-none items-center justify-center">
<div>
<div class="flex rounded-full h-12 w-12 text-white shadow" :class="[ `bg-[${getNodeColor(state.selectedTraceRoute.gateway_id)}]`, `text-[${getNodeTextColor(state.selectedTraceRoute.gateway_id)}]` ]">
<div class="mx-auto my-auto drop-shadow-sm">{{ findNodeById(state.selectedTraceRoute.gateway_id)?.short_name ?? "?" }}</div>
</div>
</div>
</div>
<div class="flex-auto py-0.5 text-sm leading-5 text-gray-500">
<div class="font-medium text-gray-900">{{ findNodeById(state.selectedTraceRoute.gateway_id)?.long_name || '???' }}</div>
<div>Hex ID: !{{ Number(state.selectedTraceRoute.gateway_id).toString(16) }}</div>
<div>Gated the packet to MQTT</div>
</div>
</li>
</ul>
</div>
<div>
<div class="bg-gray-200 p-2 font-semibold">Raw Data</div>
<div class="text-sm text-gray-700">
<pre class="bg-gray-100 rounded-sm p-2 overflow-x-auto">{{ JSON.stringify(state.selectedTraceRoute, null, 4) }}</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</transition>
</div>
</template>