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

UI: Give host models a proper id to fix infinite hosts problem.

Updated UI to match REST API changes.
Commented out references to VLANs since they're not implemented.
Fixed some more space/tab formatting.
parent 4273f9d1
No related branches found
No related tags found
No related merge requests found
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
window.Host = Backbone.Model.extend({ window.Host = Backbone.Model.extend({
defaults: { defaults: {
vlan: -1, // vlan: -1,
seen: 'never', lastSeen: 'never',
ip: ' ', ip: ' ',
swport: ' ', swport: ' ',
}, },
...@@ -43,6 +43,7 @@ window.HostCollection = Backbone.Collection.extend({ ...@@ -43,6 +43,7 @@ window.HostCollection = Backbone.Collection.extend({
// 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.id = h.mac[0];
h.swport = _.reduce(h['attachmentPoint'], function(memo, ap) { h.swport = _.reduce(h['attachmentPoint'], function(memo, ap) {
return memo + ap.switchDPID + "-" + ap.port + " "}, ""); return memo + ap.switchDPID + "-" + ap.port + " "}, "");
//console.log(h.swport); //console.log(h.swport);
...@@ -56,7 +57,7 @@ window.HostCollection = Backbone.Collection.extend({ ...@@ -56,7 +57,7 @@ window.HostCollection = Backbone.Collection.extend({
}, },
fetch:function () { fetch:function () {
this.initialize() this.initialize();
} }
/* /*
......
...@@ -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>
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