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

Implemented DeviceType component template creation and deletion

This commit is contained in:
Jeremy Stretch
2016-03-04 23:09:32 -05:00
parent 009ef41e92
commit 61cbee15ca
6 changed files with 237 additions and 86 deletions

View File

@@ -0,0 +1,13 @@
{% extends 'utilities/confirmation_form.html' %}
{% load form_helpers %}
{% block title %}Delete devie type components?{% endblock %}
{% block message %}
<p>Are you sure you want to delete these components from <strong>{{ devicetype }}</strong>?</p>
<ul>
{% for o in selected_objects %}
<li>{{ o }}</li>
{% endfor %}
</ul>
{% endblock %}

View File

@@ -73,90 +73,13 @@
</tr>
</table>
</div>
<div class="panel panel-default">
<div class="panel-heading">
{% if perms.dcim.change_devicetype %}
<a href="{% url 'dcim:devicetype_add_consoleport' pk=devicetype.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Console Ports</a>
{% endif %}
<strong>Console Ports</strong>
</div>
<table class="table table-hover panel-body">
{% for cp in devicetype.console_port_templates.all %}
<tr>
<td>{{ cp.name }}</td>
<td></td>
</tr>
{% endfor %}
</table>
</div>
<div class="panel panel-default">
<div class="panel-heading">
{% if perms.dcim.change_devicetype %}
<a href="{% url 'dcim:devicetype_add_powerport' pk=devicetype.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Power Ports</a>
{% endif %}
<strong>Power Ports</strong>
</div>
<table class="table table-hover panel-body">
{% for pp in devicetype.power_port_templates.all %}
<tr>
<td>{{ pp.name }}</td>
<td></td>
</tr>
{% endfor %}
</table>
</div>
{% include 'dcim/inc/devicetype_component_table.html' with table=consoleport_table title='Console Ports' add_url='dcim:devicetype_add_consoleport' delete_url='dcim:devicetype_delete_consoleport' %}
{% include 'dcim/inc/devicetype_component_table.html' with table=powerport_table title='Power Ports' add_url='dcim:devicetype_add_powerport' delete_url='dcim:devicetype_delete_powerport' %}
</div>
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
{% if perms.dcim.change_devicetype %}
<a href="{% url 'dcim:devicetype_add_interface' pk=devicetype.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Interfaces</a>
{% endif %}
<strong>Interfaces</strong>
</div>
<table class="table table-hover panel-body">
{% for iface in devicetype.interface_templates.all %}
<tr>
<td>{{ iface.name }}</td>
<td>{{ iface.get_form_factor_display }}</td>
<td>{{ iface.mgmt_only|yesno|capfirst }}</td>
<td></td>
</tr>
{% endfor %}
</table>
</div>
<div class="panel panel-default">
<div class="panel-heading">
{% if perms.dcim.change_devicetype %}
<a href="{% url 'dcim:devicetype_add_consoleserverport' pk=devicetype.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Console Server Ports</a>
{% endif %}
<strong>Console Server Ports</strong>
</div>
<table class="table table-hover panel-body">
{% for csp in devicetype.cs_port_templates.all %}
<tr>
<td>{{ csp.name }}</td>
<td></td>
</tr>
{% endfor %}
</table>
</div>
<div class="panel panel-default">
<div class="panel-heading">
{% if perms.dcim.change_devicetype %}
<a href="{% url 'dcim:devicetype_add_poweroutlet' pk=devicetype.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add Power Outlet</a>
{% endif %}
<strong>Power Outlets</strong>
</div>
<table class="table table-hover panel-body">
{% for po in devicetype.power_outlet_templates.all %}
<tr>
<td>{{ po.name }}</td>
<td></td>
</tr>
{% endfor %}
</table>
</div>
{% include 'dcim/inc/devicetype_component_table.html' with table=interface_table title='Interfaces' add_url='dcim:devicetype_add_interface' delete_url='dcim:devicetype_delete_interface' %}
{% include 'dcim/inc/devicetype_component_table.html' with table=consoleserverport_table title='Console Server Ports' add_url='dcim:devicetype_add_consoleserverport' delete_url='dcim:devicetype_delete_consoleserverport' %}
{% 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' %}
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,29 @@
{% load render_table from django_tables2 %}
{% if perms.dcim.change_devicetype %}
<form method="post" action="{% url delete_url pk=devicetype.pk %}">
{% csrf_token %}
<div class="panel panel-default">
<div class="panel-heading">
<a href="{% url add_url pk=devicetype.pk %}" class="btn btn-primary btn-xs pull-right"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span> Add {{ title }}</a>
<strong>{{ title }}</strong>
</div>
{% render_table table 'table.html' %}
{% if table.rows %}
<div class="panel-footer">
<button type="submit" class="btn btn-xs btn-danger">
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> Delete Selected
</button>
</div>
{% endif %}
</div>
</form>
{% else %}
<div class="panel panel-default">
<div class="panel-heading">
<strong>{{ title }}</strong>
</div>
<table class="table table-hover panel-body">
{% render_table table table_template|default:'table.html' %}
</table>
</div>
{% endif %}