Skip to content

Commit

Permalink
webui: Cleanup restore controller, model, form and views
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed Aug 27, 2019
1 parent 23e8000 commit caf81b1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 175 deletions.
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -161,7 +149,6 @@ public function indexAction()
// Create the form
$form = new RestoreForm(
$this->restore_params,
//$jobs,
$clients,
$filesets,
$restorejobs,
Expand Down
149 changes: 3 additions & 146 deletions webui/module/Restore/src/Restore/Form/RestoreForm.php
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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' => ''
)
));
}
Expand Down Expand Up @@ -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',
Expand Down
7 changes: 1 addition & 6 deletions webui/module/Restore/src/Restore/Model/RestoreModel.php
Expand Up @@ -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 {
Expand Down
9 changes: 0 additions & 9 deletions webui/module/Restore/view/restore/restore/index.phtml
Expand Up @@ -150,21 +150,12 @@ $this->headTitle($title);
echo '<p>'.$this->formRow($form->get('where')).'</p>';

echo '<p>'.$this->formRow($form->get('form-submit')).'</p>';
//echo '<p><button id="btn-form-submit" class="btn btn-primary" type="button">Restore</button></p>';

// 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'));
}
*/
?>

</div>
Expand Down

0 comments on commit caf81b1

Please sign in to comment.