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

4 5
{% block title %}
	{% if edit %}
6
		{% trans "Edit Rule" %} {{form.data.name}}
7
	{% else %}
8
		{% trans "Create new Rule" %}
9 10 11
	{% endif %}
{% endblock %}

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
12 13
{% block breadcrumbs %}
 <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 %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
19 20
</li>
{% endblock %}
21 22 23 24
{% block extrahead %}
<script>
	$(document).ready( function(){
		
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
25
		
26
		$('#setFromAll').click(function(){
27
			$("#id_source").val('0.0.0.0/0');
28 29 30 31
			return false;
		});
		
		
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 36 37 38 39 40
		$('#then_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
41
		'{% trans "Add" %}': function() {
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
			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);
					}					
				}
				});
		},
61
		'{% trans "Cancel" %}': function() {
62 63 64 65
			$('#then_diag').dialog('close');
		}
	}
		});
66
		{% endcomment %}
67 68 69 70 71 72
		$('#port_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
73
		'{% trans "Add" %}': function() {
74 75 76 77 78 79
			$.ajax({
			url:"{% url add-port %}", 
			data:$("#add_port_form").serialize(),
			type: "POST",
			cache: false,
			success:function(data){
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
80
					console.log(data);
81 82 83
					try {
						value = data.value;
						text = data.text;
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
84 85 86 87 88 89 90 91 92 93
						console.log(text, value);
						if (typeof value === 'undefined' && typeof text === 'undefined'){
							$('#port_diag').html(data);	
						}
						else{
							$('#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');
						}
94 95 96 97 98 99 100
					}
					catch (exception) {
						$('#port_diag').html(data);
					}					
				}
				});
		},
101
		'{% trans "Cancel" %}': function() {
102 103 104 105 106
			$('#port_diag').dialog('close');
		}
	}
		});
		
107
		{% comment %}
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
		$("#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;
			});
			
125
			{% endcomment %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
126
			$(".new_port").button()
127 128 129 130 131 132 133 134 135 136 137
			.click(function(){
				$.ajax({
					url: "{% url add-port %}",
					cache: false,
					success: function(data){
						$("#port_diag").html(data);
					}
				});
				$('#port_diag').dialog('open');
				return false;
			});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
138
			});
139 140 141
		
</script>
{% endblock %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
142 143
{% block content %}
<style type="text/css">
144

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
145

146 147 148 149

#rule_form_container input:not([type="submit"]), #rule_form_container select {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #DDDDDD;
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
150
	-moz-border-radius: 3px; border-radius:3px; -webkit-border-radius: 3px; 
151 152 153 154 155 156 157 158 159 160
    float: left;
    font-family: "Century Gothic",Helvetica,sans-serif;
    font-size: 13px;
    outline: medium none;
    padding: 5px;
    width: 180px;
}


#rule_form_container{
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
161 162 163 164 165
	-moz-border-radius: 10px 10px 10px 10px; border-radius:10px; -webkit-border-radius: 10px;
	-moz-box-shadow: 0 0 3px #AAAAAA; box-shadow: 0 0 3px #AAAAAA; -webkit-box-shadow: 0 0 3px #AAAAAA; 
	background-color: #F9F9F9;
	border: 2px solid #FFFFFF;
	overflow: hidden;
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
    width: 800px;
	}
#rule_form_container div label {
    color: #666666;
    float: left;
    font-family: "Century Gothic",Helvetica,sans-serif;
    font-size: 15px;
    font-weight: bold;
    line-height: 26px;
    margin-right: 15px;
    text-align: right;
    text-shadow: 1px 1px 1px #FFFFFF;
    width: 180px;
}
#rule_form_container p.submit {
    background: none repeat scroll 0 0 transparent;
    border: medium none;
    box-shadow: none;
}

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
186
</style>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
187 188 189
<div id="rule_form_wrapper" class="container">
    {% if edit %}<h4>{% trans "Edit rule" %}: {{form.data.name}}</h4>
    {% else %}<h4>{% trans "Apply for a new rule" %}</h4>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
190
    {% endif %}
191 192
    <hr>
    <br>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
193 194
    <form method="POST" class="form-horizontal">
        
