Update AS path display to show handles with clickable links

- Change AS path from descriptions to handles (short names)
- Make each AS in the path a clickable link to /as/<asn>
- Add font-weight to AS links in path for better visibility
- Prevent word wrapping on all table columns except AS path
- Remove unused maxASDescriptionLength constant
This commit is contained in:
Jeffrey Paul 2025-07-28 18:31:35 +02:00
parent 81267431f7
commit 1dcde74a90
3 changed files with 185289 additions and 22 deletions

View File

@ -20,11 +20,6 @@ import (
"github.com/go-chi/chi/v5"
)
const (
// maxASDescriptionLength is the maximum length for AS descriptions in the UI
maxASDescriptionLength = 20
)
// handleRoot returns a handler that redirects to /status
func (s *Server) handleRoot() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
@ -651,33 +646,29 @@ func (s *Server) handlePrefixDetail() http.HandlerFunc {
origins = append(origins, origin)
}
// Create enhanced routes with AS path descriptions
// Create enhanced routes with AS path handles
type ASPathEntry struct {
Number int
Description string
Number int
Handle string
}
type EnhancedRoute struct {
database.LiveRoute
ASPathWithDesc []ASPathEntry
ASPathWithHandle []ASPathEntry
}
enhancedRoutes := make([]EnhancedRoute, len(routes))
for i, route := range routes {
enhancedRoute := EnhancedRoute{
LiveRoute: route,
ASPathWithDesc: make([]ASPathEntry, len(route.ASPath)),
LiveRoute: route,
ASPathWithHandle: make([]ASPathEntry, len(route.ASPath)),
}
// Look up description for each AS in the path
// Look up handle for each AS in the path
for j, asn := range route.ASPath {
desc := asinfo.GetDescription(asn)
// Truncate description if longer than maxASDescriptionLength characters
if len(desc) > maxASDescriptionLength {
desc = desc[:maxASDescriptionLength] + "..."
}
enhancedRoute.ASPathWithDesc[j] = ASPathEntry{
Number: asn,
Description: desc,
handle := asinfo.GetHandle(asn)
enhancedRoute.ASPathWithHandle[j] = ASPathEntry{
Number: asn,
Handle: handle,
}
}

View File

@ -92,6 +92,7 @@
.route-table td {
padding: 12px;
border-bottom: 1px solid #e0e0e0;
white-space: nowrap;
}
.route-table tr:hover {
background: #f8f9fa;
@ -117,9 +118,12 @@
color: #666;
max-width: 600px;
word-wrap: break-word;
white-space: normal;
white-space: normal !important;
line-height: 1.5;
}
.as-path .as-link {
font-weight: 600;
}
.age {
color: #7f8c8d;
font-size: 14px;
@ -236,7 +240,7 @@
<a href="/as/{{.OriginASN}}" class="as-link">AS{{.OriginASN}}</a>
</td>
<td class="peer-ip">{{.PeerIP}}</td>
<td class="as-path">{{range $i, $as := .ASPathWithDesc}}{{if $i}} → {{end}}{{if $as.Description}}{{$as.Description}} ({{$as.Number}}){{else}}AS{{$as.Number}}{{end}}{{end}}</td>
<td class="as-path">{{range $i, $as := .ASPathWithHandle}}{{if $i}} → {{end}}<a href="/as/{{$as.Number}}" class="as-link">{{if $as.Handle}}{{$as.Handle}}{{else}}AS{{$as.Number}}{{end}}</a>{{end}}</td>
<td class="peer-ip">{{.NextHop}}</td>
<td>{{.LastUpdated.Format "2006-01-02 15:04:05"}}</td>
<td class="age">{{.LastUpdated | timeSince}}</td>

185272
log.txt

File diff suppressed because it is too large Load Diff