diff --git a/src/main/resources/web/js/main.js b/src/main/resources/web/js/main.js index cde561b7f24f525ee74023242b6194a498b92e6f..7e0ac8106a78109f9b48da40c70f61d43c749ad3 100644 --- a/src/main/resources/web/js/main.js +++ b/src/main/resources/web/js/main.js @@ -47,7 +47,7 @@ var AppRouter = Backbone.Router.extend({ }, topology:function () { - console.log("switching to topology view"); + //console.log("switching to topology view"); var topo = new Topology(); $('#content').html(new TopologyView({model:topo, hosts:hl}).render().el); // TODO factor this code out @@ -56,7 +56,7 @@ var AppRouter = Backbone.Router.extend({ }, switchDetails:function (id) { - console.log("switching [sic] to single switch view"); + //console.log("switching [sic] to single switch view"); var sw = swl.get(id); $('#content').html(new SwitchView({model:sw}).render().el); $('ul.nav > li').removeClass('active'); @@ -64,14 +64,14 @@ var AppRouter = Backbone.Router.extend({ }, switchList:function () { - console.log("switching [sic] to switch list view"); + //console.log("switching [sic] to switch list view"); $('#content').html(new SwitchListView({model:swl}).render().el); $('ul.nav > li').removeClass('active'); $('li > a[href*="/switches"]').parent().addClass('active'); }, hostDetails:function (id) { - console.log("switching to single host view"); + //console.log("switching to single host view"); var h = hl.get(id); $('#content').html(new HostView({model:h}).render().el); $('ul.nav > li').removeClass('active'); @@ -79,7 +79,7 @@ var AppRouter = Backbone.Router.extend({ }, hostList:function () { - console.log("switching to host list view"); + //console.log("switching to host list view"); $('#content').html(new HostListView({model:hl}).render().el); $('ul.nav > li').removeClass('active'); $('li > a[href*="/hosts"]').parent().addClass('active'); @@ -117,3 +117,11 @@ tpl.loadTemplates(['home', 'status', 'topology', 'header', 'switch', 'switch-lis }); }); +setInterval(function () { + swl.fetch(); +}, 3000); + +setInterval(function () { + hl.fetch(); +}, 3000); + diff --git a/src/main/resources/web/js/models/hostmodel.js b/src/main/resources/web/js/models/hostmodel.js index 957f275f544521c6f029fd95239b1f89753b9dfc..1c515d58a1a042f72052ab768d04cca4067b965b 100644 --- a/src/main/resources/web/js/models/hostmodel.js +++ b/src/main/resources/web/js/models/hostmodel.js @@ -33,12 +33,12 @@ window.HostCollection = Backbone.Collection.extend({ initialize:function () { var self = this; - console.log("fetching host list") + //console.log("fetching host list") $.ajax({ url:hackBase + "/wm/device/", dataType:"json", success:function (data) { - console.log("fetched host list: " + data.length); + // console.log("fetched host list: " + data.length); // console.log(data); // data is a list of device hashes _.each(data, function(h) { @@ -53,6 +53,10 @@ window.HostCollection = Backbone.Collection.extend({ } }); + }, + + fetch:function () { + this.initialize() } /* diff --git a/src/main/resources/web/js/models/switchmodel.js b/src/main/resources/web/js/models/switchmodel.js index 6d9bbf937432c1f42b5aea1328af017d2f0369fa..79480aaef8248d80f228b7b79646a10cf435576a 100644 --- a/src/main/resources/web/js/models/switchmodel.js +++ b/src/main/resources/web/js/models/switchmodel.js @@ -32,43 +32,47 @@ window.Switch = Backbone.Model.extend({ initialize:function () { var self = this; - console.log("fetching switch " + this.id + " desc") + //console.log("fetching switch " + this.id + " desc") $.ajax({ url:hackBase + "/wm/core/switch/" + self.id + '/desc/json', dataType:"json", success:function (data) { - console.log("fetched switch " + self.id + " desc"); + //console.log("fetched switch " + self.id + " desc"); //console.log(data[self.id][0]); self.set(data[self.id][0]); } }); - console.log("fetching switch " + this.id + " aggregate") + //console.log("fetching switch " + this.id + " aggregate") $.ajax({ url:hackBase + "/wm/core/switch/" + self.id + '/aggregate/json', dataType:"json", success:function (data) { - console.log("fetched switch " + self.id + " aggregate"); - //console.log(data[self.id][0]); + //console.log("fetched switch " + self.id + " aggregate"); + //console.log(data[self.id][0]); self.set(data[self.id][0]); } }); - + self.trigger('add'); this.ports = new PortCollection(); - this.flows = new FlowCollection(); + this.loadPorts(); + this.loadFlows(); + }, + fetch:function () { + this.initialize() }, loadPorts:function () { if (this.ports.length == 0) { var self = this; - console.log("fetching switch " + this.id + " ports") + //console.log("fetching switch " + this.id + " ports") $.ajax({ url:hackBase + "/wm/core/switch/" + self.id + '/port/json', dataType:"json", success:function (data) { - console.log("fetched switch " + self.id + " ports"); + //console.log("fetched switch " + self.id + " ports"); // console.log(data[self.id]); // create port models // TODO maybe clean up the errors @@ -86,12 +90,12 @@ window.Switch = Backbone.Model.extend({ loadFlows:function () { var self = this; - console.log("fetching switch " + this.id + " flows") + //console.log("fetching switch " + this.id + " flows") $.ajax({ url:hackBase + "/wm/core/switch/" + self.id + '/flow/json', dataType:"json", success:function (data) { - console.log("fetched switch " + self.id + " flows"); + //console.log("fetched switch " + self.id + " flows"); // console.log(data[self.id]); // create flow models var i = 0; @@ -119,17 +123,20 @@ window.SwitchCollection = Backbone.Collection.extend({ initialize:function () { var self = this; - console.log("fetching switch list") + //console.log("fetching switch list") $.ajax({ url:hackBase + "/wm/core/controller/switches/json", dataType:"json", success:function (data) { - console.log("fetched switch list: " + data.length); + //console.log("fetched switch list: " + data.length); // console.log(data); _.each(data, function(sw) {self.add({id: sw['dpid']})}); } }); + }, + fetch:function () { + this.initialize() } diff --git a/src/main/resources/web/js/views/switch.js b/src/main/resources/web/js/views/switch.js index 081c2b0de87d13d8f8552967a27b5e0485d7365b..9aa850a364ced8f85374fa1522268127da8c9590 100644 --- a/src/main/resources/web/js/views/switch.js +++ b/src/main/resources/web/js/views/switch.js @@ -42,7 +42,7 @@ window.SwitchListItemView = Backbone.View.extend({ initialize:function () { this.template = _.template(tpl.get('switch-list-item')); this.model.bind("change", this.render, this); - //this.model.bind("destroy", this.close, this); + //this.model.bind("destroy", this.close, this); }, render:function (eventName) { diff --git a/src/main/resources/web/js/views/topology.js b/src/main/resources/web/js/views/topology.js index a82098e1802d9f57af92524fcea805ac9c0386f4..60b1a93809853ebef2cf8deeeca8d801c4f3e10d 100644 --- a/src/main/resources/web/js/views/topology.js +++ b/src/main/resources/web/js/views/topology.js @@ -43,7 +43,12 @@ window.TopologyView = Backbone.View.extend({ for (var i = 0; i < this.hosts.length; i++) { host = this.hosts[i]; - host.name = host.attributes['network-addresses'][0]['ip'] + "\n" + host.id; + if (( host.attributes['network-addresses'].length > 0 ) && + ('ip' in host.attributes['network-addresses'][0])) { + host.name = host.attributes['network-addresses'][0]['ip'] + "\n" + host.id; + } else { + host.name = host.id; + } host.group = 2; console.log(host); } diff --git a/src/main/resources/web/tpl/switch-list-item.html b/src/main/resources/web/tpl/switch-list-item.html index 680d50934507900a90dc3a961bf65658fd1835c6..7a20a5a09ad02cb3123d38e4029ddb7c4c0e98c9 100644 --- a/src/main/resources/web/tpl/switch-list-item.html +++ b/src/main/resources/web/tpl/switch-list-item.html @@ -1 +1 @@ - <td><a href="/switch/<%= id %>"><%= id %></a></td><td><%= packetCount %></td><td><%= byteCount %></td><td><%= flowCount %></td> +<td><a href="/switch/<%= id %>"><%= id %></a></td><td><%= manufacturerDescription %><td><%= packetCount %></td><td><%= byteCount %></td><td><%= flowCount %></td> diff --git a/src/main/resources/web/tpl/switch-list.html b/src/main/resources/web/tpl/switch-list.html index 3a23f7e61776a2a9a9d750ceb28a1d2a66b9af98..45c02f55f13b1024d9882bb489cda6cce8f6c8f4 100644 --- a/src/main/resources/web/tpl/switch-list.html +++ b/src/main/resources/web/tpl/switch-list.html @@ -4,7 +4,7 @@ <h1>Switches (<%= nswitches %>)</h1> </div> <table class="table striped-table switch-table"> - <thead><tr><th>DPID</th><th>Packets</th><th>Bytes</th><th>Flows</th></tr></thead> + <thead><tr><th>DPID</th><th>Vendor</th><th>Packets</th><th>Bytes</th><th>Flows</th></tr></thead> <tbody> <!-- switches will be inserted here by SwitchListView:render --> </tbody>