]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Improve slow reloading config resource list
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 10 Nov 2017 17:53:01 +0000 (18:53 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Fri, 10 Nov 2017 17:53:01 +0000 (18:53 +0100)
gui/baculum/protected/Web/JavaScript/bacula-config.js
gui/baculum/protected/Web/Portlets/BaculaConfigComponents.tpl
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.tpl

index 23a7526cbc988a9eda55ab027d83f1d6764ba31e..3ee0c2a97aa984657fa9e3da116ed2d18ce321b3 100644 (file)
@@ -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.
index 469403b121075585bb17e13cc1653d48acfe8a37..a3f13247226c20eae8916e5b0cdafbc85a529457 100644 (file)
@@ -27,7 +27,7 @@
        </com:TActiveRepeater>
 </div>
        <com:TActiveLabel ID="ErrorMsg" Display="None" />
-<div class="config_directives" rel="<%=$this->getHost()%>new_resource" style="display: none">
+<div class="config_directives new_resource" rel="<%=$this->getHost()%>new_resource" style="display: none">
        <h2 rel="<%[ Add new %resource_type resource on %component_name (%component_type) ]%>"></h2>
        <hr />
        <com:Application.Web.Portlets.BaculaConfigDirectives ID="NewResource" LoadValues="<%=false%>" />
index befe637a22271b3debc6cd7fd5c75ce07ae04fa5..02fc3ec7321d704d4c7309d7f2837abc136019cf 100644 (file)
@@ -181,6 +181,11 @@ class BaculaConfigDirectives extends DirectiveListTemplate {
                $this->loadConfig();
        }
 
+       public function unloadDirectives() {
+               $this->RepeaterDirectives->DataSource = array();
+               $this->RepeaterDirectives->dataBind();
+       }
+
        public function createDirectiveElement($sender, $param) {
                $load_values = $this->getLoadValues();
                for ($i = 0; $i < count($this->directive_types); $i++) {
index 3c0c69f27803b0d85e26db3594123d568539d09e..d1ae5bf034fcff2eb6eced5aa2d3c48140f867d8 100644 (file)
                OnLoadDirectives="loadDirectives"
        />
        <div class="button center block">
+               <com:BActiveButton
+                       ID="Cancel"
+                       CssClass="bbutton"
+                       ActiveControl.EnableUpdate="false"
+                       OnCommand="TemplateControl.unloadDirectives"
+                       Text="<%[ Cancel ]%>"
+                       Attributes.onclick="$('div.config_directives').slideUp();"
+               />
                <com:BActiveButton
                        ID="Save"
                        ValidationGroup="Directive"