Simon Hunt

GUI -- TopoView - re-instated Instance selection showing mastership of switches.

- default showHosts to equal false.
- fixed bug on link immediate restyling on theme change.

Change-Id: I3fc456086cc104df456725290f285a20309cdfe8
...@@ -300,6 +300,10 @@ ...@@ -300,6 +300,10 @@
300 300
301 /* --- Topo Nodes --- */ 301 /* --- Topo Nodes --- */
302 302
303 +#ov-topo svg .suppressed {
304 + opacity: 0.2 !important;
305 +}
306 +
303 #ov-topo svg .node { 307 #ov-topo svg .node {
304 cursor: pointer; 308 cursor: pointer;
305 } 309 }
......
...@@ -103,9 +103,9 @@ ...@@ -103,9 +103,9 @@
103 } 103 }
104 104
105 function handleEscape() { 105 function handleEscape() {
106 - if (false) { 106 + if (tis.showMaster()) {
107 - // TODO: if an instance is selected, cancel the affinity mapping 107 + // if an instance is selected, cancel the affinity mapping
108 - // tis.cancelAffinity() 108 + tis.cancelAffinity()
109 109
110 } else if (tss.haveDetails()) { 110 } else if (tss.haveDetails()) {
111 // else if we have node selections, deselect them all 111 // else if we have node selections, deselect them all
...@@ -288,7 +288,7 @@ ...@@ -288,7 +288,7 @@
288 288
289 forceG = zoomLayer.append('g').attr('id', 'topo-force'); 289 forceG = zoomLayer.append('g').attr('id', 'topo-force');
290 tfs.initForce(forceG, uplink, dim); 290 tfs.initForce(forceG, uplink, dim);
291 - tis.initInst(); 291 + tis.initInst({ showMastership: tfs.showMastership });
292 tps.initPanels({ sendEvent: tes.sendEvent }); 292 tps.initPanels({ sendEvent: tes.sendEvent });
293 tes.openSock(); 293 tes.openSock();
294 294
......
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
73 rlk = network.revLinkToKey, 73 rlk = network.revLinkToKey,
74 deviceLabelIndex = 0, // for device label cycling 74 deviceLabelIndex = 0, // for device label cycling
75 hostLabelIndex = 0, // for host label cycling 75 hostLabelIndex = 0, // for host label cycling
76 - showHosts = true, // whether hosts are displayed 76 + showHosts = false, // whether hosts are displayed
77 showOffline = true, // whether offline devices are displayed 77 showOffline = true, // whether offline devices are displayed
78 oblique = false, // whether we are in the oblique view 78 oblique = false, // whether we are in the oblique view
79 nodeLock = false, // whether nodes can be dragged or not (locked) 79 nodeLock = false, // whether nodes can be dragged or not (locked)
...@@ -287,14 +287,15 @@ ...@@ -287,14 +287,15 @@
287 .clamp(true), 287 .clamp(true),
288 allLinkTypes = 'direct indirect optical tunnel'; 288 allLinkTypes = 'direct indirect optical tunnel';
289 289
290 - function restyleLinkElement(ldata) { 290 + function restyleLinkElement(ldata, immediate) {
291 // this fn's job is to look at raw links and decide what svg classes 291 // this fn's job is to look at raw links and decide what svg classes
292 // need to be applied to the line element in the DOM 292 // need to be applied to the line element in the DOM
293 var th = ts.theme(), 293 var th = ts.theme(),
294 el = ldata.el, 294 el = ldata.el,
295 type = ldata.type(), 295 type = ldata.type(),
296 lw = ldata.linkWidth(), 296 lw = ldata.linkWidth(),
297 - online = ldata.online(); 297 + online = ldata.online(),
298 + delay = immediate ? 0 : 1000;
298 299
299 el.classed('link', true); 300 el.classed('link', true);
300 el.classed('inactive', !online); 301 el.classed('inactive', !online);
...@@ -303,7 +304,7 @@ ...@@ -303,7 +304,7 @@
303 el.classed(type, true); 304 el.classed(type, true);
304 } 305 }
305 el.transition() 306 el.transition()
306 - .duration(1000) 307 + .duration(delay)
307 .attr('stroke-width', linkScale(lw)) 308 .attr('stroke-width', linkScale(lw))
308 .attr('stroke', linkConfig[th].baseColor); 309 .attr('stroke', linkConfig[th].baseColor);
309 } 310 }
...@@ -548,6 +549,35 @@ ...@@ -548,6 +549,35 @@
548 } 549 }
549 } 550 }
550 551
552 + function showMastership(masterId) {
553 + if (!masterId) {
554 + restoreLayerState();
555 + } else {
556 + showMastershipFor(masterId);
557 + }
558 + }
559 +
560 + function restoreLayerState() {
561 + // NOTE: this level of indirection required, for when we have
562 + // the layer filter functionality re-implemented
563 + suppressLayers(false);
564 + }
565 +
566 + function showMastershipFor(id) {
567 + suppressLayers(true);
568 + node.each(function (n) {
569 + if (n.master === id) {
570 + n.el.classed('suppressed', false);
571 + }
572 + });
573 + }
574 +
575 + function suppressLayers(b) {
576 + node.classed('suppressed', b);
577 + link.classed('suppressed', b);
578 +// d3.selectAll('svg .port').classed('inactive', b);
579 +// d3.selectAll('svg .portText').classed('inactive', b);
580 + }
551 581
552 // ========================================== 582 // ==========================================
553 583
...@@ -777,7 +807,7 @@ ...@@ -777,7 +807,7 @@
777 .data(network.links, function (d) { return d.key; }); 807 .data(network.links, function (d) { return d.key; });
778 808
779 // operate on existing links: 809 // operate on existing links:
780 - //link.each(linkExisting); 810 + link.each(linkExisting);
781 811
782 // operate on entering links: 812 // operate on entering links:
783 var entering = link.enter() 813 var entering = link.enter()
...@@ -842,7 +872,9 @@ ...@@ -842,7 +872,9 @@
842 return data; 872 return data;
843 } 873 }
844 874
845 - //function linkExisting(d) { } 875 + function linkExisting(d) {
876 + restyleLinkElement(d, true);
877 + }
846 878
847 function linkEntering(d) { 879 function linkEntering(d) {
848 var link = d3.select(this); 880 var link = d3.select(this);
...@@ -1067,6 +1099,11 @@ ...@@ -1067,6 +1099,11 @@
1067 1099
1068 icfg = is.iconConfig(); 1100 icfg = is.iconConfig();
1069 1101
1102 + var themeListener = ts.addListener(function () {
1103 + updateLinks();
1104 + updateNodes();
1105 + });
1106 +
1070 // forceG is the SVG group to display the force layout in 1107 // forceG is the SVG group to display the force layout in
1071 // uplink is the api from the main topo source file 1108 // uplink is the api from the main topo source file
1072 // dim is the initial dimensions of the SVG as [w,h] 1109 // dim is the initial dimensions of the SVG as [w,h]
...@@ -1117,6 +1154,8 @@ ...@@ -1117,6 +1154,8 @@
1117 tts.destroyTraffic(); 1154 tts.destroyTraffic();
1118 tss.destroySelect(); 1155 tss.destroySelect();
1119 tms.destroyModel(); 1156 tms.destroyModel();
1157 + ts.removeListener(themeListener);
1158 + themeListener = null;
1120 } 1159 }
1121 1160
1122 return { 1161 return {
...@@ -1129,6 +1168,7 @@ ...@@ -1129,6 +1168,7 @@
1129 toggleOffline: toggleOffline, 1168 toggleOffline: toggleOffline,
1130 cycleDeviceLabels: cycleDeviceLabels, 1169 cycleDeviceLabels: cycleDeviceLabels,
1131 unpin: unpin, 1170 unpin: unpin,
1171 + showMastership: showMastership,
1132 1172
1133 addDevice: addDevice, 1173 addDevice: addDevice,
1134 updateDevice: updateDevice, 1174 updateDevice: updateDevice,
......
...@@ -25,6 +25,12 @@ ...@@ -25,6 +25,12 @@
25 // injected refs 25 // injected refs
26 var $log, ps, sus, gs, ts, fs; 26 var $log, ps, sus, gs, ts, fs;
27 27
28 + // api from topo
29 + var api;
30 + /*
31 + showMastership( id )
32 + */
33 +
28 // configuration 34 // configuration
29 var instCfg = { 35 var instCfg = {
30 rectPad: 8, 36 rectPad: 8,
...@@ -120,13 +126,8 @@ ...@@ -120,13 +126,8 @@
120 .classed('affinity', false); 126 .classed('affinity', false);
121 el.classed('affinity', true); 127 el.classed('affinity', true);
122 128
123 - // TODO: suppress the layers and highlight only specific nodes... 129 + // suppress all elements except nodes whose master is this instance
124 - //suppressLayers(true); 130 + api.showMastership(d.id);
125 - //node.each(function (n) {
126 - // if (n.master === d.id) {
127 - // n.el.classed('suppressed', false);
128 - // }
129 - //});
130 oiShowMaster = true; 131 oiShowMaster = true;
131 } 132 }
132 133
...@@ -134,8 +135,7 @@ ...@@ -134,8 +135,7 @@
134 d3.selectAll('.onosInst') 135 d3.selectAll('.onosInst')
135 .classed('mastership affinity', false); 136 .classed('mastership affinity', false);
136 137
137 - // TODO: restore layer state 138 + api.showMastership(null);
138 - //restoreLayerState();
139 oiShowMaster = false; 139 oiShowMaster = false;
140 } 140 }
141 141
...@@ -284,7 +284,8 @@ ...@@ -284,7 +284,8 @@
284 } 284 }
285 } 285 }
286 286
287 - function initInst() { 287 + function initInst(_api_) {
288 + api = _api_;
288 oiBox = ps.createPanel(idIns, instOpts); 289 oiBox = ps.createPanel(idIns, instOpts);
289 oiBox.show(); 290 oiBox.show();
290 291
...@@ -327,10 +328,13 @@ ...@@ -327,10 +328,13 @@
327 updateInstance: updateInstance, 328 updateInstance: updateInstance,
328 removeInstance: removeInstance, 329 removeInstance: removeInstance,
329 330
331 + cancelAffinity: cancelAffinity,
332 +
330 isVisible: function () { return oiBox.isVisible(); }, 333 isVisible: function () { return oiBox.isVisible(); },
331 show: function () { oiBox.show(); }, 334 show: function () { oiBox.show(); },
332 hide: function () { oiBox.hide(); }, 335 hide: function () { oiBox.hide(); },
333 - toggle: function () { oiBox.toggle(); } 336 + toggle: function () { oiBox.toggle(); },
337 + showMaster: function () { return oiShowMaster; }
334 }; 338 };
335 }]); 339 }]);
336 }()); 340 }());
......