From b08beabc6bbb16de607234c6db2de5e592882b5d Mon Sep 17 00:00:00 2001 From: root <165865819+brianshea2@users.noreply.github.com> Date: Tue, 11 Jun 2024 22:04:27 +0000 Subject: [PATCH] show channel name from mqtt topic --- website/index.html | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/website/index.html b/website/index.html index bb3dcc8..46f861e 100644 --- a/website/index.html +++ b/website/index.html @@ -251,18 +251,32 @@ } - + - ${Object.entries(seenBy).sort((a, b) => b[1] - a[1]).map(([topic, seen]) => ` - - - - - - `).join('')} + ${Object.entries(seenBy).sort((a, b) => b[1] - a[1]).map(([topic, seen]) => { + const captures = topic.match(/^(.*)(?:\/2\/e\/(.*)\/(![0-9a-f]+)|\/2\/map\/)$/) + let reporter + if (!captures[3]) { + reporter = 'map report' + } else if (captures[3] === id) { + reporter = 'self' + } else { + reporter = parseInt(captures[3].slice(1), 16) + if (data[reporter]) { + reporter = nodeLink(reporter, captures[3]) + } else { + reporter = captures[3] + } + } + return ` + + + + + + + ` + }).join('')}
Last seenviaon root topic
Last seenviaroot topicchannel
${since(seen)}${topic.endsWith('/2/map/') ? 'map report' : topic.endsWith(`/${id}`) ? 'self' : topic.replace(/^.*\/(![0-9a-f]+)$/, (_, reporterId) => { - const reporterNum = Number(`0x${reporterId.slice(1)}`) - return data[reporterNum] ? nodeLink(reporterNum, reporterId) : reporterId - })}${html(topic.replace(/\/2\/e\/[^\/]+\/[^\/]+$|\/2\/map\/$/, ''))}
${since(seen)}${reporter}${html(captures[1])}${html(captures[2] ?? '')}
` const populateDetailsLayer = () => {