Simon Hunt
Committed by Gerrit Code Review

GUI - Added ability to differentiate between host types.

- Added addHostIcon(...) function.
- Added bullhorn glyph to library.
- Added bgpSpeaker host to links scenario.

Change-Id: I09db2467c0c8ec23933790a794fe2c93dc443141
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
24 (function (onos) { 24 (function (onos) {
25 'use strict'; 25 'use strict';
26 26
27 + // TODO: refactor this library...
28 +
27 var birdData = "M427.7,300.4 c-6.9,0.6-13.1,5-19.2,7.1" + 29 var birdData = "M427.7,300.4 c-6.9,0.6-13.1,5-19.2,7.1" +
28 "c-18.1,6.2-33.9,9.1-56.5,4.7c24.6,17.2,36.6,13,63.7,0.1" + 30 "c-18.1,6.2-33.9,9.1-56.5,4.7c24.6,17.2,36.6,13,63.7,0.1" +
29 "c-0.5,0.6-0.7,1.3-1.3,1.9c1.4-0.4,2.4-1.7,3.4-2.2" + 31 "c-0.5,0.6-0.7,1.3-1.3,1.9c1.4-0.4,2.4-1.7,3.4-2.2" +
...@@ -39,7 +41,6 @@ ...@@ -39,7 +41,6 @@
39 "c-2-11.2-8.4-21.5-19.7-24.8c-1-0.3-1.1-0.3-0.9,0" + 41 "c-2-11.2-8.4-21.5-19.7-24.8c-1-0.3-1.1-0.3-0.9,0" +
40 "c9.6,17.1,7.2,38.3,3.1,54.2C429.9,285.5,426.7,293.2,427.7,300.4z"; 42 "c9.6,17.1,7.2,38.3,3.1,54.2C429.9,285.5,426.7,293.2,427.7,300.4z";
41 43
42 -
43 function defBird(defs) { 44 function defBird(defs) {
44 defs.append('symbol') 45 defs.append('symbol')
45 .attr({ 46 .attr({
...@@ -49,9 +50,25 @@ ...@@ -49,9 +50,25 @@
49 .append('path').attr('d', birdData); 50 .append('path').attr('d', birdData);
50 } 51 }
51 52
53 + var bullhornData = "M0,13c0,3.733,2.561,6.148,6.019,6.809 " +
54 + "C6.013,19.873,6,19.935,6,20v8 c0,1.105,0.895,2,2,2h3 " +
55 + "c1.105,0,2-0.896,2-2v-8h3V6H8C3.582,6,0,8.582,0,13z " +
56 + "M18,20h3V6h-3V20z M30,0l-7,4.667v16.667L30,26 c1.105,0,2-0.895,2-2" +
57 + "V2 C32,0.896,31.105,0,30,0z";
58 +
59 + function defBullhorn(defs) {
60 + defs.append('symbol')
61 + .attr({
62 + id: 'bullhorn',
63 + viewBox: '-4 -5 40 40'
64 + })
65 + .append('path').attr('d', bullhornData);
66 + }
67 +
52 // === register the functions as a library 68 // === register the functions as a library
53 onos.ui.addLib('glyphs', { 69 onos.ui.addLib('glyphs', {
54 - defBird: defBird 70 + defBird: defBird,
71 + defBullhorn: defBullhorn
55 }); 72 });
56 73
57 }(ONOS)); 74 }(ONOS));
......
1 +{
2 + "event": "addHost",
3 + "payload": {
4 + "id": "0E:2A:69:30:BB:BB/-1",
5 + "type": "bgpSpeaker",
6 + "ingress": "0E:2A:69:30:BB:BB/-1/0-of:0000ffffffff0007/2",
7 + "egress": "of:0000ffffffff0007/2-0E:2A:69:30:BB:BB/-1/0",
8 + "cp": {
9 + "device": "of:0000ffffffff0007",
10 + "port": 2
11 + },
12 + "labels": [
13 + "BGP",
14 + "0E:2A:69:30:BB:BB"
15 + ],
16 + "props": {}
17 + }
18 +}
...@@ -101,12 +101,6 @@ svg g.portLayer text { ...@@ -101,12 +101,6 @@ svg g.portLayer text {
101 101
102 102
103 103
104 -svg .node.host circle {
105 - fill: #c96;
106 - stroke: #000;
107 -}
108 -
109 -
110 /* for debugging */ 104 /* for debugging */
111 svg .node circle.debug { 105 svg .node circle.debug {
112 fill: white; 106 fill: white;
......
...@@ -31,6 +31,11 @@ ...@@ -31,6 +31,11 @@
31 } 31 }
32 32
33 33
34 +#topo svg .glyph {
35 + fill: white;
36 + stroke: none;
37 +}
38 +
34 /* NODES */ 39 /* NODES */
35 40
36 #topo svg .node { 41 #topo svg .node {
...@@ -93,14 +98,22 @@ ...@@ -93,14 +98,22 @@
93 /* Host Nodes */ 98 /* Host Nodes */
94 99
95 #topo svg .node.host { 100 #topo svg .node.host {
96 - fill: #846; 101 + stroke: #000;
97 } 102 }
98 103
99 #topo svg .node.host text { 104 #topo svg .node.host text {
100 fill: #846; 105 fill: #846;
106 + stroke: none;
101 font: 9pt sans-serif; 107 font: 9pt sans-serif;
102 } 108 }
103 109
110 +svg .node.host circle {
111 + fill: #c96;
112 +}
113 +
114 +#topo svg .node.host.bgpSpeaker circle {
115 + fill: #853;
116 +}
104 117
105 /* LINKS */ 118 /* LINKS */
106 119
...@@ -262,7 +275,7 @@ ...@@ -262,7 +275,7 @@
262 } 275 }
263 #topo-oibox .onosInst.mastership.affinity { 276 #topo-oibox .onosInst.mastership.affinity {
264 opacity: 1.0; 277 opacity: 1.0;
265 - box-shadow: 0px 2px 8px #33e; 278 + box-shadow: 0 2px 8px #33e;
266 } 279 }
267 280
268 281
......
...@@ -1060,7 +1060,7 @@ ...@@ -1060,7 +1060,7 @@
1060 if (!node.type) { 1060 if (!node.type) {
1061 node.type = 'endstation'; 1061 node.type = 'endstation';
1062 } 1062 }
1063 - node.svgClass = 'node host'; 1063 + node.svgClass = 'node host ' + node.type;
1064 positionNode(node); 1064 positionNode(node);
1065 1065
1066 // cache label array length 1066 // cache label array length
...@@ -1237,6 +1237,18 @@ ...@@ -1237,6 +1237,18 @@
1237 } 1237 }
1238 } 1238 }
1239 1239
1240 + function addHostIcon(node, radius, iconId) {
1241 + var dim = radius * 1.5,
1242 + xlate = -dim / 2;
1243 +
1244 + node.append('use')
1245 + .classed('glyph', true)
1246 + .attr('transform', translate(xlate,xlate))
1247 + .attr('xlink:href', '#' + iconId)
1248 + .attr('width', dim)
1249 + .attr('height', dim);
1250 + }
1251 +
1240 function updateNodes() { 1252 function updateNodes() {
1241 node = nodeG.selectAll('.node') 1253 node = nodeG.selectAll('.node')
1242 .data(network.nodes, function (d) { return d.id; }); 1254 .data(network.nodes, function (d) { return d.id; });
...@@ -1310,20 +1322,36 @@ ...@@ -1310,20 +1322,36 @@
1310 } 1322 }
1311 }); 1323 });
1312 1324
1325 + // TODO: better place for this configuration state
1326 + var defaultHostRadius = 9,
1327 + hostRadius = {
1328 + bgpSpeaker: 20
1329 + },
1330 + hostIcon = {
1331 + bgpSpeaker: 'bullhorn'
1332 + };
1333 +
1334 +
1313 // augment host nodes... 1335 // augment host nodes...
1314 entering.filter('.host').each(function (d) { 1336 entering.filter('.host').each(function (d) {
1315 var node = d3.select(this), 1337 var node = d3.select(this),
1316 - box; 1338 + r = hostRadius[d.type] || defaultHostRadius,
1339 + textDy = r + 10,
1340 + icon = hostIcon[d.type];
1317 1341
1318 // provide ref to element from backing data.... 1342 // provide ref to element from backing data....
1319 d.el = node; 1343 d.el = node;
1320 1344
1321 node.append('circle') 1345 node.append('circle')
1322 - .attr('r', 8); // TODO: define host circle radius 1346 + .attr('r', r);
1347 +
1348 + if (icon) {
1349 + addHostIcon(node, r, icon);
1350 + }
1323 1351
1324 node.append('text') 1352 node.append('text')
1325 .text(hostLabel) 1353 .text(hostLabel)
1326 - .attr('dy', '1.3em') 1354 + .attr('dy', textDy)
1327 .attr('text-anchor', 'middle'); 1355 .attr('text-anchor', 'middle');
1328 1356
1329 // debug function to show the modelled x,y coordinates of nodes... 1357 // debug function to show the modelled x,y coordinates of nodes...
...@@ -1786,6 +1814,11 @@ ...@@ -1786,6 +1814,11 @@
1786 showTrafficOnHover.classed('active', !trafficHover()); 1814 showTrafficOnHover.classed('active', !trafficHover());
1787 } 1815 }
1788 1816
1817 + function loadGlyphs(svg) {
1818 + var defs = svg.append('defs');
1819 + gly.defBird(defs);
1820 + gly.defBullhorn(defs);
1821 + }
1789 1822
1790 // ============================== 1823 // ==============================
1791 // View life-cycle callbacks 1824 // View life-cycle callbacks
...@@ -1802,8 +1835,7 @@ ...@@ -1802,8 +1835,7 @@
1802 svg = view.$div.append('svg').attr('viewBox', viewBox); 1835 svg = view.$div.append('svg').attr('viewBox', viewBox);
1803 setSize(svg, view); 1836 setSize(svg, view);
1804 1837
1805 - var defs = svg.append('defs'); 1838 + loadGlyphs(svg);
1806 - gly.defBird(defs);
1807 1839
1808 zoomPanContainer = svg.append('g').attr('id', 'zoomPanContainer'); 1840 zoomPanContainer = svg.append('g').attr('id', 'zoomPanContainer');
1809 setupZoomPan(); 1841 setupZoomPan();
......