]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Switch to started job status just after job start
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 20 Dec 2015 09:20:05 +0000 (10:20 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sun, 20 Dec 2015 09:22:14 +0000 (10:22 +0100)
13 files changed:
gui/baculum/protected/Class/Miscellaneous.php
gui/baculum/protected/Lang/en/messages.mo
gui/baculum/protected/Lang/en/messages.po
gui/baculum/protected/Lang/pl/messages.mo
gui/baculum/protected/Lang/pl/messages.po
gui/baculum/protected/Pages/RestoreWizard.php
gui/baculum/protected/Portlets/JobConfiguration.php
gui/baculum/protected/Portlets/JobConfiguration.tpl
gui/baculum/protected/Portlets/JobList.tpl
gui/baculum/protected/Portlets/JobRunConfiguration.php
gui/baculum/protected/Portlets/JobRunConfiguration.tpl
gui/baculum/themes/Baculum-v1/style.css
gui/baculum/themes/Baculum-v1/wheel.gif [new file with mode: 0644]

index 58fd5d6a50b4475e1c0edf58991f8c6f5ba8642e..f1e33a03be2c07a6348615ffa50c296cbf364a3d 100644 (file)
@@ -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<jobid>\d+)$/', $output[$i], $match) === 1) {
+                               $jobid = $match['jobid'];
+                               break;
+                       }
+               }
+               return $jobid;
+       }
 }
 ?>
index 76f61215d83d3f375820247838f6420d33f0928d..14202632c6ef9dd69c127a1b5481ef74c382a50b 100644 (file)
Binary files a/gui/baculum/protected/Lang/en/messages.mo and b/gui/baculum/protected/Lang/en/messages.mo differ
index 3d956bc290c7e9ad2c3b7782300f794600753fd1..790af8a41f8f6130fd3e3df139a12aad032a576d 100644 (file)
@@ -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:"
+
index 8b5aa0da1072998851ad540a170459f7dd5b4b32..953bc6e95a16a4efa61f341f6e1eb895e721d993 100644 (file)
Binary files a/gui/baculum/protected/Lang/pl/messages.mo and b/gui/baculum/protected/Lang/pl/messages.mo differ
index a6dd6c206be0871230a4d3ed154f6a567f9c0dd0..8292ffd2b842e964402f313a4ac6c0054298c555 100644 (file)
@@ -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:"
+
index 67e7ddcd445785dda12cba588b1c2ed82d7568f5..cae5afce5ff312836e8f9c4ccd6d948a6ba6571b 100644 (file)
@@ -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);
        }
 }
 ?>
index ba3fddb6ec240de48b4c8f9ba415b5ea69d54bbe..1c5ffcb08712f469d45e6d3ae8298f196a814615 100644 (file)
@@ -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);
                }
        }
index cdf4fa841e5aa3eca26f73375efc8f41cfd1ef37..5afc5dc7c49d69fefa13f37582393386dd5a8618 100644 (file)
                                </com:TActivePanel>
                                <com:BActiveButton ID="Run" Text="<%[ Run job again ]%>" ValidationGroup="JobGroup" CausesValidation="true" OnClick="run_again">
                                        <prop:ClientSide.OnSuccess>
+                                               ConfigurationWindow.getObj('JobWindow').switchTab('job_console_tab');
                                                ConfigurationWindow.getObj('JobWindow').progress(false);
-                                               job_callback_func();
                                                oMonitor();
+                                               job_callback_func();
                                        </prop:ClientSide.OnSuccess>
                                </com:BActiveButton>
                        </div>
index 66956b43d4e18fa4aa5fe1ab46176892bb9cf6d9..e79d97f9ff214511b89c272d4a2b9cd413fd5829 100644 (file)
@@ -78,6 +78,7 @@
        </com:TCallback>
        <com:TCallback ID="RunJobCall" OnCallback="Page.JobWindow.run_again">
                <prop:ClientSide.OnLoading>
+                       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();
                </prop:ClientSide.OnComplete>
index f56e3eef4c807658cb61cda9e065ac30fe9b9ff6..cef6b799d451136c3e90ab511c7ffae5bdb119d0 100644 (file)
@@ -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) {
index 01c86e3e41808b6ab8f817d4fbfa78ff7f4940c3..c3d03305f31f0d7b31d3f1fac2f92d77a3ee2bf0 100644 (file)
                                <div class="text"><com:TLabel ForControl="Accurate" Text="<%[ Accurate: ]%>" /></div>
                                <div class="field"><com:TActiveCheckBox ID="Accurate" AutoPostBack="false" /></div>
                        </com:TPanel>
-                       <com:TCallback ID="ReloadRunJobs" OnCallback="Page.JobRunWindow.prepareData" ClientSide.OnComplete="RunSlideWindow.getObj('JobRunWindow').setLoadRequest();" />
+                       <div class="line">
+                               <div class="text"><com:TLabel ForControl="GoToStartedJob" Text="<%[ Go to started job after start: ]%>" /></div>
+                               <div class="field"><com:TActiveCheckBox ID="GoToStartedJob" AutoPostBack="false" Checked="true" /></div>
+                       </div>
+                       <com:TCallback ID="ReloadRunJobs" OnCallback="Page.JobRunWindow.prepareData" ClientSide.OnComplete="SlideWindow.getObj('JobRunWindow').setLoadRequest();" />
                        <script type="text/javascript">
                                var jobrun_callback_func = function() {
                                        /* If Job Run list window is not open or if actually toolbar is used
                                <com:BActiveButton ID="Run" Text="<%[ Run job ]%>" ValidationGroup="JobRunGroup" CausesValidation="true" OnClick="run_job">
                                        <prop:ClientSide.OnSuccess>
                                                ConfigurationWindow.getObj('JobRunWindow').progress(false);
+                                               oMonitor();
                                                jobrun_callback_func();
                                                if (Prado.Validation.isValid(Prado.Validation.getForm(), 'JobRunGroup') === true) {
-                                                       ConfigurationWindow.getObj('JobRunWindow').switchTab('jobrun_console_tab');
+                                                       if ($('<%=$this->GoToStartedJob->ClientID%>').checked === true) {
+                                                               ConfigurationWindow.getObj('JobWindow').progress(false);
+                                                               ConfigurationWindow.getObj('JobWindow').show();
+                                                               ConfigurationWindow.getObj('JobWindow').switchTabByNo(2);
+                                                       } else {
+                                                               ConfigurationWindow.getObj('JobRunWindow').switchTab('jobrun_console_tab');
+                                                       }
                                                }
                                        </prop:ClientSide.OnSuccess>
                                </com:BActiveButton>
                                        <com:BActiveButton ID="Estimate" Text="<%[ Estimate job ]%>" OnClick="estimate">
                                                <prop:ClientSide.OnSuccess>
                                                        ConfigurationWindow.getObj('JobRunWindow').progress(false);
-                                                       jobrun_callback_func();
-                                                       oMonitor();
                                                        if (Prado.Validation.isValid(Prado.Validation.getForm(), 'JobRunGroup') === true) {
                                                                ConfigurationWindow.getObj('JobRunWindow').switchTab('jobrun_console_tab');
                                                        }
index 7c8d41ace817fee54a4b540b08d7d6695067a503..70dd6318b0f88191f6035f3cfb2b47f4c521a209 100644 (file)
@@ -191,6 +191,9 @@ div.slide-window-progress {
        display: none;
 }
 
+.wheel-loader {
+       background: #ffffff url('wheel.gif') no-repeat center center;
+}
 div.actions_btn {
        position: absolute;
        width: 35px;
diff --git a/gui/baculum/themes/Baculum-v1/wheel.gif b/gui/baculum/themes/Baculum-v1/wheel.gif
new file mode 100644 (file)
index 0000000..94c1bfa
Binary files /dev/null and b/gui/baculum/themes/Baculum-v1/wheel.gif differ