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