Skip to content
Snippets Groups Projects
Commit e7c1bf6e authored by Benjamin Bertrand's avatar Benjamin Bertrand
Browse files

Clean networks view

No need to use ajax to retrieve the content of simple tables.

For Ansible groups, it takes some time to retrieve the data due to the
list of hosts for each group to compute. We keep the ajax request so
that the page is displayed quickly. We might switch to server side
processing (like for hosts).

JIRA INFRA-860
parent 780a8c1c
No related branches found
No related tags found
No related merge requests found
...@@ -507,7 +507,8 @@ def create_ansible_group(): ...@@ -507,7 +507,8 @@ def create_ansible_group():
@bp.route("/domains") @bp.route("/domains")
@login_required @login_required
def list_domains(): def list_domains():
return render_template("network/domains.html") domains = models.Domain.query.all()
return render_template("network/domains.html", domains=domains)
@bp.route("/domains/create", methods=("GET", "POST")) @bp.route("/domains/create", methods=("GET", "POST"))
...@@ -533,7 +534,8 @@ def create_domain(): ...@@ -533,7 +534,8 @@ def create_domain():
@bp.route("/scopes") @bp.route("/scopes")
@login_required @login_required
def list_scopes(): def list_scopes():
return render_template("network/scopes.html") scopes = models.NetworkScope.query.all()
return render_template("network/scopes.html", scopes=scopes)
@bp.route("/scopes/create", methods=("GET", "POST")) @bp.route("/scopes/create", methods=("GET", "POST"))
...@@ -703,30 +705,6 @@ def retrieve_ips(subnet, prefix): ...@@ -703,30 +705,6 @@ def retrieve_ips(subnet, prefix):
return jsonify(data=data) return jsonify(data=data)
@bp.route("/_retrieve_scopes")
@login_required
def retrieve_scopes():
data = [
(
scope.name,
scope.description,
scope.first_vlan,
scope.last_vlan,
scope.supernet,
str(scope.domain),
)
for scope in models.NetworkScope.query.all()
]
return jsonify(data=data)
@bp.route("/_retrieve_domains")
@login_required
def retrieve_domains():
data = [(domain.name,) for domain in models.Domain.query.all()]
return jsonify(data=data)
@bp.route("/_retrieve_groups") @bp.route("/_retrieve_groups")
@login_required @login_required
def retrieve_groups(): def retrieve_groups():
......
$(document).ready(function() { $(document).ready(function() {
var domains_table = $("#domains_table").DataTable({ var domains_table = $("#domains_table").DataTable({
"ajax": function(data, callback, settings) {
$.getJSON(
$SCRIPT_ROOT + "/network/_retrieve_domains",
function(json) {
callback(json);
});
},
"paging": false "paging": false
}); });
......
$(document).ready(function() { $(document).ready(function() {
var scopes_table = $("#scopes_table").DataTable({ var scopes_table = $("#scopes_table").DataTable({
"ajax": function(data, callback, settings) {
$.getJSON(
$SCRIPT_ROOT + "/network/_retrieve_scopes",
function(json) {
callback(json);
});
},
"paging": false "paging": false
}); });
......
...@@ -24,6 +24,13 @@ ...@@ -24,6 +24,13 @@
<th>Name</th> <th>Name</th>
</tr> </tr>
</thead> </thead>
<tbody>
{% for domain in domains %}
<tr>
<td>{{ domain.name }}</td>
</tr>
{% endfor %}
</tbody>
</table> </table>
{%- endblock %} {%- endblock %}
{%- endblock %} {%- endblock %}
......
...@@ -29,6 +29,18 @@ ...@@ -29,6 +29,18 @@
<th>Default domain</th> <th>Default domain</th>
</tr> </tr>
</thead> </thead>
<tbody>
{% for scope in scopes %}
<tr>
<td>{{ scope.name }}</td>
<td>{{ scope.description }}</td>
<td>{{ scope.first_vlan }}</td>
<td>{{ scope.last_vlan }}</td>
<td>{{ scope.supernet }}</td>
<td>{{ scope.domain }}</td>
</tr>
{% endfor %}
</tbody>
</table> </table>
{%- endblock %} {%- endblock %}
{%- endblock %} {%- endblock %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment