Commit d2e95303 by Kálmán Viktor

dashboard: fix dashboard search

parent 0a6762e9
...@@ -154,25 +154,29 @@ $(function () { ...@@ -154,25 +154,29 @@ $(function () {
addSliderMiscs(); addSliderMiscs();
/* search */ /* search */
function register_search(form, list, generateHTML) { function register_search(form, list, generateHTML) {
var my_vms = []; var my_vms = [];
var search_in_progress = false; /* 0 - default state
* 1 - ajax request sent
* 2 - ajax request received, we have our list of vms
*/
var search_state = 0;
form.find('input').keyup(function(e) { form.find('input').keyup(function(e) {
if (search_in_progress) { if (search_state == 1) {
return; return;
} }
// if my_vms is empty get a list of our vms // if my_vms is empty get a list of our vms
if(my_vms.length < 1) { if(search_state === 0) {
search_in_progress = true; search_state = 1;
var btn = form.find('button'); var btn = form.find('button');
btn.find('i').addClass("fa-spinner fa-spin"); btn.find('i').addClass("fa-spinner fa-spin");
$.get(form.prop('action'), function(result) { $.get(form.prop('action'), function(result) {
search_in_progress = false; search_state = 3;
my_vms = result; my_vms = result;
$(this).trigger("keyup"); form.find("input").trigger("keyup");
btn.find('i').removeClass("fa-spinner fa-spin").addClass("fa-search"); btn.find('i').removeClass("fa-spinner fa-spin").addClass("fa-search");
}); });
return; return;
......
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