1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Initial work on #20 - patch panels

This commit is contained in:
Jeremy Stretch
2018-10-03 14:04:16 -04:00
parent 364bbdeab8
commit 3eddeeadc5
18 changed files with 1101 additions and 34 deletions

View File

@@ -689,6 +689,111 @@
</form>
{% endif %}
{% endif %}
{% if front_panel_ports or device.device_type.is_patch_panel %}
<form method="post">
{% csrf_token %}
<div class="panel panel-default">
<div class="panel-heading">
<strong>Front Panel Ports</strong>
</div>
<table class="table table-hover table-headings panel-body component-list">
<thead>
<tr>
{% if perms.dcim.change_frontpanelport or perms.dcim.delete_frontpanelport %}
<th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
{% endif %}
<th>Name</th>
<th>Type</th>
<th>Rear Port</th>
<th>Position</th>
<th></th>
</tr>
</thead>
<tbody>
{% for frontpanelport in front_panel_ports %}
{% include 'dcim/inc/frontpanelport.html' %}
{% empty %}
<tr>
<td colspan="5" class="text-center text-muted">&mdash; No front panel ports defined &mdash;</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="panel-footer">
{% if front_panel_ports and perms.dcim.change_frontpanelport %}
<button type="submit" name="_rename" formaction="{% url 'dcim:frontpanelport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
</button>
{% endif %}
{% if front_panel_ports and perms.dcim.delete_frontpanelport %}
<button type="submit" formaction="{% url 'dcim:frontpanelport_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
</button>
{% endif %}
{% if perms.dcim.add_frontpanelport %}
<div class="pull-right">
<a href="{% url 'dcim:frontpanelport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add front panel ports
</a>
</div>
<div class="clearfix"></div>
{% endif %}
</div>
</div>
</form>
{% endif %}
{% if rear_panel_ports or device.device_type.is_patch_panel %}
<form method="post">
{% csrf_token %}
<div class="panel panel-default">
<div class="panel-heading">
<strong>Rear Panel Ports</strong>
</div>
<table class="table table-hover table-headings panel-body component-list">
<thead>
<tr>
{% if perms.dcim.change_rearpanelport or perms.dcim.delete_rearpanelport %}
<th class="pk"><input type="checkbox" class="toggle" title="Toggle all" /></th>
{% endif %}
<th>Name</th>
<th>Type</th>
<th>Positions</th>
<th></th>
</tr>
</thead>
<tbody>
{% for rearpanelport in rear_panel_ports %}
{% include 'dcim/inc/rearpanelport.html' %}
{% empty %}
<tr>
<td colspan="5" class="text-center text-muted">&mdash; No rear panel ports defined &mdash;</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="panel-footer">
{% if rear_panel_ports and perms.dcim.change_rearpanelport %}
<button type="submit" name="_rename" formaction="{% url 'dcim:rearpanelport_bulk_rename' %}?return_url={{ device.get_absolute_url }}" class="btn btn-warning btn-xs">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> Rename
</button>
{% endif %}
{% if rear_panel_ports and perms.dcim.delete_rearpanelport %}
<button type="submit" formaction="{% url 'dcim:rearpanelport_bulk_delete' pk=device.pk %}?return_url={{ device.get_absolute_url }}" class="btn btn-danger btn-xs">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete
</button>
{% endif %}
{% if perms.dcim.add_rearpanelport %}
<div class="pull-right">
<a href="{% url 'dcim:rearpanelport_add' pk=device.pk %}" class="btn btn-primary btn-xs">
<span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add rear panel ports
</a>
</div>
<div class="clearfix"></div>
{% endif %}
</div>
</div>
</form>
{% endif %}
</div>
</div>
{% include 'inc/graphs_modal.html' %}

View File

