Simon Hunt
Committed by Gerrit Code Review

GUI -- [ONOS-324] - making hosts invisible by default.

 - press the 'H' key to toggle host visibility.
 - minor update to 'simple' scenario events.
 - cleanup of alert usage.

Change-Id: I531417720e6b98e795c53729b0c30775b88f8fc1
...@@ -10,10 +10,13 @@ ...@@ -10,10 +10,13 @@
10 "lng": -122.4167 10 "lng": -122.4167
11 }, 11 },
12 "labels": [ 12 "labels": [
13 - "0000ffffffff0008", 13 + "",
14 - "FF:FF:FF:FF:00:08",
15 "sw-8", 14 "sw-8",
16 - "" 15 + "0000ffffffff0008"
17 - ] 16 + ],
17 + "metaUi": {
18 + "x": 520,
19 + "y": 350
20 + }
18 } 21 }
19 } 22 }
......
...@@ -4,16 +4,19 @@ ...@@ -4,16 +4,19 @@
4 "id": "of:0000ffffffff0003", 4 "id": "of:0000ffffffff0003",
5 "type": "switch", 5 "type": "switch",
6 "online": false, 6 "online": false,
7 - "labels": [
8 - "0000ffffffff0003",
9 - "FF:FF:FF:FF:00:03",
10 - "sw-3",
11 - ""
12 - ],
13 "location": { 7 "location": {
14 "type": "latlng", 8 "type": "latlng",
15 "lat": 40.7127, 9 "lat": 40.7127,
16 "lng": -74.0059 10 "lng": -74.0059
11 + },
12 + "labels": [
13 + "",
14 + "sw-3",
15 + "0000ffffffff0003"
16 + ],
17 + "metaUi": {
18 + "x": 800,
19 + "y": 280
17 } 20 }
18 } 21 }
19 } 22 }
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
5 "type": "switch", 5 "type": "switch",
6 "online": true, 6 "online": true,
7 "labels": [ 7 "labels": [
8 - "0000ffffffff0008", 8 + "",
9 - "FF:FF:FF:FF:00:08", 9 + "switch-8",
10 - "sw-8-yo", 10 + "0000ffffffff0008"
11 - ""
12 ], 11 ],
13 "metaUi": { 12 "metaUi": {
14 "x": 520, 13 "x": 520,
......
...@@ -5,10 +5,9 @@ ...@@ -5,10 +5,9 @@
5 "type": "switch", 5 "type": "switch",
6 "online": true, 6 "online": true,
7 "labels": [ 7 "labels": [
8 - "0000ffffffff0003", 8 + "",
9 - "FF:FF:FF:FF:00:03", 9 + "switch-3",
10 - "sw-3-yo", 10 + "0000ffffffff0003"
11 - ""
12 ], 11 ],
13 "metaUi": { 12 "metaUi": {
14 "x": 800, 13 "x": 800,
......
...@@ -143,6 +143,7 @@ ...@@ -143,6 +143,7 @@
143 O: [toggleSummary, 'Toggle ONOS summary pane'], 143 O: [toggleSummary, 'Toggle ONOS summary pane'],
144 I: [toggleInstances, 'Toggle ONOS instances pane'], 144 I: [toggleInstances, 'Toggle ONOS instances pane'],
145 B: [toggleBg, 'Toggle background image'], 145 B: [toggleBg, 'Toggle background image'],
146 + H: [toggleHosts, 'Toggle host visibility'],
146 L: [cycleLabels, 'Cycle Device labels'], 147 L: [cycleLabels, 'Cycle Device labels'],
147 P: togglePorts, 148 P: togglePorts,
148 U: [unpin, 'Unpin node'], 149 U: [unpin, 'Unpin node'],
...@@ -170,8 +171,7 @@ ...@@ -170,8 +171,7 @@
170 ctx: null, 171 ctx: null,
171 params: {}, 172 params: {},
172 evNumber: 0, 173 evNumber: 0,
173 - view: null, 174 + view: null
174 - debug: false
175 }, 175 },
176 webSock, 176 webSock,
177 sid = 0, 177 sid = 0,
...@@ -191,8 +191,10 @@ ...@@ -191,8 +191,10 @@
191 oiShowMaster = false, 191 oiShowMaster = false,
192 portLabelsOn = false, 192 portLabelsOn = false,
193 cat7 = d3u.cat7(), 193 cat7 = d3u.cat7(),
194 - colorAffinity = false; 194 + colorAffinity = false,
195 + showHosts = false;
195 196
197 + // constants
196 var hoverModeAll = 1, 198 var hoverModeAll = 1,
197 hoverModeFlows = 2, 199 hoverModeFlows = 2,
198 hoverModeIntents = 3, 200 hoverModeIntents = 3,
...@@ -247,22 +249,9 @@ ...@@ -247,22 +249,9 @@
247 cat7.testCard(svg); 249 cat7.testCard(svg);
248 } 250 }
249 251
250 - function abortIfLive() {
251 - if (config.useLiveData) {
252 - network.view.alert("Sorry, currently using live data..");
253 - return true;
254 - }
255 - return false;
256 - }
257 -
258 - function testDebug(msg) {
259 - if (scenario.debug) {
260 - scenario.view.alert(msg);
261 - }
262 - }
263 -
264 function injectTestEvent(view) { 252 function injectTestEvent(view) {
265 - if (abortIfLive()) { return; } 253 + if (config.useLiveData) { return; }
254 +
266 var sc = scenario, 255 var sc = scenario,
267 evn = ++sc.evNumber, 256 evn = ++sc.evNumber,
268 pfx = sc.evDir + sc.ctx + sc.evPrefix + evn, 257 pfx = sc.evDir + sc.ctx + sc.evPrefix + evn,
...@@ -293,7 +282,6 @@ ...@@ -293,7 +282,6 @@
293 v.alert('non-404 error:\n\n' + frame.url + '\n\n' + err); 282 v.alert('non-404 error:\n\n' + frame.url + '\n\n' + err);
294 } 283 }
295 } else { 284 } else {
296 - testDebug('loaded: ' + frame.url);
297 wsTrace('test', JSON.stringify(data)); 285 wsTrace('test', JSON.stringify(data));
298 frame.cb(data); 286 frame.cb(data);
299 } 287 }
...@@ -308,7 +296,7 @@ ...@@ -308,7 +296,7 @@
308 296
309 function injectStartupEvents(view) { 297 function injectStartupEvents(view) {
310 var last = scenario.params.lastAuto || 0; 298 var last = scenario.params.lastAuto || 0;
311 - if (abortIfLive()) { return; } 299 + if (config.useLiveData) { return; }
312 300
313 while (scenario.evNumber < last) { 301 while (scenario.evNumber < last) {
314 injectTestEvent(view); 302 injectTestEvent(view);
...@@ -317,7 +305,13 @@ ...@@ -317,7 +305,13 @@
317 305
318 function toggleBg() { 306 function toggleBg() {
319 var vis = bgImg.style('visibility'); 307 var vis = bgImg.style('visibility');
320 - bgImg.style('visibility', (vis === 'hidden') ? 'visible' : 'hidden'); 308 + bgImg.style('visibility', visVal(vis === 'hidden'));
309 + }
310 +
311 + function toggleHosts() {
312 + showHosts = !showHosts;
313 + updateHostVisibility();
314 + network.view.flash('Hosts ' + visVal(showHosts));
321 } 315 }
322 316
323 function cycleLabels() { 317 function cycleLabels() {
...@@ -332,7 +326,7 @@ ...@@ -332,7 +326,7 @@
332 } 326 }
333 327
334 function togglePorts(view) { 328 function togglePorts(view) {
335 - view.alert('togglePorts() callback') 329 + //view.alert('togglePorts() callback')
336 } 330 }
337 331
338 function unpin() { 332 function unpin() {
...@@ -568,7 +562,6 @@ ...@@ -568,7 +562,6 @@
568 562
569 function logicError(msg) { 563 function logicError(msg) {
570 // TODO, report logic error to server, via websock, so it can be logged 564 // TODO, report logic error to server, via websock, so it can be logged
571 - //network.view.alert('Logic Error:\n\n' + msg);
572 console.warn(msg); 565 console.warn(msg);
573 } 566 }
574 567
...@@ -822,7 +815,7 @@ ...@@ -822,7 +815,7 @@
822 } 815 }
823 816
824 function unknownEvent(data) { 817 function unknownEvent(data) {
825 - network.view.alert('Unknown event type: "' + data.event + '"'); 818 + console.warn('Unknown event type: "' + data.event + '"', data);
826 } 819 }
827 820
828 function handleServerEvent(data) { 821 function handleServerEvent(data) {
...@@ -833,12 +826,6 @@ ...@@ -833,12 +826,6 @@
833 // ============================== 826 // ==============================
834 // Out-going messages... 827 // Out-going messages...
835 828
836 - function userFeedback(msg) {
837 - // for now, use the alert pane as is. Maybe different alert style in
838 - // the future (centered on view; dismiss button?)
839 - network.view.alert(msg);
840 - }
841 -
842 function nSel() { 829 function nSel() {
843 return selectOrder.length; 830 return selectOrder.length;
844 } 831 }
...@@ -1221,6 +1208,10 @@ ...@@ -1221,6 +1208,10 @@
1221 appendBadge(svg, 12, instCfg.uiDy, 30, '#uiAttached', 'uiBadge'); 1208 appendBadge(svg, 12, instCfg.uiDy, 30, '#uiAttached', 'uiBadge');
1222 } 1209 }
1223 1210
1211 + function visVal(b) {
1212 + return b ? 'visible' : 'hidden';
1213 + }
1214 +
1224 // ============================== 1215 // ==============================
1225 // force layout modification functions 1216 // force layout modification functions
1226 1217
...@@ -1319,6 +1310,10 @@ ...@@ -1319,6 +1310,10 @@
1319 }); 1310 });
1320 } 1311 }
1321 1312
1313 + function showHostVis(el) {
1314 + el.style('visibility', visVal(showHosts));
1315 + }
1316 +
1322 var widthRatio = 1.4, 1317 var widthRatio = 1.4,
1323 linkScale = d3.scale.linear() 1318 linkScale = d3.scale.linear()
1324 .domain([1, 12]) 1319 .domain([1, 12])
...@@ -1350,6 +1345,9 @@ ...@@ -1350,6 +1345,9 @@
1350 // provide ref to element selection from backing data.... 1345 // provide ref to element selection from backing data....
1351 d.el = link; 1346 d.el = link;
1352 restyleLinkElement(d); 1347 restyleLinkElement(d);
1348 + if (d.type() === 'hostLink') {
1349 + showHostVis(link);
1350 + }
1353 }); 1351 });
1354 1352
1355 // operate on both existing and new links, if necessary 1353 // operate on both existing and new links, if necessary
...@@ -1663,6 +1661,12 @@ ...@@ -1663,6 +1661,12 @@
1663 updateHostLabel(hostData); 1661 updateHostLabel(hostData);
1664 } 1662 }
1665 1663
1664 + function updateHostVisibility() {
1665 + var v = visVal(showHosts);
1666 + nodeG.selectAll('.host').style('visibility', v);
1667 + linkG.selectAll('.hostLink').style('visibility', v);
1668 + }
1669 +
1666 function nodeMouseOver(d) { 1670 function nodeMouseOver(d) {
1667 hovered = d; 1671 hovered = d;
1668 requestTrafficForMode(); 1672 requestTrafficForMode();
...@@ -1692,7 +1696,6 @@ ...@@ -1692,7 +1696,6 @@
1692 1696
1693 // operate on existing nodes... 1697 // operate on existing nodes...
1694 node.filter('.device').each(function (d) { 1698 node.filter('.device').each(function (d) {
1695 - //var node = d3.select(this);
1696 var node = d.el; 1699 var node = d.el;
1697 node.classed('online', d.online); 1700 node.classed('online', d.online);
1698 updateDeviceLabel(d); 1701 updateDeviceLabel(d);
...@@ -1747,13 +1750,12 @@ ...@@ -1747,13 +1750,12 @@
1747 1750
1748 // provide ref to element from backing data.... 1751 // provide ref to element from backing data....
1749 d.el = node; 1752 d.el = node;
1753 + showHostVis(node);
1750 1754
1751 node.append('circle').attr('r', r); 1755 node.append('circle').attr('r', r);
1752 -
1753 if (iid) { 1756 if (iid) {
1754 addHostIcon(node, r, iid); 1757 addHostIcon(node, r, iid);
1755 } 1758 }
1756 -
1757 node.append('text') 1759 node.append('text')
1758 .text(hostLabel) 1760 .text(hostLabel)
1759 .attr('dy', textDy) 1761 .attr('dy', textDy)
...@@ -2014,9 +2016,9 @@ ...@@ -2014,9 +2016,9 @@
2014 if (webSock.ws) { 2016 if (webSock.ws) {
2015 webSock.ws.send(message); 2017 webSock.ws.send(message);
2016 } else if (config.useLiveData) { 2018 } else if (config.useLiveData) {
2017 - network.view.alert('no web socket open\n\n' + message); 2019 + console.warn('no web socket open', message);
2018 } else { 2020 } else {
2019 - console.log('WS Send: ' + JSON.stringify(message)); 2021 + console.log('WS Send: ', message);
2020 } 2022 }
2021 } 2023 }
2022 2024
...@@ -2607,7 +2609,7 @@ ...@@ -2607,7 +2609,7 @@
2607 } 2609 }
2608 2610
2609 function showBg() { 2611 function showBg() {
2610 - return config.options.showBackground ? 'visible' : 'hidden'; 2612 + return visVal(config.options.showBackground);
2611 } 2613 }
2612 2614
2613 function loadStaticMap() { 2615 function loadStaticMap() {
......