Statistics
| Branch: | Tag: | Revision:

root / templates / apply.html @ 97e42c7d

History | View | Annotate | Download (5.9 kB)

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

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

    
12
{% block breadcrumbs %}:: 
13
        {% if edit %}
14
                {% trans "Edit route" %} {{form.data.name}}
15
        {% else %}
16
        {% trans "Create route" %}
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 route" %}: {{form.data.name}}</h3>
148
        {% else %}
149
<h3>{% trans "Apply for a new route" %}</h3>
150
{% endif %}
151
<form method="POST">
152
{% csrf_token %}
153
{% if form.non_field_errors %}
154
<p class="error">{{ form.non_field_errors|join:", "}}</p>
155
{% endif %}
156

    
157
<fieldset {% if  %} style="display:none;" {% endif %}>
158
        <legend>{% trans "Route Basic Info" %}</legend>
159
<table>
160
<tr><th>{{ form.name.label_tag }}</th><td>{{ form.name }}<span class="error">{{ form.name.errors|join:", " }}</span></td></tr>
161
<tr class="help"><td></td><td>A unique identifier will be added as a name_suffix</td></tr>
162
</table>
163
</fieldset>
164

    
165
<fieldset>
166
<legend>{% trans "Route Match Conditions" %}</legend>
167
<table>
168
<input type="hidden" id="id_applier" name="applier" value="{{applier}}"/>
169
<tr><th>{{ form.source.label_tag }}</th><td>{{ form.source }}<span class="error">{{ form.source.errors|join:", " }}</span></td></tr>
170
<tr class="help"><td></td><td>{{ form.source.help_text }}</td></tr>
171
<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>
172
<tr class="help"><td></td><td>{{ form.sourceport.help_text }}</td></tr>
173
<tr><th>{{ form.destination.label_tag }}</th><td>{{ form.destination }}<span class="error">{{ form.destination.errors|join:", " }}</span></td></tr>
174
<tr class="help"><td></td><td>{{ form.destination.help_text }}</td></tr>
175
<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>
176
<tr class="help"><td></td><td>{{ form.destinationport.help_text }}</td></tr>
177
<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>
178
<tr class="help"><td></td><td>{{ form.port.help_text }}</td></tr>
179
</table>
180
</fieldset>
181
<fieldset>
182
<legend>{% trans "Route Actions" %}</legend>
183
<table>
184
<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>
185
</table>
186
</fieldset>
187
<fieldset>
188
<legend>{% trans "Use/Comments" %}</legend>
189
{% blocktrans %}
190
<p>Give a short description of the intended use of this route, that justifies the parameter selection above. Feel free to include any additional comments.</p>
191
{% endblocktrans %}
192
<p>{{ form.comments }}
193
{% if form.errors %}<br /><span class="error">{{ form.comments.errors|join:", " }}</span>{% endif %}
194
</p>
195
</fieldset>
196

    
197
<p><input type="submit" value="{% trans "Apply" %}" /></p>
198
</form>
199
</div>
200

    
201
<div id="then_diag" title="Add new rate-limit value">
202
</div>
203

    
204
<div id="port_diag" title="Add new port">
205
</div>
206

    
207
{% endblock %}