diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index 3120197d2..f0f3ffa35 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -1,5 +1,4 @@ from __future__ import unicode_literals -import re from natsort import natsorted from operator import attrgetter diff --git a/netbox/ipam/constants.py b/netbox/ipam/constants.py index 8413d38c3..e2b98a1ef 100644 --- a/netbox/ipam/constants.py +++ b/netbox/ipam/constants.py @@ -61,7 +61,7 @@ VLAN_STATUS_CHOICES = ( (VLAN_STATUS_DEPRECATED, 'Deprecated') ) -# Bootstrap CSS classes for various statuses +# Bootstrap CSS classes STATUS_CHOICE_CLASSES = { 0: 'default', 1: 'primary', @@ -70,6 +70,16 @@ STATUS_CHOICE_CLASSES = { 4: 'warning', 5: 'success', } +ROLE_CHOICE_CLASSES = { + 10: 'default', + 20: 'primary', + 30: 'warning', + 40: 'success', + 41: 'success', + 42: 'success', + 43: 'success', + 44: 'success', +} # IP protocols (for services) IP_PROTOCOL_TCP = 6 diff --git a/netbox/ipam/models.py b/netbox/ipam/models.py index c6efdf646..5a9a16bb1 100644 --- a/netbox/ipam/models.py +++ b/netbox/ipam/models.py @@ -460,6 +460,9 @@ class IPAddress(CreatedUpdatedModel, CustomFieldModel): def get_status_class(self): return STATUS_CHOICE_CLASSES[self.status] + def get_role_class(self): + return ROLE_CHOICE_CLASSES[self.role] + @python_2_unicode_compatible class VLANGroup(models.Model): diff --git a/netbox/project-static/css/base.css b/netbox/project-static/css/base.css index fb9687d3a..dca3cd948 100644 --- a/netbox/project-static/css/base.css +++ b/netbox/project-static/css/base.css @@ -395,6 +395,9 @@ table.reports td.stats label { } /* Misc */ +.text-nowrap { + white-space: nowrap; +} .banner-bottom { margin-bottom: 50px; } diff --git a/netbox/templates/dcim/device.html b/netbox/templates/dcim/device.html index 056396991..549b93465 100644 --- a/netbox/templates/dcim/device.html +++ b/netbox/templates/dcim/device.html @@ -7,7 +7,7 @@ {% block content %} {% include 'dcim/inc/device_header.html' with active_tab='info' %}
-
+
Device @@ -172,6 +172,69 @@ {% with device.get_custom_fields as custom_fields %} {% include 'inc/custom_fields_panel.html' %} {% endwith %} +
+
+ Comments +
+
+ {% if device.comments %} + {{ device.comments|gfm }} + {% else %} + None + {% endif %} +
+
+
+
+
+
+ Console / Power +
+ + {% for cp in console_ports %} + {% include 'dcim/inc/consoleport.html' %} + {% empty %} + {% if device.device_type.console_port_templates.exists %} + + + + {% endif %} + {% endfor %} + {% for pp in power_ports %} + {% include 'dcim/inc/powerport.html' %} + {% empty %} + {% if device.device_type.power_port_templates.exists %} + + + + {% endif %} + {% endfor %} +
+ No console ports defined + {% if perms.dcim.add_consoleport %} + + {% endif %} +
+ No power ports defined + {% if perms.dcim.add_powerport %} + + {% endif %} +
+ {% if perms.dcim.add_interface or perms.dcim.add_consoleport or perms.dcim.add_powerport %} + + {% endif %} +
{% if request.user.is_authenticated %}
@@ -224,67 +287,6 @@
{% endif %}
-
-
- Console / Power -
- - {% for cp in console_ports %} - {% include 'dcim/inc/consoleport.html' %} - {% empty %} - {% if device.device_type.console_port_templates.exists %} - - - - {% endif %} - {% endfor %} - {% for pp in power_ports %} - {% include 'dcim/inc/powerport.html' %} - {% empty %} - {% if device.device_type.power_port_templates.exists %} - - - - {% endif %} - {% endfor %} -
- No console ports defined - {% if perms.dcim.add_consoleport %} - - {% endif %} -
- No power ports defined - {% if perms.dcim.add_powerport %} - - {% endif %} -
- {% if perms.dcim.add_interface or perms.dcim.add_consoleport or perms.dcim.add_powerport %} - - {% endif %} -
-
-
- Comments -
-
- {% if device.comments %} - {{ device.comments|gfm }} - {% else %} - None - {% endif %} -
-
Images @@ -326,7 +328,9 @@ {% endif %}
-
+
+
+
{% if device_bays or device.device_type.is_parent_device %} {% if perms.dcim.delete_devicebay %}
@@ -350,7 +354,7 @@
{% for devicebay in device_bays %} - {% include 'dcim/inc/devicebay.html' with selectable=True %} + {% include 'dcim/inc/devicebay.html' %} {% empty %} @@ -405,11 +409,23 @@
No device bays defined
+ + {% if perms.dcim.change_interface or perms.dcim.delete_interface %} + + {% endif %} + + + + + + + + {% for iface in interfaces %} - {% include 'dcim/inc/interface.html' with selectable=True %} + {% include 'dcim/inc/interface.html' %} {% empty %} - + {% endfor %}
NameLAGDescriptionMTUMAC AddressConnection
No interfaces definedNo interfaces defined
@@ -467,8 +483,16 @@
+ + {% if perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %} + + {% endif %} + + + + {% for csp in cs_ports %} - {% include 'dcim/inc/consoleserverport.html' with selectable=True %} + {% include 'dcim/inc/consoleserverport.html' %} {% empty %} @@ -524,12 +548,20 @@
NameConnection
No console server ports defined
+ + {% if perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %} + + {% endif %} + + + + {% for po in power_outlets %} - {% include 'dcim/inc/poweroutlet.html' with selectable=True %} + {% include 'dcim/inc/poweroutlet.html' %} {% empty %} - + text-nowrap {% endfor %}
NameConnection
No power outlets defined
{% if perms.dcim.add_poweroutlet or perms.dcim.delete_poweroutlet %} diff --git a/netbox/templates/dcim/inc/consoleserverport.html b/netbox/templates/dcim/inc/consoleserverport.html index 62da09245..aed27d62a 100644 --- a/netbox/templates/dcim/inc/consoleserverport.html +++ b/netbox/templates/dcim/inc/consoleserverport.html @@ -1,5 +1,5 @@ - {% if selectable and perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %} + {% if perms.dcim.change_consoleserverport or perms.dcim.delete_consoleserverport %} @@ -7,7 +7,6 @@ {{ csp }} - {% if csp.connected_console %} {{ csp.connected_console.device }} @@ -20,7 +19,7 @@ Not connected {% endif %} - + {% if perms.dcim.change_consoleserverport %} {% if csp.connected_console %} {% if csp.connected_console.connection_status %} diff --git a/netbox/templates/dcim/inc/devicebay.html b/netbox/templates/dcim/inc/devicebay.html index f974f9fcb..2a1a9708d 100644 --- a/netbox/templates/dcim/inc/devicebay.html +++ b/netbox/templates/dcim/inc/devicebay.html @@ -1,5 +1,5 @@ - {% if selectable and perms.dcim.change_devicebay or perms.dcim.delete_devicebay %} + {% if perms.dcim.change_devicebay or perms.dcim.delete_devicebay %} diff --git a/netbox/templates/dcim/inc/interface.html b/netbox/templates/dcim/inc/interface.html index c6d36dbef..c67bc18ee 100644 --- a/netbox/templates/dcim/inc/interface.html +++ b/netbox/templates/dcim/inc/interface.html @@ -1,21 +1,37 @@ - - {% if selectable and perms.dcim.change_interface or perms.dcim.delete_interface %} + + + {# Checkbox #} + {% if perms.dcim.change_interface or perms.dcim.delete_interface %} {% endif %} + + {# Icon and name #} + + + + {{ iface }} + + + + {# LAG #} - - {{ iface }} {% if iface.lag %} - {{ iface.lag }} - {% endif %} - {% if iface.description %} - + {{ iface.lag }} {% endif %} + + {# Description #} + {{ iface.description }} + + {# MTU #} {{ iface.mtu|default:"" }} + + {# MAC address #} {{ iface.mac_address|default:"" }} + + {# Connection or type #} {% if iface.is_lag %} LAG interface
@@ -55,7 +71,9 @@ Not connected {% endif %} - + + {# Buttons #} + {% if show_graphs %} {% if iface.circuit_termination or iface.connection %} {% else %} - + {% endif %} {% endif %} -{% with iface.ip_addresses.all as ipaddresses %} - {% if ipaddresses %} - - {% if selectable and perms.dcim.change_interface or perms.dcim.delete_interface %} - - - {% else %} - +{% for ip in iface.ip_addresses.all %} + + + {# Placeholder #} + {% if perms.dcim.change_interface or perms.dcim.delete_interface %} + + {% endif %} + + {# IP address #} + + {{ ip }} + + + {# Primary, status, role #} + + {% if device.primary_ip4 == ip or device.primary_ip6 == ip %} + Primary {% endif %} - - {% for ip in ipaddresses %} - - - - - - - - {% endfor %} -
- {{ ip }} - {% if ip.description %} - - {% endif %} - - {% if device.primary_ip4 == ip or device.primary_ip6 == ip %} - Primary - {% endif %} - - {% if ip.vrf %} - {{ ip.vrf }} - {% else %} - Global table - {% endif %} - - {{ ip.get_status_display }} - - {% if perms.ipam.change_ipaddress %} - - - - {% endif %} - {% if perms.ipam.delete_ipaddress %} - - - - {% endif %} -
- - - {% endif %} -{% endwith %} + {{ ip.get_status_display }} + + + {# VRF #} + + {% if ip.vrf %} + {{ ip.vrf.name }} + {% else %} + Global + {% endif %} + + + {# Description #} + + {{ ip.description }} + + + {# Buttons #} + + {% if perms.ipam.change_ipaddress %} + + + + {% endif %} + {% if perms.ipam.delete_ipaddress %} + + + + {% endif %} + + +{% endfor %} diff --git a/netbox/templates/dcim/inc/poweroutlet.html b/netbox/templates/dcim/inc/poweroutlet.html index b462e1ca1..306977207 100644 --- a/netbox/templates/dcim/inc/poweroutlet.html +++ b/netbox/templates/dcim/inc/poweroutlet.html @@ -1,5 +1,5 @@ - {% if selectable and perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %} + {% if perms.dcim.change_poweroutlet or perms.dcim.delete_poweroutlet %} @@ -7,7 +7,6 @@ {{ po }} - {% if po.connected_port %} {{ po.connected_port.device }} @@ -20,7 +19,7 @@ Not connected {% endif %} - + {% if perms.dcim.change_poweroutlet %} {% if po.connected_port %} {% if po.connected_port.connection_status %} diff --git a/netbox/templates/virtualization/inc/interface.html b/netbox/templates/virtualization/inc/interface.html deleted file mode 100644 index bea4758d7..000000000 --- a/netbox/templates/virtualization/inc/interface.html +++ /dev/null @@ -1,70 +0,0 @@ - - {% if selectable and perms.dcim.change_interface or perms.dcim.delete_interface %} - - - - {% endif %} - - {{ iface }} - {% if iface.description %} - - {% endif %} - - {{ iface.mtu|default:"" }} - {{ iface.mac_address|default:"" }} - - {% if perms.ipam.add_ipaddress %} - - - - {% endif %} - {% if perms.dcim.change_interface %} - - - - {% endif %} - {% if perms.dcim.delete_interface %} - - - - {% endif %} - - -{% for ip in iface.ip_addresses.all %} - - {% if selectable and perms.dcim.change_interface or perms.dcim.delete_interface %} - - {% endif %} - - {{ ip }} - {% if ip.description %} - - {% endif %} - {% if vm.primary_ip4 == ip or vm.primary_ip6 == ip %} - Primary - {% endif %} - - - {% if ip.vrf %} - {{ ip.vrf }} - {% else %} - Global - {% endif %} - - - {{ ip.get_status_display }} - - - {% if perms.ipam.change_ipaddress %} - - - - {% endif %} - {% if perms.ipam.delete_ipaddress %} - - - - {% endif %} - - -{% endfor %} diff --git a/netbox/templates/virtualization/virtualmachine.html b/netbox/templates/virtualization/virtualmachine.html index 194461a90..7f9e948e7 100644 --- a/netbox/templates/virtualization/virtualmachine.html +++ b/netbox/templates/virtualization/virtualmachine.html @@ -41,7 +41,7 @@

{% block title %}{{ vm }}{% endblock %}

{% include 'inc/created_updated.html' with obj=vm %}
-
+
Virtual Machine @@ -123,6 +123,21 @@
+ {% include 'inc/custom_fields_panel.html' with custom_fields=vm.get_custom_fields %} +
+
+ Comments +
+
+ {% if vm.comments %} + {{ vm.comments|gfm }} + {% else %} + None + {% endif %} +
+
+
+
Cluster @@ -204,21 +219,10 @@
{% endif %}
- {% include 'inc/custom_fields_panel.html' with custom_fields=vm.get_custom_fields %} -
-
- Comments -
-
- {% if vm.comments %} - {{ vm.comments|gfm }} - {% else %} - None - {% endif %} -
-
-
+
+
+
{% if perms.dcim.change_interface or perms.dcim.delete_interface %} {% csrf_token %} @@ -244,11 +248,23 @@
+ + {% if perms.dcim.change_interface or perms.dcim.delete_interface %} + + {% endif %} + + + + + + + + {% for iface in interfaces %} - {% include 'virtualization/inc/interface.html' with selectable=True %} + {% include 'dcim/inc/interface.html' with device=vm %} {% empty %} - + {% endfor %}
NameLAGDescriptionMTUMAC AddressConnection
No interfaces definedNo interfaces defined