apply.html 13.5 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 12 13
	{% endif %}
{% endblock %}

{% block breadcrumbs %}:: 
	{% if edit %}
14
		{% trans "Edit rule" %} {{form.data.name}}
15
	{% else %}
16
	{% trans "Create rule" %}
17 18
	{% endif %}
		{% endblock %}
19 20 21 22 23 24 25 26
{% block extrahead %}
<script>
	$(document).ready( function(){
		
		$("#id_sourceport").css('width', '100px').attr('size', '5');
		$("#id_port").css('width', '100px').attr('size', '5');
		$("#id_destinationport").css('width', '100px').attr('size', '5');
		$('#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 30 31 32 33 34
		$('#then_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
35
		'{% trans "Add" %}': function() {
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
			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);
					}					
				}
				});
		},
55
		'{% trans "Cancel" %}': function() {
56 57 58 59
			$('#then_diag').dialog('close');
		}
	}
		});
60
		{% endcomment %}
61 62 63 64 65 66
		$('#port_diag').dialog({
			height: 220,
            width: 340,
			modal: true,
			autoOpen: false,
			buttons: {
67
		'{% trans "Add" %}': function() {
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
			$.ajax({
			url:"{% url add-port %}", 
			data:$("#add_port_form").serialize(),
			type: "POST",
			cache: false,
			success:function(data){
					try {
						value = data.value;
						text = data.text;
						$('#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');
					}
					catch (exception) {
						$('#port_diag').html(data);
					}					
				}
				});
		},
88
		'{% trans "Cancel" %}': function() {
89 90 91 92 93
			$('#port_diag').dialog('close');
		}
	}
		});
		
94
		{% comment %}
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
		$("#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;
			});
			
112
			{% endcomment %}
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
			$(".new_port").button({
            icons: {
                primary: "ui-icon-plusthick"
            },
			})
			.click(function(){
				$.ajax({
					url: "{% url add-port %}",
					cache: false,
					success: function(data){
						$("#port_diag").html(data);
					}
				});
				$('#port_diag').dialog('open');
				return false;
			});
129 130 131 132 133 134 135 136 137
			
		$("#portsacc").accordion({
			collapsible: true,
			active: false,

		});
		
		$("#applybutton").button();

138 139 140 141
		});
		
</script>
{% endblock %}
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
142 143 144 145 146 147 148 149
{% block content %}
<style type="text/css">
th {
	text-align: right;
	padding-right: 0.5em;
	vertical-align: top;
}

150
.accord_wrapper{
151
	height: 452px !important;
152 153
} 

Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
154 155 156 157
.help {
	font-style: italic;

}
158
div.roundbox, #portsacc, #id_comments{
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
159 160 161 162 163 164 165 166
	-moz-border-radius: 5px; border-radius:5px; -webkit-border-radius: 5px;
	-moz-box-shadow: 0 0 3px #AAAAAA; box-shadow: 0 0 3px #AAAAAA; -webkit-box-shadow: 0 0 3px #AAAAAA;
	background-color: #F4F4F4;
	border: 1px solid #FFFFFF;
	clear: both;
	float: left;
	margin: 5px 0 5px 100px;
	padding: 10px;
167 168 169 170 171 172 173 174 175 176 177 178
    width: 620px;
}
#rule_form_wrapper{
    margin: 15px auto;
    position: relative;
    text-align: center;
    width: 800px;
}

#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
179
	-moz-border-radius: 3px; border-radius:3px; -webkit-border-radius: 3px; 
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
    float: left;
    font-family: "Century Gothic",Helvetica,sans-serif;
    font-size: 13px;
    outline: medium none;
    padding: 5px;
    width: 180px;
}

#id_comments {
    background: none repeat scroll 0 0 #FFFFFF;
    border: 1px solid #DDDDDD;
    border-radius: 3px 3px 3px 3px;
    float: left;
    font-family: "Century Gothic",Helvetica,sans-serif;
    font-size: 13px;
    outline: medium none;
    padding: 5px;
   	width: 622px;
}

#rule_form_container{
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
201 202 203 204 205
	-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;
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
    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
