Commit 39b34734 by Kálmán Viktor

dashboard: don't show in progress icon in vm list for a long list

Too many SQL queries
parent e52cd2ff
...@@ -617,3 +617,11 @@ function noJS() { ...@@ -617,3 +617,11 @@ function noJS() {
$('.no-js-hidden').show(); $('.no-js-hidden').show();
$('.js-hidden').hide(); $('.js-hidden').hide();
} }
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
...@@ -163,7 +163,7 @@ $(function() { ...@@ -163,7 +163,7 @@ $(function() {
$(this).find('input[type="radio"]').prop("checked", true); $(this).find('input[type="radio"]').prop("checked", true);
}); });
if(checkStatusUpdate()) { if(checkStatusUpdate() || $("#vm-list-table tbody tr").length >= 100) {
updateStatuses(1); updateStatuses(1);
} }
...@@ -187,6 +187,7 @@ function checkStatusUpdate() { ...@@ -187,6 +187,7 @@ function checkStatusUpdate() {
function updateStatuses(runs) { function updateStatuses(runs) {
var include_deleted = getParameterByName("include_deleted");
$.get("/dashboard/vm/list/?compact", function(result) { $.get("/dashboard/vm/list/?compact", function(result) {
$("#vm-list-table tbody tr").each(function() { $("#vm-list-table tbody tr").each(function() {
vm = $(this).data("vm-pk"); vm = $(this).data("vm-pk");
...@@ -212,7 +213,8 @@ function updateStatuses(runs) { ...@@ -212,7 +213,8 @@ function updateStatuses(runs) {
$(this).find(".node").text(result[vm].node); $(this).find(".node").text(result[vm].node);
} }
} else { } else {
$(this).remove(); if(!include_deleted)
$(this).remove();
} }
}); });
......
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
<td class="name"><a class="real-link" href="{% url "dashboard.views.detail" i.pk %}">{{ i.name }}</a> </td> <td class="name"><a class="real-link" href="{% url "dashboard.views.detail" i.pk %}">{{ i.name }}</a> </td>
<td class="state"> <td class="state">
<i class="fa fa-fw <i class="fa fa-fw
{% if i.is_in_status_change %} {% if show_acts_in_progress and i.is_in_status_change %}
fa-spin fa-spinner fa-spin fa-spinner
{% else %} {% else %}
{{ i.get_status_icon }}{% endif %}"></i> {{ i.get_status_icon }}{% endif %}"></i>
......
...@@ -1792,6 +1792,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView): ...@@ -1792,6 +1792,7 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
else: else:
context['ops'].append(v) context['ops'].append(v)
context['search_form'] = self.search_form context['search_form'] = self.search_form
context['show_acts_in_progress'] = self.object_list.count() < 100
return context return context
def get(self, *args, **kwargs): def get(self, *args, **kwargs):
......
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