apply.html 14.2 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
    <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">
26
   
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
27
{% endblock %}
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

{% 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>
78 79
 <link href="{{STATIC_URL}}js/select2/select2.css" rel="stylesheet">
 <link href="{{STATIC_URL}}js/select2/select2-bootstrap.css" rel="stylesheet">
80 81
{% endblock %}

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
82 83
{% block pagejsbottom %}
<script type="text/javascript" src="{{STATIC_URL}}datepicker/js/bootstrap-datepicker.js"></script>
84
<script type="text/javascript" src="{{STATIC_URL}}js/select2/select2.js"></script>
85 86
<script>
	$(document).ready( function(){
87 88 89 90
		$('#id_then').removeAttr("multiple");
		$("#id_protocol").select2();
		$("#id_fragmenttype").select2();
		$("#id_then").select2();
91
		
92 93 94 95 96 97 98 99 100 101 102 103
		reArrangeSelect("id_sourceport");
		$("#id_sourceport").select2({
			placeholder: "Source Port(s)"
		});
		reArrangeSelect("id_destinationport");
		$("#id_destinationport").select2({
			placeholder: "Destination Port(s)"
		});
		reArrangeSelect("id_port");
		$("#id_port").select2({
			placeholder: "Port(s)"
		});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
104 105 106
		$('#id_expires').datepicker({
			startDate: '+1d',
			endDate: '+10d'
107
		});
108
		$('#setFromAll').click(function(){
109
			$("#id_source").val('0.0.0.0/0');
110 111 112
		});
		
		
113
		/*$('#id_then').attr("multiple", "");*/
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
114
		/*
115
		$( "#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
116
		*/
117
		{% comment %}
118 119 120 121 122 123
		$('#then_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
124
		'{% trans "Add" %}': function() {
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
			$.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);
					}					
				}
				});
		},
143
		'{% trans "Cancel" %}': function() {
144 145 146 147
			$('#then_diag').dialog('close');
		}
	}
		});
148
		{% endcomment %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
149

150
		{% comment %}
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
		$("#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;
			});
			
168
			{% endcomment %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
169 170 171
			$(".new_port").click(function(){
				$(".new_port").hide();
				$("#addnewport").show()
172 173 174 175 176 177 178
				$.ajax({
					url: "{% url add-port %}",
					cache: false,
					success: function(data){
						$("#port_diag").html(data);
					}
				});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
179
				// $('#port_diag').dialog('open');
180 181
				return false;
			});
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
182 183 184
			
			function reArrangeSelect(elementId) {
 			   $("#"+elementId).html($("#"+elementId+" option").sort(function(a, b) {
185
        			return parseInt(a.text) == parseInt(b.text) ? 0 : parseInt(a.text) < parseInt(b.text) ? -1 : 1
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
186 187 188
    			}));
			}
	});
189 190 191
		
</script>
{% endblock %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
192
{% block contentplaceholder %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
193

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
            <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
212
        
213 214 215
            {% csrf_token %}
            {% load unescape %}
            {% if form.non_field_errors %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
216 217 218
            <div class="form-group {% if form.non_field_errors %} has-error {% endif %}" style="color: #A94442;">
            	{{ form.non_field_errors|unescape}}
            	</div>
219 220
            {% endif %}
            <fieldset {%  if edit %}  style="display:none;" {%  endif %}>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
221 222 223 224 225 226 227 228 229
               
                 <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>
230
            </fieldset>
231 232
            {% if user.is_superuser %}
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
233 234 235 236 237 238 239 240 241
            	<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>
242 243 244 245
                </fieldset>
                {% else %}
                 <input type="hidden" id="id_applier" name="applier" value="{{applier}}"/>
                {% endif %}
246
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
247 248 249 250 251 252 253 254 255 256 257 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
                <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 -->
		
332
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
333 334 335 336 337 338 339 340 341 342 343
				<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>
                
344 345
            </fieldset>
            <fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
346 347 348 349 350 351 352 353 354
				<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>
355
            </fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
356
            
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
357 358 359 360 361 362 363 364 365 366 367 368 369
            
            <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
370
            
371
            </fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
372 373 374 375 376
			 <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
377 378 379
			</div>
                

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
380
    </form>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
381
</div></div></div></div>
382 383
<div id="then_diag" title="Add new rate-limit value">
</div>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
384 385
<!-- <div id="port_diag" title="{% trans "Add new port" %}">
</div> -->
386

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