Commit 0df9f5df by Bach Dániel

dashboard: add template search func

parent 47ecf19c
......@@ -215,6 +215,7 @@ $(function () {
register_search($("#dashboard-node-search-form"), $("#dashboard-node-list"), generateNodeHTML);
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);
/* notification message toggle */
$(document).on('click', ".notification-message-subject", function() {
......@@ -302,6 +303,16 @@ function generateUserHTML(data, is_last) {
'</a>';
}
function generateTemplateHTML(data, is_last) {
return '<a href="' + data.url + '" class="list-group-item real-link' + (is_last ? " list-group-item-last" : "") +'">'+
' <span class="index-template-list-name">' +
' <i class="fa fa-' + data.icon + '"></i> '+ safe_tags_replace(data.name) +
' </span>' +
' <small class="text-muted index-template-list-system">' + safe_tags_replace(data.system) + '</small>' +
' <div class="clearfix"></div>' +
'</a>';
}
function generateNodeHTML(data, is_last) {
return '<a href="' + data.url + '" class="list-group-item real-link' + (is_last ? ' list-group-item-last' : '') + '">' +
'<span class="index-node-list-name">' +
......
......@@ -33,7 +33,18 @@
{% endfor %}
</div>
<div class="list-group-item list-group-footer">
<div class="text-right">
<div class="row">
<div class="col-xs-6">
<form action="{% url "dashboard.views.template-list" %}" method="GET" id="dashboard-template-search-form">
<div class="input-group input-group-sm">
<input id="dashboard-group-search-input" name="s" type="text" class="form-control" placeholder="{% trans "Search..." %}" />
<div class="input-group-btn">
<button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
</div>
</div>
</form>
</div>
<div class="col-xs-6 text-right">
<a href="{% url "dashboard.views.template-list" %}" class="btn btn-primary btn-xs">
<i class="fa fa-chevron-circle-right"></i> {% trans "show all" %}
</a>
......@@ -43,4 +54,5 @@
</div>
</div>
</div>
</div>
</div>
......@@ -207,6 +207,18 @@ class TemplateList(LoginRequiredMixin, FilterMixin, SingleTableView):
def get(self, *args, **kwargs):
self.search_form = TemplateListSearchForm(self.request.GET)
self.search_form.full_clean()
if self.request.is_ajax():
templates = [{
'icon': i.os_type,
'system': i.system,
'url': reverse("dashboard.views.template-detail",
kwargs={'pk': i.pk}),
'name': i.name} for i in self.get_queryset()]
return HttpResponse(
json.dumps(templates),
content_type="application/json",
)
else:
return super(TemplateList, self).get(*args, **kwargs)
def create_acl_queryset(self, model):
......
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