Statistics
| Branch: | Tag: | Revision:

root / templates / apply.html @ 7b50e98b

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

134
                });
135
                
136
                $("#applybutton").button();
137

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

    
150
.accord_wrapper{
151
        height: 100% !important;
152
} 
153

    
154
.help {
155
        font-style: italic;
156

    
157
}
158
</style>
159
<div align="center">
160
        {% if edit %}
161
        <h3>{% trans "Edit rule" %}: {{form.data.name}}</h3>
162
        {% else %}
163
<h3>{% trans "Apply for a new rule" %}</h3>
164
{% endif %}
165
<form method="POST">
166
{% csrf_token %}
167
{% load unescape %}
168
{% if form.non_field_errors %}
169
<p class="error">{{ form.non_field_errors|unescape}}</p>
170
{% endif %}
171

    
172
<fieldset {% if  %} style="display:none;" {% endif %}>
173
        <legend>{% trans "Rule Basic Info" %}</legend>
174
<table>
175
<tr><th>{{ form.name.label_tag }}</th><td>{{ form.name }}<span class="error">{{ form.name.errors|join:", " }}</span></td></tr>
176
<tr class="help"><td></td><td>A unique identifier will be added as a name_suffix</td></tr>
177
</table>
178
</fieldset>
179

    
180
<fieldset>
181
<legend>{% trans "Rule Match Conditions" %}</legend>
182
<table>
183
<input type="hidden" id="id_applier" name="applier" value="{{applier}}"/>
184
<tr><th>{{ form.source.label_tag }}</th><td>{{ form.source }}<span class="error">{{ form.source.errors|join:", " }}</span></td></tr>
185
<tr class="help"><td></td><td>{{ form.source.help_text }}</td></tr>
186
<tr><th>{{ form.destination.label_tag }}</th><td>{{ form.destination }}<span class="error">{{ form.destination.errors|join:", " }}</span></td></tr>
187
<tr class="help"><td></td><td>{{ form.destination.help_text }}</td></tr>
188
</table>
189
<div id='portsacc' style="width: 500px;">
190
        <h3 style="padding: 0.5em 0.5em 0.5em 0.7em;">Advanced Settings (Ports)</h3>
191
        <div class='accord_wrapper' style="height: 100% !important;">
192
        Select source/destination port(s), or select common port(s) for both source/destination
193
<table>
194
<tr><th>{{ form.sourceport.label_tag }}</th><td>{{ form.sourceport }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.sourceport.errors|join:", " }}</span></td></tr>
195
<tr class="help"><td></td><td>{{ form.sourceport.help_text }}</td></tr>
196
<tr><th>{{ form.destinationport.label_tag }}</th><td>{{ form.destinationport }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.destinationport.errors|join:", " }}</span></td></tr>
197
<tr class="help"><td></td><td>{{ form.destinationport.help_text }}</td></tr>
198
<tr><th>{{ form.port.label_tag }}</th><td>{{ form.port }}&nbsp;&nbsp;<button class="new_port">Port</button><span class="error">{{ form.port.errors|join:", " }}</span></td></tr>
199
<tr class="help"><td></td><td>{{ form.port.help_text }}</td></tr>
200
</div>
201
</table>
202
</div>
203
</fieldset>
204
<fieldset>
205
<legend>{% trans "Rule Actions" %}</legend>
206
<table>
207
<tr><th>{{ form.then.label_tag }}</th><td>{{ form.then }}&nbsp;&nbsp;<button id="new_then_actions">Rate-limit</button><span class="error">{{ form.then.errors|join:", " }}</span></td></tr>
208
</table>
209
</fieldset>
210
<fieldset>
211
<legend>{% trans "Expiration" %}</legend>
212
<table>
213
<tr><th>{{ form.expires.label_tag }}</th><td>{{ form.expires }}<span class="error">{{ form.expires.errors|join:", " }}</span></td></tr>
214
</table>
215
</fieldset>
216
<fieldset>
217
<legend>{% trans "Use/Comments" %}</legend>
218
{% blocktrans %}
219
<p>Give a short description of the intended use of this rule, that justifies the parameter selection above. Feel free to include any additional comments.</p>
220
{% endblocktrans %}
221
<p>{{ form.comments }}
222
{% if form.errors %}<br /><span class="error">{{ form.comments.errors|join:", " }}</span>{% endif %}
223
</p>
224
</fieldset>
225

    
226
<p><input type="submit" id="applybutton" value="{% trans "Apply" %}" /></p>
227
</form>
228
</div>
229

    
230
<div id="then_diag" title="Add new rate-limit value">
231
</div>
232

    
233
<div id="port_diag" title="Add new port">
234
</div>
235

    
236
{% endblock %}