root / templates / apply.html @ 138e4e37
History | View | Annotate | Download (10.1 kB)
1 |
{% extends "base.html" %} |
---|---|
2 |
{% load i18n %} |
3 |
|
4 |
{% block title %} |
5 |
{% if edit %} |
6 |
{% trans "Edit Rule" %} {{form.data.name}} |
7 |
{% else %} |
8 |
{% trans "Create new Rule" %} |
9 |
{% endif %} |
10 |
{% endblock %} |
11 |
|
12 |
{% block breadcrumbs %}:: |
13 |
{% if edit %} |
14 |
{% trans "Edit rule" %} {{form.data.name}} |
15 |
{% else %} |
16 |
{% trans "Create rule" %} |
17 |
{% endif %} |
18 |
{% endblock %} |
19 |
{% block extrahead %} |
20 |
<script>
|
21 |
$(document).ready( function(){
|
22 |
|
23 |
$("#id_sourceport").css('width', '100px').attr('size', '5');
|
24 |
$("#id_port").css('width', '100px').attr('size', '5');
|
25 |
$("#id_destinationport").css('width', '100px').attr('size', '5');
|
26 |
$('#id_then').attr("multiple", "");
|
27 |
$( "#id_expires" ).datepicker({ dateFormat: 'yy-mm-dd' , maxDate: '+10d', minDate: '+1d', changeMonth: false, changeYear: false }).datepicker( $.datepicker.regional[ "el" ] );
|
28 |
$('#then_diag').dialog({
|
29 |
height: 220,
|
30 |
width: 340,
|
31 |
modal: true,
|
32 |
autoOpen: false,
|
33 |
buttons: {
|
34 |
'Add': function() {
|
35 |
console.log($("#add_rl_form").serialize());
|
36 |
$.ajax({
|
37 |
url:"{% url add-rate-limit %}",
|
38 |
data:$("#add_rl_form").serialize(),
|
39 |
type: "POST",
|
40 |
cache: false,
|
41 |
success:function(data){
|
42 |
try {
|
43 |
value = data.pk;
|
44 |
text = data.value;
|
45 |
$('#id_then').append($("<option></option>").attr("value",value).text(text));
|
46 |
$('#then_diag').dialog('close');
|
47 |
}
|
48 |
catch (exception) {
|
49 |
$('#then_diag').html(data);
|
50 |
}
|
51 |
}
|
52 |
});
|
53 |
},
|
54 |
Cancel: function() {
|
55 |
$('#then_diag').dialog('close');
|
56 |
}
|
57 |
}
|
58 |
});
|
59 |
|
60 |
$('#port_diag').dialog({
|
61 |
height: 220,
|
62 |
width: 340,
|
63 |
modal: true,
|
64 |
autoOpen: false,
|
65 |
buttons: {
|
66 |
'Add': function() {
|
67 |
console.log($("#add_port_form").serialize());
|
68 |
$.ajax({
|
69 |
url:"{% url add-port %}",
|
70 |
data:$("#add_port_form").serialize(),
|
71 |
type: "POST",
|
72 |
cache: false,
|
73 |
success:function(data){
|
74 |
try {
|
75 |
value = data.value;
|
76 |
text = data.text;
|
77 |
$('#id_port').append($("<option></option>").attr("value",value).text(text));
|
78 |
$('#id_destinationport').append($("<option></option>").attr("value",value).text(text));
|
79 |
$('#id_sourceport').append($("<option></option>").attr("value",value).text(text));
|
80 |
$('#port_diag').dialog('close');
|
81 |
}
|
82 |
catch (exception) {
|
83 |
$('#port_diag').html(data);
|
84 |
}
|
85 |
}
|
86 |
});
|
87 |
},
|
88 |
Cancel: function() {
|
89 |
$('#port_diag').dialog('close');
|
90 |
}
|
91 |
}
|
92 |
});
|
93 |
|
94 |
{% comment %}
|
95 |
$("#new_then_actions").button({
|
96 |
icons: {
|
97 |
primary: "ui-icon-plusthick"
|
98 |
},
|
99 |
})
|
100 |
.click(function(){
|
101 |
$.ajax({
|
102 |
url: "{% url add-rate-limit %}",
|
103 |
cache: false,
|
104 |
success: function(data){
|
105 |
$("#then_diag").html(data);
|
106 |
}
|
107 |
});
|
108 |
$('#then_diag').dialog('open');
|
109 |
return false;
|
110 |
});
|
111 |
|
112 |
{% endcomment %}
|
113 |
$(".new_port").button({
|
114 |
icons: {
|
115 |
primary: "ui-icon-plusthick"
|
116 |
},
|
117 |
})
|
118 |
.click(function(){
|
119 |
$.ajax({
|
120 |
url: "{% url add-port %}",
|
121 |
cache: false,
|
122 |
success: function(data){
|
123 |
$("#port_diag").html(data);
|
124 |
}
|
125 |
});
|
126 |
$('#port_diag').dialog('open');
|
127 |
return false;
|
128 |
});
|
129 |
|
130 |
$("#portsacc").accordion({
|
131 |
collapsible: true,
|
132 |
active: false,
|
133 |
|
134 |
});
|
135 |
|
136 |
$("#applybutton").button();
|
137 |
|
138 |
});
|
139 |
|
140 |
</script>
|
141 |
{% endblock %} |
142 |
{% block content %} |
143 |
<style type="text/css"> |
144 |
th { |
145 |
text-align: right; |
146 |
padding-right: 0.5em; |
147 |
vertical-align: top; |
148 |
} |
149 |
|
150 |
.accord_wrapper{ |
151 |
height: 452px !important; |
152 |
} |
153 |
|
154 |
.help { |
155 |
font-style: italic; |
156 |
|
157 |
} |
158 |
</style>
|
159 |
<div align="center"> |
160 |
{% if edit %}<h3>{% trans "Edit rule" %}: {{form.data.name}}</h3> |
161 |
{% else %}<h3>{% trans "Apply for a new rule" %}</h3> |
162 |
{% endif %} |
163 |
<form method="POST"> |
164 |
{% csrf_token %} |
165 |
{% load unescape %} |
166 |
{% if form.non_field_errors %} |
167 |
<p class="error"> |
168 |
{{ form.non_field_errors|unescape}} |
169 |
</p>
|
170 |
{% endif %} |
171 |
<fieldset {% if %} style="display:none;" {% endif %}> |
172 |
<legend>
|
173 |
{% trans "Rule Basic Info" %} |
174 |
</legend>
|
175 |
<table>
|
176 |
<tr>
|
177 |
<th>
|
178 |
{{ form.name.label_tag }} |
179 |
</th>
|
180 |
<td>
|
181 |
{{ form.name }}<span class="error">{{ form.name.errors|join:", " }}</span> |
182 |
</td>
|
183 |
</tr>
|
184 |
<tr class="help"> |
185 |
<td>
|
186 |
</td>
|
187 |
<td>
|
188 |
A unique identifier will be added as a name_suffix |
189 |
</td>
|
190 |
</tr>
|
191 |
</table>
|
192 |
</fieldset>
|
193 |
<fieldset>
|
194 |
<legend>
|
195 |
{% trans "Rule Match Conditions" %} |
196 |
</legend>
|
197 |
<table>
|
198 |
<input type="hidden" id="id_applier" name="applier" value="{{applier}}"/> |
199 |
<tr>
|
200 |
<th>
|
201 |
{{ form.source.label_tag }} |
202 |
</th>
|
203 |
<td>
|
204 |
{{ form.source }}<span class="error">{{ form.source.errors|join:", " }}</span> |
205 |
</td>
|
206 |
</tr>
|
207 |
<tr class="help"> |
208 |
<td>
|
209 |
</td>
|
210 |
<td>
|
211 |
{{ form.source.help_text }} |
212 |
</td>
|
213 |
</tr>
|
214 |
<tr>
|
215 |
<th>
|
216 |
{{ form.destination.label_tag }} |
217 |
</th>
|
218 |
<td>
|
219 |
{{ form.destination }}<span class="error">{{ form.destination.errors|join:", " }}</span> |
220 |
</td>
|
221 |
</tr>
|
222 |
<tr class="help"> |
223 |
<td>
|
224 |
</td>
|
225 |
<td>
|
226 |
{{ form.destination.help_text }} |
227 |
</td>
|
228 |
</tr>
|
229 |
</table>
|
230 |
<div id='portsacc' style="width: 500px;"> |
231 |
<h3 style="padding: 0.5em 0.5em 0.5em 0.7em;">Advanced Settings (Ports)</h3> |
232 |
<div class='accord_wrapper' style="height: 452px !important;"> |
233 |
Select source/destination port(s), or select common port(s) for both source/destination |
234 |
<table>
|
235 |
<tr>
|
236 |
<th>
|
237 |
{{ form.sourceport.label_tag }} |
238 |
</th>
|
239 |
<td>
|
240 |
{{ form.sourceport }} |
241 |
<button class="new_port"> |
242 |
Port |
243 |
</button>
|
244 |
<span class="error">{{ form.sourceport.errors|join:", " }}</span> |
245 |
</td>
|
246 |
</tr>
|
247 |
<tr class="help"> |
248 |
<td>
|
249 |
</td>
|
250 |
<td>
|
251 |
{{ form.sourceport.help_text }} |
252 |
</td>
|
253 |
</tr>
|
254 |
<tr>
|
255 |
<th>
|
256 |
{{ form.destinationport.label_tag }} |
257 |
</th>
|
258 |
<td>
|
259 |
{{ form.destinationport }} |
260 |
<button class="new_port"> |
261 |
Port |
262 |
</button>
|
263 |
<span class="error">{{ form.destinationport.errors|join:", " }}</span> |
264 |
</td>
|
265 |
</tr>
|
266 |
<tr class="help"> |
267 |
<td>
|
268 |
</td>
|
269 |
<td>
|
270 |
{{ form.destinationport.help_text }} |
271 |
</td>
|
272 |
</tr>
|
273 |
<tr>
|
274 |
<th>
|
275 |
{{ form.port.label_tag }} |
276 |
</th>
|
277 |
<td>
|
278 |
{{ form.port }} |
279 |
<button class="new_port"> |
280 |
Port |
281 |
</button>
|
282 |
<span class="error">{{ form.port.errors|join:", " }}</span> |
283 |
</td>
|
284 |
</tr>
|
285 |
<tr class="help"> |
286 |
<td>
|
287 |
</td>
|
288 |
<td>
|
289 |
{{ form.port.help_text }} |
290 |
</td>
|
291 |
</tr>
|
292 |
</div>
|
293 |
</table>
|
294 |
</div>
|
295 |
</fieldset>
|
296 |
<fieldset>
|
297 |
<legend>
|
298 |
{% trans "Rule Actions" %} |
299 |
</legend>
|
300 |
<table>
|
301 |
<tr>
|
302 |
<th>
|
303 |
{{ form.then.label_tag }} |
304 |
</th>
|
305 |
<td>
|
306 |
{{ form.then }}{% comment %} |
307 |
<button id="new_then_actions"> |
308 |
Rate-limit |
309 |
</button>{% endcomment %}
|
310 |
<span class="error">{{ form.then.errors|join:", " }}</span> |
311 |
</td>
|
312 |
</tr>
|
313 |
</table>
|
314 |
</fieldset>
|
315 |
<fieldset>
|
316 |
<legend>
|
317 |
{% trans "Expiration" %} |
318 |
</legend>
|
319 |
<table>
|
320 |
<tr>
|
321 |
<th>
|
322 |
{{ form.expires.label_tag }} |
323 |
</th>
|
324 |
<td>
|
325 |
{{ form.expires }}<span class="error">{{ form.expires.errors|join:", " }}</span> |
326 |
</td>
|
327 |
</tr>
|
328 |
</table>
|
329 |
</fieldset>
|
330 |
<fieldset>
|
331 |
<legend>
|
332 |
{% trans "Use/Comments" %} |
333 |
</legend>
|
334 |
{% blocktrans %} |
335 |
<p>
|
336 |
Give a short description of the intended use of this rule, that justifies the parameter selection above. Feel free to include any additional comments. |
337 |
</p>
|
338 |
{% endblocktrans %} |
339 |
<p>
|
340 |
{{ form.comments }} |
341 |
{% if form.errors %} |
342 |
<br/> |
343 |
<span class="error">{{ form.comments.errors|join:", " }}</span>{% endif %} |
344 |
</p>
|
345 |
</fieldset>
|
346 |
<p>
|
347 |
<input type="submit" id="applybutton" value="{% trans "Apply" %}" /> |
348 |
</p>
|
349 |
</form>
|
350 |
</div>
|
351 |
<div id="then_diag" title="Add new rate-limit value"> |
352 |
</div>
|
353 |
<div id="port_diag" title="Add new port"> |
354 |
</div>
|
355 |
|
356 |
{% endblock %} |