Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2160.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Show VLAN description in ipdevinfo portslist
7 changes: 7 additions & 0 deletions python/nav/models/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,13 @@ def audit_logname(self):
ifname=self.ifname, netbox=self.netbox.get_short_sysname()
)

@property
def vlan_description(self):
if self.vlan is None:
return None
swportvlan = self.swport_vlans.filter(vlan__vlan=self.vlan).first()
return swportvlan.vlan.description if swportvlan else None

@classmethod
def sort_ports_by_ifname(cls, ports):
return sorted(ports, key=lambda p: nav.natsort.split(p.ifname))
Expand Down
1 change: 1 addition & 0 deletions python/nav/web/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ class InterfaceSerializer(serializers.ModelSerializer):
source='get_bundled_interfaces', many=True
)
netbox = SubNetboxSerializer()
vlan_description = serializers.CharField(read_only=True)

class Meta(object):
model = manage.Interface
Expand Down
9 changes: 8 additions & 1 deletion python/nav/web/static/js/src/porttable.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ define(function(require) {
}
},

{
data: "vlan_description",
render: function(data, type, row, meta) {
return data;
}
},

{
data: "speed",
render: function(data, type, row, meta) {
Expand Down Expand Up @@ -163,7 +170,7 @@ define(function(require) {
fixSearchDelay(this.dataTable);

// Special treatment for the last used column that is an optional column
var lastUsedColIndex = 8;
var lastUsedColIndex = 9;
var lastUsedColumn = this.dataTable.column(lastUsedColIndex);

// Create form, add handlers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<th title="Administrative status - is enabled or not">Admin</th>
<th title="Operational status - has link or not">Link</th>
<th>Vlan</th>
<th>Vlan description</th>
<th title="Speed in Mbit/s and duplex (full or half)">Speed</th>
<th title="Last time a mac-address was seen behind this port" class="last_used">
Last used
Expand Down
Loading