Statistics
| Branch: | Tag: | Revision:

root / templates / apply.html @ 62ee35d6

History | View | Annotate | Download (14.3 kB)

1
{% extends "base.html" %}
2
{% load i18n %}
3

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

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

    
139

    
140

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

    
153

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

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

    
245

    
246
                </div>
247
                <div class="control-group {% if form.destination.errors %} error {% endif %}">
248
                        <label class="control-label" for="id_destination">{% trans "Destination Address" %}</label>
249
                    <div class="controls">
250
                                        {{ form.destination }}&nbsp;<img src="/static/secure_destination.png" style="height: 30px;"/>
251
                                        {% if form.destination.errors %}
252
                    <span class="help-inline">
253
                        {{ form.destination.errors|join:", " }}
254
                    </span>
255
                    {% endif %}
256
                                        <span class="help-block">{{ form.destination.help_text }}</span>
257
                                        </div> 
258

    
259
                </div>
260
                                <div class="control-group {% if form.protocol.errors %} error {% endif %}">
261
                        <label class="control-label" for="id_protocol">{% trans "Protocol" %}</label>
262
                   <div class="controls">{{ form.protocol }}
263
                   {% if form.protocol.errors %}
264
                    <span class="help-inline">
265
                        {{ form.protocol.errors|join:", " }}
266
                    </span>
267
                    {% endif %}
268
                   </div>
269
                   
270
                </div>
271
                        <div
272
                                class="control-group {% if form.port.errors %} error {% endif %}">
273
                                <label class="control-label" for="id_port">{% trans "Ports"        %}</label>
274
                                <div class="controls">
275
                                        <div id="portsaccordion" class="accordion">
276
                                                <div class="accordion-group">
277
                                                        <div class="accordion-heading">
278
                                                                <a class="accordion-toggle" data-toggle="collapse"
279
                                                                        data-parent="#accordion2" href="#collapseOne"> {% trans "Advanced Settings (Ports)" %}</a>
280
                                                        </div>
281
                                                        <div id="collapseOne" class="accordion-body collapse">
282
                                                                <div class="accordion-inner">
283
                                                                <label>{% trans "Select source/destination port(s), or select common port(s) for both source/destination" %}</label>
284
                                                                <div class="control-group  {% if form.sourceport.errors %} error {% endif %}">
285
                                                        <label class="control-label" for="id_sourceport">{% trans "Source Port" %}</label>
286
                                                    <div class="controls">
287
                                                    {{ form.sourceport }}
288
                                                    
289
                                                    <span class="help-inline">
290
                                                    <button class="new_port btn  btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button>
291
                                                    {% if form.sourceport.errors %}
292
                                                        {{ form.sourceport.errors|join:", " }}
293
                                                    {% endif %}
294
                                                    </span>
295
                                                    
296
                                                    <span class="help-block">{{ form.sourceport.help_text }}</span>
297
                                                    </div>
298
                                                </div>
299
                                                <div class="control-group  {% if form.destinationport.errors %} error {% endif %}">
300
                                                        <label class="control-label" for="id_destinationport">{% trans "Destination Port" %}</label>
301
                                                    <div class="controls">
302
                                                    {{ form.destinationport }}
303
                                                    
304
                                                    <span class="help-inline">
305
                                                    <button class="new_port btn  btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button>
306
                                                    {% if form.destinationport.errors %}
307
                                                        {{ form.destinationport.errors|join:", " }}
308
                                                    {% endif %}
309
                                                    </span>
310
                                                    
311
                                                    <span class="help-block">{{ form.destinationport.help_text }}</span>
312
                                                    </div>
313
                                                </div>
314
                                                <div class="control-group  {% if form.port.errors %} error {% endif %}">
315
                                                        <label class="control-label" for="id_port">{% trans "Port" %}</label>
316
                                                    <div class="controls">
317
                                                    {{ form.port }}
318
                                                    
319
                                                    <span class="help-inline">
320
                                                    <button class="new_port btn  btn-small"><i class="icon-plus"></i>{% trans "Port" %}</button>
321
                                                    {% if form.port.errors %}
322
                                                        {{ form.port.errors|join:", " }}
323
                                                    {% endif %}
324
                                                    </span>
325
                                                    
326
                                                    <span class="help-block">{{ form.port.help_text }}</span>
327
                                                    </div>
328
                                                </div>
329

    
330
                                                                </div>
331
                                                        </div>
332
                                                </div>
333
                                        </div>
334
                                </div>
335
                        </div>
336

    
337
                </fieldset>
338
            <fieldset>
339
                <legend>
340
                    {% trans "Rule Actions" %}
341
                </legend>
342
                <div class="control-group {% if form.then.errors %} error {% endif %}">
343
                        <label class="control-label" for="id_then">{% trans "Then" %}</label>
344
                    <div class="controls">{{ form.then }}
345
                    {% if form.then.errors %}
346
                    <span class="help-inline">
347
                        {{ form.then.errors|join:", " }}
348
                    </span>
349
                    {% endif %}
350
                    </div>
351
                    {% comment %}&nbsp;&nbsp;
352
                    <button id="new_then_actions">
353
                        Rate-limit
354
                    </button>
355
                    {% endcomment %}
356
                    
357
                </div>
358
            </fieldset>
359
            <fieldset>
360
                <legend>
361
                    {% trans "Expiration" %}
362
                </legend>
363
                <div class="control-group  {% if form.expires.errors %} error {% endif %}">
364
                        <label class="control-label" for="id_expires">{% trans "Expires" %}</label>
365
                    <div class="controls">{{ form.expires }}
366
                    {% if form.expires.errors %}
367
                    <span class="help-inline">
368
                        {{ form.expires.errors|join:", " }}
369
                    </span>
370
                    {% endif %}
371
                    </div>
372
                </div>
373
            </fieldset>
374
            <fieldset>
375
            
376
            <legend>
377
                    {% trans "Use/Comments" %}
378
                </legend>
379
                <div class="control-group  {% if form.comments.errors %} error {% endif %}">
380
                        <label class="control-label" for="id_comments">{% trans "Comments" %}</label>
381
                    <div class="controls">
382
                    <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>
383
                    {{ form.comments }}
384
                    
385
                    {% if form.comments.errors %}
386
                    <span class="help-inline">
387
                        {{ form.comments.errors|join:", " }}
388
                    </span>
389
                    {% endif %}
390
                    </div>
391
                </div>
392
            
393
            </fieldset>
394
                         <div class="control-group">
395
                        <div class="controls">
396
                        <button type="submit" id="applybutton" value="{% trans "Apply" %}" class="btn btn-large btn-primary"/>Apply</button>
397
                        </div>
398
                        </div>
399
                
400

    
401
    </form>
402
</div>
403
<div id="then_diag" title="Add new rate-limit value">
404
</div>
405
<div id="port_diag" title="{% trans "Add  port" %}">
406
</div>
407

    
408
{% endblock %}