]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Improve jobs monitor refresh interval
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 9 Jul 2015 05:49:25 +0000 (07:49 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 13 Aug 2015 06:51:50 +0000 (08:51 +0200)
gui/baculum/protected/Portlets/JobConfiguration.tpl
gui/baculum/protected/Portlets/TrayBar.tpl

index 1f9141a3a02d4b191a812d5d5677b3a6852e7626..2d0d73df8fe6bc59ab239b7911e517eeb96da80b 100644 (file)
                                <com:TActiveCustomValidator ID="PriorityValidator" ValidationGroup="JobGroup" ControlToValidate="Priority" ErrorMessage="<%[ Priority value must be integer greather than 0. ]%>" ControlCssClass="validation-error" Display="None" OnServerValidate="priorityValidator" />
                        </div>
                </div>
-               <com:TCallback ID="ReloadJobs" OnCallback="Page.JobWindow.prepareData" ClientSide.OnComplete="SlideWindow.getObj('JobWindow').setLoadRequest();" />
+               <com:TCallback ID="ReloadJobs" OnCallback="Page.JobWindow.prepareData" ClientSide.OnComplete="SlideWindow.getObj('JobWindow').setLoadRequest(); job_callback_duration = new Date().getTime();" />
                <script type="text/javascript">
+                       var job_callback_duration;
                        var job_callback_func = function() {
                                /*
                                 * Check if Job list window is open and if any checkbox from actions is not checked.
                        <com:TActiveLabel ID="CancelButton"><com:BActiveButton ID="Cancel" Text="<%[ Cancel job ]%>" CausesValidation="false" OnClick="cancel" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();" CssClass="bbutton" /> </com:TActiveLabel>
                        <com:BActiveButton ID="Run" Text="<%[ Run job again ]%>" ValidationGroup="JobGroup" CausesValidation="true" OnClick="run_again" ClientSide.OnSuccess="ConfigurationWindow.getObj('JobWindow').progress(false);job_callback_func();oMonitor();"/>
                </div>
-               <com:TCallback ID="RefreshStatus" OnCallback="status" ClientSide.OnComplete="status_callback_timeout = setTimeout('status_callback_func()', 10000);" />
+               <com:TCallback ID="RefreshStatus" OnCallback="status" ClientSide.OnComplete="job_callback_duration = new Date().getTime();" />
                <script type="text/javascript">
-                       var status_callback_timeout;
                        var status_prev = false;
                        var status_callback_func = function() {
-                               if(status_callback_timeout) {
-                                       clearTimeout(status_callback_timeout);
-                               }
                                if($('<%=$this->getID()%>configuration').visible() && ($('<%=$this->RefreshStart->ClientID%>').value === 'true' || status_prev === true)) {
                                        status_prev = ($('<%=$this->RefreshStart->ClientID%>').value === 'true');
                                        var callback = <%=$this->RefreshStatus->ActiveControl->Javascript%>;
-                                       oMonitor();
                                        callback.dispatch();
                                } else {
                                        status_prev = false;
index 7fedf0b50ea1e8cede29cefbcb6842cbd0354500..87e9174d3458a9ba6c5535cfedc2d4e26ef5a92d 100644 (file)
@@ -7,20 +7,29 @@
        var default_refresh_interval = 60000;
        var default_fast_refresh_interval = 10000;
        var timeout_handler;
+       var last_callback_time = 0;
+       var callback_time_offset = 0;
        document.observe("dom:loaded", function() {
                oMonitor = function() {
                        return new Ajax.Request('<%=$this->Service->constructUrl("Monitor")%>', {
+                               onCreate: function() {
+                                       if (job_callback_duration) {
+                                               callback_time_offset = job_callback_duration - last_callback_time;
+                                       }
+                                       last_callback_time = new Date().getTime();
+                               },
                                onSuccess: function(response) {
                                        if (timeout_handler) {
                                                clearTimeout(timeout_handler);
                                        }
                                        var jobs = (response.responseText).evalJSON();
                                        if (jobs.running_jobs.length > 0) {
-                                               refreshInterval = default_fast_refresh_interval;
+                                               refreshInterval =  callback_time_offset + default_fast_refresh_interval;
                                        } else {
                                                refreshInterval = default_refresh_interval;
                                        }
                                        job_callback_func();
+                                       status_callback_func();
                                        $('running_jobs').update(jobs.running_jobs.length);
                                        $('finished_jobs').update(jobs.terminated_jobs.length);
                                        timeout_handler = setTimeout("oMonitor()", refreshInterval);