root / templates / apply.html @ 802dfff6
History | View | Annotate | Download (14.5 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 |
<li class="active"><span class="divider">/</span> |
14 |
{% if edit %} |
15 |
{% trans "Edit rule" %} {{form.data.name}} |
16 |
{% else %} |
17 |
{% trans "Create rule" %} |
18 |
{% endif %} |
19 |
</li>
|
20 |
{% endblock %} |
21 |
{% block extrahead %} |
22 |
<script>
|
23 |
$(document).ready( function(){
|
24 |
|
25 |
|
26 |
$('#setFromAll').click(function(){
|
27 |
$("#id_source").val('0.0.0.0/32');
|
28 |
return false;
|
29 |
});
|
30 |
|
31 |
|
32 |
$('#id_then').attr("multiple", "");
|
33 |
$( "#id_expires" ).datepicker({ dateFormat: 'yy-mm-dd' , maxDate: '+10d', minDate: '+1d', changeMonth: false, changeYear: false }).datepicker( $.datepicker.regional[ "el" ] );
|
34 |
{% comment %}
|
35 |
$('#then_diag').dialog({
|
36 |
height: 220,
|
37 |
width: 340,
|
38 |
modal: true,
|
39 |
autoOpen: false,
|
40 |
buttons: {
|
41 |
'{% trans "Add" %}': function() {
|
42 |
console.log($("#add_rl_form").serialize());
|
43 |
$.ajax({
|
44 |
url:"{% url add-rate-limit %}",
|
45 |
data:$("#add_rl_form").serialize(),
|
46 |
type: "POST",
|
47 |
cache: false,
|
48 |
success:function(data){
|
49 |
try {
|
50 |
value = data.pk;
|
51 |
text = data.value;
|
52 |
$('#id_then').append($("<option></option>").attr("value",value).text(text));
|
53 |
$('#then_diag').dialog('close');
|
54 |
}
|
55 |
catch (exception) {
|
56 |
$('#then_diag').html(data);
|
57 |
}
|
58 |
}
|
59 |
});
|
60 |
},
|
61 |
'{% trans "Cancel" %}': function() {
|
62 |
$('#then_diag').dialog('close');
|
63 |
}
|
64 |
}
|
65 |
});
|
66 |
{% endcomment %}
|
67 |
$('#port_diag').dialog({
|
68 |
height: 220,
|
69 |
width: 340,
|
70 |
modal: true,
|
71 |
autoOpen: false,
|
72 |
buttons: {
|
73 |
'{% trans "Add" %}': function() {
|
74 |
$.ajax({
|
75 |
url:"{% url add-port %}",
|
76 |
data:$("#add_port_form").serialize(),
|
77 |
type: "POST",
|
78 |
cache: false,
|
79 |
success:function(data){
|
80 |
console.log(data);
|
81 |
try {
|
82 |
value = data.value;
|
83 |
text = data.text;
|
84 |
console.log(text, value);
|
85 |
if (typeof value === 'undefined' && typeof text === 'undefined'){
|
86 |
$('#port_diag').html(data);
|
87 |
}
|
88 |
else{
|
89 |
$('#id_port').append($("<option></option>").attr("value",value).text(text));
|
90 |
$('#id_destinationport').append($("<option></option>").attr("value",value).text(text));
|
91 |
$('#id_sourceport').append($("<option></option>").attr("value",value).text(text));
|
92 |
$('#port_diag').dialog('close');
|
93 |
}
|
94 |
}
|
95 |
catch (exception) {
|
96 |
$('#port_diag').html(data);
|
97 |
}
|
98 |
}
|
99 |
});
|
100 |
},
|
101 |
'{% trans "Cancel" %}': function() {
|
102 |
$('#port_diag').dialog('close');
|
103 |
}
|
104 |
}
|
105 |
});
|
106 |
|
107 |
{% comment %}
|
108 |
$("#new_then_actions").button({
|
109 |
icons: {
|
110 |
primary: "ui-icon-plusthick"
|
111 |
},
|
112 |
})
|
113 |
.click(function(){
|
114 |
$.ajax({
|
115 |
url: "{% url add-rate-limit %}",
|
116 |
cache: false,
|
117 |
success: function(data){
|
118 |
$("#then_diag").html(data);
|
119 |
}
|
120 |
});
|
121 |
$('#then_diag').dialog('open');
|
122 |
return false;
|
123 |
});
|
124 |
|
125 |
{% endcomment %}
|
126 |
$(".new_port").button()
|
127 |
.click(function(){
|
128 |
$.ajax({
|
129 |
url: "{% url add-port %}",
|
130 |
cache: false,
|
131 |
success: function(data){
|
132 |
$("#port_diag").html(data);
|
133 |
}
|
134 |
});
|
135 |
$('#port_diag').dialog('open');
|
136 |
return false;
|
137 |
});
|
138 |
});
|
139 |
|
140 |
</script>
|
141 |
{% endblock %} |
142 |
{% block content %} |
143 |
<style type="text/css"> |
144 |
|
145 |
|
146 |
|
147 |
#rule_form_container input:not([type="submit"]), #rule_form_container select { |
148 |
background: none repeat scroll 0 0 #FFFFFF; |
149 |
border: 1px solid #DDDDDD; |
150 |
-moz-border-radius: 3px; border-radius:3px; -webkit-border-radius: 3px; |
151 |
float: left; |
152 |
font-family: "Century Gothic",Helvetica,sans-serif; |
153 |
font-size: 13px; |
154 |
outline: medium none; |
155 |
padding: 5px; |
156 |
width: 180px; |
157 |
} |
158 |
|
159 |
|
160 |
#rule_form_container{ |
161 |
-moz-border-radius: 10px 10px 10px 10px; border-radius:10px; -webkit-border-radius: 10px; |
162 |
-moz-box-shadow: 0 0 3px #AAAAAA; box-shadow: 0 0 3px #AAAAAA; -webkit-box-shadow: 0 0 3px #AAAAAA; |
163 |
background-color: #F9F9F9; |
164 |
border: 2px solid #FFFFFF; |
165 |
overflow: hidden; |
166 |
width: 800px; |
167 |
} |
168 |
#rule_form_container div label { |
169 |
color: #666666; |
170 |
float: left; |
171 |
font-family: "Century Gothic",Helvetica,sans-serif; |
172 |
font-size: 15px; |
173 |
font-weight: bold; |
174 |
line-height: 26px; |
175 |
margin-right: 15px; |
176 |
text-align: right; |
177 |
text-shadow: 1px 1px 1px #FFFFFF; |
178 |
width: 180px; |
179 |
} |
180 |
#rule_form_container p.submit { |
181 |
background: none repeat scroll 0 0 transparent; |
182 |
border: medium none; |
183 |
box-shadow: none; |
184 |
} |
185 |
|
186 |
</style>
|
187 |
<div id="rule_form_wrapper" class="container"> |
188 |
{% if edit %}<h4>{% trans "Edit rule" %}: {{form.data.name}}</h4> |
189 |
{% else %}<h4>{% trans "Apply for a new rule" %}</h4> |
190 |
{% endif %} |
191 |
<hr>
|
192 |
<br>
|
193 |
<form method="POST" class="form-horizontal"> |
194 |
|
195 |
{% csrf_token %} |
196 |
{% load unescape %} |
197 |
{% if form.non_field_errors %} |
198 |
<p class="error"> |
199 |
{{ form.non_field_errors|unescape}} |
200 |
</p>
|
201 |
{% endif %} |
202 |
<fieldset {% if %} style="display:none;" {% endif %}> |
203 |
<legend>
|
204 |
{% trans "Rule Basic Info" %} |
205 |
</legend>
|
206 |
<div class="control-group {% if form.name.errors %} error {% endif %}"> |
207 |
<label class="control-label" for="id_name"><b>{% trans "Name" %}</b></label> |
208 |
<div class="controls"> |
209 |
{{ form.name }} |
210 |
{% if form.name.errors %} |
211 |
<span class="help-inline"> |
212 |
{{ form.name.errors|join:", " }} |
213 |
</span>
|
214 |
{% endif %} |
215 |
<span class="help-block">A unique identifier will be added as a name_suffix</span> |
216 |
</div>
|
217 |
</div>
|
218 |
</fieldset>
|
219 |
{% if user.is_superuser %} |
220 |
<fieldset>
|
221 |
<legend>
|
222 |
{% trans "Admin Options" %} |
223 |
</legend>
|
224 |
<div class="control-group"> |
225 |
<label class="control-label" for="id_applier"><b>{% trans "Applier" %}</b></label> |
226 |
<div class="controls">{{ form.applier }}</div> |
227 |
{% if form.applier.errors %} |
228 |
<br>
|
229 |
<p class="error" style="clear:both;"> |
230 |
{{ form.applier.errors|join:", " }} |
231 |
</p>
|
232 |
{% endif %} |
233 |
</div>
|
234 |
</fieldset>
|
235 |
{% else %} |
236 |
<input type="hidden" id="id_applier" name="applier" value="{{applier}}"/> |
237 |
{% endif %} |
238 |
<fieldset>
|
239 |
<legend>
|
240 |
{% trans "Rule Match Conditions" %} |
241 |
</legend>
|
242 |
<div class="control-group {% if form.source.errors %} error {% endif %}"> |
243 |
<label class="control-label" for="id_source"><b>{% trans "Source Address" %}</b></label> |
244 |
<div class="controls">{{ form.source }} <img src="/fodstatic/threat_source.png" style="height: 30px;"/> <a class="btn btn-small btn-info" id="setFromAll" href="#">Any</a> |
245 |
{% if form.source.errors %} |
246 |
<span class="help-inline"> |
247 |
{{ form.source.errors|join:", " }} |
248 |
</span>
|
249 |
{% endif %} |
250 |
<span class="help-block"> {{ form.source.help_text }}</span> |
251 |
</div>
|
252 |
|
253 |
|
254 |
</div>
|
255 |
<div class="control-group {% if form.destination.errors %} error {% endif %}"> |
256 |
<label class="control-label" for="id_destination"><b>{% trans "Destination Address" %}</b></label> |
257 |
<div class="controls"> |
258 |
{{ form.destination }} <img src="/fodstatic/secure_destination.png" style="height: 30px;"/> |
259 |
{% if form.destination.errors %} |
260 |
<span class="help-inline"> |
261 |
{{ form.destination.errors|join:", " }} |
262 |
</span>
|
263 |
{% endif %} |
264 |
<span class="help-block">{{ form.destination.help_text }}</span> |
265 |
</div>
|
266 |
|
267 |
</div>
|
268 |
<div class="control-group {% if form.protocol.errors %} error {% endif %}"> |
269 |
<label class="control-label" for="id_protocol">{% trans "Protocol" %}</label> |
270 |
<div class="controls">{{ form.protocol }} |
271 |
{% if form.protocol.errors %} |
272 |
<span class="help-inline"> |
273 |
{{ form.protocol.errors|join:", " }} |
274 |
</span>
|
275 |
{% endif %} |
276 |
</div>
|
277 |
|
278 |
</div>
|
279 |
<div
|
280 |
class="control-group {% if form.port.errors %} error {% endif %}"> |
281 |
<label class="control-label" for="id_port">{% trans "Ports" %}</label> |
282 |
<div class="controls"> |
283 |
<div id="portsaccordion" class="accordion"> |
284 |
<div class="accordion-group"> |
285 |
<div class="accordion-heading"> |
286 |
<a class="accordion-toggle" data-toggle="collapse" |
287 |
data-parent="#accordion2" href="#collapseOne"> {% trans "Advanced Settings (Ports)" %}</a> |
288 |
</div>
|
289 |
<div id="collapseOne" class="accordion-body collapse"> |
290 |
<div class="accordion-inner"> |
291 |
<label>{% trans "Select source/destination port(s), or select common port(s) for both source/destination" %}</label> |
292 |
<div class="control-group {% if form.sourceport.errors %} error {% endif %}"> |
293 |
<label class="control-label" for="id_sourceport">{% trans "Source Port" %}</label> |
294 |
<div class="controls"> |
295 |
{{ form.sourceport }} |
296 |
|
297 |
<span class="help-inline"> |
298 |
<button class="new_port btn btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button> |
299 |
{% if form.sourceport.errors %} |
300 |
{{ form.sourceport.errors|join:", " }} |
301 |
{% endif %} |
302 |
</span>
|
303 |
|
304 |
<span class="help-block">{{ form.sourceport.help_text }}</span> |
305 |
</div>
|
306 |
</div>
|
307 |
<div class="control-group {% if form.destinationport.errors %} error {% endif %}"> |
308 |
<label class="control-label" for="id_destinationport">{% trans "Destination Port" %}</label> |
309 |
<div class="controls"> |
310 |
{{ form.destinationport }} |
311 |
|
312 |
<span class="help-inline"> |
313 |
<button class="new_port btn btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button> |
314 |
{% if form.destinationport.errors %} |
315 |
{{ form.destinationport.errors|join:", " }} |
316 |
{% endif %} |
317 |
</span>
|
318 |
|
319 |
<span class="help-block">{{ form.destinationport.help_text }}</span> |
320 |
</div>
|
321 |
</div>
|
322 |
<div class="control-group {% if form.port.errors %} error {% endif %}"> |
323 |
<label class="control-label" for="id_port">{% trans "Port" %}</label> |
324 |
<div class="controls"> |
325 |
{{ form.port }} |
326 |
|
327 |
<span class="help-inline"> |
328 |
<button class="new_port btn btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button> |
329 |
{% if form.port.errors %} |
330 |
{{ form.port.errors|join:", " }} |
331 |
{% endif %} |
332 |
</span>
|
333 |
|
334 |
<span class="help-block">{{ form.port.help_text }}</span> |
335 |
</div>
|
336 |
</div>
|
337 |
|
338 |
</div>
|
339 |
</div>
|
340 |
</div>
|
341 |
</div>
|
342 |
</div>
|
343 |
</div>
|
344 |
|
345 |
</fieldset>
|
346 |
<fieldset>
|
347 |
<legend>
|
348 |
{% trans "Rule Actions" %} |
349 |
</legend>
|
350 |
<div class="control-group {% if form.then.errors %} error {% endif %}"> |
351 |
<label class="control-label" for="id_then"><b>{% trans "Then" %}</b></label> |
352 |
<div class="controls">{{ form.then }} |
353 |
{% if form.then.errors %} |
354 |
<span class="help-inline"> |
355 |
{{ form.then.errors|join:", " }} |
356 |
</span>
|
357 |
{% endif %} |
358 |
</div>
|
359 |
{% comment %} |
360 |
<button id="new_then_actions"> |
361 |
Rate-limit |
362 |
</button>
|
363 |
{% endcomment %} |
364 |
|
365 |
</div>
|
366 |
</fieldset>
|
367 |
<fieldset>
|
368 |
<legend>
|
369 |
{% trans "Expiration" %} |
370 |
</legend>
|
371 |
<div class="control-group {% if form.expires.errors %} error {% endif %}"> |
372 |
<label class="control-label" for="id_expires">{% trans "Expires" %}</label> |
373 |
<div class="controls">{{ form.expires }} |
374 |
{% if form.expires.errors %} |
375 |
<span class="help-inline"> |
376 |
{{ form.expires.errors|join:", " }} |
377 |
</span>
|
378 |
{% endif %} |
379 |
</div>
|
380 |
</div>
|
381 |
</fieldset>
|
382 |
<fieldset>
|
383 |
|
384 |
<legend>
|
385 |
{% trans "Use/Comments" %} |
386 |
</legend>
|
387 |
<div class="control-group {% if form.comments.errors %} error {% endif %}"> |
388 |
<label class="control-label" for="id_comments">{% trans "Comments" %}</label> |
389 |
<div class="controls"> |
390 |
<span class="help-block">{% blocktrans %}Give a short description of the intended use of this rule, that justifies the parameter selection above. Feel free to include any additional comments.{% endblocktrans %}</span> |
391 |
{{ form.comments }} |
392 |
|
393 |
{% if form.comments.errors %} |
394 |
<span class="help-inline"> |
395 |
{{ form.comments.errors|join:", " }} |
396 |
</span>
|
397 |
{% endif %} |
398 |
</div>
|
399 |
</div>
|
400 |
|
401 |
</fieldset>
|
402 |
<div class="control-group"> |
403 |
<div class="controls"> |
404 |
<button type="submit" id="applybutton" value="{% trans 'Apply' %}" class="btn btn-large btn-primary"/>Apply</button> |
405 |
</div>
|
406 |
</div>
|
407 |
|
408 |
|
409 |
</form>
|
410 |
</div>
|
411 |
<div id="then_diag" title="Add new rate-limit value"> |
412 |
</div>
|
413 |
<div id="port_diag" title="{% trans "Add port" %}"> |
414 |
</div>
|
415 |
|
416 |
{% endblock %} |