From f5c2e027eb8bed9baf04ee5c46573d87462974a7 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Fri, 10 Nov 2017 18:53:01 +0100 Subject: [PATCH] baculum: Improve slow reloading config resource list --- .../protected/Web/JavaScript/bacula-config.js | 28 +++++++++++++++---- .../Web/Portlets/BaculaConfigComponents.tpl | 2 +- .../Web/Portlets/BaculaConfigDirectives.php | 5 ++++ .../Web/Portlets/BaculaConfigDirectives.tpl | 8 ++++++ 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/gui/baculum/protected/Web/JavaScript/bacula-config.js b/gui/baculum/protected/Web/JavaScript/bacula-config.js index 23a7526cbc..3ee0c2a97a 100644 --- a/gui/baculum/protected/Web/JavaScript/bacula-config.js +++ b/gui/baculum/protected/Web/JavaScript/bacula-config.js @@ -1,16 +1,19 @@ var BaculaConfigClass = jQuery.klass({ - show_item: function(element, show) { + show_item: function(element, show, after_finish) { var el = $(element); var duration; if (show === true && el.is(':visible') === false) { - el.slideDown({duration: 400}); + el.slideDown({duration: 400, complete: after_finish}); } else if (show === false && el.is(':visible') === true) { - el.slideUp({duration: 500}); + el.slideUp({duration: 500, complete: after_finish}); } }, - show_items: function(selector, show) { + show_items: function(selector, show, callback) { $(selector).each(function(index, el) { - this.show_item(el, show); + var cb = function() { + callback(el); + } + this.show_item(el, show, cb); }.bind(this)); }, show_new_config: function(sender, component_type, component_name, resource_type) { @@ -45,7 +48,20 @@ var BaculaConfigClass = jQuery.klass({ unset_config_items: function(id) { var child_container = this.get_child_container(id); var selector = [child_container[0].nodeName.toLowerCase(), child_container[0].className].join('.'); - this.show_items(selector, false); + var callback = function(el) { + if (el.style.display === 'none' && !el.classList.contains('new_resource')) { + // element closed + var divs = el.getElementsByTagName('DIV'); + if (divs.length > 0) { + var fc = divs[0]; + // clear by removing elements + while (fc.firstChild) { + fc.removeChild(fc.firstChild); + } + } + } + } + this.show_items(selector, false, callback); /** * Send request about items only if items are invisible to avoid * asking about items when they are visible already. diff --git a/gui/baculum/protected/Web/Portlets/BaculaConfigComponents.tpl b/gui/baculum/protected/Web/Portlets/BaculaConfigComponents.tpl index 469403b121..a3f1324722 100644 --- a/gui/baculum/protected/Web/Portlets/BaculaConfigComponents.tpl +++ b/gui/baculum/protected/Web/Portlets/BaculaConfigComponents.tpl @@ -27,7 +27,7 @@ -