From caf81b155a74ef45171b38b44ac33d91f3901554 Mon Sep 17 00:00:00 2001 From: Frank Bergkemper Date: Thu, 22 Aug 2019 15:58:38 +0200 Subject: [PATCH] webui: Cleanup restore controller, model, form and views --- .../Restore/Controller/RestoreController.php | 15 +- .../Restore/src/Restore/Form/RestoreForm.php | 149 +----------------- .../src/Restore/Model/RestoreModel.php | 7 +- .../Restore/view/restore/restore/index.phtml | 9 -- 4 files changed, 5 insertions(+), 175 deletions(-) diff --git a/webui/module/Restore/src/Restore/Controller/RestoreController.php b/webui/module/Restore/src/Restore/Controller/RestoreController.php index c814264936f..2e3e6b8ac3d 100644 --- a/webui/module/Restore/src/Restore/Controller/RestoreController.php +++ b/webui/module/Restore/src/Restore/Controller/RestoreController.php @@ -92,18 +92,7 @@ public function indexAction() $this->setRestoreParams(); $errors = null; $result = null; -/* - if($this->restore_params['client'] == null) { - try { - $clients = $this->getClientModel()->getClients($this->bsock); - $client = array_pop($clients); - $this->restore_params['client'] = $client['name']; - } - catch(Exception $e) { - echo $e->getMessage(); - } - } -*/ + 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); @@ -145,7 +134,6 @@ public function indexAction() } try { - //$jobs = $this->getJobModel()->getJobs(); $clients = $this->getClientModel()->getClients($this->bsock); $filesets = $this->getFilesetModel()->getDotFilesets($this->bsock); $restorejobs = $this->getJobModel()->getRestoreJobs($this->bsock); @@ -161,7 +149,6 @@ public function indexAction() // Create the form $form = new RestoreForm( $this->restore_params, - //$jobs, $clients, $filesets, $restorejobs, diff --git a/webui/module/Restore/src/Restore/Form/RestoreForm.php b/webui/module/Restore/src/Restore/Form/RestoreForm.php index b05dd47d274..a3868070baf 100644 --- a/webui/module/Restore/src/Restore/Form/RestoreForm.php +++ b/webui/module/Restore/src/Restore/Form/RestoreForm.php @@ -5,7 +5,7 @@ * bareos-webui - Bareos Web-Frontend * * @link https://github.com/bareos/bareos-webui for the canonical source repository -* @copyright Copyright (c) 2013-2015 dass-IT GmbH (http://www.dass-it.de/) +* @copyright Copyright (c) 2013-2019 dass-IT GmbH (http://www.dass-it.de/) * @license GNU Affero General Public License (http://www.gnu.org/licenses/) * * This program is free software: you can redistribute it and/or modify @@ -32,59 +32,24 @@ class RestoreForm extends Form { protected $restore_params; - //protected $jobs; protected $clients; protected $filesets; protected $restorejobs; protected $jobids; protected $backups; - public function __construct($restore_params=null, /*$jobs=null,*/ $clients=null, $filesets=null, $restorejobs=null, $jobids=null, $backups=null) + public function __construct($restore_params=null, $clients=null, $filesets=null, $restorejobs=null, $jobids=null, $backups=null) { parent::__construct('restore'); $this->restore_params = $restore_params; - //$this->jobs = $jobs; $this->clients = $clients; $this->filesets = $filesets; $this->restorejobs = $restorejobs; $this->jobids = $jobids; $this->backups = $backups; -/* - // Job - if(isset($restore_params['jobid'])) { - $this->add(array( - 'name' => 'jobid', - 'type' => 'select', - 'options' => array( - 'label' => _('Job'), - 'empty_option' => _('Please choose a job'), - 'value_options' => $this->getJobList() - ), - 'attributes' => array( - 'id' => 'jobid', - 'value' => $restore_params['jobid'] - ) - )); - } - else { - $this->add(array( - 'name' => 'jobid', - 'type' => 'select', - 'options' => array( - 'label' => _('Job'), - 'empty_option' => _('Please choose a job'), - 'value_options' => $this->getJobList() - ), - 'attributes' => array( - 'id' => 'jobid' - ) - )); - } -*/ - // Backup jobs if(isset($restore_params['jobid'])) { $this->add(array( @@ -171,7 +136,7 @@ public function __construct($restore_params=null, /*$jobs=null,*/ $clients=null, 'class' => 'form-control selectpicker show-tick', 'data-live-search' => 'true', 'id' => 'client', - 'value' => '' //@array_pop($this->getClientList()) + 'value' => '' ) )); } @@ -478,115 +443,7 @@ public function __construct($restore_params=null, /*$jobs=null,*/ $clients=null, ) ); } -/* - // Path - if(isset($restore_params['path'])) { - $this->add(array( - 'name' => 'path', - 'type' => 'text', - 'options' => array( - 'label' => _('Path') - ), - 'attributes' => array( - 'class' => 'form-control', - 'id' => 'path', - 'size' => '15', - 'placeholder' => '/', - 'value' => $restore_params['path'] - ) - ) - ); - } - else { - $this->add(array( - 'name' => 'path', - 'type' => 'text', - 'options' => array( - 'label' => _('Path') - ), - 'attributes' => array( - 'class' => 'form-control', - 'id' => 'path', - 'size' => '15', - 'placeholder' => '/', - 'value' => '' - ) - ) - ); - } - // Limit - if(isset($restore_params['limit'])) { - $this->add(array( - 'name' => 'limit', - 'type' => 'text', - 'options' => array( - 'label' => _('Limit') - ), - 'attributes' => array( - 'class' => 'form-control', - 'id' => 'limit', - 'size' => '15', - 'placeholder' => 2000, - 'value' => $restore_params['limit'] - ) - ) - ); - } - else { - $this->add(array( - 'name' => 'limit', - 'type' => 'text', - 'options' => array( - 'label' => _('Limit') - ), - 'attributes' => array( - 'class' => 'form-control', - 'id' => 'limit', - 'size' => '15', - 'placeholder' => 2000, - 'value' => 2000 - ) - ) - ); - } - - // Offset - if(isset($restore_params['offset'])) { - $this->add(array( - 'name' => 'offset', - 'type' => 'text', - 'options' => array( - 'label' => _('Offset') - ), - 'attributes' => array( - 'class' => 'form-control', - 'id' => 'offset', - 'size' => '15', - 'placeholder' => 0, - 'value' => $restore_params['offset'] - ) - ) - ); - } - else { - $this->add(array( - 'name' => 'offset', - 'type' => 'text', - 'options' => array( - 'label' => _('Offset') - ), - 'attributes' => array( - 'class' => 'form-control', - 'id' => 'offset', - 'size' => '15', - 'placeholder' => 0, - 'value' => 0 - ) - ) - ); - } - */ // JobIds hidden $this->add(array( 'name' => 'jobids_hidden', diff --git a/webui/module/Restore/src/Restore/Model/RestoreModel.php b/webui/module/Restore/src/Restore/Model/RestoreModel.php index ce1b3b663b3..b66478bf377 100644 --- a/webui/module/Restore/src/Restore/Model/RestoreModel.php +++ b/webui/module/Restore/src/Restore/Model/RestoreModel.php @@ -258,12 +258,7 @@ public function updateBvfsCache(&$bsock=null, $jobid=null) public function restore(&$bsock=null, $type=null, $jobid=null, $client=null, $restoreclient=null, $restorejob=null, $where=null, $fileid=null, $dirid=null, $jobids=null, $replace=null) { if(isset($bsock, $type)) { - if($type == "client") { - $result = $bsock->restore($type, $jobid, $client, $restoreclient, $restorejob, $where, $fileid, $dirid, $jobids, $replace); - } - elseif($type == "job") { - // TODO - } + $result = $bsock->restore($type, $jobid, $client, $restoreclient, $restorejob, $where, $fileid, $dirid, $jobids, $replace); return $result; } else { diff --git a/webui/module/Restore/view/restore/restore/index.phtml b/webui/module/Restore/view/restore/restore/index.phtml index aa668a53d1e..951bcb3936d 100644 --- a/webui/module/Restore/view/restore/restore/index.phtml +++ b/webui/module/Restore/view/restore/restore/index.phtml @@ -150,21 +150,12 @@ $this->headTitle($title); echo '

'.$this->formRow($form->get('where')).'

'; echo '

'.$this->formRow($form->get('form-submit')).'

'; - //echo '

'; // Hidden fields echo $this->formRow($form->get('checked_files')); echo $this->formRow($form->get('checked_directories')); echo $this->formRow($form->get('jobids_hidden')); } - /* - elseif($this->restore_params['type'] == "job") { - echo $this->formRow($form->get('jobid')->setAttribute('class', 'form-control')); - echo $this->formRow($form->get('restoreclient')->setAttribute('class','form-control')); - echo $this->formRow($form->get('restorejob')->setAttribute('class','form-control')); - echo $this->formRow($form->get('where')->setAttribute('class','form-control')); - } - */ ?>