51 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			HTML
		
	
	
	
{% extends "base.html" %}
 | 
						|
 | 
						|
{% load crispy_forms_tags %}
 | 
						|
 | 
						|
{% block content %}
 | 
						|
<div class="row">
 | 
						|
	<div class="col-sm-12">
 | 
						|
		<div class="panel panel-default">
 | 
						|
			<div class="panel-heading">Header</div>
 | 
						|
			<div class="panel-body">
 | 
						|
				<form method="post" action="#">
 | 
						|
					{% csrf_token %}
 | 
						|
					{{ form | crispy }}
 | 
						|
					<button type="submit" class="btn btn-primary">Create</button>
 | 
						|
				</form>
 | 
						|
			</div>
 | 
						|
		</div>
 | 
						|
	</div>
 | 
						|
</div>
 | 
						|
 | 
						|
<script>
 | 
						|
function getSubnet() {
 | 
						|
	var netInp = $('#div_id_prefix input');
 | 
						|
	netInp.val("");
 | 
						|
	netInp.attr("placeholder", "Getting network...");
 | 
						|
 | 
						|
	var parentNetOpt = $('#id_parentNet option:selected');
 | 
						|
	if(parentNetOpt.val()) {
 | 
						|
		$.get("{% url "api:inetnum-get-subnet" %}", {net: parentNetOpt.text()}, function(data) {
 | 
						|
			if(data.success) {
 | 
						|
				netInp.attr("placeholder", "")
 | 
						|
				netInp.val(data.network);
 | 
						|
			} else {
 | 
						|
				errorMsg = "Nothing returned via API";
 | 
						|
				if(data.errorMsg)
 | 
						|
					errorMsg = data.errorMsg;
 | 
						|
				netInp.attr("placeholder", data.errorMsg);
 | 
						|
			}
 | 
						|
		});
 | 
						|
	} else {
 | 
						|
		netInp.attr("placeholder", "No Parent Range selected!");
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
$(document).ready(function() {
 | 
						|
	$('#div_id_prefix label').append(' <small>(<a onClick="getSubnet();">autofill network</a>)</small>');
 | 
						|
});
 | 
						|
</script>
 | 
						|
{% endblock %}
 | 
						|
 |