From 96239db6001be4428a4f51d59459e60c17524889 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Thu, 14 Nov 2024 12:30:43 -0500 Subject: [PATCH] chore: added trace style Minor improvements to presentation - color & layout. --- pkg/browser/correlate.go | 20 +++++++++++--------- pkg/browser/graph.go | 9 +++------ pkg/browser/templates/correlate.html.tmpl | 4 ++-- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/pkg/browser/correlate.go b/pkg/browser/correlate.go index 8cca40f..216bf9e 100644 --- a/pkg/browser/correlate.go +++ b/pkg/browser/correlate.go @@ -26,11 +26,14 @@ import ( // correlate web page handler. type correlate struct { URL *url.URL + // URL Query parameter fields + Start string // Start query Goal string // Goal class or neighbourhood depth // Computed fields used by page template. + Depth int Graph *Graph Diagram, DiagramTxt, DiagramImg string @@ -38,6 +41,7 @@ type correlate struct { UpdateTime time.Duration // Other context + Err error // Accumulated errors from template. Browser *Browser } @@ -128,11 +132,12 @@ func (c *correlate) update(req *http.Request) { } var domainAttrs = map[string]Attrs{ - "k8s": {"shape": "octagon", "fillcolor": "#326CE5", "fontcolor": "white"}, - "log": {"shape": "note", "fillcolor": "goldenrod", "fontname": "Courier"}, - "alert": {"shape": "triangle", "fillcolor": "yellow"}, - "metric": {"shape": "oval", "fillcolor": "wheat"}, - "netobserv": {"shape": "rectangle", "fillcolor": "brick"}, + "k8s": {"shape": "septagon", "fillcolor": "#326CE5", "fontcolor": "white"}, + "log": {"shape": "note", "fillcolor": "yellow"}, + "alert": {"shape": "triangle", "fillcolor": "yellow"}, + "metric": {"shape": "egg", "fillcolor": "wheat"}, + "netflow": {"shape": "component", "fillcolor": "skyblue"}, + "trace": {"shape": "folder", "fillcolor": "aquamarine"}, } func nodeToolTip(g *Graph, n *Node) string { @@ -161,15 +166,12 @@ func nodeToolTip(g *Graph, n *Node) string { // updateDiagram generates an SVG diagram via graphviz. func (c *correlate) updateDiagram() { - if c.Depth > 0 { - c.Graph.GraphAttrs["layout"] = "twopi" - } nodes := c.Graph.Nodes() for nodes.Next() { n := nodes.Node().(*Node) count := n.Model.Count a := n.Attrs - a["style"] += "filled" + a["style"] = "filled" a["label"] = fmt.Sprintf("%v\n%v", n.Model.Class, count) a["tooltip"] = nodeToolTip(c.Graph, n) maps.Copy(a, domainAttrs[strings.SplitN(n.Model.Class, ":", 2)[0]]) diff --git a/pkg/browser/graph.go b/pkg/browser/graph.go index 1ac2ae7..d09f042 100644 --- a/pkg/browser/graph.go +++ b/pkg/browser/graph.go @@ -30,12 +30,9 @@ func NewGraph(mg *models.Graph) *Graph { DirectedGraph: simple.NewDirectedGraph(), Model: mg, GraphAttrs: Attrs{ - "fontname": "Helvetica", - "fontsize": "12", - "splines": "true", - "overlap": "prism", - "overlap_scaling": "-2", - "layout": "dot", + "fontname": "Helvetica", + "fontsize": "10", + "layout": "dot", }, NodeAttrs: Attrs{ "fontname": "Helveticax", diff --git a/pkg/browser/templates/correlate.html.tmpl b/pkg/browser/templates/correlate.html.tmpl index 2dcd7d8..a17e183 100644 --- a/pkg/browser/templates/correlate.html.tmpl +++ b/pkg/browser/templates/correlate.html.tmpl @@ -11,10 +11,10 @@
-

+

-

+