Skip to content

Commit

Permalink
chore: added trace style
Browse files Browse the repository at this point in the history
Minor improvements to presentation - color & layout.
  • Loading branch information
alanconway committed Nov 14, 2024
1 parent db2fe33 commit 96239db
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
20 changes: 11 additions & 9 deletions pkg/browser/correlate.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ 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
ConsoleURL *url.URL
UpdateTime time.Duration

// Other context

Err error // Accumulated errors from template.
Browser *Browser
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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]])
Expand Down
9 changes: 3 additions & 6 deletions pkg/browser/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions pkg/browser/templates/correlate.html.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
<input type="text" id="goal" name="goal" value="{{.Goal}}" size="50" accesskey="k">
<br>
</div>
<p>
<div>
<input type="submit" id="submit" value="Update Graph">
<span id="waiting" style="display:none;"><img src="images/gears.gif" id="loading"></span>
</p>
</div>
</form>

<script type="text/javascript">
Expand Down

0 comments on commit 96239db

Please sign in to comment.