Commit 05dec61d by Kálmán Viktor

dashboard: search for deleted vms

parent f8bac858
...@@ -1174,7 +1174,12 @@ class VmListSearchForm(forms.Form): ...@@ -1174,7 +1174,12 @@ class VmListSearchForm(forms.Form):
})) }))
stype = forms.ChoiceField(vm_search_choices, widget=forms.Select(attrs={ stype = forms.ChoiceField(vm_search_choices, widget=forms.Select(attrs={
'class': "btn btn-default input-tags", 'class': "btn btn-default form-control input-tags",
'style': "min-width: 80px;",
}))
include_deleted = forms.BooleanField(widget=forms.CheckboxInput(attrs={
'id': "vm-list-search-checkbox",
})) }))
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
......
...@@ -940,3 +940,9 @@ textarea[name="list-new-namelist"] { ...@@ -940,3 +940,9 @@ textarea[name="list-new-namelist"] {
#vm-list-search, #vm-mass-ops { #vm-list-search, #vm-mass-ops {
margin-top: 8px; margin-top: 8px;
} }
#vm-list-search-checkbox {
margin-top: -1px;
display: inline-block;
vertical-align: middle;
}
...@@ -166,6 +166,15 @@ $(function() { ...@@ -166,6 +166,15 @@ $(function() {
if(checkStatusUpdate()) { if(checkStatusUpdate()) {
updateStatuses(1); updateStatuses(1);
} }
$("#vm-list-search-checkbox-span").css("cursor", "pointer");
$("#vm-list-search-checkbox-span").click(function(e) {
if(e.target.type === "checkbox") return;
var checkbox = $(this).find("input");
checkbox.prop("checked", !checkbox.prop("checked"));
return false;
});
}); });
......
...@@ -33,6 +33,12 @@ ...@@ -33,6 +33,12 @@
{{ search_form.s }} {{ search_form.s }}
<div class="input-group-btn"> <div class="input-group-btn">
{{ search_form.stype }} {{ search_form.stype }}
</div>
<span class="input-group-addon input-tags" title="{% trans "Include deleted VMs" %}"
id="vm-list-search-checkbox-span" data-container="body">
{{ search_form.include_deleted }}
</span>
<div class="input-group-btn">
<button type="submit" class="btn btn-primary input-tags"> <button type="submit" class="btn btn-primary input-tags">
<i class="fa fa-search"></i> <i class="fa fa-search"></i>
</button> </button>
......
...@@ -1835,10 +1835,16 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView): ...@@ -1835,10 +1835,16 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
content_type="application/json", content_type="application/json",
) )
def create_acl_queryset(self, model):
queryset = super(VmList, self).create_acl_queryset(model)
if not self.search_form.cleaned_data.get("include_deleted"):
queryset = queryset.filter(destroyed_at=None)
return queryset
def get_queryset(self): def get_queryset(self):
logger.debug('VmList.get_queryset() called. User: %s', logger.debug('VmList.get_queryset() called. User: %s',
unicode(self.request.user)) unicode(self.request.user))
queryset = self.create_acl_queryset(Instance).filter(destroyed_at=None) queryset = self.create_acl_queryset(Instance)
self.create_fake_get() self.create_fake_get()
sort = self.request.GET.get("sort") sort = self.request.GET.get("sort")
......
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