From: Marcin Haba Date: Sun, 18 Aug 2019 06:39:00 +0000 (+0200) Subject: baculum: Add graphical running job status on running job page X-Git-Tag: Release-9.6.0~134 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c72d85db9a5d495e9df6f5d14669d64e2cbdeda1;p=thirdparty%2Fbacula.git baculum: Add graphical running job status on running job page --- diff --git a/gui/baculum/protected/Web/Pages/JobHistoryView.page b/gui/baculum/protected/Web/Pages/JobHistoryView.page index cb7a83c2d..e19037f04 100644 --- a/gui/baculum/protected/Web/Pages/JobHistoryView.page +++ b/gui/baculum/protected/Web/Pages/JobHistoryView.page @@ -84,9 +84,313 @@ -
-
+ + + + +
+ +
+
+ <%[ Refresh interval (sec.): ]%> +
+
+ + +
+ +
+ +
+
Request->contains('jobid')) { $jobid = intval($this->Request['jobid']); - $this->RunJobModal->setJobId($jobid); } $jobdata = $this->getModule('api')->get( array('jobs', $jobid), null, true, self::USE_CACHE ); - $this->jobdata = $jobdata->error === 0 ? $jobdata->output : null; - $this->RunJobModal->setJobName($this->jobdata->name); - $this->setJobId($this->jobdata->jobid); - $this->setJobName($this->jobdata->name); - $this->setJobUname($this->jobdata->job); - $this->setJobType($this->jobdata->type); - $this->is_running = $this->getModule('misc')->isJobRunning($this->jobdata->jobstatus); + $jobdata = $jobdata->error === 0 ? $jobdata->output : null; + $this->setJobId($jobdata->jobid); + $this->setJobName($jobdata->name); + $this->setJobUname($jobdata->job); + $this->setJobType($jobdata->type); + $this->setClientId($jobdata->clientid); + $this->is_running = $this->getModule('misc')->isJobRunning($jobdata->jobstatus); + $this->allow_graph_mode = ($this->is_running && !in_array($jobdata->type, $this->no_graph_mode_types)); + } + + public function onInit($param) { + parent::onInit($param); + $this->RunJobModal->setJobId($this->getJobId()); + $this->RunJobModal->setJobName($this->getJobName()); } public function onLoad($param) { @@ -72,10 +79,59 @@ class JobHistoryView extends BaculumWebPage { $this->refreshJobLog(null, null); } + public function runningJobStatus($sender, $param) { + $running_job_status = $this->getRunningJobStatus($this->getClientId()); + $this->getCallbackClient()->callClientFunction('init_graphical_running_job_status', array($running_job_status)); + } + + public function getRunningJobStatus($clientid) { + $client_name = null; + $client = $this->getModule('api')->get( + array('clients', $clientid), + ); + if ($client->error === 0) { + $client_name = $client->output->name; + } + + $running_job_status = array( + 'header' => array(), + 'job' => array(), + 'is_running' => $this->is_running + ); + if (is_string($client_name)) { + $query_str = '?name=' . rawurlencode($client_name) . '&type=header'; + $graph_status = $this->getModule('api')->get( + array('status', 'client', $query_str), + ); + + if ($graph_status->error === 0) { + $running_job_status['header'] = $graph_status->output; + } + + $query_str = '?name=' . rawurlencode($client_name) . '&type=running'; + $graph_status = $this->getModule('api')->get( + array('status', 'client', $query_str), + ); + if ($graph_status->error === 0) { + $jobid = $this->getJobId(); + for ($i = 0; $i < count($graph_status->output); $i++) { + foreach ($graph_status->output[$i] as $key => $val) { + $prop = strtolower($key); + if ($prop === 'jobid' && intval($val) == $jobid) { + $running_job_status['job'] = $graph_status->output[$i]; + break 2; + } + } + } + } + } + return $running_job_status; + } + /** * Set jobid to run job again. * - * @return none; + * @return none */ public function setJobId($jobid) { $jobid = intval($jobid); @@ -91,6 +147,25 @@ class JobHistoryView extends BaculumWebPage { return $this->getViewState(self::JOBID, 0); } + /** + * Set job clientid + * + * @return none + */ + public function setClientId($clientid) { + $clientid = intval($clientid); + $this->setViewState(self::CLIENTID, $clientid, 0); + } + + /** + * Get client jobid. + * + * @return integer clientid + */ + public function getClientId() { + return $this->getViewState(self::CLIENTID, 0); + } + /** * Set job name to run job again. *