Update coord display in ui to account for segments

This commit is contained in:
Kyle Havlovitz 2017-08-29 19:30:46 -07:00
parent 14b027a3c2
commit 21513b0393
No known key found for this signature in database
GPG Key ID: 8A5E6B173056AD6C
5 changed files with 53 additions and 44 deletions

File diff suppressed because one or more lines are too long

View File

@ -44,12 +44,12 @@ type AgentMember struct {
DelegateCur uint8
}
// MemberOpts is used for querying member information.
type MemberOpts struct {
// MembersOpts is used for querying member information.
type MembersOpts struct {
// Wan is whether to show members from the LAN.
Wan bool
// Segment is the LAN segment to show members
// Segment is the LAN segment to show members.
Segment string
}
@ -265,12 +265,12 @@ func (a *Agent) Members(wan bool) ([]*AgentMember, error) {
return out, nil
}
// Members returns the known gossip members. The WAN
// flag can be used to query a server for WAN members.
func (a *Agent) MembersOpts(wan bool, segment string) ([]*AgentMember, error) {
// MembersOpts returns the known gossip members and can be passed
// additional options for WAN/segment filtering.
func (a *Agent) MembersOpts(opts MembersOpts) ([]*AgentMember, error) {
r := a.c.newRequest("GET", "/v1/agent/members")
r.params.Set("segment", segment)
if wan {
r.params.Set("segment", opts.Segment)
if opts.Wan {
r.params.Set("wan", "1")
}

View File

@ -65,7 +65,10 @@ func (c *MembersCommand) Run(args []string) int {
return 1
}
members, err := client.Agent().MembersOpts(wan, segment)
members, err := client.Agent().MembersOpts(consulapi.MembersOpts{
Wan: wan,
Segment: segment,
})
if err != nil {
c.UI.Error(fmt.Sprintf("Error retrieving members: %s", err))
return 1

View File

@ -101,7 +101,12 @@ function notify(message, ttl) {
// TODO: not sure how to how do to this more Ember.js-y
function tomographyMouseOver(el) {
var buf = el.getAttribute('data-node') + ' - ' + el.getAttribute('data-distance') + 'ms';
var segment = el.getAttribute('data-segment');
if (segment !== "") {
buf += ' (Segment: ' + segment + ')';
}
document.getElementById('tomography-node-info').innerHTML = buf;
}
Ember.Handlebars.helper('tomographyGraph', function(tomography, size) {
@ -146,7 +151,7 @@ Ember.Handlebars.helper('tomographyGraph', function(tomography, size) {
}
distances.forEach(function (d, i) {
buf += ' <line transform="rotate(' + (i * 360 / n) + ')" y2="' + (-insetSize * (d.distance / max)) + '" ' +
'data-node="' + d.node + '" data-distance="' + d.distance + '" onmouseover="tomographyMouseOver(this);"/>';
'data-node="' + d.node + '" data-distance="' + d.distance + '" data-segment="' + d.segment + '" onmouseover="tomographyMouseOver(this);"/>';
});
buf += '' +
' </g>' +

View File

@ -292,10 +292,11 @@ App.NodesShowRoute = App.BaseRoute.extend({
var distances = [];
dc.coordinates.forEach(function (node) {
if (params.name == node.Node) {
var segment = node.Segment;
dc.coordinates.forEach(function (other) {
if (node.Node != other.Node) {
if (node.Node != other.Node && other.Segment == segment) {
var dist = distance(node, other);
distances.push({ node: other.Node, distance: dist });
distances.push({ node: other.Node, distance: dist, segment: segment });
sum += dist;
if (dist < min) {
min = dist;