blob: ef190e7e531ecf68f5c0dd3031bb608792b7478e [file] [log] [blame]
Simon Hunt0b05d4a2014-10-21 21:50:15 -07001/*
2 ONOS network topology viewer - PoC version 1.0
3
4 @author Simon Hunt
5 */
6
7(function (onos) {
8 'use strict';
9
10 var api = onos.api;
11
12 var config = {
Simon Hunt2c9e0c22014-10-23 15:12:58 -070013 options: {
14 layering: false,
15 collisionPrevention: true
16 },
Simon Hunt0b05d4a2014-10-21 21:50:15 -070017 jsonUrl: 'network.json',
Simon Hunt68ae6652014-10-22 13:58:07 -070018 iconUrl: {
Simon Hunt2c9e0c22014-10-23 15:12:58 -070019 logo: 'img/onos-logo.tiff',
20 device: 'img/device.png',
21 host: 'img/host.png',
22 pkt: 'img/pkt.png',
23 opt: 'img/opt.png'
Simon Hunt68ae6652014-10-22 13:58:07 -070024 },
Simon Hunt0b05d4a2014-10-21 21:50:15 -070025 mastHeight: 32,
26 force: {
Simon Hunt2c9e0c22014-10-23 15:12:58 -070027 note: 'node.class or link.class is used to differentiate',
28 linkDistance: {
29 infra: 240,
30 host: 100
31 },
32 linkStrength: {
33 infra: 1.0,
34 host: 0.4
35 },
36 charge: {
37 device: -800,
38 host: -400
39 },
Simon Hunt0b05d4a2014-10-21 21:50:15 -070040 ticksWithoutCollisions: 50,
41 marginLR: 20,
42 marginTB: 20,
43 translate: function() {
44 return 'translate(' +
45 config.force.marginLR + ',' +
46 config.force.marginTB + ')';
47 }
48 },
49 labels: {
Simon Hunt1c5f8b62014-10-22 14:43:01 -070050 imgPad: 22,
51 padLR: 8,
52 padTB: 6,
Simon Hunt0b05d4a2014-10-21 21:50:15 -070053 marginLR: 3,
54 marginTB: 2
55 },
Simon Hunt2c9e0c22014-10-23 15:12:58 -070056 icons: {
57 w: 32,
58 h: 32,
59 xoff: -12,
60 yoff: -10
61 },
Simon Hunt0b05d4a2014-10-21 21:50:15 -070062 constraints: {
63 ypos: {
Simon Hunt2c9e0c22014-10-23 15:12:58 -070064 host: 0.15,
65 switch: 0.3,
66 roadm: 0.7
Simon Hunt0b05d4a2014-10-21 21:50:15 -070067 }
Simon Hunt2c9e0c22014-10-23 15:12:58 -070068 },
69 hostLinkWidth: 1.0,
70 mouseOutTimerDelayMs: 120
Simon Hunt0b05d4a2014-10-21 21:50:15 -070071 },
72 view = {},
73 network = {},
74 selected = {},
75 highlighted = null;
76
77
78 function loadNetworkView() {
79 // Hey, here I am, calling something on the ONOS api:
80 api.printTime();
81
82 resize();
83
84 d3.json(config.jsonUrl, function (err, data) {
85 if (err) {
86 alert('Oops! Error reading JSON...\n\n' +
Simon Huntae968a62014-10-22 14:54:41 -070087 'URL: ' + config.jsonUrl + '\n\n' +
Simon Hunt0b05d4a2014-10-21 21:50:15 -070088 'Error: ' + err.message);
89 return;
90 }
91 console.log("here is the JSON data...");
92 console.log(data);
93
94 network.data = data;
95 drawNetwork();
96 });
97
98 $(document).on('click', '.select-object', function() {
99 // when any object of class "select-object" is clicked...
100 // TODO: get a reference to the object via lookup...
101 var obj = network.lookup[$(this).data('id')];
102 if (obj) {
103 selectObject(obj);
104 }
105 // stop propagation of event (I think) ...
106 return false;
107 });
108
109 $(window).on('resize', resize);
110 }
111
112
113 // ========================================================
114
115 function drawNetwork() {
116 $('#view').empty();
117
118 prepareNodesAndLinks();
119 createLayout();
120 console.log("\n\nHere is the augmented network object...");
121 console.warn(network);
122 }
123
124 function prepareNodesAndLinks() {
125 network.lookup = {};
126 network.nodes = [];
127 network.links = [];
128
129 var nw = network.forceWidth,
130 nh = network.forceHeight;
131
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700132 function yPosConstraintForNode(n) {
133 return config.constraints.ypos[n.type || 'host'];
134 }
135
136 // Note that both 'devices' and 'hosts' get mapped into the nodes array
137
138 // first, the devices...
139 network.data.devices.forEach(function(n) {
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700140 var ypc = yPosConstraintForNode(n),
Simon Hunt3ab76a82014-10-22 13:07:32 -0700141 ix = Math.random() * 0.6 * nw + 0.2 * nw,
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700142 iy = ypc * nh,
143 node = {
144 id: n.id,
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700145 labels: n.labels,
146 class: 'device',
147 icon: 'device',
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700148 type: n.type,
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700149 x: ix,
150 y: iy,
151 constraint: {
152 weight: 0.7,
153 y: iy
154 }
155 };
156 network.lookup[n.id] = node;
157 network.nodes.push(node);
158 });
159
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700160 // then, the hosts...
161 network.data.hosts.forEach(function(n) {
162 var ypc = yPosConstraintForNode(n),
163 ix = Math.random() * 0.6 * nw + 0.2 * nw,
164 iy = ypc * nh,
165 node = {
166 id: n.id,
167 labels: n.labels,
168 class: 'host',
169 icon: 'host',
170 type: n.type,
171 x: ix,
172 y: iy,
173 constraint: {
174 weight: 0.7,
175 y: iy
176 }
177 };
178 network.lookup[n.id] = node;
179 network.nodes.push(node);
180 });
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700181
182
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700183 // now, process the explicit links...
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700184 network.data.links.forEach(function(n) {
185 var src = network.lookup[n.src],
186 dst = network.lookup[n.dst],
187 id = src.id + "~" + dst.id;
188
189 var link = {
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700190 class: 'infra',
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700191 id: id,
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700192 type: n.type,
193 width: n.linkWidth,
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700194 source: src,
195 target: dst,
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700196 strength: config.force.linkStrength.infra
197 };
198 network.links.push(link);
199 });
200
201 // finally, infer host links...
202 network.data.hosts.forEach(function(n) {
203 var src = network.lookup[n.id],
204 dst = network.lookup[n.cp.device],
205 id = src.id + "~" + dst.id;
206
207 var link = {
208 class: 'host',
209 id: id,
210 type: 'hostLink',
211 width: config.hostLinkWidth,
212 source: src,
213 target: dst,
214 strength: config.force.linkStrength.host
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700215 };
216 network.links.push(link);
217 });
218 }
219
220 function createLayout() {
221
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700222 var cfg = config.force;
223
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700224 network.force = d3.layout.force()
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700225 .size([network.forceWidth, network.forceHeight])
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700226 .nodes(network.nodes)
227 .links(network.links)
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700228 .linkStrength(function(d) { return cfg.linkStrength[d.class]; })
229 .linkDistance(function(d) { return cfg.linkDistance[d.class]; })
230 .charge(function(d) { return cfg.charge[d.class]; })
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700231 .on('tick', tick);
232
233 network.svg = d3.select('#view').append('svg')
234 .attr('width', view.width)
235 .attr('height', view.height)
236 .append('g')
Simon Huntae968a62014-10-22 14:54:41 -0700237 .attr('transform', config.force.translate());
Simon Hunt3ab76a82014-10-22 13:07:32 -0700238// .attr('id', 'zoomable')
Simon Hunt3ab76a82014-10-22 13:07:32 -0700239// .call(d3.behavior.zoom().on("zoom", zoomRedraw));
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700240
Simon Hunt3ab76a82014-10-22 13:07:32 -0700241// function zoomRedraw() {
242// d3.select("#zoomable").attr("transform",
243// "translate(" + d3.event.translate + ")"
244// + " scale(" + d3.event.scale + ")");
245// }
246
247 // TODO: svg.append('defs') for markers?
248
249 // TODO: move glow/blur stuff to util script
250 var glow = network.svg.append('filter')
251 .attr('x', '-50%')
252 .attr('y', '-50%')
253 .attr('width', '200%')
254 .attr('height', '200%')
255 .attr('id', 'blue-glow');
256
257 glow.append('feColorMatrix')
258 .attr('type', 'matrix')
259 .attr('values', '0 0 0 0 0 ' +
260 '0 0 0 0 0 ' +
261 '0 0 0 0 .7 ' +
262 '0 0 0 1 0 ');
263
264 glow.append('feGaussianBlur')
265 .attr('stdDeviation', 3)
266 .attr('result', 'coloredBlur');
267
268 glow.append('feMerge').selectAll('feMergeNode')
269 .data(['coloredBlur', 'SourceGraphic'])
270 .enter().append('feMergeNode')
271 .attr('in', String);
272
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700273 // TODO: legend (and auto adjust on scroll)
Simon Hunt3ab76a82014-10-22 13:07:32 -0700274// $('#view').on('scroll', function() {
275//
276// });
277
278
279
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700280
281 network.link = network.svg.append('g').selectAll('.link')
282 .data(network.force.links(), function(d) {return d.id})
283 .enter().append('line')
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700284 .attr('class', function(d) {return 'link ' + d.class});
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700285
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700286
287 // == define node drag behavior...
Simon Hunt3ab76a82014-10-22 13:07:32 -0700288 network.draggedThreshold = d3.scale.linear()
289 .domain([0, 0.1])
290 .range([5, 20])
291 .clamp(true);
292
293 function dragged(d) {
294 var threshold = network.draggedThreshold(network.force.alpha()),
295 dx = d.oldX - d.px,
296 dy = d.oldY - d.py;
297 if (Math.abs(dx) >= threshold || Math.abs(dy) >= threshold) {
298 d.dragged = true;
299 }
300 return d.dragged;
301 }
302
303 network.drag = d3.behavior.drag()
304 .origin(function(d) { return d; })
305 .on('dragstart', function(d) {
306 d.oldX = d.x;
307 d.oldY = d.y;
308 d.dragged = false;
309 d.fixed |= 2;
310 })
311 .on('drag', function(d) {
312 d.px = d3.event.x;
313 d.py = d3.event.y;
314 if (dragged(d)) {
315 if (!network.force.alpha()) {
316 network.force.alpha(.025);
317 }
318 }
319 })
320 .on('dragend', function(d) {
321 if (!dragged(d)) {
322 selectObject(d, this);
323 }
324 d.fixed &= ~6;
325 });
326
327 $('#view').on('click', function(e) {
328 if (!$(e.target).closest('.node').length) {
329 deselectObject();
330 }
331 });
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700332
Simon Hunt1c5f8b62014-10-22 14:43:01 -0700333
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700334 network.node = network.svg.selectAll('.node')
335 .data(network.force.nodes(), function(d) {return d.id})
336 .enter().append('g')
Simon Hunt3ab76a82014-10-22 13:07:32 -0700337 .attr('class', function(d) {
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700338 var cls = 'node ' + d.class;
339 if (d.type) {
340 cls += ' ' + d.type;
341 }
342 return cls;
Simon Hunt3ab76a82014-10-22 13:07:32 -0700343 })
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700344 .attr('transform', function(d) {
345 return translate(d.x, d.y);
346 })
Simon Hunt3ab76a82014-10-22 13:07:32 -0700347 .call(network.drag)
348 .on('mouseover', function(d) {
349 if (!selected.obj) {
350 if (network.mouseoutTimeout) {
351 clearTimeout(network.mouseoutTimeout);
352 network.mouseoutTimeout = null;
353 }
354 highlightObject(d);
355 }
356 })
357 .on('mouseout', function(d) {
358 if (!selected.obj) {
359 if (network.mouseoutTimeout) {
360 clearTimeout(network.mouseoutTimeout);
361 network.mouseoutTimeout = null;
362 }
363 network.mouseoutTimeout = setTimeout(function() {
364 highlightObject(null);
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700365 }, config.mouseOutTimerDelayMs);
Simon Hunt3ab76a82014-10-22 13:07:32 -0700366 }
367 });
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700368
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700369 network.nodeRect = network.node.append('rect')
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700370 .attr('rx', 5)
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700371 .attr('ry', 5);
372 // note that width/height are adjusted to fit the label text
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700373
374 network.node.each(function(d) {
375 var node = d3.select(this),
Simon Hunt68ae6652014-10-22 13:58:07 -0700376 rect = node.select('rect'),
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700377 icon = iconUrl(d),
Simon Hunt68ae6652014-10-22 13:58:07 -0700378 text = node.append('text')
379 .text(d.id)
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700380 .attr('dy', '1.1em');
381
382 if (icon) {
383 var cfg = config.icons;
384 node.append('svg:image')
385 .attr('width', cfg.w)
386 .attr('height', cfg.h)
387 .attr('xlink:href', icon);
388 // note, icon relative positioning (x,y) is done after we have
389 // adjusted the bounds of the rectangle...
390 }
Simon Hunt68ae6652014-10-22 13:58:07 -0700391
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700392 });
393
394 // this function is scheduled to happen soon after the given thread ends
395 setTimeout(function() {
396 network.node.each(function(d) {
397 // for every node, recompute size, padding, etc. so text fits
398 var node = d3.select(this),
399 text = node.selectAll('text'),
400 bounds = {},
401 first = true;
402
403 // NOTE: probably unnecessary code if we only have one line.
Simon Hunt1c5f8b62014-10-22 14:43:01 -0700404 text.each(function() {
405 var box = this.getBBox();
406 if (first || box.x < bounds.x1) {
407 bounds.x1 = box.x;
408 }
409 if (first || box.y < bounds.y1) {
410 bounds.y1 = box.y;
411 }
412 if (first || box.x + box.width < bounds.x2) {
413 bounds.x2 = box.x + box.width;
414 }
415 if (first || box.y + box.height < bounds.y2) {
416 bounds.y2 = box.y + box.height;
417 }
418 first = false;
419 }).attr('text-anchor', 'middle');
420
421 var lab = config.labels,
422 oldWidth = bounds.x2 - bounds.x1;
423
424 bounds.x1 -= oldWidth / 2;
425 bounds.x2 -= oldWidth / 2;
426
427 bounds.x1 -= (lab.padLR + lab.imgPad);
428 bounds.y1 -= lab.padTB;
429 bounds.x2 += lab.padLR;
430 bounds.y2 += lab.padTB;
431
432 node.select('rect')
433 .attr('x', bounds.x1)
434 .attr('y', bounds.y1)
435 .attr('width', bounds.x2 - bounds.x1)
436 .attr('height', bounds.y2 - bounds.y1);
437
438 node.select('image')
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700439 .attr('x', bounds.x1 + config.icons.xoff)
440 .attr('y', bounds.y1 + config.icons.yoff);
Simon Hunt1c219892014-10-22 16:32:39 -0700441
442 d.extent = {
443 left: bounds.x1 - lab.marginLR,
444 right: bounds.x2 + lab.marginLR,
445 top: bounds.y1 - lab.marginTB,
446 bottom: bounds.y2 + lab.marginTB
447 };
448
449 d.edge = {
450 left : new geo.LineSegment(bounds.x1, bounds.y1, bounds.x1, bounds.y2),
451 right : new geo.LineSegment(bounds.x2, bounds.y1, bounds.x2, bounds.y2),
452 top : new geo.LineSegment(bounds.x1, bounds.y1, bounds.x2, bounds.y1),
453 bottom : new geo.LineSegment(bounds.x1, bounds.y2, bounds.x2, bounds.y2)
454 };
455
Simon Hunt1c5f8b62014-10-22 14:43:01 -0700456 // ====
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700457 });
458
459 network.numTicks = 0;
460 network.preventCollisions = false;
461 network.force.start();
Simon Hunt1c219892014-10-22 16:32:39 -0700462 for (var i = 0; i < config.force.ticksWithoutCollisions; i++) {
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700463 network.force.tick();
464 }
465 network.preventCollisions = true;
466 $('#view').css('visibility', 'visible');
467 });
468
469 }
470
Simon Hunt68ae6652014-10-22 13:58:07 -0700471 function iconUrl(d) {
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700472 return config.iconUrl[d.icon];
Simon Hunt68ae6652014-10-22 13:58:07 -0700473 }
474
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700475 function translate(x, y) {
476 return 'translate(' + x + ',' + y + ')';
477 }
478
Simon Hunt1c219892014-10-22 16:32:39 -0700479 function preventCollisions() {
480 var quadtree = d3.geom.quadtree(network.nodes);
481
482 network.nodes.forEach(function(n) {
483 var nx1 = n.x + n.extent.left,
484 nx2 = n.x + n.extent.right,
485 ny1 = n.y + n.extent.top,
486 ny2 = n.y + n.extent.bottom;
487
488 quadtree.visit(function(quad, x1, y1, x2, y2) {
489 if (quad.point && quad.point !== n) {
490 // check if the rectangles intersect
491 var p = quad.point,
492 px1 = p.x + p.extent.left,
493 px2 = p.x + p.extent.right,
494 py1 = p.y + p.extent.top,
495 py2 = p.y + p.extent.bottom,
496 ix = (px1 <= nx2 && nx1 <= px2 && py1 <= ny2 && ny1 <= py2);
497 if (ix) {
498 var xa1 = nx2 - px1, // shift n left , p right
499 xa2 = px2 - nx1, // shift n right, p left
500 ya1 = ny2 - py1, // shift n up , p down
501 ya2 = py2 - ny1, // shift n down , p up
502 adj = Math.min(xa1, xa2, ya1, ya2);
503
504 if (adj == xa1) {
505 n.x -= adj / 2;
506 p.x += adj / 2;
507 } else if (adj == xa2) {
508 n.x += adj / 2;
509 p.x -= adj / 2;
510 } else if (adj == ya1) {
511 n.y -= adj / 2;
512 p.y += adj / 2;
513 } else if (adj == ya2) {
514 n.y += adj / 2;
515 p.y -= adj / 2;
516 }
517 }
518 return ix;
519 }
520 });
521
522 });
523 }
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700524
525 function tick(e) {
526 network.numTicks++;
527
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700528 if (config.options.layering) {
Simon Hunt68ae6652014-10-22 13:58:07 -0700529 // adjust the y-coord of each node, based on y-pos constraints
530 network.nodes.forEach(function (n) {
531 var z = e.alpha * n.constraint.weight;
532 if (!isNaN(n.constraint.y)) {
533 n.y = (n.constraint.y * z + n.y * (1 - z));
534 }
535 });
536 }
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700537
Simon Hunt2c9e0c22014-10-23 15:12:58 -0700538 if (config.options.collisionPrevention && network.preventCollisions) {
Simon Hunt1c219892014-10-22 16:32:39 -0700539 preventCollisions();
540 }
541
542 // TODO: use intersection technique for source end of link also
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700543 network.link
544 .attr('x1', function(d) {
545 return d.source.x;
546 })
547 .attr('y1', function(d) {
548 return d.source.y;
549 })
Simon Hunt1c219892014-10-22 16:32:39 -0700550 .each(function(d) {
551 var x = d.target.x,
552 y = d.target.y,
553 line = new geo.LineSegment(d.source.x, d.source.y, x, y);
554
555 for (var e in d.target.edge) {
556 var ix = line.intersect(d.target.edge[e].offset(x,y));
557 if (ix.in1 && ix.in2) {
558 x = ix.x;
559 y = ix.y;
560 break;
561 }
562 }
563
564 d3.select(this)
565 .attr('x2', x)
566 .attr('y2', y);
567
Simon Hunt0b05d4a2014-10-21 21:50:15 -0700568 });
569
570 network.node
571 .attr('transform', function(d) {
572 return translate(d.x, d.y);
573 });
574
575 }
576
577 // $('#docs-close').on('click', function() {
578 // deselectObject();
579 // return false;
580 // });
581
582 // $(document).on('click', '.select-object', function() {
583 // var obj = graph.data[$(this).data('name')];
584 // if (obj) {
585 // selectObject(obj);
586 // }
587 // return false;
588 // });
589
590 function selectObject(obj, el) {
591 var node;
592 if (el) {
593 node = d3.select(el);
594 } else {
595 network.node.each(function(d) {
596 if (d == obj) {
597 node = d3.select(el = this);
598 }
599 });
600 }
601 if (!node) return;
602
603 if (node.classed('selected')) {
604 deselectObject();
605 return;
606 }
607 deselectObject(false);
608
609 selected = {
610 obj : obj,
611 el : el
612 };
613
614 highlightObject(obj);
615
616 node.classed('selected', true);
617
618 // TODO animate incoming info pane
619 // resize(true);
620 // TODO: check bounds of selected node and scroll into view if needed
621 }
622
623 function deselectObject(doResize) {
624 // Review: logic of 'resize(...)' function.
625 if (doResize || typeof doResize == 'undefined') {
626 resize(false);
627 }
628 // deselect all nodes in the network...
629 network.node.classed('selected', false);
630 selected = {};
631 highlightObject(null);
632 }
633
634 function highlightObject(obj) {
635 if (obj) {
636 if (obj != highlighted) {
637 // TODO set or clear "inactive" class on nodes, based on criteria
638 network.node.classed('inactive', function(d) {
639 // return (obj !== d &&
640 // d.relation(obj.id));
641 return (obj !== d);
642 });
643 // TODO: same with links
644 network.link.classed('inactive', function(d) {
645 return (obj !== d.source && obj !== d.target);
646 });
647 }
648 highlighted = obj;
649 } else {
650 if (highlighted) {
651 // clear the inactive flag (no longer suppressed visually)
652 network.node.classed('inactive', false);
653 network.link.classed('inactive', false);
654 }
655 highlighted = null;
656
657 }
658 }
659
660 function resize(showDetails) {
661 console.log("resize() called...");
662
663 var $details = $('#details');
664
665 if (typeof showDetails == 'boolean') {
666 var showingDetails = showDetails;
667 // TODO: invoke $details.show() or $details.hide()...
668 // $details[showingDetails ? 'show' : 'hide']();
669 }
670
671 view.height = window.innerHeight - config.mastHeight;
672 view.width = window.innerWidth;
673 $('#view')
674 .css('height', view.height + 'px')
675 .css('width', view.width + 'px');
676
677 network.forceWidth = view.width - config.force.marginLR;
678 network.forceHeight = view.height - config.force.marginTB;
679 }
680
681 // ======================================================================
682 // register with the UI framework
683
684 api.addView('network', {
685 load: loadNetworkView
686 });
687
688
689}(ONOS));
690