From: Marcin Haba Date: Sun, 30 Jul 2017 14:29:53 +0000 (+0200) Subject: baculum: Add fileset info endpoint and use it in restore wizard X-Git-Tag: Release-9.0.3~15 X-Git-Url: https://git.sur5r.net/?p=bacula%2Fbacula;a=commitdiff_plain;h=1f54f3c275d53c281c5e69338d68d07dc531806a baculum: Add fileset info endpoint and use it in restore wizard --- diff --git a/gui/baculum/protected/API/Pages/API/FileSetsInfo.php b/gui/baculum/protected/API/Pages/API/FileSetsInfo.php new file mode 100644 index 0000000000..e361548b83 --- /dev/null +++ b/gui/baculum/protected/API/Pages/API/FileSetsInfo.php @@ -0,0 +1,49 @@ +getModule('fileset')->getFileSets(); + $allowed_filesets = $this->getModule('bconsole')->bconsoleCommand($this->director, array('.fileset'), $this->user); + if ($allowed_filesets->exitcode === 0) { + if (is_array($filesets) && count($filesets) > 0) { + $fs = array(); + for ($i = 0; $i < count($filesets); $i++) { + if(in_array($filesets[$i]->fileset, $allowed_filesets->output)) { + $fs[] = $filesets[$i]; + } + } + $this->output = $fs; + $this->error = FileSetError::ERROR_NO_ERRORS; + } else { + $this->output = FileSetError::MSG_ERROR_FILESET_DOES_NOT_EXISTS; + $this->error = FileSetError::ERROR_FILESET_DOES_NOT_EXISTS; + } + } else { + $this->output = $allowed_filesets->output; + $this->error = $allowed_filesets->exitcode; + } + } +} + +?> diff --git a/gui/baculum/protected/API/endpoints.xml b/gui/baculum/protected/API/endpoints.xml index dc9aa05dbc..cc5c656d45 100644 --- a/gui/baculum/protected/API/endpoints.xml +++ b/gui/baculum/protected/API/endpoints.xml @@ -59,7 +59,7 @@ - + @@ -86,6 +86,7 @@ + diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.page b/gui/baculum/protected/Web/Pages/RestoreWizard.page index df7c0d66ba..d4d5bfdd62 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.page +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.page @@ -91,18 +91,6 @@ -
-
-
- -
-
-
-
-
- -
-
diff --git a/gui/baculum/protected/Web/Pages/RestoreWizard.php b/gui/baculum/protected/Web/Pages/RestoreWizard.php index 63323e4f90..b9c8637b7f 100644 --- a/gui/baculum/protected/Web/Pages/RestoreWizard.php +++ b/gui/baculum/protected/Web/Pages/RestoreWizard.php @@ -68,7 +68,7 @@ class RestoreWizard extends BaculumWebPage parent::onLoad($param); if($this->RestoreWizard->ActiveStepIndex == 0) { $this->jobs = $this->getModule('api')->get(array('jobs'))->output; - $this->filesets = $this->getModule('api')->get(array('filesets'))->output; + $this->filesets = $this->getModule('api')->get(array('filesets', 'info'))->output; } $this->clients = $this->getModule('api')->get(array('clients'))->output; @@ -162,15 +162,16 @@ class RestoreWizard extends BaculumWebPage } $fileset_list = array(); - foreach($this->filesets as $director => $filesets) { - $fileset_list = array_merge($fileset_list, $filesets); + for ($i = 0; $i < count($this->filesets); $i++) { + $fileset_list[$this->filesets[$i]->filesetid] = $this->filesets[$i]->fileset . ' (' . $this->filesets[$i]->createtime . ')'; } + asort($fileset_list); $this->BackupToRestore->dataSource = $jobs_list; $this->BackupToRestore->dataBind(); $this->GroupBackupToRestore->dataSource = $jobs_group_list; $this->GroupBackupToRestore->dataBind(); - $this->GroupBackupFileSet->dataSource = array_combine($fileset_list, $fileset_list); + $this->GroupBackupFileSet->dataSource = $fileset_list; $this->GroupBackupFileSet->dataBind(); $this->setRestoreClients($sender, $param); } @@ -198,30 +199,6 @@ class RestoreWizard extends BaculumWebPage } } - public function setStorage($sender, $param) { - if(!$this->IsPostBack) { - $storagesList = array(); - $storages = $this->getModule('api')->get(array('storages'))->output; - foreach($storages as $storage) { - $storagesList[$storage->storageid] = $storage->name; - } - $this->GroupBackupStorage->dataSource = $storagesList; - $this->GroupBackupStorage->dataBind(); - } - } - - public function setPool($sender, $param) { - if(!$this->IsPostBack) { - $poolsList = array(); - $pools = $this->getModule('api')->get(array('pools'))->output; - foreach($pools as $pool) { - $poolsList[$pool->poolid] = $pool->name; - } - $this->GroupBackupPool->dataSource = $poolsList; - $this->GroupBackupPool->dataBind(); - } - } - public function setBackupClient($sender, $param) { $this->ClientToRestore->SelectedValue = $param->SelectedValue; } @@ -318,7 +295,7 @@ class RestoreWizard extends BaculumWebPage $this->GroupBackupToRestore->SelectedValue, 'client', $this->BackupClientName->SelectedValue, - 'fileset', + 'filesetid', $this->GroupBackupFileSet->SelectedValue ); $jobs_recent = $this->getModule('api')->get($params);