]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Add restore job selection in restore job wizard
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 29 Jul 2017 18:48:50 +0000 (20:48 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 29 Jul 2017 18:48:50 +0000 (20:48 +0200)
15 files changed:
gui/baculum/protected/API/Pages/API/JobTasks.php
gui/baculum/protected/API/Pages/API/RestoreRun.php
gui/baculum/protected/API/endpoints.xml
gui/baculum/protected/Common/Class/Miscellaneous.php
gui/baculum/protected/Web/Lang/en/messages.mo
gui/baculum/protected/Web/Lang/en/messages.po
gui/baculum/protected/Web/Lang/ja/messages.mo
gui/baculum/protected/Web/Lang/ja/messages.po
gui/baculum/protected/Web/Lang/pl/messages.mo
gui/baculum/protected/Web/Lang/pl/messages.po
gui/baculum/protected/Web/Lang/pt/messages.mo
gui/baculum/protected/Web/Lang/pt/messages.po
gui/baculum/protected/Web/Pages/RestoreWizard.page
gui/baculum/protected/Web/Pages/RestoreWizard.php
gui/baculum/protected/Web/Portlets/JobList.php

index a138a98258657c9d8164d71a62cc884500ce6377..4b83a9bcb7d50c00c893d3467d1f2f55914938dc 100644 (file)
@@ -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
 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;
index a60e627c0be01ab2b5b1636af057889de204afe5..09e517fd8dae26c6175c99356cd740d1a7de9996 100644 (file)
@@ -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;
index 6fc1041a9cbf54436663369b131e2358cd094abd..4d003682048fe98a66e4c41b1beb6ffa41c3a2d8 100644 (file)
@@ -54,6 +54,8 @@
        <!-- jobs endpoints-->
        <url ServiceParameter="API.Jobs" pattern="api/jobs/" />
        <url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/" />
+       <url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/type/{type}" parameters.type="[a-zA-Z]" />
+       <url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/type/{type}/limit/{limit}/" parameters.type="[a-zA-Z]" parameters.limit="\d+" />
        <url ServiceParameter="API.JobTasks" pattern="api/jobs/tasks/limit/{limit}/" parameters.limit="\d+" />
        <url ServiceParameter="API.Job" pattern="api/jobs/{id}/" parameters.id="\d+" />
        <url ServiceParameter="API.Jobs" pattern="api/jobs/limit/{limit}/" parameters.limit="\d+" />
index b143d25d4e73a5dd2dc0451641a8e52cdd228b6f..fc3f8a9a811bc7f349b99b96503c31c31ccf2e1a 100644 (file)
@@ -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();
index b0f0bc0009f8e3349e7132fe7ac3ff6d45ffea6b..07248f9c71cf56397f21ccd295976f1a675fb791 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/en/messages.mo and b/gui/baculum/protected/Web/Lang/en/messages.mo differ
index d3239fa41fddfc7790f8fcbf8efe9730428ae536..3e88541eb0a253f1e59ce8de80ca4b0923370cf3 100644 (file)
@@ -1405,3 +1405,6 @@ msgstr "OAuth2 Redirect URI:"
 
 msgid "OAuth2 Scope:"
 msgstr "OAuth2 Scope:"
+
+msgid "Restore job:"
+msgstr "Restore job:"
index 635a814ce9a07f197255b209356e0736996fc68d..d1bf720ba3f3ff0bdf0f8c6e3a28d990c5c55187 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/ja/messages.mo and b/gui/baculum/protected/Web/Lang/ja/messages.mo differ
index 86dfcaa0d71f767e00a9bbb47a262b0a301755fa..ed84f3abd911f02220374d00e183fd808430f449 100644 (file)
@@ -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:"
index f5b03c68e6b6e0a4e2fc337ff01b929ae6df7211..2224193e683a93e047d328c848e3477656ebb2d3 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pl/messages.mo and b/gui/baculum/protected/Web/Lang/pl/messages.mo differ
index 876b0ed98bc1df18c44af48fe86834e17df0a206..602a85d865beadb4a5776a127c43bae04a50e86a 100644 (file)
@@ -1407,3 +1407,5 @@ msgstr "OAuth2 Redirect URI:"
 msgid "OAuth2 Scope:"
 msgstr "Zakresy OAuth2:"
 
+msgid "Restore job:"
+msgstr "Zadanie przywracania:"
index 8361deb804b8f159faf104a2758b62d1a0cc5085..52783a3f0f50cf733a781a7c4238f1166a8a9968 100644 (file)
Binary files a/gui/baculum/protected/Web/Lang/pt/messages.mo and b/gui/baculum/protected/Web/Lang/pt/messages.mo differ
index 3977ca92faa32fe8fd8ed19bcc27e120133f70a6..a20c093b027d47e5082328eec13d2a3241ce2c84 100644 (file)
@@ -1406,3 +1406,5 @@ msgstr "OAuth2 Redirect URI:"
 msgid "OAuth2 Scope:"
 msgstr "OAuth2 Scope:"
 
+msgid "Restore job:"
+msgstr "Restore job:"
index 091d5d448a64a03a9f5e7001f46d602e6a19891e..38b8c4da94dd25e3ad5dc80e96737197944a7855 100644 (file)
                        </div>
                </com:TWizardStep>
                <com:TWizardStep ID="Step5" Title="<%[ Step 5 - options for restore ]%>" StepType="Auto">
+                       <div class="line">
+                               <div class="text"><com:TLabel ForControl="RestoreJob" Text="<%[ Restore job: ]%>" /></div>
+                               <div class="field">
+                                       <com:TActiveDropDownList ID="RestoreJob" CssClass="textbox" Width="350px" CausesValidation="false" />
+                               </div>
+                       </div>
                        <div class="line">
                                <div class="text"><com:TLabel ForControl="ReplaceFiles" Text="<%[ Replace files: ]%>" /></div>
                                <div class="field">
                        </fieldset>
                        <fieldset>
                                <legend><%[ Restore job options ]%></legend>
+                               <div class="line">
+                                       <div class="text"><%[ Restore job: ]%></div>
+                                       <div class="field bold"><%=$this->RestoreJob->Text%></div>
+                               </div>
                                <div class="line">
                                        <div class="text"><%[ Replace files: ]%></div>
                                        <div class="field bold">
index dc95202ed15ff402ab1abb8995bd7d97466a7339..7feb1dc1184bcc649cccfa24fcf30c9ab89aae71 100644 (file)
@@ -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();
        }
 }
 ?>
index 1878467dbbc8fbe801fb4fafbeeb6988e2b2183c..15e73021e41f4507d1fe49d7f4505a4143132be5 100644 (file)
@@ -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();
        }