mirror of
https://github.com/brianshea2/meshmap.net.git
synced 2024-11-09 23:24:09 -08:00
parse mqtt topic into reporting node and root topic
This commit is contained in:
parent
12e7815bd6
commit
b2021f7b31
|
@ -251,23 +251,18 @@
|
|||
}
|
||||
</tbody></table>
|
||||
<table><thead>
|
||||
<tr><th>Last seen</th><th>On MQTT topic</th></tr>
|
||||
<tr><th>Last seen</th><th>via</th><th>on root topic</th></tr>
|
||||
</thead><tbody>
|
||||
${Object.entries(seenBy).sort((a, b) => b[1] - a[1]).map(([topic, seen]) => {
|
||||
topic = html(topic).replace(/\/!([0-9a-f]+)$/, (match, reporterId) => {
|
||||
const reporterNum = Number(`0x${reporterId}`)
|
||||
if (data[reporterNum] === undefined) {
|
||||
return match
|
||||
}
|
||||
return `/${nodeLink(reporterNum, `!${reporterId}`)}`
|
||||
})
|
||||
return `
|
||||
<tr>
|
||||
<td>${since(seen)}</td>
|
||||
<td class="break">${topic}</td>
|
||||
</tr>
|
||||
`
|
||||
}).join('')}
|
||||
${Object.entries(seenBy).sort((a, b) => b[1] - a[1]).map(([topic, seen]) => `
|
||||
<tr>
|
||||
<td>${since(seen)}</td>
|
||||
<td>${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
|
||||
})}</td>
|
||||
<td class="break">${html(topic.replace(/\/2\/e\/[^\/]+\/[^\/]+$|\/2\/map\/$/, ''))}</td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
</tbody></table>
|
||||
`
|
||||
const populateDetailsLayer = () => {
|
||||
|
|
Loading…
Reference in a new issue