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

Closes #1326: Added dropdown widget with common values for circuit speed fields

This commit is contained in:
Jeremy Stretch
2017-08-29 22:29:30 -04:00
parent aaca28c1a6
commit ecdf66c454
3 changed files with 62 additions and 3 deletions

View File

@ -9,7 +9,16 @@
{% render_field form.cid %}
{% render_field form.type %}
{% render_field form.install_date %}
{% render_field form.commit_rate %}
<div class="form-group">
<label class="col-md-3 control-label" for="id_commit_rate">{{ form.commit_rate.label }}</label>
<div class="col-md-9">
<div class="input-group">
{{ form.commit_rate }}
{% include 'circuits/inc/speed_widget.html' with target_field='commit_rate' %}
</div>
<span class="help-block">{{ form.commit_rate.help_text }}</span>
</div>
</div>
{% render_field form.description %}
</div>
</div>
@ -35,3 +44,12 @@
</div>
</div>
{% endblock %}
{% block javascript %}
<script type="text/javascript">
$("a.set_speed").click(function(e) {
e.preventDefault();
$("#id_" + $(this).attr("target")).val($(this).attr("data"));
});
</script>
{% endblock %}

View File

@ -49,8 +49,26 @@
<div class="panel panel-default">
<div class="panel-heading"><strong>Termination Details</strong></div>
<div class="panel-body">
{% render_field form.port_speed %}
{% render_field form.upstream_speed %}
<div class="form-group">
<label class="col-md-3 control-label required" for="id_port_speed">{{ form.port_speed.label }}</label>
<div class="col-md-9">
<div class="input-group">
{{ form.port_speed }}
{% include 'circuits/inc/speed_widget.html' with target_field='port_speed' %}
</div>
<span class="help-block">{{ form.port_speed.help_text }}</span>
</div>
</div>
<div class="form-group">
<label class="col-md-3 control-label" for="id_upstream_speed">{{ form.upstream_speed.label }}</label>
<div class="col-md-9">
<div class="input-group">
{{ form.upstream_speed }}
{% include 'circuits/inc/speed_widget.html' with target_field='upstream_speed' %}
</div>
<span class="help-block">{{ form.upstream_speed.help_text }}</span>
</div>
</div>
{% render_field form.xconnect_id %}
{% render_field form.pp_info %}
</div>
@ -72,4 +90,10 @@
{% block javascript %}
<script src="{% static 'js/livesearch.js' %}?v{{ settings.VERSION }}"></script>
<script type="text/javascript">
$("a.set_speed").click(function(e) {
e.preventDefault();
$("#id_" + $(this).attr("target")).val($(this).attr("data"));
});
</script>
{% endblock %}

View File

@ -0,0 +1,17 @@
<span class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-right">
<li><a href="#" target="{{ target_field }}" data="10000" class="set_speed">10 Mbps</a></li>
<li><a href="#" target="{{ target_field }}" data="100000" class="set_speed">100 Mbps</a></li>
<li><a href="#" target="{{ target_field }}" data="1000000" class="set_speed">1 Gbps</a></li>
<li><a href="#" target="{{ target_field }}" data="10000000" class="set_speed">10 Gbps</a></li>
<li><a href="#" target="{{ target_field }}" data="25000000" class="set_speed">25 Gbps</a></li>
<li><a href="#" target="{{ target_field }}" data="40000000" class="set_speed">40 Gbps</a></li>
<li><a href="#" target="{{ target_field }}" data="100000000" class="set_speed">100 Gbps</a></li>
<li class="divider"></li>
<li><a href="#" target="{{ target_field }}" data="1544" class="set_speed">T1 (1.544 Mbps)</a></li>
<li><a href="#" target="{{ target_field }}" data="2048" class="set_speed">E1 (2.048 Mbps)</a></li>
</ul>
</span>