226
</style>
227
<div align="center" id="rule_form_wrapper">
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
228 229 230 231
    {% if edit %}<h3>{% trans "Edit rule" %}: {{form.data.name}}</h3>
    {% else %}<h3>{% trans "Apply for a new rule" %}</h3>
    {% endif %}
    <form method="POST">
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
        <div id="rule_form_container">
            {% 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>
                <div class="roundbox">
                    {{ form.name.label_tag }}{{ form.name }}
                    <br>
                    {% if form.name.errors %}
                    <br>
                    <p class="error" style="clear:both;">
                        {{ form.name.errors|join:", " }}
                    </p>
                    {% endif %}
                    <br>
                    <p style="clear:both;">
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
255
                        A unique identifier will be added as a name_suffix
256 257 258
                    </p>
                </div>
            </fieldset>
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
            {% if user.is_superuser %}
            <fieldset>
                <legend>
                    {% trans "Admin Options" %}
                </legend>
                 <div class="roundbox">
                    {{ form.applier.label_tag }}{{ form.applier }}
                    <br>
                    {% 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 %}
278 279 280 281 282 283 284 285 286 287 288 289 290
            <fieldset>
                <legend>
                    {% trans "Rule Match Conditions" %}
                </legend>
                <div class="roundbox">
                    {{ form.source.label_tag }}{{ form.source }}<img src="/static/threat_source.png"/> {% if form.source.errors %}
                    <br>
                    <p class="error" style="clear:both;">
                        {{ form.source.errors|join:", " }}
                    </p>
                    {% endif %}
                    <br>
                    <p style="clear:both;">
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
291
                        {{ form.source.help_text }}
292 293 294 295 296 297 298 299 300 301 302
                    </p>
                </div>
                <div class="roundbox">
                    {{ form.destination.label_tag }}{{ form.destination }}<img src="/static/secure_destination.png"/> {% if form.destination.errors %}
                    <br>
                    <p class="error" style="clear:both;">
                        {{ form.destination.errors|join:", " }}
                    </p>
                    {% endif %}
                    <br>
                    <p style="clear:both;">
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
303
                        {{ form.destination.help_text }}
304
                    </p>
305 306 307 308 309 310 311 312
                </div>
				<div class="roundbox">
                    {{ form.protocol.label_tag }}{{ form.protocol }}{% if form.protocol.errors %}
                    <br>
                    <p class="error" style="clear:both;">
                        {{ form.protocol.errors|join:", " }}
                    </p>
                    {% endif %}
313 314
                </div>
                <div id='portsacc'>
315
                <h3 style="padding: 0.5em 0.5em 0.5em 0.7em;">{% trans "Advanced Settings (Ports)" %}</h3>
316
                <div class='accord_wrapper' style="height: 452px !important;">
317
                    {% trans "Select source/destination port(s), or select common port(s) for both source/destination" %}
318 319 320 321 322 323 324 325
                    <table>
                    <tr>
                        <th>
                            {{ form.sourceport.label_tag }}
                        </th>
                        <td>
                            {{ form.sourceport }}&nbsp;&nbsp;
                            <button class="new_port">
326
                                {% trans "Port" %}
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
                            </button>
                            <span class="error">{{ form.sourceport.errors|join:", " }}</span>
                        </td>
                    </tr>
                    <tr class="help">
                        <td>
                        </td>
                        <td>
                            {{ form.sourceport.help_text }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ form.destinationport.label_tag }}
                        </th>
                        <td>
                            {{ form.destinationport }}&nbsp;&nbsp;
                            <button class="new_port">
345
                                {% trans "Port" %}
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
                            </button>
                            <span class="error">{{ form.destinationport.errors|join:", " }}</span>
                        </td>
                    </tr>
                    <tr class="help">
                        <td>
                        </td>
                        <td>
                            {{ form.destinationport.help_text }}
                        </td>
                    </tr>
                    <tr>
                        <th>
                            {{ form.port.label_tag }}
                        </th>
                        <td>
                            {{ form.port }}&nbsp;&nbsp;
                            <button class="new_port">
364
                                {% trans "Port" %}
365 366 367 368 369 370 371 372 373 374 375 376 377
                            </button>
                            <span class="error">{{ form.port.errors|join:", " }}</span>
                        </td>
                    </tr>
                    <tr class="help">
                        <td>
                        </td>
                        <td>
                            {{ form.port.help_text }}
                        </td>
                    </tr>
                </div>
                </table>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
378
            </div>
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414
            </fieldset>
            <fieldset>
                <legend>
                    {% trans "Rule Actions" %}
                </legend>
                <div class="roundbox">
                    {{ form.then.label_tag }}{{ form.then }}{% comment %}&nbsp;&nbsp;
                    <button id="new_then_actions">
                        Rate-limit
                    </button>{% endcomment %}
                    {% if form.then.errors %}
                    <p class="error">
                        {{ form.then.errors|join:", " }}
                    </p>
                    {% endif %}
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    {% trans "Expiration" %}
                </legend>
                <div class="roundbox">
                    {{ form.expires.label_tag }}{{ form.expires }}
                    {% if form.expires.errors %}
                    <br>
                    <p class="error">
                        {{ form.expires.errors|join:", " }}
                    </p>
                    {% endif %}
                </div>
            </fieldset>
            <fieldset>
                <legend>
                    {% trans "Use/Comments" %}
                </legend>
                <p class="roundbox">
415
                    {% 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 %}
416
                </p>
417
                
418 419 420 421 422 423 424
                <p>
                    {{ form.comments }}
                    {% if form.errors %}
                    <br/>
                    <span class="error">{{ form.comments.errors|join:", " }}</span>{% endif %}
                </p>
            </fieldset>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
425
            <p>
426
                <input type="submit" id="applybutton" value="{% trans "Apply" %}" />
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
427
            </p>
428
        </div>
Leonidas Poulopoulos's avatar
Leonidas Poulopoulos committed
429
    </form>
430
</div>
431 432
<div id="then_diag" title="Add new rate-limit value">
</div>
433
<div id="port_diag" title="{% trans "Add new port" %}">
434 435
</div>

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