apply.html 5.87 KB
Newer Older
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
1 2
{% extends "base.html" %}
{% load i18n %}
3

4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{% block title %}
	{% if edit %}
		{% trans "Edit Route" %} {{form.data.name}}
	{% else %}
		{% trans "Create new Route" %}
	{% endif %}
{% endblock %}

{% block breadcrumbs %}:: 
	{% if edit %}
		{% trans "Edit route" %} {{form.data.name}}
	{% else %}
	{% trans "Create route" %}
	{% endif %}
		{% endblock %}
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
{% block extrahead %}
<script>
	$(document).ready( function(){
		
		$("#id_sourceport").css('width', '100px').attr('size', '5');
		$("#id_port").css('width', '100px').attr('size', '5');
		$("#id_destinationport").css('width', '100px').attr('size', '5');
		$('#id_then').attr("multiple", "");
		$('#then_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
		'Add': function() {
			console.log($("#add_rl_form").serialize());
			$.ajax({
			url:"{% url add-rate-limit %}", 
			data:$("#add_rl_form").serialize(),
			type: "POST",
			cache: false,
			success:function(data){
					try {
						value = data.pk;
						text = data.value;
						$('#id_then').append($("<option></option>").attr("value",value).text(text));
						$('#then_diag').dialog('close');
					}
					catch (exception) {
						$('#then_diag').html(data);
					}					
				}
				});
		},
		Cancel: function() {
			$('#then_diag').dialog('close');
		}
	}
		});
		
		$('#port_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
		'Add': function() {
			console.log($("#add_port_form").serialize());
			$.ajax({
			url:"{% url add-port %}", 
			data:$("#add_port_form").serialize(),
			type: "POST",
			cache: false,
			success:function(data){
					try {
						value = data.value;
						text = data.text;
						$('#id_port').append($("<option></option>").attr("value",value).text(text));
						$('#id_destinationport').append($("<option></option>").attr("value",value).text(text));
						$('#id_sourceport').append($("<option></option>").attr("value",value).text(text));
						$('#port_diag').dialog('close');
					}
					catch (exception) {
						$('#port_diag').html(data);
					}					
				}
				});
		},
		Cancel: function() {
			$('#port_diag').dialog('close');
		}
	}
		});
		
		
		$("#new_then_actions").button({
            icons: {
                primary: "ui-icon-plusthick"
            },
			})
			.click(function(){
				$.ajax({
					url: "{% url add-rate-limit %}",
					cache: false,
					success: function(data){
						$("#then_diag").html(data);
					}
				});
				$('#then_diag').dialog('open');
				return false;
			});
			
			
			$(".new_port").button({
            icons: {
                primary: "ui-icon-plusthick"
            },
			})
			.click(function(){
				$.ajax({
					url: "{% url add-port %}",
					cache: false,
					success: function(data){
						$("#port_diag").html(data);
					}
				});
				$('#port_diag').dialog('open');
				return false;
			});
		});
		
</script>
{% endblock %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145
{% block content %}
<style type="text/css">
th {
	text-align: right;
	padding-right: 0.5em;
	vertical-align: top;
}

.help {
	font-style: italic;

}
</style>
<div align="center">
146 147 148
	{% if edit %}
	<h3>{% trans "Edit route" %}: {{form.data.name}}</h3>
	{% else %}
149
<h3>{% trans "Apply for a new route" %}</h3>
150
{% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
151 152
<form method="POST">
{% csrf_token %}
153 154 155
{% if form.non_field_errors %}
<p class="error">{{ form.non_field_errors|join:", "}}</p>
{% endif %}
156 157

<fieldset {% if edit %} style="display:none;" {% endif %}>
158
	<legend>{% trans "Route Basic Info" %}</legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
159
<table>
160
<tr><th>{{ form.name.label_tag }}</th><td>{{ form.name }}<span class="error">{{ form.name.errors|join:", " }}</span></td></tr>
161
<tr class="help"><td></td><td>A unique identifier will be added as a name_suffix</td></tr>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
162 163 164 165
</table>
</fieldset>

<fieldset>
166 167
<legend>{% trans "Route Match Conditions" %}</legend>
<table>
168
<input type="hidden" id="id_applier" name="applier" value="{{applier}}"/>
169 170
<tr><th>{{ form.source.label_tag }}</th><td>{{ form.source }}<span class="error">{{ form.source.errors|join:", " }}</span></td></tr>
<tr class="help"><td></td><td>{{ form.source.help_text }}</td></tr>
171
<tr><th>{{ form.sourceport.label_tag }}</th><td>{{ form.sourceport }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.sourceport.errors|join:", " }}</span></td></tr>
172 173 174
<tr class="help"><td></td><td>{{ form.sourceport.help_text }}</td></tr>
<tr><th>{{ form.destination.label_tag }}</th><td>{{ form.destination }}<span class="error">{{ form.destination.errors|join:", " }}</span></td></tr>
<tr class="help"><td></td><td>{{ form.destination.help_text }}</td></tr>
175
<tr><th>{{ form.destinationport.label_tag }}</th><td>{{ form.destinationport }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.destinationport.errors|join:", " }}</span></td></tr>
176
<tr class="help"><td></td><td>{{ form.destinationport.help_text }}</td></tr>
177
<tr><th>{{ form.port.label_tag }}</th><td>{{ form.port }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.port.errors|join:", " }}</span></td></tr>
178 179
<tr class="help"><td></td><td>{{ form.port.help_text }}</td></tr>
</table>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
180 181
</fieldset>
<fieldset>
182
<legend>{% trans "Route Actions" %}</legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
183
<table>
184
<tr><th>{{ form.then.label_tag }}</th><td>{{ form.then }}&nbsp;&nbsp;<button id="new_then_actions">Rate-limit</button><span class="error">{{ form.then.errors|join:", " }}</span></td></tr>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
185 186 187
</table>
</fieldset>
<fieldset>
188
<legend>{% trans "Use/Comments" %}</legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
189
{% blocktrans %}
190
<p>Give a short description of the intended use of this route, that justifies the parameter selection above. Feel free to include any additional comments.</p>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
191
{% endblocktrans %}
192 193
<p>{{ form.comments }}
{% if form.errors %}<br /><span class="error">{{ form.comments.errors|join:", " }}</span>{% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
194 195 196 197 198 199
</p>
</fieldset>

<p><input type="submit" value="{% trans "Apply" %}" /></p>
</form>
</div>
200

201 202 203 204 205 206
<div id="then_diag" title="Add new rate-limit value">
</div>

<div id="port_diag" title="Add new port">
</div>

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
207
{% endblock %}