Implement AS and prefix detail pages
- Implement handleASDetail() and handlePrefixDetail() HTML handlers - Create AS detail HTML template with prefix listings - Create prefix detail HTML template with route information - Add timeSince template function for human-readable durations - Update templates.go to include new templates - Server-side rendered pages as requested (no client-side API calls)
This commit is contained in:
253
internal/templates/prefix_detail.html
Normal file
253
internal/templates/prefix_detail.html
Normal file
@@ -0,0 +1,253 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{.Prefix}} - RouteWatch</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
background: #f5f5f5;
|
||||
color: #333;
|
||||
}
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
background: white;
|
||||
padding: 30px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
h1 {
|
||||
margin: 0 0 10px 0;
|
||||
color: #2c3e50;
|
||||
font-family: monospace;
|
||||
font-size: 28px;
|
||||
}
|
||||
.subtitle {
|
||||
color: #7f8c8d;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.info-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
.info-card {
|
||||
background: #f8f9fa;
|
||||
padding: 20px;
|
||||
border-radius: 6px;
|
||||
border-left: 4px solid #3498db;
|
||||
}
|
||||
.info-label {
|
||||
font-size: 14px;
|
||||
color: #7f8c8d;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.info-value {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: #2c3e50;
|
||||
}
|
||||
.routes-section {
|
||||
margin-top: 30px;
|
||||
}
|
||||
.routes-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.routes-header h2 {
|
||||
margin: 0;
|
||||
color: #2c3e50;
|
||||
}
|
||||
.route-count {
|
||||
background: #e74c3c;
|
||||
color: white;
|
||||
padding: 5px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.route-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
background: white;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.route-table th {
|
||||
background: #34495e;
|
||||
color: white;
|
||||
padding: 12px;
|
||||
text-align: left;
|
||||
font-weight: 600;
|
||||
}
|
||||
.route-table td {
|
||||
padding: 12px;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
}
|
||||
.route-table tr:hover {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
.route-table tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
.as-link {
|
||||
color: #3498db;
|
||||
text-decoration: none;
|
||||
}
|
||||
.as-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.peer-ip {
|
||||
font-family: monospace;
|
||||
font-size: 14px;
|
||||
color: #555;
|
||||
}
|
||||
.as-path {
|
||||
font-family: monospace;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
max-width: 300px;
|
||||
overflow-x: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.age {
|
||||
color: #7f8c8d;
|
||||
font-size: 14px;
|
||||
}
|
||||
.nav-link {
|
||||
display: inline-block;
|
||||
margin-bottom: 20px;
|
||||
color: #3498db;
|
||||
text-decoration: none;
|
||||
}
|
||||
.nav-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.origins-section {
|
||||
margin-top: 30px;
|
||||
background: #f8f9fa;
|
||||
padding: 20px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.origins-section h3 {
|
||||
margin-top: 0;
|
||||
color: #2c3e50;
|
||||
}
|
||||
.origin-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
.origin-item {
|
||||
background: white;
|
||||
padding: 10px 15px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e0e0e0;
|
||||
}
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #7f8c8d;
|
||||
}
|
||||
@media (max-width: 768px) {
|
||||
.container {
|
||||
padding: 20px;
|
||||
}
|
||||
.info-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.route-table {
|
||||
font-size: 14px;
|
||||
}
|
||||
.as-path {
|
||||
max-width: 150px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<a href="/status" class="nav-link">← Back to Status</a>
|
||||
|
||||
<h1>{{.Prefix}}</h1>
|
||||
<p class="subtitle">IPv{{.IPVersion}} Prefix{{if .MaskLength}} • /{{.MaskLength}}{{end}}</p>
|
||||
|
||||
<div class="info-grid">
|
||||
<div class="info-card">
|
||||
<div class="info-label">Seen from Peers</div>
|
||||
<div class="info-value">{{.PeerCount}}</div>
|
||||
</div>
|
||||
<div class="info-card">
|
||||
<div class="info-label">Origin ASNs</div>
|
||||
<div class="info-value">{{.OriginCount}}</div>
|
||||
</div>
|
||||
<div class="info-card">
|
||||
<div class="info-label">IP Version</div>
|
||||
<div class="info-value">IPv{{.IPVersion}}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{if .Origins}}
|
||||
<div class="origins-section">
|
||||
<h3>Origin ASNs</h3>
|
||||
<div class="origin-list">
|
||||
{{range .Origins}}
|
||||
<div class="origin-item">
|
||||
<a href="/as/{{.Number}}" class="as-link">AS{{.Number}}</a>
|
||||
{{if .Handle}} ({{.Handle}}){{end}}
|
||||
<span style="color: #7f8c8d; margin-left: 10px;">{{.PeerCount}} peer{{if ne .PeerCount 1}}s{{end}}</span>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
{{if .Routes}}
|
||||
<div class="routes-section">
|
||||
<div class="routes-header">
|
||||
<h2>Route Details</h2>
|
||||
<span class="route-count">{{.PeerCount}} route{{if ne .PeerCount 1}}s{{end}}</span>
|
||||
</div>
|
||||
<table class="route-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Origin AS</th>
|
||||
<th>Peer IP</th>
|
||||
<th>AS Path</th>
|
||||
<th>Next Hop</th>
|
||||
<th>Last Updated</th>
|
||||
<th>Age</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Routes}}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="/as/{{.OriginASN}}" class="as-link">AS{{.OriginASN}}</a>
|
||||
</td>
|
||||
<td class="peer-ip">{{.PeerIP}}</td>
|
||||
<td class="as-path">{{range $i, $as := .ASPath}}{{if $i}} → {{end}}{{$as}}{{end}}</td>
|
||||
<td class="peer-ip">{{.NextHop}}</td>
|
||||
<td>{{.LastUpdated.Format "2006-01-02 15:04:05"}}</td>
|
||||
<td class="age">{{.LastUpdated | timeSince}}</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="empty-state">
|
||||
<p>No routes found for this prefix</p>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user