root / templates / apply.html @ 6d153302
History | View | Annotate | Download (5.9 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 |
$('#then_diag').dialog({
|
28 |
height: 220,
|
29 |
width: 340,
|
30 |
modal: true,
|
31 |
autoOpen: false,
|
32 |
buttons: {
|
33 |
'Add': function() {
|
34 |
console.log($("#add_rl_form").serialize());
|
35 |
$.ajax({
|
36 |
url:"{% url add-rate-limit %}",
|
37 |
data:$("#add_rl_form").serialize(),
|
38 |
type: "POST",
|
39 |
cache: false,
|
40 |
success:function(data){
|
41 |
try {
|
42 |
value = data.pk;
|
43 |
text = data.value;
|
44 |
$('#id_then').append($("<option></option>").attr("value",value).text(text));
|
45 |
$('#then_diag').dialog('close');
|
46 |
}
|
47 |
catch (exception) {
|
48 |
$('#then_diag').html(data);
|
49 |
}
|
50 |
}
|
51 |
});
|
52 |
},
|
53 |
Cancel: function() {
|
54 |
$('#then_diag').dialog('close');
|
55 |
}
|
56 |
}
|
57 |
});
|
58 |
|
59 |
$('#port_diag').dialog({
|
60 |
height: 220,
|
61 |
width: 340,
|
62 |
modal: true,
|
63 |
autoOpen: false,
|
64 |
buttons: {
|
65 |
'Add': function() {
|
66 |
console.log($("#add_port_form").serialize());
|
67 |
$.ajax({
|
68 |
url:"{% url add-port %}",
|
69 |
data:$("#add_port_form").serialize(),
|
70 |
type: "POST",
|
71 |
cache: false,
|
72 |
success:function(data){
|
73 |
try {
|
74 |
value = data.value;
|
75 |
text = data.text;
|
76 |
$('#id_port').append($("<option></option>").attr("value",value).text(text));
|
77 |
$('#id_destinationport').append($("<option></option>").attr("value",value).text(text));
|
78 |
$('#id_sourceport').append($("<option></option>").attr("value",value).text(text));
|
79 |
$('#port_diag').dialog('close');
|
80 |
}
|
81 |
catch (exception) {
|
82 |
$('#port_diag').html(data);
|
83 |
}
|
84 |
}
|
85 |
});
|
86 |
},
|
87 |
Cancel: function() {
|
88 |
$('#port_diag').dialog('close');
|
89 |
}
|
90 |
}
|
91 |
});
|
92 |
|
93 |
|
94 |
$("#new_then_actions").button({
|
95 |
icons: {
|
96 |
primary: "ui-icon-plusthick"
|
97 |
},
|
98 |
})
|
99 |
.click(function(){
|
100 |
$.ajax({
|
101 |
url: "{% url add-rate-limit %}",
|
102 |
cache: false,
|
103 |
success: function(data){
|
104 |
$("#then_diag").html(data);
|
105 |
}
|
106 |
});
|
107 |
$('#then_diag').dialog('open');
|
108 |
return false;
|
109 |
});
|
110 |
|
111 |
|
112 |
$(".new_port").button({
|
113 |
icons: {
|
114 |
primary: "ui-icon-plusthick"
|
115 |
},
|
116 |
})
|
117 |
.click(function(){
|
118 |
$.ajax({
|
119 |
url: "{% url add-port %}",
|
120 |
cache: false,
|
121 |
success: function(data){
|
122 |
$("#port_diag").html(data);
|
123 |
}
|
124 |
});
|
125 |
$('#port_diag').dialog('open');
|
126 |
return false;
|
127 |
});
|
128 |
});
|
129 |
|
130 |
</script>
|
131 |
{% endblock %} |
132 |
{% block content %} |
133 |
<style type="text/css"> |
134 |
th { |
135 |
text-align: right; |
136 |
padding-right: 0.5em; |
137 |
vertical-align: top; |
138 |
} |
139 |
|
140 |
.help { |
141 |
font-style: italic; |
142 |
|
143 |
} |
144 |
</style>
|
145 |
<div align="center"> |
146 |
{% if edit %} |
147 |
<h3>{% trans "Edit rule" %}: {{form.data.name}}</h3> |
148 |
{% else %} |
149 |
<h3>{% trans "Apply for a new rule" %}</h3> |
150 |
{% endif %} |
151 |
<form method="POST"> |
152 |
{% csrf_token %} |
153 |
{% load unescape %} |
154 |
{% if form.non_field_errors %} |
155 |
<p class="error">{{ form.non_field_errors|unescape}}</p> |
156 |
{% endif %} |
157 |
|
158 |
<fieldset {% if %} style="display:none;" {% endif %}> |
159 |
<legend>{% trans "Rule Basic Info" %}</legend> |
160 |
<table>
|
161 |
<tr><th>{{ form.name.label_tag }}</th><td>{{ form.name }}<span class="error">{{ form.name.errors|join:", " }}</span></td></tr> |
162 |
<tr class="help"><td></td><td>A unique identifier will be added as a name_suffix</td></tr> |
163 |
</table>
|
164 |
</fieldset>
|
165 |
|
166 |
<fieldset>
|
167 |
<legend>{% trans "Rule Match Conditions" %}</legend> |
168 |
<table>
|
169 |
<input type="hidden" id="id_applier" name="applier" value="{{applier}}"/> |
170 |
<tr><th>{{ form.source.label_tag }}</th><td>{{ form.source }}<span class="error">{{ form.source.errors|join:", " }}</span></td></tr> |
171 |
<tr class="help"><td></td><td>{{ form.source.help_text }}</td></tr> |
172 |
<tr><th>{{ form.sourceport.label_tag }}</th><td>{{ form.sourceport }} <button class="new_port">Port</button><span class="error">{{ form.sourceport.errors|join:", " }}</span></td></tr> |
173 |
<tr class="help"><td></td><td>{{ form.sourceport.help_text }}</td></tr> |
174 |
<tr><th>{{ form.destination.label_tag }}</th><td>{{ form.destination }}<span class="error">{{ form.destination.errors|join:", " }}</span></td></tr> |
175 |
<tr class="help"><td></td><td>{{ form.destination.help_text }}</td></tr> |
176 |
<tr><th>{{ form.destinationport.label_tag }}</th><td>{{ form.destinationport }} <button class="new_port">Port</button><span class="error">{{ form.destinationport.errors|join:", " }}</span></td></tr> |
177 |
<tr class="help"><td></td><td>{{ form.destinationport.help_text }}</td></tr> |
178 |
<tr><th>{{ form.port.label_tag }}</th><td>{{ form.port }} <button class="new_port">Port</button><span class="error">{{ form.port.errors|join:", " }}</span></td></tr> |
179 |
<tr class="help"><td></td><td>{{ form.port.help_text }}</td></tr> |
180 |
</table>
|
181 |
</fieldset>
|
182 |
<fieldset>
|
183 |
<legend>{% trans "Rule Actions" %}</legend> |
184 |
<table>
|
185 |
<tr><th>{{ form.then.label_tag }}</th><td>{{ form.then }} <button id="new_then_actions">Rate-limit</button><span class="error">{{ form.then.errors|join:", " }}</span></td></tr> |
186 |
</table>
|
187 |
</fieldset>
|
188 |
<fieldset>
|
189 |
<legend>{% trans "Use/Comments" %}</legend> |
190 |
{% blocktrans %} |
191 |
<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> |
192 |
{% endblocktrans %} |
193 |
<p>{{ form.comments }}
|
194 |
{% if form.errors %}<br /><span class="error">{{ form.comments.errors|join:", " }}</span>{% endif %} |
195 |
</p>
|
196 |
</fieldset>
|
197 |
|
198 |
<p><input type="submit" value="{% trans "Apply" %}" /></p> |
199 |
</form>
|
200 |
</div>
|
201 |
|
202 |
<div id="then_diag" title="Add new rate-limit value"> |
203 |
</div>
|
204 |
|
205 |
<div id="port_diag" title="Add new port"> |
206 |
</div>
|
207 |
|
208 |
{% endblock %} |