@@ -135,6 +135,19 @@
<small class="text-muted">This device {% if devicetype.is_network_device %}has{% else %}does not have{% endif %} network interfaces</small>
</td>
</tr>
<tr>
<td class="text-right">
{% if devicetype.is_patch_panel %}
<i class="glyphicon glyphicon-ok text-success" title="Yes"></i>
{% else %}
<i class="glyphicon glyphicon-remove text-danger" title="No"></i>
{% endif %}
</td>
<td>
<strong>Patch Panel</strong><br />
<small class="text-muted">This device {% if devicetype.is_patch_panel %}has{% else %}does not have{% endif %} patch panel ports</small>
</td>
</tr>
<tr>
<td class="text-right">
{% if devicetype.subdevice_role == True %}
@@ -188,6 +201,12 @@
{% if devicetype.is_pdu or poweroutlet_table.rows %}
{% include 'dcim/inc/devicetype_component_table.html' with table=poweroutlet_table title='Power Outlets' add_url='dcim:devicetype_add_poweroutlet' delete_url='dcim:devicetype_delete_poweroutlet' %}
{% endif %}
{% if devicetype.is_patch_panel or front_panel_port_table.rows %}
{% include 'dcim/inc/devicetype_component_table.html' with table=front_panel_port_table title='Front Panel Ports' add_url='dcim:devicetype_add_frontpanelport' delete_url='dcim:devicetype_delete_frontpanelport' %}
{% endif %}
{% if devicetype.is_patch_panel or rear_panel_port_table.rows %}
{% include 'dcim/inc/devicetype_component_table.html' with table=rear_panel_port_table title='Rear Panel Ports' add_url='dcim:devicetype_add_rearpanelport' delete_url='dcim:devicetype_delete_rearpanelport' %}
{% endif %}
</div>
</div>
{% endblock %}

View File

@@ -20,6 +20,7 @@
{% render_field form.is_console_server %}
{% render_field form.is_pdu %}
{% render_field form.is_network_device %}
{% render_field form.is_patch_panel %}
{% render_field form.subdevice_role %}
</div>
</div>

View File

@@ -0,0 +1,25 @@
<tr class="frontpanelport">
{% if perms.dcim.change_frontpanelport or perms.dcim.delete_frontpanelport %}
<td class="pk">
<input name="pk" type="checkbox" value="{{ frontpanelport.pk }}" />
</td>
{% endif %}
<td>
<i class="fa fa-fw fa-square-o"></i> {{ frontpanelport }}
</td>
<td>{{ frontpanelport.get_type_display }}</td>
<td>{{ frontpanelport.rear_port }}</td>
<td>{{ frontpanelport.rear_port_position }}</td>
<td class="text-right">
{% if perms.dcim.change_frontpanelport %}
<a href="{% url 'dcim:frontpanelport_edit' pk=frontpanelport.pk %}?return_url={{ device.get_absolute_url }}" title="Edit port" class="btn btn-info btn-xs">
<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.dcim.delete_frontpanelport %}
<a href="{% url 'dcim:frontpanelport_delete' pk=frontpanelport.pk %}?return_url={{ device.get_absolute_url }}" title="Delete port" class="btn btn-danger btn-xs">
<i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
</a>
{% endif %}
</td>
</tr>

View File

@@ -0,0 +1,24 @@
<tr class="rearpanelport">
{% if perms.dcim.change_rearpanelport or perms.dcim.delete_rearpanelport %}
<td class="pk">
<input name="pk" type="checkbox" value="{{ rearpanelport.pk }}" />
</td>
{% endif %}
<td>
<i class="fa fa-fw fa-square-o"></i> {{ rearpanelport }}
</td>
<td>{{ rearpanelport.get_type_display }}</td>
<td>{{ rearpanelport.positions }}</td>
<td class="text-right">
{% if perms.dcim.change_rearpanelport %}
<a href="{% url 'dcim:rearpanelport_edit' pk=rearpanelport.pk %}?return_url={{ device.get_absolute_url }}" title="Edit port" class="btn btn-info btn-xs">
<i class="glyphicon glyphicon-pencil" aria-hidden="true"></i>
</a>
{% endif %}
{% if perms.dcim.delete_rearpanelport %}
<a href="{% url 'dcim:rearpanelport_delete' pk=rearpanelport.pk %}?return_url={{ device.get_absolute_url }}" title="Delete port" class="btn btn-danger btn-xs">
<i class="glyphicon glyphicon-trash" aria-hidden="true"></i>
</a>
{% endif %}
</td>
</tr>