Skip to content
Snippets Groups Projects
Commit 4f61acc6 authored by Wes Felter's avatar Wes Felter
Browse files

UI: Fix topology view when you only have one switch.

parent 3b16b7b8
No related branches found
No related tags found
No related merge requests found
......@@ -34,14 +34,20 @@ window.Topology = Backbone.Model.extend({
// console.log(data);
self.nodes = {};
self.links = [];
// step 1: build unique array of switch IDs
/* this doesn't work if there's only one switch,
because there are no switch-switch links
_.each(data, function (l) {
self.nodes[l['src-switch']] = true;
self.nodes[l['dst-switch']] = true;
});
// console.log(self.nodes);
var nl = _.keys(self.nodes);
*/
var nl = swl.pluck('id');
self.nodes = _.map(nl, function (n) {return {name:n}});
// step 2: build array of links in format D3 expects
_.each(data, function (l) {
self.links.push({source:nl.indexOf(l['src-switch']),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment