From: Marcin Haba Date: Sat, 29 Jul 2017 18:48:50 +0000 (+0200) Subject: baculum: Add restore job selection in restore job wizard X-Git-Tag: Release-9.0.3~22 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=d064238c91c1fa5be5dff6fd1ae5cfe7e5dff241;p=bacula%2Fbacula baculum: Add restore job selection in restore job wizard --- diff --git a/gui/baculum/protected/API/Pages/API/JobTasks.php b/gui/baculum/protected/API/Pages/API/JobTasks.php index a138a98258..4b83a9bcb7 100644 --- a/gui/baculum/protected/API/Pages/API/JobTasks.php +++ b/gui/baculum/protected/API/Pages/API/JobTasks.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2016 Kern Sibbald + * Copyright (C) 2013-2017 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -23,13 +23,18 @@ class JobTasks extends BaculumAPIServer { public function get() { $limit = intval($this->Request['limit']); + $jobs_cmd = array('.jobs'); + if ($this->Request->contains('type') && array_key_exists($this->Request['type'], $this->getModule('misc')->job_types)) { + array_push($jobs_cmd, 'type="' . $this->Request['type']. '"'); + } + $directors = $this->getModule('bconsole')->getDirectors(); if($directors->exitcode === 0) { $jobs = array(); $error = false; $error_obj = null; for($i = 0; $i < count($directors->output); $i++) { - $jobsList = $this->getModule('bconsole')->bconsoleCommand($directors->output[$i], array('.jobs'), $this->user); + $jobsList = $this->getModule('bconsole')->bconsoleCommand($directors->output[$i], $jobs_cmd, $this->user); if ($jobsList->exitcode != 0) { $error_obj = $jobsList; $error = true; diff --git a/gui/baculum/protected/API/Pages/API/RestoreRun.php b/gui/baculum/protected/API/Pages/API/RestoreRun.php index a60e627c0b..09e517fd8d 100644 --- a/gui/baculum/protected/API/Pages/API/RestoreRun.php +++ b/gui/baculum/protected/API/Pages/API/RestoreRun.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2016 Kern Sibbald + * Copyright (C) 2013-2017 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -42,6 +42,10 @@ class RestoreRun extends BaculumAPIServer { $priority = property_exists($params, 'priority') ? intval($params->priority) : 10; // default priority is set to 10 $where = property_exists($params, 'where') ? $params->where : null; $replace = property_exists($params, 'replace') ? $params->replace : null; + $restorejob = null; + if (property_exists($params, 'restorejob') && $this->getModule('misc')->isValidName($params->restorejob)) { + $restorejob = $params->restorejob; + } $misc = $this->getModule('misc'); if(!is_null($fileset)) { @@ -55,9 +59,12 @@ class RestoreRun extends BaculumAPIServer { 'where="' . $where . '"', 'replace="' . $replace . '"', 'fileset="' . $fileset . '"', - 'priority="' . $priority . '"', - 'yes' + 'priority="' . $priority . '"' ); + if (!is_null($restorejob)) { + $command[] = 'restorejob="' . $restorejob . '"'; + } + $command[] = 'yes'; $restore = $this->getModule('bconsole')->bconsoleCommand($this->director, $command, $this->user); $this->removeTmpRestoreTable($rfile); $this->output = $restore->output; diff --git a/gui/baculum/protected/API/endpoints.xml b/gui/baculum/protected/API/endpoints.xml index 6fc1041a9c..4d00368204 100644 --- a/gui/baculum/protected/API/endpoints.xml +++ b/gui/baculum/protected/API/endpoints.xml @@ -54,6 +54,8 @@ + + diff --git a/gui/baculum/protected/Common/Class/Miscellaneous.php b/gui/baculum/protected/Common/Class/Miscellaneous.php index b143d25d4e..fc3f8a9a81 100644 --- a/gui/baculum/protected/Common/Class/Miscellaneous.php +++ b/gui/baculum/protected/Common/Class/Miscellaneous.php @@ -22,7 +22,7 @@ class Miscellaneous extends TModule { const RPATH_PATTERN = '/^b2\d+$/'; - private $jobTypes = array( + public $job_types = array( 'B' => 'Backup', 'M' => 'Migrated', 'V' => 'Verify', @@ -138,17 +138,6 @@ class Miscellaneous extends TModule { return $name; } - public function getJobType($jobTypeLetter = null) { - $type; - if(is_null($jobTypeLetter)) { - $type = $this->jobTypes; - } else { - $type = array_key_exists($jobTypeLetter, $this->jobTypes) ? $this->jobTypes[$jobTypeLetter] : null; - } - return $type; - - } - public function getJobStatesByType($type) { $statesByType = array(); $states = array(); diff --git a/gui/baculum/protected/Web/Lang/en/messages.mo b/gui/baculum/protected/Web/Lang/en/messages.mo index b0f0bc0009..07248f9c71 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 d3239fa41f..3e88541eb0 100644 --- a/gui/baculum/protected/Web/Lang/en/messages.po +++ b/gui/baculum/protected/Web/Lang/en/messages.po @@ -1405,3 +1405,6 @@ msgstr "OAuth2 Redirect URI:" msgid "OAuth2 Scope:" msgstr "OAuth2 Scope:" + +msgid "Restore job:" +msgstr "Restore job:" diff --git a/gui/baculum/protected/Web/Lang/ja/messages.mo b/gui/baculum/protected/Web/Lang/ja/messages.mo index 635a814ce9..d1bf720ba3 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 86dfcaa0d7..ed84f3abd9 100644 --- a/gui/baculum/protected/Web/Lang/ja/messages.po +++ b/gui/baculum/protected/Web/Lang/ja/messages.po @@ -1150,3 +1150,6 @@ msgstr "Jobs for Client" msgid "No jobs for the client." msgstr "No jobs for the client." + +msgid "Restore job:" +msgstr "Restore job:" diff --git a/gui/baculum/protected/Web/Lang/pl/messages.mo b/gui/baculum/protected/Web/Lang/pl/messages.mo index f5b03c68e6..2224193e68 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 876b0ed98b..602a85d865 100644 --- a/gui/baculum/protected/Web/Lang/pl/messages.po +++ b/gui/baculum/protected/Web/Lang/pl/messages.po @@ -1407,3 +1407,5 @@ msgstr "OAuth2 Redirect URI:" msgid "OAuth2 Scope:" msgstr "Zakresy OAuth2:" +msgid "Restore job:" +msgstr "Zadanie przywracania:" diff --git a/gui/baculum/protected/Web/Lang/pt/messages.mo b/gui/baculum/protected/Web/Lang/pt/messages.mo index 8361deb804..52783a3f0f 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 3977ca92fa..a20c093b02 100644 --- a/gui/baculum/protected/Web/Lang/pt/messages.po +++ b/gui/baculum/protected/Web/Lang/pt/messages.po @@ -1406,3 +1406,5 @@ msgstr "OAuth2 Redirect URI:" msgid "OAuth2 Scope:" msgstr "OAuth2 Scope:" +msgid "Restore job:" +msgstr "Restore job:" diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.page b/gui/baculum/protected/Web/Pages/RestoreWizard.page index 091d5d448a..38b8c4da94 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.page +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.page @@ -262,6 +262,12 @@ +
+
+
+ +
+
@@ -332,6 +338,10 @@
<%[ Restore job options ]%> +
+
<%[ Restore job: ]%>
+
<%=$this->RestoreJob->Text%>
+
<%[ Replace files: ]%>
diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.php b/gui/baculum/protected/Web/Pages/RestoreWizard.php index dc95202ed1..7feb1dc118 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.php +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2016 Kern Sibbald + * Copyright (C) 2013-2017 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -59,6 +59,7 @@ class RestoreWizard extends BaculumWebPage $this->setFileVersions(array()); $this->setFilesToRestore(array()); $this->markFileToRestore(null, null); + $this->setRestoreJobs(); $_SESSION['restore_path'] = array(); } } @@ -414,31 +415,42 @@ class RestoreWizard extends BaculumWebPage public function wizardCompleted() { $jobids = $this->getElementaryBackup(); $path = self::BVFS_PATH_PREFIX . getmypid(); - $restoreElements = $this->getRestoreElements(); - $cmdProps = array('jobids' => $jobids, 'path' => $path); - if(count($restoreElements['fileid']) > 0) { - $cmdProps['fileid'] = implode(',', $restoreElements['fileid']); + $restore_elements = $this->getRestoreElements(); + $cmd_props = array('jobids' => $jobids, 'path' => $path); + if(count($restore_elements['fileid']) > 0) { + $cmd_props['fileid'] = implode(',', $restore_elements['fileid']); } - if(count($restoreElements['dirid']) > 0) { - $cmdProps['dirid'] = implode(',', $restoreElements['dirid']); + if(count($restore_elements['dirid']) > 0) { + $cmd_props['dirid'] = implode(',', $restore_elements['dirid']); } - $this->getModule('api')->create(array('bvfs', 'restore'), $cmdProps); - $restoreProps = array(); - $restoreProps['rpath'] = $path; - $restoreProps['clientid'] = intval($this->RestoreClient->SelectedValue); - $restoreProps['fileset'] = $this->GroupBackupFileSet->SelectedValue; - $restoreProps['priority'] = intval($this->RestoreJobPriority->Text); - $restoreProps['where'] = $this->RestorePath->Text; - $restoreProps['replace'] = $this->ReplaceFiles->SelectedValue; + $this->getModule('api')->create(array('bvfs', 'restore'), $cmd_props); + $restore_props = array(); + $restore_props['rpath'] = $path; + $restore_props['clientid'] = intval($this->RestoreClient->SelectedValue); + $restore_props['fileset'] = $this->GroupBackupFileSet->SelectedValue; + $restore_props['priority'] = intval($this->RestoreJobPriority->Text); + $restore_props['where'] = $this->RestorePath->Text; + $restore_props['replace'] = $this->ReplaceFiles->SelectedValue; + $restore_props['restorejob'] = $this->RestoreJob->SelectedValue; - $ret = $this->getModule('api')->create(array('jobs', 'restore'), $restoreProps); + $ret = $this->getModule('api')->create(array('jobs', 'restore'), $restore_props); $jobid = $this->getModule('misc')->findJobIdStartedJob($ret->output); - $urlParams = array('open' => 'Job'); + $url_params = array('open' => 'Job'); if (is_numeric($jobid)) { - $urlParams['id'] = $jobid; + $url_params['id'] = $jobid; } - $this->goToDefaultPage($urlParams); + $this->goToDefaultPage($url_params); + } + + private function setRestoreJobs() { + $restore_job_tasks = $this->Application->getModule('api')->get(array('jobs', 'tasks', 'type', 'R'))->output; + $jobs = array(); + foreach ($restore_job_tasks as $director => $restore_jobs) { + $jobs = array_merge($jobs, $restore_jobs); + } + $this->RestoreJob->DataSource = array_combine($jobs, $jobs); + $this->RestoreJob->dataBind(); } } ?> diff --git a/gui/baculum/protected/Web/Portlets/JobList.php b/gui/baculum/protected/Web/Portlets/JobList.php index 1878467dbb..15e73021e4 100644 --- a/gui/baculum/protected/Web/Portlets/JobList.php +++ b/gui/baculum/protected/Web/Portlets/JobList.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2016 Kern Sibbald + * Copyright (C) 2013-2017 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -66,7 +66,7 @@ class JobList extends Portlets implements ISlideWindow { $misc = $this->Application->getModule('misc'); $this->jobLevels = $misc->getJobLevels(); $this->jobStates = $misc->getJobState(); - $this->jobTypes = $misc->getJobType(); + $this->jobTypes = $misc->job_types; $this->runningJobStates = $misc->getRunningJobStates(); }