]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Use in run job window estimate command in background to avoid HTTP timeout
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 14 May 2019 17:18:36 +0000 (19:18 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 14 Dec 2019 14:50:01 +0000 (15:50 +0100)
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Portlets/RunJob.php
gui/baculum/protected/Web/Portlets/RunJob.tpl

index d686e73856270cf26b3c012e64870a1922827aca..1b34e4db7a98150ccf28ecb5cbff6f0a33a1e3c2 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index 53456a7a63744891af98b98a0015ecfe040256b1..c58f91c8e289b62e1ee8e866dcb4adf97f3459d3 100644 (file)
@@ -2056,3 +2056,9 @@ msgstr "Selected directory cannot be restored. Usually it means that the directo
 
 msgid "Please select other path which is inside paths defined in FileSet."
 msgstr "Please select other path which is inside paths defined in FileSet."
+
+msgid "Command status:"
+msgstr "Command status:"
+
+msgid "Ready"
+msgstr "Ready"
index fb618b1947fdfe8859f529a24add87e83c479369..91db7e811c31d9343c8f32f87e244818970c73d0 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index 287d1f0908e5db8894ef25cc8f7a9d2fe852b457..6964cafbfb5051400e1c07f71360e64516c2a24e 100644 (file)
@@ -2157,3 +2157,9 @@ msgstr "Selected directory cannot be restored. Usually it means that the directo
 
 msgid "Please select other path which is inside paths defined in FileSet."
 msgstr "Please select other path which is inside paths defined in FileSet."
+
+msgid "Command status:"
+msgstr "Command status:"
+
+msgid "Ready"
+msgstr "Ready"
index 526be49919e9c2de286e08116a63ddfce79c4e02..87ef7ceaf2265ee84fc217e3721dadbb427eaa3f 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index 6b3b051571ac5ba941a338a00a24d2edab7f31e5..9aa65be8be1abc070fcbbbec20ce3ad5300b0293 100644 (file)
@@ -2063,3 +2063,9 @@ msgstr "Wybrany katalog nie może być przywrócony. Zazwyczaj oznacza to, że l
 
 msgid "Please select other path which is inside paths defined in FileSet."
 msgstr "Proszę wybrać inną ścieżkę, która jest wewnątrz ścieżek zdefiniowanych w zasobie FileSet."
+
+msgid "Command status:"
+msgstr "Status komendy:"
+
+msgid "Ready"
+msgstr "Gotowy"
index c4d62d1e76f65d71ceceb2a8a026b497720d1890..a974968ce2f73b796fd0c8ad65f270464973582f 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index 3510db34fa7bb16415652215a7d15757ded54f9b..3d3c8cb4c4d29795aac64de6c1fb61d329728358 100644 (file)
@@ -2071,3 +2071,9 @@ msgstr "Selected directory cannot be restored. Usually it means that the directo
 
 msgid "Please select other path which is inside paths defined in FileSet."
 msgstr "Please select other path which is inside paths defined in FileSet."
+
+msgid "Command status:"
+msgstr "Command status:"
+
+msgid "Ready"
+msgstr "Ready"
index 3457f6f2cdff45750e325d9ee5551c2c2eb17e55..94ef64c76122fd0cfca7e8c37045849adb327890 100644 (file)
@@ -302,14 +302,54 @@ class RunJob extends Portlets {
                $params['clientid'] = $this->Client->SelectedValue;
                $params['accurate'] = (integer)$this->Accurate->Checked;
                $result = $this->getModule('api')->create(array('jobs', 'estimate'), $params);
+               if ($result->error === 0 && count($result->output) == 1) {
+                       $out = json_decode($result->output[0]);
+                       if (is_object($out) && property_exists($out, 'out_id')) {
+                               $result = $this->getEstimateOutput($out->out_id);
+                               $this->getPage()->getCallbackClient()->callClientFunction(
+                                       'estimate_output_refresh',
+                                       array($out->out_id)
+                               );
+                       }
+               }
+
                if ($result->error === 0) {
-                       $this->EstimationLog->Text = implode(PHP_EOL, $result->output);
+                       $this->getPage()->getCallbackClient()->callClientFunction('set_loading_status', array('loading'));
+                       $this->EstimationLog->Text = implode($result->output);
                } else {
                        $this->EstimationLog->Text = $result->output;
                }
        }
 
-       public function run_again($sender, $param) {
+       public function getEstimateOutput($out_id) {
+               $result = $this->getModule('api')->get(
+                       array('jobs', 'estimate', '?out_id=' . rawurlencode($out_id))
+               );
+               return $result;
+       }
+
+       public function refreshEstimateOutput($sender, $param) {
+               $out_id = $param->getCallbackParameter();
+               $result = $this->getEstimateOutput($out_id);
+
+               if ($result->error === 0) {
+                       if (count($result->output) > 0) {
+                               $this->EstimationLog->Text = implode($result->output);
+                               $this->getPage()->getCallbackClient()->callClientFunction(
+                                       'estimate_output_refresh',
+                                       array($out_id)
+                               );
+                       } else {
+                               $this->getPage()->getCallbackClient()->callClientFunction(
+                                       'set_loading_status',
+                                       array('finish')
+                               );
+                       }
+               } else {
+                       $this->EstimationLog->Text = $result->output;
+               }
+       }
+       public function runJobAgain($sender, $param) {
                $jobid = $this->getJobId();
                $job_name = $this->getJobName();
                if ($jobid > 0) {
index 711b4ea3ee62d848240ddbfeaaba199bb6840fd0..0f8ac62a4f7b5632facddbd17c15b510b62820f3 100644 (file)
@@ -1,7 +1,7 @@
 <div id="run_job" class="w3-modal">
        <div class="w3-modal-content w3-animate-top w3-card-4">
                <header class="w3-container w3-teal"> 
-                       <span onclick="document.getElementById('run_job').style.display='none'" class="w3-button w3-display-topright">&times;</span>
+                       <span onclick="close_run_job_window();" class="w3-button w3-display-topright">&times;</span>
                        <h2><%[ Run job ]%><%=$this->getJobName() ? ' - ' . $this->getJobName() : ''%></h2>
                </header>
                <div class="w3-container w3-margin-left w3-margin-right">
                                <div class="field"><com:TActiveCheckBox ID="Accurate" AutoPostBack="false" CssClass="w3-check" /></div>
                        </com:TActivePanel>
                </div>
+               <div class="w3-row-padding w3-section">
+                       <div class="w3-col w3-half"><%[ Command status: ]%></div>
+                       <div class="w3-col w3-half">
+                               <i id="command_status_start" class="fa fa-step-forward" title="<%[ Ready ]%>"></i>
+                               <i id="command_status_loading" class="fa fa-sync w3-spin" style="display: none" title="<%[ Loading... ]%>"></i>
+                               <i id="command_status_finish" class="fa fa-check" style="display: none" title="<%[ Finished ]%>"></i>
+                       </div>
+               </div>
                <div id="run_job_log" class="w3-panel w3-card w3-light-grey" style="display: none; max-height: 200px; overflow-x: auto;">
                        <div class="w3-code notranslate">
                                <pre><com:TActiveLabel ID="EstimationLog" /></pre>
                        </div>
                </div>
                <footer class="w3-container w3-center">
-                       <i id="estimate_status" class="fa fa-sync w3-spin" style="display: none"></i> &nbsp;
                        <com:TActiveButton
                                ID="Estimate"
                                Text="<%[ Estimate job ]%>"
                                CssClass="w3-button w3-section w3-teal w3-padding"
                        >
                                <prop:ClientSide.OnLoading>
-                                       document.getElementById('estimate_status').style.display = '';
+                                       document.getElementById('status_command_loading').style.visibility = 'visible';
                                </prop:ClientSide.OnLoading>
                                <prop:ClientSide.OnComplete>
-                                       document.getElementById('estimate_status').style.display = 'none';
+                                       $('#status_update_slots_loading').css('visibility', 'hidden');
+                                       document.getElementById('status_command_loading').style.visibility = 'hidden';
                                        document.getElementById('run_job_log').style.display = '';
+                                       var logbox = document.getElementById('run_job_log');
+                                       logbox.scrollTo(0, logbox.scrollHeight);
                                </prop:ClientSide.OnComplete>
                        </com:TActiveButton>
                        <com:TButton
                                Text="<%[ Run job ]%>"
                                ValidationGroup="JobGroup"
                                CausesValidation="true"
-                               OnClick="run_again"
+                               OnClick="runJobAgain"
                                CssClass="w3-button w3-section w3-teal w3-padding"
                        >
                                <prop:Attributes.onclick>
                                        return send;
                                </prop:Attributes.onclick>
                        </com:TButton>
+                       <i id="status_command_loading" class="fa fa-sync w3-spin" style="visibility: hidden;"></i>
                </footer>
        </div>
 </div>
+<com:TCallback ID="EstimateOutputRefresh"
+       OnCallback="refreshEstimateOutput"
+>
+       <prop:ClientSide.OnLoading>
+               $('#status_command_loading').css('visibility', 'visible');
+               var logbox = document.getElementById('run_job_log');
+               if ((logbox.offsetHeight + logbox.scrollTop) === logbox.scrollHeight) {
+                       command_logbox_scroll = true;
+               } else {
+                       command_logbox_scroll = false;
+               }
+       </prop:ClientSide.OnLoading>
+       <prop:ClientSide.OnComplete>
+               $('#status_command_loading').css('visibility', 'hidden');
+               if (command_logbox_scroll) {
+                       var logbox = document.getElementById('run_job_log');
+                       logbox.scrollTo(0, logbox.scrollHeight);
+               }
+       </prop:ClientSide.OnComplete>
+</com:TCallback>
+<script type="text/javascript">
+var command_logbox_scroll = false;
+function close_run_job_window() {
+       document.getElementById('run_job').style.display = 'none';
+       var joblog = document.getElementById('<%=$this->EstimationLog->ClientID%>');
+       joblog.innerHTML = '';
+       joblog.style.display = 'none';
+       set_loading_status('start');
+}
+function set_loading_status(status) {
+       var start = document.getElementById('command_status_start');
+       var loading = document.getElementById('command_status_loading');
+       var finish = document.getElementById('command_status_finish');
+       if (status === 'finish') {
+               start.style.display = 'none';
+               loading.style.display = 'none';
+               finish.style.display = '';
+       } else if (status === 'loading') {
+               start.style.display = 'none';
+               loading.style.display = '';
+               finish.style.display = 'none';
+       } else if (status === 'start') {
+               start.style.display = '';
+               loading.style.display = 'none';
+               finish.style.display = 'none';
+       }
+}
+function estimate_output_refresh(out_id) {
+       setTimeout(function() {
+               set_estimate_output(out_id)
+       }, 3000);
+}
+function set_estimate_output(out_id) {
+       var cb = <%=$this->EstimateOutputRefresh->ActiveControl->Javascript%>;
+       cb.setCallbackParameter(out_id);
+       cb.dispatch();
+}
+</script>