diff --git a/src/main/resources/web/js/models/topologymodel.js b/src/main/resources/web/js/models/topologymodel.js index be9fa302fa2b78ed0260e04118acaddd9823ade9..a1fef52df892d5641ca983aba209d47ba7b28045 100644 --- a/src/main/resources/web/js/models/topologymodel.js +++ b/src/main/resources/web/js/models/topologymodel.js @@ -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']),