apply.html 14.5 KB
Newer Older
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
1 2
{% extends "b3theme/base.html" %}
{% load widget_tweaks %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
3
{% load i18n %}
4

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

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
13 14
{% block breadcrumbs %}
 <li class="active"><span class="divider">/</span>
15
	{% if edit %}
16
		{% trans "Edit rule" %} {{form.data.name}}
17
	{% else %}
18
	{% trans "Create rule" %}
19
	{% endif %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
20 21
</li>
{% endblock %}
22
{% block extrahead %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
23 24 25 26 27 28
    <link href="{{STATIC_URL}}b3theme/css/plugins/morris/morris-0.4.3.min.css" rel="stylesheet">
    <link href="{{STATIC_URL}}b3theme/css/plugins/timeline/timeline.css" rel="stylesheet">
    <link href="{{STATIC_URL}}datepicker/css/datepicker.css" rel="stylesheet">
{% endblock %}
{% block pagejsbottom %}
<script type="text/javascript" src="{{STATIC_URL}}datepicker/js/bootstrap-datepicker.js"></script>
29 30 31
<script>
	$(document).ready( function(){
		
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
32 33 34 35
		$('#id_expires').datepicker({
			startDate: '+1d',
			endDate: '+10d'
		})
36
		$('#setFromAll').click(function(){
37
			$("#id_source").val('0.0.0.0/0');
38 39 40
		});
		
		
41
		/*$('#id_then').attr("multiple", "");*/
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
42
		/*
43
		$( "#id_expires" ).datepicker({ dateFormat: 'yy-mm-dd' , maxDate: '+10d', minDate: '+1d', changeMonth: false, changeYear: false }).datepicker( $.datepicker.regional[ "el" ] );
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
44
		*/
45
		{% comment %}
46 47 48 49 50 51
		$('#then_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
52
		'{% trans "Add" %}': function() {
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
			$.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);
					}					
				}
				});
		},
71
		'{% trans "Cancel" %}': function() {
72 73 74 75
			$('#then_diag').dialog('close');
		}
	}
		});
76
		{% endcomment %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
77

78
		{% comment %}
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
		$("#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;
			});
			
96
			{% endcomment %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
97 98 99
			$(".new_port").click(function(){
				$(".new_port").hide();
				$("#addnewport").show()
100 101 102 103 104 105 106
				$.ajax({
					url: "{% url add-port %}",
					cache: false,
					success: function(data){
						$("#port_diag").html(data);
					}
				});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
107
				// $('#port_diag').dialog('open');
108 109
				return false;
			});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
			
			$('body').on('click', "#addportbtn", function(){
			$.ajax({
			url:"{% url add-port %}", 
			data:$("#add_port_form").serialize(),
			type: "POST",
			cache: false,
			success:function(data){
					try {
						value = data.value;
						text = data.text;
						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').html('');
							$('#addnewport').hide();
							$(".new_port").show();
						}
					}
					catch (exception) {
						$('#port_diag').html(data);
					}					
				}
				});
			
			});
			$('body').on('click', "#canceladdportbtn", function(){
				$('#port_diag').html('');
				$('#addnewport').hide();
				$(".new_port").show();
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
144
			});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
145 146 147 148 149 150 151 152
			{% comment %}
			function reArrangeSelect(elementId) {
 			   $("#"+elementId).html($("#"+elementId+" option").sort(function(a, b) {
        			return int(a.text) == int(b.text) ? 0 : int(a.text) < int(b.text) ? -1 : 1
    			}));
			}
			{% endcomment %}
	});
153 154 155
		
