From: Marcin Haba Date: Sat, 12 Mar 2016 01:33:19 +0000 (+0100) Subject: baculum: Show jobs for client X-Git-Tag: Release-7.4.1~25 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=740ac545e244877ece455f328ea82dc46d9d3101;p=bacula%2Fbacula baculum: Show jobs for client --- diff --git a/gui/baculum/protected/Class/JobManager.php b/gui/baculum/protected/Class/JobManager.php index f08a27001b..078efeea00 100644 --- a/gui/baculum/protected/Class/JobManager.php +++ b/gui/baculum/protected/Class/JobManager.php @@ -131,5 +131,21 @@ class JobManager extends TModule { return JobRecord::finder()->findAllBySql($sql); } + /** + * Get jobs for given client. + * + * @param string $clientid client identifier + * @param array $allowed_jobs jobs allowed to show + * @return array jobs for specific client + */ + public function getJobsForClient($clientid, $allowed_jobs = array()) { + $jobs_criteria = ''; + if (count($allowed_jobs) > 0) { + $jobs_sql = implode("', '", $allowed_jobs); + $jobs_criteria = " AND Job.Name IN ('" . $jobs_sql . "')"; + } + $sql = "SELECT DISTINCT Job.* FROM Client, Job WHERE Client.ClientId='$clientid' AND Client.ClientId=Job.ClientId $jobs_criteria"; + return JobRecord::finder()->findAllBySql($sql); + } } ?> diff --git a/gui/baculum/protected/Lang/en/messages.mo b/gui/baculum/protected/Lang/en/messages.mo index 5fc682c7ea..5479eef48c 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 3b630625d7..a3b2b2d37d 100644 --- a/gui/baculum/protected/Lang/en/messages.po +++ b/gui/baculum/protected/Lang/en/messages.po @@ -1142,3 +1142,9 @@ msgstr "Jobs on Volume" msgid "No jobs on the volume." msgstr "No jobs on the volume." +msgid "Jobs for Client" +msgstr "Jobs for Client" + +msgid "No jobs for the client." +msgstr "No jobs for the client." + diff --git a/gui/baculum/protected/Lang/pl/messages.mo b/gui/baculum/protected/Lang/pl/messages.mo index 7b2fe04242..dd0d0b3261 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 6b6f6c04f0..96d70df014 100644 --- a/gui/baculum/protected/Lang/pl/messages.po +++ b/gui/baculum/protected/Lang/pl/messages.po @@ -1143,3 +1143,9 @@ msgstr "Zadania na volumenie" msgid "No jobs on the volume." msgstr "Na wolumenie nie ma żadnych zadań." +msgid "Jobs for Client" +msgstr "Zadania dla klienta" + +msgid "No jobs for the client." +msgstr "Nie ma żadnych zadań dla klienta." + diff --git a/gui/baculum/protected/Lang/pt/messages.mo b/gui/baculum/protected/Lang/pt/messages.mo index 73e8e97cac..8791c99bdc 100644 Binary files a/gui/baculum/protected/Lang/pt/messages.mo and b/gui/baculum/protected/Lang/pt/messages.mo differ diff --git a/gui/baculum/protected/Lang/pt/messages.po b/gui/baculum/protected/Lang/pt/messages.po index 75c6eedc52..759db72637 100644 --- a/gui/baculum/protected/Lang/pt/messages.po +++ b/gui/baculum/protected/Lang/pt/messages.po @@ -1145,3 +1145,9 @@ msgstr "Jobs on Volume" msgid "No jobs on the volume." msgstr "No jobs on the volume." +msgid "Jobs for Client" +msgstr "Jobs for Client" + +msgid "No jobs for the client." +msgstr "No jobs for the client." + diff --git a/gui/baculum/protected/Pages/API/JobsForClient.php b/gui/baculum/protected/Pages/API/JobsForClient.php new file mode 100644 index 0000000000..ff027be006 --- /dev/null +++ b/gui/baculum/protected/Pages/API/JobsForClient.php @@ -0,0 +1,46 @@ +Request['id']); + $error = false; + if (!is_null($this->user)) { + $allowed_jobs = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.jobs'), $this->user); + if ($allowed_jobs->exitcode === 0) { + $allowed = $allowed_jobs->output; + } else { + $error = true; + $this->output = $allowed_jobs->output; + $this->error = $allowed_jobs->exitcode; + } + } + + if ($error === false) { + $jobs = $this->getModule('job')->getJobsForClient($clientid, $allowed); + $this->output = $jobs; + $this->error = JobError::ERROR_NO_ERRORS; + } + } +} +?> diff --git a/gui/baculum/protected/Portlets/ClientConfiguration.php b/gui/baculum/protected/Portlets/ClientConfiguration.php index 1b9ed6b76d..f3dd43c43b 100644 --- a/gui/baculum/protected/Portlets/ClientConfiguration.php +++ b/gui/baculum/protected/Portlets/ClientConfiguration.php @@ -21,6 +21,7 @@ */ Prado::using('System.Web.UI.ActiveControls.TActiveCustomValidator'); +Prado::using('System.Web.UI.ActiveControls.TActiveDataGrid'); Prado::using('Application.Portlets.Portlets'); class ClientConfiguration extends Portlets { @@ -41,6 +42,10 @@ class ClientConfiguration extends Portlets { $this->FileRetention->Text = intval($client->fileretention / 86400); // conversion to days $this->JobRetention->Text = intval($client->jobretention / 86400); // conversion to days $this->AutoPrune->Checked = $client->autoprune == 1; + + $jobs_for_client = $this->Application->getModule('api')->get(array('clients', 'jobs', $client->clientid))->output; + $this->JobsForClient->DataSource = $this->Application->getModule('misc')->objectToArray($jobs_for_client); + $this->JobsForClient->dataBind(); } public function status($sender, $param) { @@ -69,5 +74,10 @@ class ClientConfiguration extends Portlets { $isValid = preg_match('/^\d+$/', $this->JobRetention->Text) && $this->JobRetention->Text >= 0; $param->setIsValid($isValid); } + + public function openJob($sender, $param) { + $jobid = $param->CallbackParameter; + $this->getPage()->JobConfiguration->configure($jobid); + } } ?> diff --git a/gui/baculum/protected/Portlets/ClientConfiguration.tpl b/gui/baculum/protected/Portlets/ClientConfiguration.tpl index fd13e84479..8a0ac8c78b 100644 --- a/gui/baculum/protected/Portlets/ClientConfiguration.tpl +++ b/gui/baculum/protected/Portlets/ClientConfiguration.tpl @@ -5,6 +5,7 @@ <%[ Actions ]%> <%[ Console status ]%> + <%[ Jobs for Client ]%>
+ diff --git a/gui/baculum/protected/Portlets/ClientList.tpl b/gui/baculum/protected/Portlets/ClientList.tpl index 59388ab0a4..cc021407a3 100644 --- a/gui/baculum/protected/Portlets/ClientList.tpl +++ b/gui/baculum/protected/Portlets/ClientList.tpl @@ -47,6 +47,8 @@ ConfigurationWindow.getObj('ClientWindow').show(); + Formatters.set_formatters(); + bind_jobs_for_client_action(); ConfigurationWindow.getObj('ClientWindow').progress(false); diff --git a/gui/baculum/protected/application.xml b/gui/baculum/protected/application.xml index 38cf970894..dcfd01cc96 100644 --- a/gui/baculum/protected/application.xml +++ b/gui/baculum/protected/application.xml @@ -27,6 +27,7 @@ +