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:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user