Skip to content
Snippets Groups Projects
Commit ee9658ac authored by abat's avatar abat
Browse files

Merge into master from pull request #173:

Update Web UI to match recent REST API changes (https://github.com/floodlight/floodlight/pull/173)
parents 37f9676c 15695d78
No related branches found
No related tags found
No related merge requests found
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
window.Host = Backbone.Model.extend({ window.Host = Backbone.Model.extend({
defaults: { defaults: {
vlan: -1, // vlan: -1,
seen: 'never', lastSeen: 'never',
ip: ' ', ip: ' ',
swport: ' ', swport: ' ',
}, },
// initialize:function () {} // initialize:function () {}
...@@ -42,12 +42,13 @@ window.HostCollection = Backbone.Collection.extend({ ...@@ -42,12 +42,13 @@ window.HostCollection = Backbone.Collection.extend({
// console.log(data); // console.log(data);
// data is a list of device hashes // data is a list of device hashes
_.each(data, function(h) { _.each(data, function(h) {
if (h['attachmentPoint'].length > 0) { if (h['attachmentPoint'].length > 0) {
h.swport = _.reduce(h['attachmentPoint'], function(memo, ap) { h.id = h.mac[0];
return memo + ap.dpid + "-" + ap.port + " "}, "") h.swport = _.reduce(h['attachmentPoint'], function(memo, ap) {
console.log(h.swport); return memo + ap.switchDPID + "-" + ap.port + " "}, "");
self.add(h, {silent: true}); //console.log(h.swport);
} self.add(h, {silent: true});
}
}); });
self.trigger('add'); // batch redraws self.trigger('add'); // batch redraws
} }
...@@ -56,24 +57,15 @@ window.HostCollection = Backbone.Collection.extend({ ...@@ -56,24 +57,15 @@ window.HostCollection = Backbone.Collection.extend({
}, },
fetch:function () { fetch:function () {
this.initialize() this.initialize();
} }
/* /*
findByName:function (key) { * findByName:function (key) { // TODO: Modify service to include firstName
// TODO: Modify service to include firstName in search * in search var url = (key == '') ? '/host/' : "/host/search/" + key;
var url = (key == '') ? '/host/' : "/host/search/" + key; * console.log('findByName: ' + key); var self = this; $.ajax({ url:url,
console.log('findByName: ' + key); * dataType:"json", success:function (data) { console.log("search success: " +
var self = this; * data.length); self.reset(data); } }); }
$.ajax({ */
url:url,
dataType:"json",
success:function (data) {
console.log("search success: " + data.length);
self.reset(data);
}
});
}
*/
}); });
...@@ -42,7 +42,7 @@ window.HostListView = Backbone.View.extend({ ...@@ -42,7 +42,7 @@ window.HostListView = Backbone.View.extend({
$(this.el).html(this.template({nhosts:hl.length})); $(this.el).html(this.template({nhosts:hl.length}));
_.each(this.model.models, function (h) { _.each(this.model.models, function (h) {
$(this.el).find('table.host-table > tbody') $(this.el).find('table.host-table > tbody')
.append(new HostListItemView({model:h}).render().el); .append(new HostListItemView({model:h}).render().el);
}, this); }, this);
return this; return this;
} }
......
<td><a href="/host/<%= mac %>"><%= mac %></a></td><td><%= vlan %></td><td><%= ipv4 %></td><td><%= swport %></td><td><%= lastSeen %></td> <td><a href="/host/<%= mac %>"><%= mac %></a></td><!-- <td><%= vlan %></td> --><td><%= ipv4 %></td><td><%= swport %></td><td><%= lastSeen %></td>
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<h1>Hosts (<%= nhosts %>)</h1> <h1>Hosts (<%= nhosts %>)</h1>
</div> </div>
<table class="table striped-table host-table"> <table class="table striped-table host-table">
<thead><tr><th>MAC Address</th><th>VLAN</th><th>IP Address</th><th>Switch Port</th><th>Last Seen</th></tr></thead> <thead><tr><th>MAC Address</th><!-- <th>VLAN</th> --><th>IP Address</th><th>Switch Port</th><th>Last Seen</th></tr></thead>
<tbody> <tbody>
<!-- hosts will be inserted here by HostListView.render --> <!-- hosts will be inserted here by HostListView.render -->
</tbody> </tbody>
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
</div> </div>
<p> <p>
<!-- VLAN: <a href="/vlan/<%= vlan %>"><%= vlan %></a><br> --> <!-- VLAN: <a href="/vlan/<%= vlan %>"><%= vlan %></a><br> -->
VLAN: <%= vlan %><br> IP addresses: <%= ipv4 %><br>
IP addresses: <%= ip %><br>
Attachment points: <%= swport %><br> Attachment points: <%= swport %><br>
Last seen: <%= seen %> Last seen: <%= lastSeen %>
</p> </p>
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<div class="page-header"> <div class="page-header">
<h1>Network Topology</h1> <h1>Network Topology</h1>
</div> </div>
<p>Beautiful topology graph goes here</p>
<div id="topology-graph"></div> <div id="topology-graph"></div>
</div> </div>
</div> </div>
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