Skip to content

Commit

Permalink
webui: Remove the functionality of preselecting a backup client in th…
Browse files Browse the repository at this point in the history
…e restore module indexAction
  • Loading branch information
fbergkemper committed Aug 27, 2019
1 parent eb0fcf7 commit 8c9bb1e
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 108 deletions.
100 changes: 60 additions & 40 deletions webui/module/Restore/src/Restore/Controller/RestoreController.php
Expand Up @@ -52,6 +52,7 @@ class RestoreController extends AbstractActionController
private $files = null;

private $required_commands = array(
"list",
"llist",
".filesets",
".jobs",
Expand All @@ -61,7 +62,8 @@ class RestoreController extends AbstractActionController
".bvfs_lsdirs",
".bvfs_lsfiles",
".bvfs_restore",
".bvfs_cleanup"
".bvfs_cleanup",
".bvfs_versions"
);

/**
Expand Down Expand Up @@ -90,7 +92,7 @@ public function indexAction()
$this->setRestoreParams();
$errors = null;
$result = null;

/*
if($this->restore_params['client'] == null) {
try {
$clients = $this->getClientModel()->getClients($this->bsock);
Expand All @@ -101,8 +103,8 @@ public function indexAction()
echo $e->getMessage();
}
}

if($this->restore_params['type'] == "client" && $this->restore_params['jobid'] == null) {
*/
if($this->restore_params['type'] == "client" && $this->restore_params['jobid'] == null && $this->restore_params['client'] != null) {
try {
$latestbackup = $this->getClientModel()->getClientBackups($this->bsock, $this->restore_params['client'], "any", "desc", 1);
if(empty($latestbackup)) {
Expand Down Expand Up @@ -130,14 +132,17 @@ public function indexAction()
}
}

if($this->restore_params['type'] == "client") {
if($this->restore_params['type'] == "client" && $this->restore_params['client'] != null) {
try {
$backups = $this->getClientModel()->getClientBackups($this->bsock, $this->restore_params['client'], "any", "desc", null);
}
catch(Exception $e) {
echo $e->getMessage();
}
}
else {
$backups = null;
}

try {
//$jobs = $this->getJobModel()->getJobs();
Expand All @@ -149,7 +154,7 @@ public function indexAction()
echo $e->getMessage();
}

if(empty($backups)) {
if(isset($this->restore_params['client']) && empty($backups)) {
$errors = 'No backups of client <strong>'.$this->restore_params['client'].'</strong> found.';
}

Expand Down Expand Up @@ -401,7 +406,6 @@ public function versionsAction()

}


/**
* Delivers a subtree as Json for JStree
*/
Expand Down Expand Up @@ -429,24 +433,15 @@ private function getDirectories()
$this->directories = null;

try {
if($this->restore_params['type'] == "client") {
if(empty($this->restore_params['jobid'])) {
$this->restore_params['jobids'] = null;
}
else {
$jobids = $this->getRestoreModel()->getJobIds($this->bsock, $this->restore_params['jobid'],$this->restore_params['mergefilesets'],$this->restore_params['mergejobs']);
$this->restore_params['jobids'] = $jobids;
$this->directories = $this->getRestoreModel()->getDirectories($this->bsock, $this->restore_params['jobids'], $this->restore_params['id']);
}
}
else {
$this->directories = $this->getRestoreModel()->getDirectories($this->bsock, $this->restore_params['jobid'], $this->restore_params['id']);
}
$this->directories = $this->getRestoreModel()->getDirectories(
$this->bsock,
$this->restore_params['jobids'],
$this->restore_params['id']
);
}
catch(Exception $e) {
echo $e->getMessage();
}

}

/**
Expand All @@ -457,34 +452,64 @@ private function getFiles()
$this->files = null;

try {
if($this->restore_params['type'] == "client") {
if(empty($this->restore_params['jobid'])) {
$this->restore_params['jobids'] = null;
}
else {
$jobids = $this->getRestoreModel()->getJobIds($this->bsock, $this->restore_params['jobid'],$this->restore_params['mergefilesets'],$this->restore_params['mergejobs']);
$this->restore_params['jobids'] = $jobids;
$this->files = $this->getRestoreModel()->getFiles($this->bsock, $this->restore_params['jobids'], $this->restore_params['id']);
}
}
else {
$this->files = $this->getRestoreModel()->getFiles($this->bsock, $this->restore_params['jobid'], $this->restore_params['id']);
}
$this->files = $this->getRestoreModel()->getFiles(
$this->bsock,
$this->restore_params['jobids'],
$this->restore_params['id']
);
}
catch(Exception $e) {
echo $e->getMessage();
}
}

/**
* Get depending JobIds considering the merge criteria
*/
private function getJobIds()
{
try {
$this->restore_params['jobids'] = $this->getRestoreModel()->getJobIds(
$this->bsock,
$this->restore_params['jobid'],
$this->restore_params['mergefilesets'],
$this->restore_params['mergejobs']
);
}
catch(Exception $e) {
echo $e->getMessage();
}
}

/**
* Update Bvfs cache
*/
private function updateBvfsCache()
{
try {
$this->getRestoreModel()->updateBvfsCache(
$this->bsock,
$this->restore_params['jobids']
);
}
catch(Exception $e) {
echo $e->getMessage();
}
}

/**
* Builds a subtree as Json for JStree
*/
private function buildSubtree()
{

$this->bsock = $this->getServiceLocator()->get('director');
$this->setRestoreParams();
$this->getJobIds();

if($this->restore_params['id'] == null || $this->restore_params['id'] == "#") {
$this->updateBvfsCache();
}

$this->getDirectories();
$this->getFiles();

Expand All @@ -496,7 +521,6 @@ private function buildSubtree()
$items = '[';

if($dnum > 0) {

foreach($this->directories as $dir) {
if($dir['name'] == ".") {
--$dnum;
Expand All @@ -521,15 +545,12 @@ private function buildSubtree()
}
}
}

if($fnum > 0) {
$items .= ",";
}

}

if($fnum > 0) {

foreach($this->files as $file) {
$items .= '{';
$items .= '"id":"' . $file["fileid"] . '"';
Expand All @@ -543,7 +564,6 @@ private function buildSubtree()
$items .= ",";
}
}

}

$items .= ']';
Expand Down

0 comments on commit 8c9bb1e

Please sign in to comment.