Simon Hunt
Committed by Gerrit Code Review

GUI -- Detail pane now uses Glyphs for selected item (no longer png)

- deadwood removal.

Change-Id: I804a0334b48f2e261fa108e43d23d3257d8a143d
...@@ -33,6 +33,9 @@ ...@@ -33,6 +33,9 @@
33 padding: 10px; 33 padding: 10px;
34 color: black; 34 color: black;
35 font-size: 10pt; 35 font-size: 10pt;
36 +
37 + -moz-border-radius: 6px;
38 + border-radius: 6px;
36 box-shadow: 2px 2px 16px #777; 39 box-shadow: 2px 2px 16px #777;
37 } 40 }
38 41
......
...@@ -174,16 +174,26 @@ svg .node.host circle { ...@@ -174,16 +174,26 @@ svg .node.host circle {
174 /* gets base CSS from .fpanel in floatPanel.css */ 174 /* gets base CSS from .fpanel in floatPanel.css */
175 } 175 }
176 176
177 -#topo-detail h2 { 177 +#topo-detail svg {
178 - margin: 8px 4px; 178 + display: inline-block;
179 - color: black; 179 + width: 42px;
180 - vertical-align: middle; 180 + height: 42px;
181 +}
182 +
183 +#topo-detail svg .glyphIcon {
184 + fill: black;
185 + stroke: none;
186 + fill-rule: evenodd;
181 } 187 }
182 188
183 -#topo-detail h2 img { 189 +#topo-detail h2 {
184 - height: 32px; 190 + position: absolute;
185 - padding-right: 8px; 191 + /*display: inline-block;*/
186 - vertical-align: middle; 192 + /*vertical-align: bottom;*/
193 + margin: 0px 4px;
194 + top: 20px;
195 + left: 50px;
196 + color: black;
187 } 197 }
188 198
189 #topo-detail p, table { 199 #topo-detail p, table {
...@@ -284,10 +294,6 @@ svg .node.host circle { ...@@ -284,10 +294,6 @@ svg .node.host circle {
284 fill-rule: evenodd; 294 fill-rule: evenodd;
285 } 295 }
286 296
287 -/*#topo-oibox .onosInst img {*/
288 - /*opacity: 0.5;*/
289 - /*padding: 3px;*/
290 -/*}*/
291 297
292 #topo-oibox .onosInst.online img { 298 #topo-oibox .onosInst.online img {
293 opacity: 1.0; 299 opacity: 1.0;
...@@ -316,7 +322,7 @@ svg .node.host circle { ...@@ -316,7 +322,7 @@ svg .node.host circle {
316 opacity: 0.2; 322 opacity: 0.2;
317 } 323 }
318 324
319 -/* Web Socket Closed Mask (starts hidden) */ 325 +/* Death Mask (starts hidden) */
320 326
321 #topo-mask { 327 #topo-mask {
322 display: none; 328 display: none;
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
18 ONOS network topology viewer - version 1.1 18 ONOS network topology viewer - version 1.1
19 19
20 @author Simon Hunt 20 @author Simon Hunt
21 + @author Thomas Vachuska
21 */ 22 */
22 23
23 (function (onos) { 24 (function (onos) {
...@@ -25,8 +26,7 @@ ...@@ -25,8 +26,7 @@
25 26
26 // shorter names for library APIs 27 // shorter names for library APIs
27 var d3u = onos.lib.d3util, 28 var d3u = onos.lib.d3util,
28 - gly = onos.lib.glyphs, 29 + gly = onos.lib.glyphs;
29 - trace;
30 30
31 // configuration data 31 // configuration data
32 var config = { 32 var config = {
...@@ -887,9 +887,22 @@ ...@@ -887,9 +887,22 @@
887 }); 887 });
888 } 888 }
889 889
890 + // TODO: these should be moved out to utility module.
890 function stripPx(s) { 891 function stripPx(s) {
891 return s.replace(/px$/,''); 892 return s.replace(/px$/,'');
892 } 893 }
894 +
895 + function appendGlyph(svg, ox, oy, dim, iid) {
896 + svg.append('use').attr({
897 + class: 'glyphIcon',
898 + transform: translate(ox,oy),
899 + 'xlink:href': iid,
900 + width: dim,
901 + height: dim
902 +
903 + });
904 + }
905 +
893 // ============================== 906 // ==============================
894 // onos instance panel functions 907 // onos instance panel functions
895 908
...@@ -918,25 +931,13 @@ ...@@ -918,25 +931,13 @@
918 height: h 931 height: h
919 }); 932 });
920 var dim = 30; 933 var dim = 30;
921 - svg.append('use').attr({ 934 + appendGlyph(svg, 2, 2, 30, '#node');
922 - class: 'glyphIcon',
923 - transform: translate(2,2),
924 - 'xlink:href': '#node',
925 - width: dim,
926 - height: dim
927 -
928 - });
929 -
930 - //$('<img src="img/node.png">').appendTo(el);
931 - //img = el.select('img')
932 - // .attr({
933 - // width: 30
934 - // });
935 935
936 $('<div>').attr('class', 'onosTitle').text(d.id).appendTo(el); 936 $('<div>').attr('class', 'onosTitle').text(d.id).appendTo(el);
937 937
938 // is the UI attached to this instance? 938 // is the UI attached to this instance?
939 // TODO: need uiAttached boolean in instance data 939 // TODO: need uiAttached boolean in instance data
940 + // TODO: use SVG glyph, not png..
940 //if (d.uiAttached) { 941 //if (d.uiAttached) {
941 if (i === 0) { 942 if (i === 0) {
942 $('<img src="img/ui.png">').attr('class','ui').appendTo(el); 943 $('<img src="img/ui.png">').attr('class','ui').appendTo(el);
...@@ -1043,8 +1044,7 @@ ...@@ -1043,8 +1044,7 @@
1043 } 1044 }
1044 1045
1045 function createLink(link) { 1046 function createLink(link) {
1046 - var lnk = linkEndPoints(link.src, link.dst), 1047 + var lnk = linkEndPoints(link.src, link.dst);
1047 - type = link.type;
1048 1048
1049 if (!lnk) { 1049 if (!lnk) {
1050 return null; 1050 return null;
...@@ -1223,18 +1223,7 @@ ...@@ -1223,18 +1223,7 @@
1223 dy = p.y2 - p.y1, 1223 dy = p.y2 - p.y1,
1224 xMid = dx/2 + p.x1, 1224 xMid = dx/2 + p.x1,
1225 yMid = dy/2 + p.y1; 1225 yMid = dy/2 + p.y1;
1226 - //length = Math.sqrt(dx*dx + dy*dy),
1227 - //rads = Math.asin(dy/length),
1228 - //degs = rads / (Math.PI*2) * 360;
1229 -
1230 return translate(xMid, yMid); 1226 return translate(xMid, yMid);
1231 -
1232 - // TODO: consider making label parallel to line
1233 - //return [
1234 - // translate(xMid, yMid),
1235 - // rotate(degs),
1236 - // translate(0, 8)
1237 - //].join('');
1238 } 1227 }
1239 1228
1240 function createDeviceNode(device) { 1229 function createDeviceNode(device) {
...@@ -1437,19 +1426,13 @@ ...@@ -1437,19 +1426,13 @@
1437 host.select('text').text(label); 1426 host.select('text').text(label);
1438 } 1427 }
1439 1428
1429 + // TODO: should be using updateNodes() to do the upates!
1440 function updateDeviceState(nodeData) { 1430 function updateDeviceState(nodeData) {
1441 nodeData.el.classed('online', nodeData.online); 1431 nodeData.el.classed('online', nodeData.online);
1442 updateDeviceLabel(nodeData); 1432 updateDeviceLabel(nodeData);
1443 // TODO: review what else might need to be updated 1433 // TODO: review what else might need to be updated
1444 } 1434 }
1445 1435
1446 - function updateLinkState(linkData) {
1447 - updateLinkWidth(linkData);
1448 - linkData.el.classed('inactive', !linkData.online);
1449 - // TODO: review what else might need to be updated
1450 - // update label, if showing
1451 - }
1452 -
1453 function updateHostState(hostData) { 1436 function updateHostState(hostData) {
1454 updateHostLabel(hostData); 1437 updateHostLabel(hostData);
1455 // TODO: review what else might need to be updated 1438 // TODO: review what else might need to be updated
...@@ -1569,7 +1552,6 @@ ...@@ -1569,7 +1552,6 @@
1569 addHostIcon(node, r, iid); 1552 addHostIcon(node, r, iid);
1570 } 1553 }
1571 1554
1572 -
1573 node.append('text') 1555 node.append('text')
1574 .text(hostLabel) 1556 .text(hostLabel)
1575 .attr('dy', textDy) 1557 .attr('dy', textDy)
...@@ -1659,34 +1641,8 @@ ...@@ -1659,34 +1641,8 @@
1659 height: cfg.dim 1641 height: cfg.dim
1660 }); 1642 });
1661 1643
1662 -/*
1663 - if (icon) {
1664 - node.append('rect')
1665 - .attr({
1666 - class: 'iconUnderlay',
1667 - x: box.x + config.icons.xoff,
1668 - y: box.y + config.icons.yoff,
1669 - width: cfg.w,
1670 - height: cfg.h,
1671 - rx: 4
1672 - }).style({
1673 - stroke: '#000',
1674 - fill: '#ddd'
1675 - });
1676 - node.append('svg:image')
1677 - .attr({
1678 - x: box.x + config.icons.xoff + 2,
1679 - y: box.y + config.icons.yoff + 2,
1680 - width: cfg.w - 4,
1681 - height: cfg.h - 4,
1682 - 'xlink:href': icon
1683 - });
1684 - }
1685 -*/
1686 } 1644 }
1687 1645
1688 -
1689 -
1690 function find(key, array) { 1646 function find(key, array) {
1691 for (var idx = 0, n = array.length; idx < n; idx++) { 1647 for (var idx = 0, n = array.length; idx < n; idx++) {
1692 if (array[idx].key === key) { 1648 if (array[idx].key === key) {
...@@ -1990,12 +1946,15 @@ ...@@ -1990,12 +1946,15 @@
1990 function populateDetails(data) { 1946 function populateDetails(data) {
1991 detailPane.empty(); 1947 detailPane.empty();
1992 1948
1949 + var svg = detailPane.append('svg'),
1950 + iid = iconGlyphUrl(data);
1951 +
1993 var title = detailPane.append("h2"), 1952 var title = detailPane.append("h2"),
1994 table = detailPane.append("table"), 1953 table = detailPane.append("table"),
1995 tbody = table.append("tbody"); 1954 tbody = table.append("tbody");
1996 1955
1997 - $('<img src="img/' + data.type + '.png">').appendTo(title); 1956 + appendGlyph(svg, 0, 0, 40, iid);
1998 - $('<span>').attr('class', 'icon').text(data.id).appendTo(title); 1957 + title.text(data.id);
1999 1958
2000 data.propOrder.forEach(function(p) { 1959 data.propOrder.forEach(function(p) {
2001 if (p === '-') { 1960 if (p === '-') {
...@@ -2120,8 +2079,6 @@ ...@@ -2120,8 +2079,6 @@
2120 } 2079 }
2121 2080
2122 showInstances = mkTogBtn('Show Instances', toggleInst); 2081 showInstances = mkTogBtn('Show Instances', toggleInst);
2123 - //doPanZoom = mkTogBtn('Pan/Zoom', togglePanZoom);
2124 - //showTrafficOnHover = mkTogBtn('Show traffic on hover', toggleTrafficHover);
2125 } 2082 }
2126 2083
2127 function instShown() { 2084 function instShown() {
...@@ -2138,10 +2095,6 @@ ...@@ -2138,10 +2095,6 @@
2138 2095
2139 function panZoom() { 2096 function panZoom() {
2140 return false; 2097 return false;
2141 - //return doPanZoom.classed('active');
2142 - }
2143 - function togglePanZoom() {
2144 - doPanZoom.classed('active', !panZoom());
2145 } 2098 }
2146 2099
2147 function trafficHover() { 2100 function trafficHover() {
...@@ -2152,10 +2105,6 @@ ...@@ -2152,10 +2105,6 @@
2152 return hoverModes[hoverMode] === 'flows'; 2105 return hoverModes[hoverMode] === 'flows';
2153 } 2106 }
2154 2107
2155 - function toggleTrafficHover() {
2156 - showTrafficOnHover.classed('active', !trafficHover());
2157 - }
2158 -
2159 function loadGlyphs(svg) { 2108 function loadGlyphs(svg) {
2160 var defs = svg.append('defs'); 2109 var defs = svg.append('defs');
2161 gly.defBird(defs); 2110 gly.defBird(defs);
...@@ -2305,13 +2254,6 @@ ...@@ -2305,13 +2254,6 @@
2305 2254
2306 // Load map data asynchronously; complete startup after that.. 2255 // Load map data asynchronously; complete startup after that..
2307 loadGeoJsonData(); 2256 loadGeoJsonData();
2308 -
2309 - //var dashIdx = 0;
2310 - //antTimer = setInterval(function () {
2311 - // // TODO: figure out how to choose Src-->Dst and Dst-->Src, per link
2312 - // dashIdx = dashIdx === 0 ? 14 : dashIdx - 2;
2313 - // d3.selectAll('.animated').style('stroke-dashoffset', dashIdx);
2314 - //}, 35);
2315 } 2257 }
2316 2258
2317 function startAntTimer() { 2259 function startAntTimer() {
...@@ -2338,7 +2280,7 @@ ...@@ -2338,7 +2280,7 @@
2338 } 2280 }
2339 2281
2340 // TODO: move these to config/state portion of script 2282 // TODO: move these to config/state portion of script
2341 - var geoJsonUrl = 'json/map/continental_us.json', // TODO: Paul 2283 + var geoJsonUrl = 'json/map/continental_us.json',
2342 geoJson; 2284 geoJson;
2343 2285
2344 function loadGeoJsonData() { 2286 function loadGeoJsonData() {
......