</script>
{% endblock %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
156
{% block contentplaceholder %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
157
<style type="text/css">
158

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
159

160 161 162 163

#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
164
	-moz-border-radius: 3px; border-radius:3px; -webkit-border-radius: 3px; 
165 166 167 168 169 170 171 172 173 174
    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
175 176 177 178 179
	-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;
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
    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
200 201 202 203
.errorlist{
	list-style: none outside none;
}

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
204
</style>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header"> {% if edit %}{% trans "Edit rule" %}: {{form.data.name}}
    {% else %}{% trans "Apply for a new rule" %}
    {% endif %}</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>

<div class="row">
                <div class="col-lg-8">
                	<div class="panel panel-primary">
                        <div class="panel-heading">
                            <i class="fa fa-shield fa-fw"></i> Firewall Rule
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
    <form method="POST" role="form" class="form-horizontal">     
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
223
        
224 225 226
            {% csrf_token %}
            {% load unescape %}
            {% if form.non_field_errors %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
227 228 229
            <div class="form-group {% if form.non_field_errors %} has-error {% endif %}" style="color: #A94442;">
            	{{ form.non_field_errors|unescape}}
            	</div>
230 231
            {% endif %}
            <fieldset {%  if edit %}  style="display:none;" {%  endif %}>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
232 233 234 235 236 237 238 239 240
               
                 <div class="form-group {% if form.name.errors %} has-error {% endif %}">
        <label for="id_name" class="col-md-2 control-label"><b>{% trans "Name" %}</b></label>
        <div class="col-md-8">
            {% render_field form.name class+="form-control" placeholder="Eg. ntpattack. A unique identifier will be added as a suffix" %}
            {% if form.name.errors %} <span class="help-block"> {{ form.name.errors|join:", " }} </span>
            {% endif %}
        </div>
        </div>
241
            </fieldset>
242 243
            {% if user.is_superuser %}
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
244 245 246 247 248 249 250 251 252
            	<hr>
                   <div class="form-group {% if form.applier.errors %} has-error {% endif %}">
        		<label for="id_name" class="col-md-2 control-label"><b>{% trans "Applier" %}</b></label>
		        <div class="col-md-8">
		            {% render_field form.applier class+="form-control" %}
		            {% if form.applier.errors %} <span class="help-block"> {{ form.applier.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        </div>
253 254 255 256
                </fieldset>
                {% else %}
                 <input type="hidden" id="id_applier" name="applier" value="{{applier}}"/>
                {% endif %}
257
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 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
                <hr>
                <div class="form-group {% if form.source.errors %} has-error {% endif %}"> 
        		<label for="id_source" class="col-md-2 control-label"><b>{% trans "Source Address" %}</b></label>
		        <div class="col-md-6">
		            {% render_field form.source class+="form-control" placeholder=form.source.help_text %}
		            {% if form.source.errors %} <span class="help-block"> {{ form.source.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        <div class="col-md-2">
		            <img src="{{STATIC_URL}}threat_source.png" style="height: 30px;"/> &nbsp;&nbsp;<button type="button" class="btn btn-md btn-info btn-outline" id="setFromAll">Any</button>
		        </div>
		        </div>
		        
				<div class="form-group {% if form.destination.errors %} has-error {% endif %}"> 
        		<label for="id_destination" class="col-md-2 control-label"><b>{% trans "Destination Address" %}</b></label>
		        <div class="col-md-6">
		            {% render_field form.destination class+="form-control" placeholder=form.destination.help_text %}
		            {% if form.destination.errors %} <span class="help-block"> {{ form.destination.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        <div class="col-md-2">
		            <img src="{{STATIC_URL}}secure_destination.png" style="height: 30px;"/>
		        </div>
		        </div>
		        
				<div class="form-group {% if form.protocol.errors %} has-error {% endif %}"> 
        		<label for="id_protocol" class="col-md-2 control-label" style="font-weight: normal;">{% trans "Protocol(s)" %}</label>
		        <div class="col-md-8">
		            {% render_field form.protocol class+="form-control" %}
		            {% if form.protocol.errors %} <span class="help-block"> {{ form.protocol.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        </div>
		        
		        <div class="form-group {% if form.fragmenttype.errors %} has-error {% endif %}"> 
        		<label for="id_fragmenttype" class="col-md-2 control-label" style="font-weight: normal;">{% trans "Fragment Type" %}</label>
		        <div class="col-md-8">
		            {% render_field form.fragmenttype class+="form-control" %}
		            {% if form.fragmenttype.errors %} <span class="help-block"> {{ form.fragmenttype.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        </div>
		        </fieldset>
		        <!--  PORTS -->
		        <fieldset>
                <hr>
		        <div class="form-group ">
		        	<label class="col-md-10" style="font-weight: normal;"><small>{% trans "Select source/destination port(s), or select common port(s) for both source/destination" %}. {{ form.sourceport.help_text }}</small></label>
		        </div>
		        <div class="form-group {% if form.sourceport.errors %} has-error {% endif %} {% if form.destinationport.errors %} has-error {% endif %} {% if form.port.errors %} has-error {% endif %}"> 
        		<label for="id_sourceport" class="col-md-2 control-label" style="font-weight: normal;">{% trans "Src. Port(s)" %}</label>
		        <div class="col-md-2">
		            {% render_field form.sourceport class+="form-control"  %}
		            {% if form.sourceport.errors %} <span class="help-block"> {{ form.sourceport.errors|join:", " }} </span>
		            {% endif %}
		        </div>
				<label for="id_destinationport" class="col-md-1 control-label" style="font-weight: normal;">{% trans "Dest. Port(s)" %}</label>
		        <div class="col-md-2">
		            {% render_field form.destinationport class+="form-control"  %}
		            {% if form.destinationport.errors %} <span class="help-block"> {{ form.destinationport.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        <label for="id_port" class="col-md-1 control-label" style="font-weight: normal;">{% trans "Port(s)" %}</label>
		        <div class="col-md-2">
		            {% render_field form.port class+="form-control"  %}
		            {% if form.port.errors %} <span class="help-block"> {{ form.port.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        </div>
				<div class="form-group ">
		        	<label class="col-md-2" style="font-weight: normal;"></label>
		        	<div class="col-md-8">
		        		<button class="new_port btn-info btn btn-md btn-outline" type="button">{% trans "Add Port" %}</button>
		        	</div>
		        </div>
		        <div class="form-group " id="addnewport" style="display:none">
		        	<label class="col-md-2  control-label" style="font-weight: normal;">{% trans "Add New Port" %}</label>
		        	<div class="col-md-8">
		        		<div id="port_diag" title="{% trans "Add new port" %}">
		        	</div>
		        </div>
				</fieldset>
		        
		        <!--  END OF PORTS -->
		
343
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
344 345 346 347 348 349 350 351 352 353 354
				<hr>
                
               	<div class="form-group {% if form.then.errors %} has-error {% endif %}"> 
        		<label for="id_then" class="col-md-2 control-label">{% trans "Then Actions" %}</label>
		        <div class="col-md-8">
		            {% render_field form.then class+="form-control" %}
		            {% if form.then.errors %} <span class="help-block"> {{ form.then.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        </div>
                
355 356
            </fieldset>
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
357 358 359 360 361 362 363 364 365
				<hr>
                <div class="form-group {% if form.expires.errors %} has-error {% endif %}"> 
        		<label for="id_then" class="col-md-2 control-label">{% trans "Expires" %}</label>
		        <div class="col-md-8">
		            {% render_field form.expires class+="form-control datepicker" data-date-format="yyyy-mm-dd"  %}
		            {% if form.expires.errors %} <span class="help-block"> {{ form.expires.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        </div>
366
            </fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
367
            
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
368 369 370 371 372 373 374 375 376 377 378 379 380
            
            <fieldset>
			<hr>
                
                               	<div class="form-group {% if form.comments.errors %} has-error {% endif %}"> 
        		<label for="id_comments" class="col-md-2 control-label">{% trans "Comments" %}</label>
		        <div class="col-md-8">
		            {% render_field form.comments class+="form-control" placeholder="Give a short description of the intended use of this rule, that justifies the parameter selection above. Feel free to include any additional comments." %}
		            {% if form.comments.errors %} <span class="help-block"> {{ form.comments.errors|join:", " }} </span>
		            {% endif %}
		        </div>
		        </div>

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
381
            
382
            </fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
383 384 385 386 387
			 <div class="form-group">
			 	<div class="col-md-2"></div>
			 	 <div class="col-md-8">
			<button type="submit" id="applybutton" value="{% trans 'Apply' %}" class="btn btn-md btn-primary">Apply</button>
				</div>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
388 389 390
			</div>
                

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
391
    </form>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
392
</div></div></div></div>
393 394
<div id="then_diag" title="Add new rate-limit value">
</div>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
395 396
<!-- <div id="port_diag" title="{% trans "Add new port" %}">
</div> -->
397

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