]> git.sur5r.net Git - bacula/bacula/commitdiff
baculum: Add fileset info endpoint and use it in restore wizard
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 30 Jul 2017 14:29:53 +0000 (16:29 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Sun, 30 Jul 2017 14:29:53 +0000 (16:29 +0200)
gui/baculum/protected/API/Pages/API/FileSetsInfo.php [new file with mode: 0644]
gui/baculum/protected/API/endpoints.xml
gui/baculum/protected/Web/Pages/RestoreWizard.page
gui/baculum/protected/Web/Pages/RestoreWizard.php

diff --git a/gui/baculum/protected/API/Pages/API/FileSetsInfo.php b/gui/baculum/protected/API/Pages/API/FileSetsInfo.php
new file mode 100644 (file)
index 0000000..e361548
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2017 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+class FileSetsInfo extends BaculumAPIServer {
+
+       public function get() {
+               $filesets = $this->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;
+               }
+       }
+}
+
+?>
index dc9aa05dbcd49f0f9aeffce8a92699334fb28da0..cc5c656d450bea3b83b1addeb89447746afa8796 100644 (file)
@@ -59,7 +59,7 @@
        <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+" />
-       <url ServiceParameter="API.JobsRecent" pattern="api/jobs/recent/{name}/client/{client}/fileset/{fileset}/" parameters.name="[a-zA-Z0-9:.\-_ ]+" parameters.client="[a-zA-Z0-9:.\-_ ]+" parameters.fileset="[a-zA-Z0-9:.\-_ ]+" />
+       <url ServiceParameter="API.JobsRecent" pattern="api/jobs/recent/{name}/client/{client}/filesetid/{filesetid}/" parameters.name="[a-zA-Z0-9:.\-_ ]+" parameters.client="[a-zA-Z0-9:.\-_ ]+" parameters.filesetid="\d+" />
        <url ServiceParameter="API.JobsRecent" pattern="api/jobs/recent/{name}/clientid/{clientid}/filesetid/{filesetid}/" parameters.name="[a-zA-Z0-9:.\-_ ]+" parameters.clientid="\d+" parameters.filesetid="\d+" />
        <url ServiceParameter="API.JobEstimate" pattern="api/jobs/estimate/" />
        <url ServiceParameter="API.JobRun" pattern="api/jobs/run/" />
@@ -86,6 +86,7 @@
        <!-- fileset endpoints -->
        <url ServiceParameter="API.FileSets" pattern="api/filesets/" />
        <url ServiceParameter="API.FileSet" pattern="api/filesets/{id}/" parameters.id="\d+" />
+       <url ServiceParameter="API.FileSetsInfo" pattern="api/filesets/info/" />
        <!-- Bacula config module endpoints -->
        <url ServiceParameter="API.JSONToolsTest" pattern="api/config/tools/test/" />
        <url ServiceParameter="API.ConfigDirTest" pattern="api/config/directory/test/" />
index df7c0d66ba9b401b2ad5e306d146fa5175817739..d4d5bfdd6292eb5e7d9932bd12e57a9b7f547409 100644 (file)
                                                <com:TActiveDropDownList ID="GroupBackupFileSet" CssClass="textbox" Width="350px" CausesValidation="false" />
                                        </div>
                                </div>
-                               <div class="line">
-                                       <div class="text"><com:TLabel ForControl="GroupBackupStorage" Text="<%[ Storage resource: ]%>" /></div>
-                                       <div class="field">
-                                               <com:TActiveDropDownList ID="GroupBackupStorage" OnInit="setStorage" CssClass="textbox" Width="350px" CausesValidation="false" />
-                                       </div>
-                               </div>
-                               <div class="line">
-                                       <div class="text"><com:TLabel ForControl="GroupBackupPool" Text="<%[ Pool resource: ]%>" /></div>
-                                       <div class="field">
-                                               <com:TActiveDropDownList ID="GroupBackupPool" OnInit="setPool" CssClass="textbox" Width="350px" CausesValidation="false" />
-                                       </div>
-                               </div>
                        </com:TActivePanel>
                </com:TWizardStep>
                <com:TWizardStep ID="Step3" Title="<%[ Step 3 - select files to restore ]%>" StepType="Auto">
index 63323e4f9000e811206c3569828e44dd72f5e473..b9c8637b7f6fe0665609db5b823fccefbc30cf35 100644 (file)
@@ -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);