View Issue Details

IDProjectCategoryView StatusLast Update
0000936bareos-core[All Projects] webuipublic2019-05-16 20:33
ReportermsilveiraAssigned Tofrank 
PriorityhighSeverityfeatureReproducibilityalways
Status assignedResolutionopen 
PlatformLinuxOSanyOS Version3
Product Version17.2.5 
Target VersionFixed in Version 
Summary0000936: The field "Restore location on client" Should be updated after selecting "Restore Job"
DescriptionI've been engaged in programming this feature, because it bothered me too much to have to type the destination folder, considering that I have a real path ( Where parameter ) set for every RestoreJob.
Additional InformationI've written a patch to make the webui force a RestoreJob selection and then, the system will check for the selected RestoreJob's "Where = " parameter.

The patch has been written against the source from bareos-webui-17.2.4-15.1.el7.src.rpm .

I'm not a professional programmer, it took me almost half a day to find out how to get this working. But it was worthy. I hope it makes into the master branch.
TagsNo tags attached.
bareos-master: impact
bareos-master: action
bareos-18.2: impact
bareos-18.2: action
bareos-17.2: impact
bareos-17.2: action
bareos-16.2: impact
bareos-16.2: action
bareos-15.2: impact
bareos-15.2: action
bareos-14.2: impact
bareos-14.2: action
bareos-13.2: impact
bareos-13.2: action
bareos-12.4: impact
bareos-12.4: action

Activities

msilveira

msilveira

2018-03-28 23:28

reporter  

bareos-webui-populate-where-from-restorejob.patch (4,813 bytes)
diff -udpr bareos-webui-17.2.4/module/Job/src/Job/Model/JobModel.php bareos-webui-17.2.4-20180328/module/Job/src/Job/Model/JobModel.php
--- bareos-webui-17.2.4/module/Job/src/Job/Model/JobModel.php	2017-12-14 09:19:17.000000000 -0200
+++ bareos-webui-17.2.4-20180328/module/Job/src/Job/Model/JobModel.php	2018-03-28 17:45:36.994980164 -0300
@@ -449,6 +449,28 @@ class JobModel
       }
    }
 
+    /**
+    * Get Restore job Where
+    *
+    * @param $bsock
+    * @param $name
+    *
+    * @return string
+    */
+   public function getRestoreJobWhere(&$bsock=null, $name=null)
+   {
+      $defaultpath = "/tmp/bareos-restores";
+      if(isset($bsock, $name)) {
+         $cmd = '.defaults job="'.$name.'"';
+         $result = $bsock->send_command($cmd, 2, null);
+         $jobdefaults = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
+         return $jobdefaults['result']['defaults']['where'];
+      }
+      else {
+         return $defaultpath;
+      }
+   }
+
    /**
     * Run a custom job
     *
diff -udpr bareos-webui-17.2.4/module/Restore/src/Restore/Controller/RestoreController.php bareos-webui-17.2.4-20180328/module/Restore/src/Restore/Controller/RestoreController.php
--- bareos-webui-17.2.4/module/Restore/src/Restore/Controller/RestoreController.php	2018-03-28 17:47:08.418303894 -0300
+++ bareos-webui-17.2.4-20180328/module/Restore/src/Restore/Controller/RestoreController.php	2018-03-28 17:42:41.287434645 -0300
@@ -116,6 +116,16 @@ class RestoreController extends Abstract
          }
       }
 
+      if($this->restore_params['restorejob'] != null ) {
+         try {
+           $restorepath = $this->getJobModel()->getRestoreJobWhere($this->bsock, $this->restore_params['restorejob']);
+           $this->restore_params['where'] = $restorepath;
+         }
+         catch(Exception $e) {
+            echo $e->getMessage();
+         }
+      }
+
       if(isset($this->restore_params['mergejobs']) && $this->restore_params['mergejobs'] == 1) {
          $jobids = $this->restore_params['jobid'];
       }
diff -udpr bareos-webui-17.2.4/module/Restore/src/Restore/Form/RestoreForm.php bareos-webui-17.2.4-20180328/module/Restore/src/Restore/Form/RestoreForm.php
--- bareos-webui-17.2.4/module/Restore/src/Restore/Form/RestoreForm.php	2017-12-14 09:19:14.000000000 -0200
+++ bareos-webui-17.2.4-20180328/module/Restore/src/Restore/Form/RestoreForm.php	2018-03-28 17:45:09.291579043 -0300
@@ -271,6 +271,7 @@ class RestoreForm extends Form
             'attributes' => array(
                'class' => 'form-control selectpicker show-tick',
                'data-live-search' => 'true',
+               'title' => _('Please select a Restore Job'),
                'id' => 'restorejob',
                'value' => $restore_params['restorejob']
             )
@@ -289,6 +290,7 @@ class RestoreForm extends Form
                'attributes' => array(
                   'class' => 'form-control selectpicker show-tick',
                   'data-live-search' => 'true',
+                  'title' => _('Please select a Restore Job'),
                   'id' => 'restorejob',
                   'value' => @array_pop($this->getRestoreJobList())
                )
@@ -306,6 +308,7 @@ class RestoreForm extends Form
                'attributes' => array(
                   'class' => 'form-control selectpicker show-tick',
                   'data-live-search' => 'true',
+                  'title' => _('Please select a Restore Job'),
                   'id' => 'restorejob'
                )
             ));
@@ -422,7 +425,7 @@ class RestoreForm extends Form
             ),
          'attributes' => array(
             'class' => 'form-control selectpicker show-tick',
-            'value' => '/tmp/bareos-restores/',
+            'value' => $restore_params['where'],
             'id' => 'where',
             'size' => '30',
             'placeholder' => _('e.g. / or /tmp/bareos-restores/')
diff -udpr bareos-webui-17.2.4/module/Restore/view/restore/restore/index.phtml bareos-webui-17.2.4-20180328/module/Restore/view/restore/restore/index.phtml
--- bareos-webui-17.2.4/module/Restore/view/restore/restore/index.phtml	2017-12-14 09:19:14.000000000 -0200
+++ bareos-webui-17.2.4-20180328/module/Restore/view/restore/restore/index.phtml	2018-03-28 17:46:18.066574842 -0300
@@ -353,6 +353,10 @@ $this->headTitle($title);
       window.location.href = window.location.pathname + '?' + updateRestoreParams('mergejobs', this.value);
    });
 
+   $('#restorejob').change(function(event) {
+      window.location.href = window.location.pathname + '?' + updateRestoreParams('restorejob', this.value);
+   });
+
    $('#limit').change(function(event) {
       window.location.href = window.location.pathname + '?' + updateRestoreParams('limit', this.value);
    });

Issue History

Date Modified Username Field Change
2018-03-28 23:28 msilveira New Issue
2018-03-28 23:28 msilveira File Added: bareos-webui-populate-where-from-restorejob.patch
2018-04-06 16:38 frank Assigned To => frank
2018-04-06 16:38 frank Status new => assigned