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 @@
window.Host = Backbone.Model.extend({
defaults: {
vlan: -1,
seen: 'never',
// vlan: -1,
lastSeen: 'never',
ip: ' ',
swport: ' ',
},
......@@ -43,6 +43,7 @@ window.HostCollection = Backbone.Collection.extend({
// data is a list of device hashes
_.each(data, function(h) {
if (h['attachmentPoint'].length > 0) {
h.id = h.mac[0];
h.swport = _.reduce(h['attachmentPoint'], function(memo, ap) {
return memo + ap.switchDPID + "-" + ap.port + " "}, "");
//console.log(h.swport);
......@@ -56,7 +57,7 @@ window.HostCollection = Backbone.Collection.extend({
},
fetch:function () {
this.initialize()
this.initialize();
}
/*
......
......@@ -42,7 +42,7 @@ window.HostListView = Backbone.View.extend({
$(this.el).html(this.template({nhosts:hl.length}));
_.each(this.model.models, function (h) {
$(this.el).find('table.host-table > tbody')
.append(new HostListItemView({model:h}).render().el);
.append(new HostListItemView({model:h}).render().el);
}, 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 @@
<h1>Hosts (<%= nhosts %>)</h1>
</div>
<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>
<!-- hosts will be inserted here by HostListView.render -->
</tbody>
......
......@@ -5,8 +5,7 @@
</div>
<p>
<!-- VLAN: <a href="/vlan/<%= vlan %>"><%= vlan %></a><br> -->
VLAN: <%= vlan %><br>
IP addresses: <%= ip %><br>
IP addresses: <%= ipv4 %><br>
Attachment points: <%= swport %><br>
Last seen: <%= seen %>
Last seen: <%= lastSeen %>
</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