Commit 877e65ec by Czémán Arnold

network, dashboard: add quick search to dashboard and fix vxlan template

parent 66659765
......@@ -223,6 +223,7 @@ $(function () {
register_search($("#dashboard-group-search-form"), $("#dashboard-group-list"), generateGroupHTML);
register_search($("#dashboard-user-search-form"), $("#dashboard-user-list"), generateUserHTML);
register_search($("#dashboard-template-search-form"), $("#dashboard-template-list"), generateTemplateHTML);
register_search($("#dashboard-vxlan-search-form"), $("#dashboard-vxlan-list"), generateVxlanHTML);
/* notification message toggle */
$(document).on('click', ".notification-message-subject", function() {
......@@ -331,6 +332,18 @@ function generateNodeHTML(data, is_last) {
'</a>';
}
function generateVxlanHTML(data, is_last) {
html = '<a href="' + data.url + '" class="list-group-item real-link' + (is_last ? ' list-group-item-last' : '') + '">' +
'<span class="index-vxlan-list-name">' +
'<i class="fa ' + data.icon + '" title="' + data.name + '"></i> ' + safe_tags_replace(data.name);
if(data.vni !== null && data.vni !== undefined)
html += ' <small class="text-muted"> vni: ' + data.vni + '</small>';
html += '</span>' +
'<div style="clear: both;"></div>' +
'</a>';
return html;
}
/* copare vm-s by fav, pk order */
function compareVmByFav(a, b) {
if(a.fav && b.fav) {
......
......@@ -8,12 +8,15 @@
</h3>
</div>
<div class="list-group" id="vxlan-list-view">
<div id="dashboard-user-list">
<div id="dashboard-vxlan-list">
{% for vxlan in vxlans %}
<a href="{% url "network.vxlan" vni=vxlan.vni %}" class="list-group-item
{% if forloop.last and vxlan|length < 5 %} list-group-item-last{% endif %}">
<span class="index-template-list-name">
<span class="index-vxlan-list-name">
<i class="fa fa-sitemap"></i> {{ vxlan.name }}
{% if user.is_superuser %}
<small class="text-muted"> vni: {{ vxlan.vni }} </small>
{% endif %}
</span>
</a>
{% endfor %}
......
......@@ -4,12 +4,12 @@
{% load l10n %}
{% load staticfiles %}
{% block title-page %}{% trans "Vlans" %}{% endblock %}
{% block title-page %}{% trans "Vxlans" %}{% endblock %}
{% block content %}
<div class="page-header">
<a href="{% url "network.vxlan-create" %}" class="btn btn-success pull-right"><i class="fa fa-plus-circle"></i> {% trans "Create a new vxlan" %}</a>
<h1>Vlans <small>{% trans "list of all vxlans" %}</small></h1>
<h1>Vxlans <small>{% trans "list of all vxlans" %}</small></h1>
</div>
<div class="table-responsive">
......
......@@ -922,6 +922,23 @@ class VxlanList(LoginRequiredMixin, SuperuserRequiredMixin, SingleTableView):
template_name = "network/vxlan-list.html"
table_pagination = False
def get(self, *args, **kwargs):
if self.request.is_ajax():
return self._create_ajax_request()
return super(VxlanList, self).get(*args, **kwargs)
def _create_ajax_request(self):
vxlans = Vxlan.get_objects_with_level(
'user', self.request.user)
vxlans = [{
'pk': i.pk,
'url': reverse_lazy('network.vxlan', args=[i.pk]),
'icon': 'fa-sitemap',
'name': i.name,
'vni': i.vni if self.request.user.is_superuser else None
} for i in vxlans]
return JsonResponse(list(vxlans), safe=False)
class VxlanAclUpdateView(AclUpdateView):
model = Vxlan
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment