From: Marcin Haba Date: Tue, 14 May 2019 17:18:36 +0000 (+0200) Subject: baculum: Use in run job window estimate command in background to avoid HTTP timeout X-Git-Tag: Release-9.6.0~228 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=63445f9302fbea6aa1ef3538417596830ed53320;p=thirdparty%2Fbacula.git baculum: Use in run job window estimate command in background to avoid HTTP timeout --- diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index d686e73856..1b34e4db7a 100644 Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/en/messages.po b/gui/baculum/protected/Web/Lang/en/messages.po index 53456a7a63..c58f91c8e2 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -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" diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index fb618b1947..91db7e811c 100644 Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/ja/messages.po b/gui/baculum/protected/Web/Lang/ja/messages.po index 287d1f0908..6964cafbfb 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -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" diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index 526be49919..87ef7ceaf2 100644 Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pl/messages.po b/gui/baculum/protected/Web/Lang/pl/messages.po index 6b3b051571..9aa65be8be 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -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" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index c4d62d1e76..a974968ce2 100644 Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Web/Lang/pt/messages.po b/gui/baculum/protected/Web/Lang/pt/messages.po index 3510db34fa..3d3c8cb4c4 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -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" diff --git a/gui/baculum/protected/Web/Portlets/RunJob.php b/gui/baculum/protected/Web/Portlets/RunJob.php index 3457f6f2cd..94ef64c761 100644 --- a/gui/baculum/protected/Web/Portlets/RunJob.php +++ b/gui/baculum/protected/Web/Portlets/RunJob.php @@ -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) { diff --git a/gui/baculum/protected/Web/Portlets/RunJob.tpl b/gui/baculum/protected/Web/Portlets/RunJob.tpl index 711b4ea3ee..0f8ac62a4f 100644 --- a/gui/baculum/protected/Web/Portlets/RunJob.tpl +++ b/gui/baculum/protected/Web/Portlets/RunJob.tpl @@ -1,7 +1,7 @@
- × + ×

<%[ Run job ]%><%=$this->getJobName() ? ' - ' . $this->getJobName() : ''%>

@@ -121,13 +121,20 @@
+
+
<%[ Command status: ]%>
+
+ + + +
+
-   - document.getElementById('estimate_status').style.display = ''; + document.getElementById('status_command_loading').style.visibility = 'visible'; - 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); @@ -159,6 +169,65 @@ return send; +
+ + + $('#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; + } + + + $('#status_command_loading').css('visibility', 'hidden'); + if (command_logbox_scroll) { + var logbox = document.getElementById('run_job_log'); + logbox.scrollTo(0, logbox.scrollHeight); + } + + +