apply.html 14.6 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
    <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 %}
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

{% block extraheadbottom %}
<style type="text/css">



#rule_form_container input:not([type="submit"]), #rule_form_container select {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #DDDDDD;
	-moz-border-radius: 3px; border-radius:3px; -webkit-border-radius: 3px; 
    float: left;
    font-family: "Century Gothic",Helvetica,sans-serif;
    font-size: 13px;
    outline: medium none;
    padding: 5px;
    width: 180px;
}


#rule_form_container{
	-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;
    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;
}

.errorlist{
	list-style: none outside none;
}

</style>
{% endblock %}

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
79 80
{% block pagejsbottom %}
<script type="text/javascript" src="{{STATIC_URL}}datepicker/js/bootstrap-datepicker.js"></script>
81 82 83
<script>
	$(document).ready( function(){
		
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
84 85 86 87
		$('#id_expires').datepicker({
			startDate: '+1d',
			endDate: '+10d'
		})
88
		$('#setFromAll').click(function(){
89
			$("#id_source").val('0.0.0.0/0');
90 91 92
		});
		
		
93
		/*$('#id_then').attr("multiple", "");*/
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
94
		/*
95
		$( "#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
96
		*/
97
		{% comment %}
98 99 100 101 102 103
		$('#then_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
104
		'{% trans "Add" %}': function() {
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
			$.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);
					}					
				}
				});
		},
123
		'{% trans "Cancel" %}': function() {
124 125 126 127
			$('#then_diag').dialog('close');
		}
	}
		});
128
		{% endcomment %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
129

130
		{% comment %}
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
		$("#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;
			});
			
148
			{% endcomment %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
149 150 151
			$(".new_port").click(function(){
				$(".new_port").hide();
				$("#addnewport").show()
152 153 154 155 156 157 158
				$.ajax({
					url: "{% url add-port %}",
					cache: false,
					success: function(data){
						$("#port_diag").html(data);
					}
				});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
159
				// $('#port_diag').dialog('open');
160 161
				return false;
			});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
			
			$('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
196
			});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
197 198 199 200 201 202 203 204
			{% 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 %}
	});
205 206 207
		
</script>
{% endblock %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
208
{% block contentplaceholder %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
209

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
            <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
228
        
229 230 231
            {% csrf_token %}
            {% load unescape %}
            {% if form.non_field_errors %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
232 233 234
            <div class="form-group {% if form.non_field_errors %} has-error {% endif %}" style="color: #A94442;">
            	{{ form.non_field_errors|unescape}}
            	</div>
235 236
            {% endif %}
            <fieldset {%  if edit %}  style="display:none;" {%  endif %}>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
237 238 239 240 241 242 243 244 245
               
                 <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>
246
            </fieldset>
247 248
            {% if user.is_superuser %}
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
249 250 251 252 253 254 255 256 257
            	<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>
258 259 260 261
                </fieldset>
                {% else %}
                 <input type="hidden" id="id_applier" name="applier" value="{{applier}}"/>
                {% endif %}
262
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
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 343 344 345 346 347
                <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 -->
		
348
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
349 350 351 352 353 354 355 356 357 358 359
				<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>
                
360 361
            </fieldset>
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
362 363 364 365 366 367 368 369 370
				<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>
371
            </fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
372
            
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
373 374 375 376 377 378 379 380 381 382 383 384 385
            
            <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
386
            
387
            </fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
388 389 390 391 392
			 <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
393 394 395
			</div>
                

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
396
    </form>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
397
</div></div></div></div>
398 399
<div id="then_diag" title="Add new rate-limit value">
</div>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
400 401
<!-- <div id="port_diag" title="{% trans "Add new port" %}">
</div> -->
402

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