GUI - Fixed link labels - now they update correctly.
- Fixed repositioning of icon underlay rectangle on label cycle. - updateInstance() event handler started (WIP) Change-Id: Icd1d4bd35369ccbe9b6a5f6e92d95016f0e475d8
Showing
3 changed files
with
37 additions
and
8 deletions
| ... | @@ -12,9 +12,9 @@ | ... | @@ -12,9 +12,9 @@ |
| 12 | "of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0" | 12 | "of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0" |
| 13 | ], | 13 | ], |
| 14 | "labels": [ | 14 | "labels": [ |
| 15 | - "Load{rate=20, latest=20000}", | 15 | + "123 bytes", |
| 16 | - "Load{rate=10, latest=20000}", | 16 | + "10 bytes", |
| 17 | - "" | 17 | + "0 bytes" |
| 18 | ] | 18 | ] |
| 19 | } | 19 | } |
| 20 | ] | 20 | ] | ... | ... |
| ... | @@ -12,9 +12,9 @@ | ... | @@ -12,9 +12,9 @@ |
| 12 | "of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0" | 12 | "of:0000ffffffff0007/1-0E:2A:69:30:13:89/-1/0" |
| 13 | ], | 13 | ], |
| 14 | "labels": [ | 14 | "labels": [ |
| 15 | - "", | 15 | + "99997 bytes", |
| 16 | - "Load{rate=98, latest=38456}", | 16 | + "200 bytes", |
| 17 | - "Load{rate=98, latest=38789}" | 17 | + "3.1415926 bytes" |
| 18 | ] | 18 | ] |
| 19 | } | 19 | } |
| 20 | ] | 20 | ] | ... | ... |
| ... | @@ -643,6 +643,21 @@ | ... | @@ -643,6 +643,21 @@ |
| 643 | } | 643 | } |
| 644 | 644 | ||
| 645 | // TODO: fold updateX(...) methods into one base method; remove duplication | 645 | // TODO: fold updateX(...) methods into one base method; remove duplication |
| 646 | + | ||
| 647 | + function updateInstance(data) { | ||
| 648 | + evTrace(data); | ||
| 649 | + var inst = data.payload, | ||
| 650 | + id = inst.id, | ||
| 651 | + instData = onosInstances[id]; | ||
| 652 | + if (instData) { | ||
| 653 | + $.extend(instData, inst); | ||
| 654 | + updateInstances(); | ||
| 655 | + //updateInstanceState(instData); | ||
| 656 | + } else { | ||
| 657 | + logicError('updateInstance lookup fail. ID = "' + id + '"'); | ||
| 658 | + } | ||
| 659 | + } | ||
| 660 | + | ||
| 646 | function updateDevice(data) { | 661 | function updateDevice(data) { |
| 647 | evTrace(data); | 662 | evTrace(data); |
| 648 | var device = data.payload, | 663 | var device = data.payload, |
| ... | @@ -1082,7 +1097,15 @@ | ... | @@ -1082,7 +1097,15 @@ |
| 1082 | linkLabel = linkLabelG.selectAll('.linkLabel') | 1097 | linkLabel = linkLabelG.selectAll('.linkLabel') |
| 1083 | .data(data, function (d) { return d.id; }); | 1098 | .data(data, function (d) { return d.id; }); |
| 1084 | 1099 | ||
| 1085 | - linkLabel.text(function (d) { return d.label; }); | 1100 | + // for elements already existing, we need to update the text |
| 1101 | + // and adjust the rectangle size to fit | ||
| 1102 | + linkLabel.each(function (d) { | ||
| 1103 | + var el = d3.select(this), | ||
| 1104 | + rect = el.select('rect'), | ||
| 1105 | + text = el.select('text'); | ||
| 1106 | + text.text(d.label); | ||
| 1107 | + rect.attr(rectAroundText(el)); | ||
| 1108 | + }); | ||
| 1086 | 1109 | ||
| 1087 | entering = linkLabel.enter().append('g') | 1110 | entering = linkLabel.enter().append('g') |
| 1088 | .classed('linkLabel', true) | 1111 | .classed('linkLabel', true) |
| ... | @@ -1302,10 +1325,15 @@ | ... | @@ -1302,10 +1325,15 @@ |
| 1302 | .transition() | 1325 | .transition() |
| 1303 | .attr(box); | 1326 | .attr(box); |
| 1304 | 1327 | ||
| 1305 | - node.select('image') | 1328 | + node.select('rect.iconUnderlay') |
| 1306 | .transition() | 1329 | .transition() |
| 1307 | .attr('x', box.x + config.icons.xoff) | 1330 | .attr('x', box.x + config.icons.xoff) |
| 1308 | .attr('y', box.y + config.icons.yoff); | 1331 | .attr('y', box.y + config.icons.yoff); |
| 1332 | + | ||
| 1333 | + node.select('image') | ||
| 1334 | + .transition() | ||
| 1335 | + .attr('x', box.x + config.icons.xoff + 2) | ||
| 1336 | + .attr('y', box.y + config.icons.yoff + 2); | ||
| 1309 | } | 1337 | } |
| 1310 | 1338 | ||
| 1311 | function updateHostLabel(d) { | 1339 | function updateHostLabel(d) { |
| ... | @@ -1410,6 +1438,7 @@ | ... | @@ -1410,6 +1438,7 @@ |
| 1410 | var cfg = config.icons; | 1438 | var cfg = config.icons; |
| 1411 | node.append('rect') | 1439 | node.append('rect') |
| 1412 | .attr({ | 1440 | .attr({ |
| 1441 | + class: 'iconUnderlay', | ||
| 1413 | x: box.x + config.icons.xoff, | 1442 | x: box.x + config.icons.xoff, |
| 1414 | y: box.y + config.icons.yoff, | 1443 | y: box.y + config.icons.yoff, |
| 1415 | width: cfg.w, | 1444 | width: cfg.w, | ... | ... |
-
Please register or login to post a comment