From: Marcin Haba Date: Sun, 20 Dec 2015 09:20:05 +0000 (+0100) Subject: baculum: Switch to started job status just after job start X-Git-Tag: Release-7.4.0~102 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8faea865adb1673896788a780d2472ab2e7e2cf7;p=bacula%2Fbacula baculum: Switch to started job status just after job start --- diff --git a/gui/baculum/protected/Class/Miscellaneous.php b/gui/baculum/protected/Class/Miscellaneous.php index 58fd5d6a50..f1e33a03be 100644 --- a/gui/baculum/protected/Class/Miscellaneous.php +++ b/gui/baculum/protected/Class/Miscellaneous.php @@ -241,5 +241,17 @@ class Miscellaneous extends TModule { } return $elements; } + + public function findJobIdStartedJob($output) { + $jobid = null; + $output = array_reverse($output); // jobid is ussually at the end of output + for ($i = 0; $i < count($output); $i++) { + if (preg_match('/^Job queued\.\sJobId=(?P\d+)$/', $output[$i], $match) === 1) { + $jobid = $match['jobid']; + break; + } + } + return $jobid; + } } ?> diff --git a/gui/baculum/protected/Lang/en/messages.mo b/gui/baculum/protected/Lang/en/messages.mo index 76f61215d8..14202632c6 100644 Binary files a/gui/baculum/protected/Lang/en/messages.mo and b/gui/baculum/protected/Lang/en/messages.mo differ diff --git a/gui/baculum/protected/Lang/en/messages.po b/gui/baculum/protected/Lang/en/messages.po index 3d956bc290..790af8a41f 100644 --- a/gui/baculum/protected/Lang/en/messages.po +++ b/gui/baculum/protected/Lang/en/messages.po @@ -1022,3 +1022,6 @@ msgstr "Job:" msgid "Media Type" msgstr "Media Type" +msgid "Go to started job after start:" +msgstr "Go to started job after start:" + diff --git a/gui/baculum/protected/Lang/pl/messages.mo b/gui/baculum/protected/Lang/pl/messages.mo index 8b5aa0da10..953bc6e95a 100644 Binary files a/gui/baculum/protected/Lang/pl/messages.mo and b/gui/baculum/protected/Lang/pl/messages.mo differ diff --git a/gui/baculum/protected/Lang/pl/messages.po b/gui/baculum/protected/Lang/pl/messages.po index a6dd6c206b..8292ffd2b8 100644 --- a/gui/baculum/protected/Lang/pl/messages.po +++ b/gui/baculum/protected/Lang/pl/messages.po @@ -1023,3 +1023,6 @@ msgstr "Zadanie:" msgid "Media Type" msgstr "Media Type" +msgid "Go to started job after start:" +msgstr "Przejdź do uruchomionego zadania po starcie:" + diff --git a/gui/baculum/protected/Pages/RestoreWizard.php b/gui/baculum/protected/Pages/RestoreWizard.php index 67e7ddcd44..cae5afce5f 100644 --- a/gui/baculum/protected/Pages/RestoreWizard.php +++ b/gui/baculum/protected/Pages/RestoreWizard.php @@ -426,7 +426,12 @@ class RestoreWizard extends BaculumPage $restoreProps['replace'] = $this->ReplaceFiles->SelectedValue; $ret = $this->getModule('api')->create(array('jobs', 'restore'), $restoreProps); - $this->goToDefaultPage(array('open' => 'Job')); + $jobid = $this->getModule('misc')->findJobIdStartedJob($ret->output); + $urlParams = array('open' => 'Job'); + if (is_numeric($jobid)) { + $urlParams['id'] = $jobid; + } + $this->goToDefaultPage($urlParams); } } ?> diff --git a/gui/baculum/protected/Portlets/JobConfiguration.php b/gui/baculum/protected/Portlets/JobConfiguration.php index ba3fddb6ec..1c5ffcb087 100644 --- a/gui/baculum/protected/Portlets/JobConfiguration.php +++ b/gui/baculum/protected/Portlets/JobConfiguration.php @@ -35,11 +35,17 @@ class JobConfiguration extends Portlets { public $verifyOptions = array('jobname' => 'Verify by Job Name', 'jobid' => 'Verify by JobId'); - public function configure($jobId) { + public function configure($jobId, $params = array()) { $jobdata = $this->Application->getModule('api')->get(array('jobs', $jobId))->output; $this->JobName->Text = $jobdata->job; $this->JobID->Text = $jobdata->jobid; $joblog = $this->Application->getModule('api')->get(array('joblog', $jobdata->jobid))->output; + $runningJobStates = $this->Application->getModule('misc')->getRunningJobStates(); + if (in_array($jobdata->jobstatus, $runningJobStates)) { + $this->Estimation->CssClass = 'textbox-auto wheel-loader'; + } else { + $this->Estimation->CssClass = 'textbox-auto'; + } $this->Estimation->Text = is_array($joblog) ? implode(PHP_EOL, $joblog) : Prado::localize("Output for selected job is not available yet or you do not have enabled logging job logs to catalog database. For watching job log there is need to add to the job Messages resource next directive: console = all, !skipped, !saved"); $this->Level->dataSource = $this->Application->getModule('misc')->getJobLevels(); @@ -86,11 +92,12 @@ class JobConfiguration extends Portlets { foreach($filesetsAll as $director => $filesets) { $filesetsList = array_merge($filesets, $filesetsList); } + $selectedFileset = ''; if($jobdata->filesetid != 0) { - $selectedFileset = $this->Application->getModule('api')->get(array('filesets', $jobdata->filesetid), true)->output; + $selectedFileset = $this->Application->getModule('api')->get(array('filesets', $jobdata->filesetid), true)->output->fileset; } $this->FileSet->dataSource = array_combine($filesetsList, $filesetsList); - $this->FileSet->SelectedValue = @$selectedFileset->fileset; + $this->FileSet->SelectedValue = array_key_exists('fileset', $params) ? $params['fileset'] : $selectedFileset; $this->FileSet->dataBind(); $pools = $this->Application->getModule('api')->get(array('pools'), true)->output; @@ -99,7 +106,7 @@ class JobConfiguration extends Portlets { $poolList[$pool->poolid] = $pool->name; } $this->Pool->dataSource = $poolList; - $this->Pool->SelectedValue = $jobdata->poolid; + $this->Pool->SelectedValue = array_key_exists('poolid', $params) ? $params['poolid'] : $jobdata->poolid; $this->Pool->dataBind(); $jobshow = $this->Application->getModule('api')->get(array('jobs', 'show', $jobdata->jobid), true)->output; @@ -120,24 +127,27 @@ class JobConfiguration extends Portlets { $this->Storage->dataBind(); $runningJobStates = $this->Application->getModule('misc')->getRunningJobStates(); + $isJobRunning = in_array($jobdata->jobstatus, $runningJobStates); $this->Priority->Text = ($jobdata->priorjobid == 0) ? self::DEFAULT_JOB_PRIORITY : $jobdata->priorjobid; $this->DeleteButton->Visible = true; - $this->CancelButton->Visible = $this->RefreshStart->Value = in_array($jobdata->jobstatus, $runningJobStates); + $this->CancelButton->Visible = $isJobRunning; + $this->RefreshStart->Value = $isJobRunning; $this->Run->Display = 'Dynamic'; $this->EstimateLine->Display = 'Dynamic'; $this->Status->Visible = true; } public function status($sender, $param) { - $refreshStart = false; - for ($i = 0; $i < count($_SESSION['monitor_data']['running_jobs']); $i++) { - if ($_SESSION['monitor_data']['running_jobs'][$i]->jobid == $this->JobID->Text) { - $refreshStart = true; - break; - } + $jobdata = $this->Application->getModule('api')->get(array('jobs', $this->JobID->Text))->output; + $runningJobStates = $this->Application->getModule('misc')->getRunningJobStates(); + if (in_array($jobdata->jobstatus, $runningJobStates)) { + $this->RefreshStart->Value = true; + } else { + $this->RefreshStart->Value = false; + $this->CancelButton->Visible = false; + $this->Estimation->CssClass = 'textbox-auto'; } - $this->RefreshStart->Value = $refreshStart; $joblog = $this->Application->getModule('api')->get(array('joblog', $this->JobID->Text))->output; $this->Estimation->Text = is_array($joblog) ? implode(PHP_EOL, $joblog) : Prado::localize("Output for selected job is not available yet or you do not have enabled logging job logs to catalog database. For watching job log there is need to add to the job Messages resource next directive: console = all, !skipped, !saved"); @@ -149,12 +159,14 @@ class JobConfiguration extends Portlets { $this->Run->Display = 'None'; $this->DeleteButton->Visible = false; $this->EstimateLine->Display = 'None'; + $this->Estimation->CssClass = 'textbox-auto'; } public function cancel($sender, $param) { $this->Application->getModule('api')->set(array('jobs', 'cancel', $this->JobID->Text), array('a' => 'b')); $this->CancelButton->Visible = false; $this->status(null, null); + $this->Estimation->CssClass = 'textbox-auto'; } public function run_again($sender, $param) { @@ -193,7 +205,11 @@ class JobConfiguration extends Portlets { } } $result = $this->Application->getModule('api')->create(array('jobs', 'run'), $params)->output; - if (!is_null($sender) || !is_numeric($param)) { + $startedJobId = $this->Application->getModule('misc')->findJobIdStartedJob($result); + if (is_numeric($startedJobId)) { + $params['jobid'] = $startedJobId; + $this->configure($startedJobId, $params); + } else { $this->Estimation->Text = implode(PHP_EOL, $result); } } diff --git a/gui/baculum/protected/Portlets/JobConfiguration.tpl b/gui/baculum/protected/Portlets/JobConfiguration.tpl index cdf4fa841e..5afc5dc7c4 100644 --- a/gui/baculum/protected/Portlets/JobConfiguration.tpl +++ b/gui/baculum/protected/Portlets/JobConfiguration.tpl @@ -174,9 +174,10 @@ + ConfigurationWindow.getObj('JobWindow').switchTab('job_console_tab'); ConfigurationWindow.getObj('JobWindow').progress(false); - job_callback_func(); oMonitor(); + job_callback_func(); diff --git a/gui/baculum/protected/Portlets/JobList.tpl b/gui/baculum/protected/Portlets/JobList.tpl index 66956b43d4..e79d97f9ff 100644 --- a/gui/baculum/protected/Portlets/JobList.tpl +++ b/gui/baculum/protected/Portlets/JobList.tpl @@ -78,6 +78,7 @@ + ConfigurationWindow.getObj('JobWindow').progress(true); var img_btn = $('run_job_again_btn'); var img_src_path = img_btn.readAttribute('src').replace(/[^\/]+\S$/, ''); img_btn.writeAttribute('disabled', 'disabled'); @@ -88,6 +89,9 @@ var img_src_path = img_btn.readAttribute('src').replace(/[^\/]+\S$/, ''); img_btn.writeAttribute('src', img_src_path + 'play.png'); img_btn.removeAttribute('disabled'); + ConfigurationWindow.getObj('JobWindow').progress(false); + ConfigurationWindow.getObj('JobWindow').show(); + ConfigurationWindow.getObj('JobWindow').switchTabByNo(2); status_callback_func(); oMonitor(); diff --git a/gui/baculum/protected/Portlets/JobRunConfiguration.php b/gui/baculum/protected/Portlets/JobRunConfiguration.php index f56e3eef4c..cef6b799d4 100644 --- a/gui/baculum/protected/Portlets/JobRunConfiguration.php +++ b/gui/baculum/protected/Portlets/JobRunConfiguration.php @@ -152,7 +152,14 @@ class JobRunConfiguration extends Portlets { } $result = $this->Application->getModule('api')->create(array('jobs', 'run'), $params)->output; - $this->Estimation->Text = implode(PHP_EOL, $result); + + $startedJobId = $this->Application->getModule('misc')->findJobIdStartedJob($result); + if ($this->GoToStartedJob->Checked === true && is_numeric($startedJobId)) { + $params['jobid'] = $startedJobId; + $this->getPage()->JobConfiguration->configure($startedJobId, $params); + } else { + $this->Estimation->Text = implode(PHP_EOL, $result); + } } public function estimate($sender, $param) { diff --git a/gui/baculum/protected/Portlets/JobRunConfiguration.tpl b/gui/baculum/protected/Portlets/JobRunConfiguration.tpl index 01c86e3e41..c3d03305f3 100644 --- a/gui/baculum/protected/Portlets/JobRunConfiguration.tpl +++ b/gui/baculum/protected/Portlets/JobRunConfiguration.tpl @@ -118,7 +118,11 @@
- +
+
+
+
+