Run manual diagnostic attachments in the background
This commit is contained in:
1 parent
d845a5e4b6
commit
89ac4d5bcd
40 files changed
+1560
-58
No files matched your search
@@ -2,6 +2,7 @@ package dashboard
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -122,6 +123,39 @@ type ipsPageData struct {
|
||||
type ipDetailData struct {
|
||||
PageData
|
||||
Detail ipDetailResponse
|
||||
Events []eventView
|
||||
}
|
||||
|
||||
// tracerouteView is a parsed traceroute_result event payload.
|
||||
type tracerouteView struct {
|
||||
Target string `json:"target"`
|
||||
Host string `json:"host"`
|
||||
IP string `json:"ip"`
|
||||
Status string `json:"status"`
|
||||
DurationMS int64 `json:"duration_ms"`
|
||||
Output string `json:"output"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
// eventView is an event plus, for traceroute_result, its parsed payload
|
||||
// (nil = render the raw payload as for any other event).
|
||||
type eventView struct {
|
||||
event
|
||||
Trace *tracerouteView
|
||||
}
|
||||
|
||||
func buildEventViews(events []event) []eventView {
|
||||
out := make([]eventView, len(events))
|
||||
for i, e := range events {
|
||||
out[i].event = e
|
||||
if e.EventType == "traceroute_result" {
|
||||
var t tracerouteView
|
||||
if json.Unmarshal([]byte(e.Payload), &t) == nil {
|
||||
out[i].Trace = &t
|
||||
}
|
||||
}
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// loadIPsData fetches the page of the queue selected by the request's
|
||||
@@ -193,7 +227,7 @@ func (s *Server) handleIPsPage(w http.ResponseWriter, r *http.Request) {
|
||||
func (s *Server) handleIPDetail(w http.ResponseWriter, r *http.Request) {
|
||||
ip := r.PathValue("ip")
|
||||
detail, err := s.CA.GetIP(r.Context(), ip)
|
||||
data := ipDetailData{Detail: detail}
|
||||
data := ipDetailData{Detail: detail, Events: buildEventViews(detail.Events)}
|
||||
data.ActiveNav = "ips"
|
||||
data.Banner = bannerFor(err)
|
||||
s.renderPage(w, r, "ip_detail_page", data)
|
||||
|
||||
Reference in new issue
Block a user