Add Expandable attribute to detailed-pane rows

This commit is contained in:
Alfonso Acosta
2015-08-20 15:26:23 +00:00
parent 0fd54e40da
commit c78f9d812c
2 changed files with 34 additions and 21 deletions
+6 -5
View File
@@ -46,6 +46,7 @@ type Row struct {
Key string `json:"key"` // e.g. Ingress
ValueMajor string `json:"value_major"` // e.g. 25
ValueMinor string `json:"value_minor,omitempty"` // e.g. KB/s
Expandable bool `json:expandable,omitempty` // Whether it can be expanded (hidden by default)
}
type rows []Row
@@ -99,21 +100,21 @@ func MakeDetailedNode(r report.Report, n RenderableNode) DetailedNode {
{
rows := []Row{}
if n.EdgeMetadata.MaxConnCountTCP != nil {
rows = append(rows, Row{"TCP connections", strconv.FormatUint(*n.EdgeMetadata.MaxConnCountTCP, 10), ""})
rows = append(rows, Row{"TCP connections", strconv.FormatUint(*n.EdgeMetadata.MaxConnCountTCP, 10), "", false})
}
if rate, ok := rate(n.EdgeMetadata.EgressPacketCount); ok {
rows = append(rows, Row{"Egress packet rate", fmt.Sprintf("%.0f", rate), "packets/sec"})
rows = append(rows, Row{"Egress packet rate", fmt.Sprintf("%.0f", rate), "packets/sec", false})
}
if rate, ok := rate(n.EdgeMetadata.IngressPacketCount); ok {
rows = append(rows, Row{"Ingress packet rate", fmt.Sprintf("%.0f", rate), "packets/sec"})
rows = append(rows, Row{"Ingress packet rate", fmt.Sprintf("%.0f", rate), "packets/sec", false})
}
if rate, ok := rate(n.EdgeMetadata.EgressByteCount); ok {
s, unit := shortenByteRate(rate)
rows = append(rows, Row{"Egress byte rate", s, unit})
rows = append(rows, Row{"Egress byte rate", s, unit, false})
}
if rate, ok := rate(n.EdgeMetadata.IngressByteCount); ok {
s, unit := shortenByteRate(rate)
rows = append(rows, Row{"Ingress byte rate", s, unit})
rows = append(rows, Row{"Ingress byte rate", s, unit, false})
}
if len(rows) > 0 {
tables = append(tables, Table{"Connections", true, connectionsRank, rows})
+28 -16
View File
@@ -19,8 +19,8 @@ func TestOriginTable(t *testing.T) {
Numeric: false,
Rank: 2,
Rows: []render.Row{
{"Name", "apache", ""},
{"PID", test.ServerPID, ""},
{"Name", "apache", "", false},
{"PID", test.ServerPID, "", false},
},
},
test.ServerHostNodeID: {
@@ -28,9 +28,9 @@ func TestOriginTable(t *testing.T) {
Numeric: false,
Rank: 1,
Rows: []render.Row{
{"Host name", test.ServerHostName, ""},
{"Load", "0.01 0.01 0.01", ""},
{"Operating system", "Linux", ""},
{"Host name", test.ServerHostName, "", false},
{"Load", "0.01 0.01 0.01", "", false},
{"Operating system", "Linux", "", false},
},
},
} {
@@ -63,6 +63,7 @@ func TestMakeDetailedHostNode(t *testing.T) {
Key: "TCP connections",
ValueMajor: "3",
ValueMinor: "",
Expandable: false,
},
},
},
@@ -75,16 +76,19 @@ func TestMakeDetailedHostNode(t *testing.T) {
Key: "Host name",
ValueMajor: "client.hostname.com",
ValueMinor: "",
Expandable: false,
},
{
Key: "Load",
ValueMajor: "0.01 0.01 0.01",
ValueMinor: "",
Expandable: false,
},
{
Key: "Operating system",
ValueMajor: "Linux",
ValueMinor: "",
Expandable: false,
},
},
},
@@ -97,11 +101,13 @@ func TestMakeDetailedHostNode(t *testing.T) {
Key: "Client",
ValueMajor: "Server",
ValueMinor: "",
Expandable: false,
},
{
Key: "10.10.10.20",
ValueMajor: "192.168.1.1",
ValueMinor: "",
Expandable: false,
},
},
},
@@ -126,8 +132,8 @@ func TestMakeDetailedContainerNode(t *testing.T) {
Numeric: true,
Rank: 100,
Rows: []render.Row{
{"Egress packet rate", "105", "packets/sec"},
{"Egress byte rate", "1.0", "KBps"},
{"Egress packet rate", "105", "packets/sec", false},
{"Egress byte rate", "1.0", "KBps", false},
},
},
{
@@ -135,9 +141,9 @@ func TestMakeDetailedContainerNode(t *testing.T) {
Numeric: false,
Rank: 3,
Rows: []render.Row{
{"ID", test.ServerContainerID, ""},
{"Name", "server", ""},
{"Image ID", test.ServerContainerImageID, ""},
{"ID", test.ServerContainerID, "", false},
{"Name", "server", "", false},
{"Image ID", test.ServerContainerImageID, "", false},
},
},
{
@@ -145,8 +151,8 @@ func TestMakeDetailedContainerNode(t *testing.T) {
Numeric: false,
Rank: 2,
Rows: []render.Row{
{"Name", "apache", ""},
{"PID", test.ServerPID, ""},
{"Name", "apache", "", false},
{"PID", test.ServerPID, "", false},
},
},
{
@@ -154,45 +160,51 @@ func TestMakeDetailedContainerNode(t *testing.T) {
Numeric: false,
Rank: 1,
Rows: []render.Row{
{"Host name", test.ServerHostName, ""},
{"Load", "0.01 0.01 0.01", ""},
{"Operating system", "Linux", ""},
{"Host name", test.ServerHostName, "", false},
{"Load", "0.01 0.01 0.01", "", false},
{"Operating system", "Linux", "", false},
},
},
{
Title: "Connection Details",
Numeric: false,
Rows: []render.Row{
{"Client", "Server", ""},
{"Client", "Server", "", false},
{
fmt.Sprintf("%s:%s", test.UnknownClient1IP, test.ClientPort54010),
fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
"",
false,
},
{
fmt.Sprintf("%s:%s", test.UnknownClient1IP, test.ClientPort54020),
fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
"",
false,
},
{
fmt.Sprintf("%s:%s", test.UnknownClient3IP, test.ClientPort54020),
fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
"",
false,
},
{
fmt.Sprintf("%s:%s", test.ClientIP, test.ClientPort54001),
fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
"",
false,
},
{
fmt.Sprintf("%s:%s", test.ClientIP, test.ClientPort54002),
fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
"",
false,
},
{
fmt.Sprintf("%s:%s", test.RandomClientIP, test.ClientPort12345),
fmt.Sprintf("%s:%s", test.ServerIP, test.ServerPort),
"",
false,
},
},
},