195 196 197 198 199 200 201 202 203 204 205
            {% csrf_token %}
            {% load unescape %}
            {% if form.non_field_errors %}
            <p class="error">
                {{ form.non_field_errors|unescape}}
            </p>
            {% endif %}
            <fieldset {%  if edit %}  style="display:none;" {%  endif %}>
                <legend>
                    {% trans "Rule Basic Info" %}
                </legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
206
                <div class="control-group  {% if form.name.errors %} error {% endif %}">
207
	                <label class="control-label" for="id_name"><b>{% trans "Name" %}</b></label>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
208 209
                    <div class="controls">
                    {{ form.name }}
210
                    {% if form.name.errors %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
211
                    <span class="help-inline">
212
                        {{ form.name.errors|join:", " }}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
213
                    </span>
214
                    {% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
215 216
                    <span class="help-block">A unique identifier will be added as a name_suffix</span>
                    </div>
217 218
                </div>
            </fieldset>
219 220 221 222 223
            {% if user.is_superuser %}
            <fieldset>
                <legend>
                    {% trans "Admin Options" %}
                </legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
224
                  <div class="control-group">
225
	                <label class="control-label" for="id_applier"><b>{% trans "Applier" %}</b></label>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
226
                   <div class="controls">{{ form.applier }}</div>
227 228 229 230 231 232 233 234 235 236 237
                    {% if form.applier.errors %}
                    <br>
                    <p class="error" style="clear:both;">
                        {{ form.applier.errors|join:", " }}
                    </p>
                    {% endif %}
                </div>
                </fieldset>
                {% else %}
                 <input type="hidden" id="id_applier" name="applier" value="{{applier}}"/>
                {% endif %}
238 239 240 241
            <fieldset>
                <legend>
                    {% trans "Rule Match Conditions" %}
                </legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
242
                <div class="control-group {% if form.source.errors %} error {% endif %}">
243 244
	                <label class="control-label" for="id_source"><b>{% trans "Source Address" %}</b></label>
                    <div class="controls">{{ form.source }}&nbsp;<img src="/fodstatic/threat_source.png" style="height: 30px;"/>&nbsp;&nbsp;<a class="btn btn-small btn-info" id="setFromAll" href="#">Any</a>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
245 246
                    {% if form.source.errors %}
                    <span class="help-inline">
247
                        {{ form.source.errors|join:", " }}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
248
                    </span>
249
                    {% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
250 251 252 253
                    <span class="help-block"> {{ form.source.help_text }}</span>
                    </div> 


254
                </div>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
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>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
257
                    <div class="controls">
258
					{{ form.destination }}&nbsp;<img src="/fodstatic/secure_destination.png" style="height: 30px;"/>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
259 260
					{% if form.destination.errors %}
                    <span class="help-inline">
261
                        {{ form.destination.errors|join:", " }}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
262
                    </span>
263
                    {% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
264 265 266
					<span class="help-block">{{ form.destination.help_text }}</span>
					</div> 

267
                </div>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
268 269 270 271 272
				<div class="control-group {% if form.protocol.errors %} error {% endif %}">
	                <label class="control-label" for="id_protocol">{% trans "Protocol" %}</label>
                   <div class="controls">{{ form.protocol }}
                   {% if form.protocol.errors %}
                    <span class="help-inline">
273
                        {{ form.protocol.errors|join:", " }}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
274
                    </span>
275
                    {% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
276 277
                   </div>
                   
278
                </div>
279 280 281 282 283 284 285 286 287 288 289 290
                <div class="control-group {% if form.fragmenttype.errors %} error {% endif %}">
	                <label class="control-label" for="id_fragmenttype">{% trans "Fragment Type" %}</label>
                   <div class="controls">{{ form.fragmenttype }}
                   {% if form.fragmenttype.errors %}
                    <span class="help-inline">
                        {{ form.fragmenttype.errors|join:", " }}
                    </span>
                    {% endif %}
                   </div>
                   
                </div>
                
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
			<div
				class="control-group {% if form.port.errors %} error {% endif %}">
				<label class="control-label" for="id_port">{% trans "Ports"	%}</label>
				<div class="controls">
					<div id="portsaccordion" class="accordion">
						<div class="accordion-group">
							<div class="accordion-heading">
								<a class="accordion-toggle" data-toggle="collapse"
									data-parent="#accordion2" href="#collapseOne"> {% trans "Advanced Settings (Ports)" %}</a>
							</div>
							<div id="collapseOne" class="accordion-body collapse">
								<div class="accordion-inner">
								<label>{% trans "Select source/destination port(s), or select common port(s) for both source/destination" %}</label>
								<div class="control-group  {% if form.sourceport.errors %} error {% endif %}">
					                <label class="control-label" for="id_sourceport">{% trans "Source Port" %}</label>
				                    <div class="controls">
				                    {{ form.sourceport }}
				                    
				                    <span class="help-inline">
				                    <button class="new_port btn  btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button>
				                    {% if form.sourceport.errors %}
				                        {{ form.sourceport.errors|join:", " }}
				                    {% endif %}
				                    </span>
				                    
				                    <span class="help-block">{{ form.sourceport.help_text }}</span>
				                    </div>
				                </div>
				                <div class="control-group  {% if form.destinationport.errors %} error {% endif %}">
					                <label class="control-label" for="id_destinationport">{% trans "Destination Port" %}</label>
				                    <div class="controls">
				                    {{ form.destinationport }}
				                    
				                    <span class="help-inline">
				                    <button class="new_port btn  btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button>
				                    {% if form.destinationport.errors %}
				                        {{ form.destinationport.errors|join:", " }}
				                    {% endif %}
				                    </span>
				                    
				                    <span class="help-block">{{ form.destinationport.help_text }}</span>
				                    </div>
				                </div>
				                <div class="control-group  {% if form.port.errors %} error {% endif %}">
					                <label class="control-label" for="id_port">{% trans "Port" %}</label>
				                    <div class="controls">
				                    {{ form.port }}
				                    
				                    <span class="help-inline">
				                    <button class="new_port btn  btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button>
				                    {% if form.port.errors %}
				                        {{ form.port.errors|join:", " }}
				                    {% endif %}
				                    </span>
				                    
				                    <span class="help-block">{{ form.port.help_text }}</span>
				                    </div>
				                </div>

								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

		</fieldset>
358 359 360 361
            <fieldset>
                <legend>
                    {% trans "Rule Actions" %}
                </legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
362
                <div class="control-group {% if form.then.errors %} error {% endif %}">
363
	                <label class="control-label" for="id_then"><b>{% trans "Then" %}</b></label>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
364
                    <div class="controls">{{ form.then }}
365
                    {% if form.then.errors %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
366
                    <span class="help-inline">
367
                        {{ form.then.errors|join:", " }}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
368
                    </span>
369
                    {% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
370 371 372 373 374 375 376
                    </div>
                    {% comment %}&nbsp;&nbsp;
                    <button id="new_then_actions">
                        Rate-limit
                    </button>
                    {% endcomment %}
                    
377 378 379 380 381 382
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    {% trans "Expiration" %}
                </legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
383 384 385
                <div class="control-group  {% if form.expires.errors %} error {% endif %}">
	                <label class="control-label" for="id_expires">{% trans "Expires" %}</label>
                    <div class="controls">{{ form.expires }}
386
                    {% if form.expires.errors %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
387
                    <span class="help-inline">
388
                        {{ form.expires.errors|join:", " }}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
389
                    </span>
390
                    {% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
391
                    </div>
392 393 394
                </div>
            </fieldset>
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
395 396
            
            <legend>
397 398
                    {% trans "Use/Comments" %}
                </legend>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
399 400 401 402
                <div class="control-group  {% if form.comments.errors %} error {% endif %}">
	                <label class="control-label" for="id_comments">{% trans "Comments" %}</label>
                    <div class="controls">
                    <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>
403
                    {{ form.comments }}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
404 405 406 407 408 409 410 411 412
                    
                    {% if form.comments.errors %}
                    <span class="help-inline">
                        {{ form.comments.errors|join:", " }}
                    </span>
                    {% endif %}
                    </div>
                </div>
            
413
            </fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
414 415
			 <div class="control-group">
			<div class="controls">
416
			<button type="submit" id="applybutton" value="{% trans 'Apply' %}" class="btn btn-large btn-primary"/>Apply</button>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
417 418 419 420
			</div>
			</div>
                

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
421
    </form>
422
</div>
423 424
<div id="then_diag" title="Add new rate-limit value">
</div>
425
<div id="port_diag" title="{% trans "Add new port" %}">
426 427
</div>

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