From 081ff47867124b64514fc5a2397d9dc5d9b95918 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Sun, 28 Sep 2014 10:56:44 +0200 Subject: [PATCH] baculum: Tweak end of lines (CF+LF => LF) --- gui/baculum/protected/Class/FileSetRecord.php | 56 ++-- gui/baculum/protected/Class/JobRecord.php | 104 +++---- gui/baculum/protected/Class/PoolRecord.php | 98 +++---- gui/baculum/protected/Class/VolumeRecord.php | 146 +++++----- .../Portlets/ClientConfiguration.php | 140 ++++----- gui/baculum/protected/Portlets/ClientList.php | 146 +++++----- gui/baculum/protected/Portlets/JobList.php | 232 +++++++-------- .../Portlets/JobRunConfiguration.php | 214 +++++++------- gui/baculum/protected/Portlets/JobRunList.php | 178 ++++++------ .../protected/Portlets/PoolConfiguration.php | 234 +++++++-------- gui/baculum/protected/Portlets/PoolList.php | 140 ++++----- .../Portlets/StorageConfiguration.php | 164 +++++------ .../protected/Portlets/StorageList.php | 136 ++++----- .../Portlets/VolumeConfiguration.php | 274 +++++++++--------- gui/baculum/protected/Portlets/VolumeList.php | 196 ++++++------- 15 files changed, 1229 insertions(+), 1229 deletions(-) diff --git a/gui/baculum/protected/Class/FileSetRecord.php b/gui/baculum/protected/Class/FileSetRecord.php index 841ab02fd3..a6adc1c1cf 100644 --- a/gui/baculum/protected/Class/FileSetRecord.php +++ b/gui/baculum/protected/Class/FileSetRecord.php @@ -1,32 +1,32 @@ - \ No newline at end of file diff --git a/gui/baculum/protected/Class/JobRecord.php b/gui/baculum/protected/Class/JobRecord.php index 7b4b746dfe..cd8acaf13b 100644 --- a/gui/baculum/protected/Class/JobRecord.php +++ b/gui/baculum/protected/Class/JobRecord.php @@ -1,56 +1,56 @@ - \ No newline at end of file diff --git a/gui/baculum/protected/Class/PoolRecord.php b/gui/baculum/protected/Class/PoolRecord.php index d6a146901b..61a66af8f7 100644 --- a/gui/baculum/protected/Class/PoolRecord.php +++ b/gui/baculum/protected/Class/PoolRecord.php @@ -1,53 +1,53 @@ - \ No newline at end of file diff --git a/gui/baculum/protected/Class/VolumeRecord.php b/gui/baculum/protected/Class/VolumeRecord.php index a28c4e88ab..45df3e2385 100644 --- a/gui/baculum/protected/Class/VolumeRecord.php +++ b/gui/baculum/protected/Class/VolumeRecord.php @@ -1,77 +1,77 @@ - \ No newline at end of file diff --git a/gui/baculum/protected/Portlets/ClientConfiguration.php b/gui/baculum/protected/Portlets/ClientConfiguration.php index e2a6c44beb..4d61010c47 100644 --- a/gui/baculum/protected/Portlets/ClientConfiguration.php +++ b/gui/baculum/protected/Portlets/ClientConfiguration.php @@ -1,75 +1,75 @@ -Status->setActionClass($this); - $this->Apply->setActionClass($this); - } - - public function configure($clientId) { - $clientdata = $this->Application->getModule('api')->get(array('clients', 'show', $clientId))->output; - $this->ShowClient->Text = implode(PHP_EOL, $clientdata); - $client = $this->Application->getModule('api')->get(array('clients', $clientId))->output; - $this->ClientName->Text = $client->name; - $this->ClientIdentifier->Text = $client->clientid; - $this->ClientDescription->Text = $client->uname; - $this->FileRetention->Text = intval($client->fileretention / 86400); // conversion to days - $this->JobRetention->Text = intval($client->jobretention / 86400); // conversion to days - $this->AutoPrune->Checked = $client->autoprune == 1; - } - - public function save($sender, $param) { - switch($sender->getParent()->ID) { - case $this->Status->ID: { - $status = $this->Application->getModule('api')->get(array('clients', 'status', $this->ClientIdentifier->Text))->output; - $this->ShowClient->Text = implode(PHP_EOL, $status); - break; - } - case $this->Apply->ID: { - if($this->JobRetentionValidator->IsValid === false || $this->FileRetentionValidator->IsValid === false) { - return false; - } - $client = array(); - $client['clientid'] = $this->ClientIdentifier->Text; - $client['fileretention'] = $this->FileRetention->Text * 86400; // conversion to seconds - $client['jobretention'] = $this->JobRetention->Text * 86400; // conversion to seconds - $client['autoprune'] = (integer)$this->AutoPrune->Checked; - $this->Application->getModule('api')->set(array('clients', $client['clientid']), $client); - break; - } - } - } - - public function fileRetentionValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->FileRetention->Text) && $this->FileRetention->Text >= 0; - $param->setIsValid($isValid); - } - + parent::onInit($param); + $this->Status->setActionClass($this); + $this->Apply->setActionClass($this); + } + + public function configure($clientId) { + $clientdata = $this->Application->getModule('api')->get(array('clients', 'show', $clientId))->output; + $this->ShowClient->Text = implode(PHP_EOL, $clientdata); + $client = $this->Application->getModule('api')->get(array('clients', $clientId))->output; + $this->ClientName->Text = $client->name; + $this->ClientIdentifier->Text = $client->clientid; + $this->ClientDescription->Text = $client->uname; + $this->FileRetention->Text = intval($client->fileretention / 86400); // conversion to days + $this->JobRetention->Text = intval($client->jobretention / 86400); // conversion to days + $this->AutoPrune->Checked = $client->autoprune == 1; + } + + public function save($sender, $param) { + switch($sender->getParent()->ID) { + case $this->Status->ID: { + $status = $this->Application->getModule('api')->get(array('clients', 'status', $this->ClientIdentifier->Text))->output; + $this->ShowClient->Text = implode(PHP_EOL, $status); + break; + } + case $this->Apply->ID: { + if($this->JobRetentionValidator->IsValid === false || $this->FileRetentionValidator->IsValid === false) { + return false; + } + $client = array(); + $client['clientid'] = $this->ClientIdentifier->Text; + $client['fileretention'] = $this->FileRetention->Text * 86400; // conversion to seconds + $client['jobretention'] = $this->JobRetention->Text * 86400; // conversion to seconds + $client['autoprune'] = (integer)$this->AutoPrune->Checked; + $this->Application->getModule('api')->set(array('clients', $client['clientid']), $client); + break; + } + } + } + + public function fileRetentionValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->FileRetention->Text) && $this->FileRetention->Text >= 0; + $param->setIsValid($isValid); + } + public function jobRetentionValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->JobRetention->Text) && $this->JobRetention->Text >= 0; + $isValid = preg_match('/^\d+$/', $this->JobRetention->Text) && $this->JobRetention->Text >= 0; $param->setIsValid($isValid); - } -} + } +} ?> \ No newline at end of file diff --git a/gui/baculum/protected/Portlets/ClientList.php b/gui/baculum/protected/Portlets/ClientList.php index 021c7a10b6..01c152b053 100644 --- a/gui/baculum/protected/Portlets/ClientList.php +++ b/gui/baculum/protected/Portlets/ClientList.php @@ -1,78 +1,78 @@ -prepareData(); - } - - public function setWindowTitle($param) { - $this->windowTitle = $param; - } - - public function prepareData($forceReload = false) { + parent::onLoad($param); + $this->prepareData(); + } + + public function setWindowTitle($param) { + $this->windowTitle = $param; + } + + public function prepareData($forceReload = false) { $allowedButtons = array('ClientBtn', 'ReloadClients'); - if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { - if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { - $params = $this->getUrlParams('clients', $this->getPage()->ClientWindow->ID); - $clients = $this->Application->getModule('api')->get($params); - $isDetailView = $_SESSION['view' . $this->getPage()->ClientWindow->ID] == 'details'; - $clientsList = $this->Application->getModule('misc')->objectToArray($clients->output); - $this->RepeaterShow->Visible = !$isDetailView; - $this->Repeater->DataSource = $isDetailView === false ? $clientsList : array(); - $this->Repeater->dataBind(); - $this->DataGridShow->Visible = $isDetailView; - $this->DataGrid->DataSource = $isDetailView === true ? $clientsList : array(); - $this->DataGrid->dataBind(); - } + if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { + if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { + $params = $this->getUrlParams('clients', $this->getPage()->ClientWindow->ID); + $clients = $this->Application->getModule('api')->get($params); + $isDetailView = $_SESSION['view' . $this->getPage()->ClientWindow->ID] == 'details'; + $clientsList = $this->Application->getModule('misc')->objectToArray($clients->output); + $this->RepeaterShow->Visible = !$isDetailView; + $this->Repeater->DataSource = $isDetailView === false ? $clientsList : array(); + $this->Repeater->dataBind(); + $this->DataGridShow->Visible = $isDetailView; + $this->DataGrid->DataSource = $isDetailView === true ? $clientsList : array(); + $this->DataGrid->dataBind(); + } } - } - - public function sortDataGrid($sender, $param) { - $params = $this->getUrlParams('clients', $this->getPage()->ClientWindow->ID); - $data = $this->Application->getModule('api')->get($params)->output; - $data = $this->Application->getModule('misc')->objectToArray($data); - $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); - $this->DataGrid->dataBind(); - } - - - public function setShowID($ShowID) { - $this->ShowID = $this->getMaster()->ShowID = $ShowID; - } - - public function getShowID() { - return $this->ShowID; - } - - public function configure($sender, $param) { - if($this->Page->IsCallBack) { - $this->getPage()->ClientConfiguration->configure($param->CallbackParameter); - } - } -} + } + + public function sortDataGrid($sender, $param) { + $params = $this->getUrlParams('clients', $this->getPage()->ClientWindow->ID); + $data = $this->Application->getModule('api')->get($params)->output; + $data = $this->Application->getModule('misc')->objectToArray($data); + $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); + $this->DataGrid->dataBind(); + } + + + public function setShowID($ShowID) { + $this->ShowID = $this->getMaster()->ShowID = $ShowID; + } + + public function getShowID() { + return $this->ShowID; + } + + public function configure($sender, $param) { + if($this->Page->IsCallBack) { + $this->getPage()->ClientConfiguration->configure($param->CallbackParameter); + } + } +} ?> \ No newline at end of file diff --git a/gui/baculum/protected/Portlets/JobList.php b/gui/baculum/protected/Portlets/JobList.php index 3ce0091d6e..484e92152c 100644 --- a/gui/baculum/protected/Portlets/JobList.php +++ b/gui/baculum/protected/Portlets/JobList.php @@ -1,121 +1,121 @@ - 'Backup', 'M' => 'Migrated', 'V' => 'Verify', 'R' => 'Restore', 'I' => 'Internal', 'D' => 'Admin', 'A' => 'Archive', 'C' => 'Copy', 'g' => 'Migration'); - - private $jobStates; - - public $jobLevels; - + + public $ShowID, $windowTitle; + + private $jobTypes = array('B' => 'Backup', 'M' => 'Migrated', 'V' => 'Verify', 'R' => 'Restore', 'I' => 'Internal', 'D' => 'Admin', 'A' => 'Archive', 'C' => 'Copy', 'g' => 'Migration'); + + private $jobStates; + + public $jobLevels; + public function onLoad($param) { - parent::onLoad($param); - $this->prepareData(); - $this->jobLevels = $this->Application->getModule('misc')->getJobLevels(); - } - - public function setWindowTitle($param) { - $this->windowTitle = $param; - } - + parent::onLoad($param); + $this->prepareData(); + $this->jobLevels = $this->Application->getModule('misc')->getJobLevels(); + } + + public function setWindowTitle($param) { + $this->windowTitle = $param; + } + public function getJobType($jobLetter) { return array_key_exists($jobLetter, $this->jobTypes) ? $this->jobTypes[$jobLetter] : null; - } - - public function getJobState($jobStateLetter) { - $jobstates = array( - 'C' => (object)array('value' => 'Created', 'description' =>'Created but not yet running'), - 'R' => (object)array('value' => 'Running', 'description' => 'Running'), - 'B' => (object)array('value' => 'Blocked', 'description' => 'Blocked'), - 'T' => (object)array('value' => 'Terminated', 'description' =>'Terminated normally'), - 'W' => (object)array('value' => 'Terminated with warnings', 'description' =>'Terminated normally with warnings'), - 'E' => (object)array('value' => 'Error', 'description' =>'Terminated in Error'), - 'e' => (object)array('value' => 'Non-fatal error', 'description' =>'Non-fatal error'), - 'f' => (object)array('value' => 'Fatal error', 'description' =>'Fatal error'), - 'D' => (object)array('value' => 'Verify', 'description' =>'Verify Differences'), - 'A' => (object)array('value' => 'Canceled by user', 'description' =>'Canceled by the user'), - 'I' => (object)array('value' => 'Incomplete', 'description' =>'Incomplete Job'), - 'F' => (object)array('value' => 'Waiting on FD', 'description' =>'Waiting on the File daemon'), - 'S' => (object)array('value' => 'Waiting on SD', 'description' =>'Waiting on the Storage daemon'), - 'm' => (object)array('value' => 'Waiting for new vol.', 'description' =>'Waiting for a new Volume to be mounted'), - 'M' => (object)array('value' => 'Waiting for mount', 'description' =>'Waiting for a Mount'), - 's' => (object)array('value' => 'Waiting for storage', 'description' =>'Waiting for Storage resource'), - 'j' => (object)array('value' => 'Waiting for job', 'description' =>'Waiting for Job resource'), - 'c' => (object)array('value' => 'Waiting for client', 'description' =>'Waiting for Client resource'), - 'd' => (object)array('value' => 'Waiting for Max. jobs', 'description' =>'Wating for Maximum jobs'), - 't' => (object)array('value' => 'Waiting for start', 'description' =>'Waiting for Start Time'), - 'p' => (object)array('value' => 'Waiting for higher priority', 'description' =>'Waiting for higher priority job to finish'), - 'i' => (object)array('value' => 'Batch insert', 'description' =>'Doing batch insert file records'), - 'a' => (object)array('value' => 'Despooling attributes', 'description' =>'SD despooling attributes'), - 'l' => (object)array('value' => 'Data despooling', 'description' =>'Doing data despooling'), - 'L' => (object)array('value' => 'Commiting data', 'description' =>'Committing data (last despool)') - ); - return array_key_exists($jobStateLetter, $jobstates) ? $jobstates[$jobStateLetter] : null; - } - - public function prepareData($forceReload = false) { - $allowedButtons = array('JobBtn', 'ReloadJobs', 'Run'); - if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { - if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { - $params = $this->getUrlParams('jobs', $this->getPage()->JobWindow->ID); - $jobs = $this->Application->getModule('api')->get($params); - $isDetailView = $_SESSION['view' . $this->getPage()->JobWindow->ID] == 'details'; - $this->RepeaterShow->Visible = !$isDetailView; - $this->Repeater->DataSource = $isDetailView == false ? $jobs->output : array(); - $this->Repeater->dataBind(); - $this->DataGridShow->Visible = $isDetailView; - $this->DataGrid->DataSource = $isDetailView === true ? $this->Application->getModule('misc')->objectToArray($jobs->output) : array(); - $this->DataGrid->dataBind(); - } - } - } - - public function sortDataGrid($sender, $param) { - $params = $this->getUrlParams('jobs', $this->getPage()->JobWindow->ID); - $data = $this->Application->getModule('api')->get($params)->output; - $data = $this->Application->getModule('misc')->objectToArray($data); - $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); - $this->DataGrid->dataBind(); - } - - public function setShowID($ShowID) { - $this->ShowID = $this->getMaster()->ShowID = $ShowID; - } - - public function getShowID() { - return $this->ShowID; - } - - public function configure($sender, $param) { - if($this->Page->IsCallBack) { - $this->getPage()->JobConfiguration->configure($param->CallbackParameter); - } - } -} + } + + public function getJobState($jobStateLetter) { + $jobstates = array( + 'C' => (object)array('value' => 'Created', 'description' =>'Created but not yet running'), + 'R' => (object)array('value' => 'Running', 'description' => 'Running'), + 'B' => (object)array('value' => 'Blocked', 'description' => 'Blocked'), + 'T' => (object)array('value' => 'Terminated', 'description' =>'Terminated normally'), + 'W' => (object)array('value' => 'Terminated with warnings', 'description' =>'Terminated normally with warnings'), + 'E' => (object)array('value' => 'Error', 'description' =>'Terminated in Error'), + 'e' => (object)array('value' => 'Non-fatal error', 'description' =>'Non-fatal error'), + 'f' => (object)array('value' => 'Fatal error', 'description' =>'Fatal error'), + 'D' => (object)array('value' => 'Verify', 'description' =>'Verify Differences'), + 'A' => (object)array('value' => 'Canceled by user', 'description' =>'Canceled by the user'), + 'I' => (object)array('value' => 'Incomplete', 'description' =>'Incomplete Job'), + 'F' => (object)array('value' => 'Waiting on FD', 'description' =>'Waiting on the File daemon'), + 'S' => (object)array('value' => 'Waiting on SD', 'description' =>'Waiting on the Storage daemon'), + 'm' => (object)array('value' => 'Waiting for new vol.', 'description' =>'Waiting for a new Volume to be mounted'), + 'M' => (object)array('value' => 'Waiting for mount', 'description' =>'Waiting for a Mount'), + 's' => (object)array('value' => 'Waiting for storage', 'description' =>'Waiting for Storage resource'), + 'j' => (object)array('value' => 'Waiting for job', 'description' =>'Waiting for Job resource'), + 'c' => (object)array('value' => 'Waiting for client', 'description' =>'Waiting for Client resource'), + 'd' => (object)array('value' => 'Waiting for Max. jobs', 'description' =>'Wating for Maximum jobs'), + 't' => (object)array('value' => 'Waiting for start', 'description' =>'Waiting for Start Time'), + 'p' => (object)array('value' => 'Waiting for higher priority', 'description' =>'Waiting for higher priority job to finish'), + 'i' => (object)array('value' => 'Batch insert', 'description' =>'Doing batch insert file records'), + 'a' => (object)array('value' => 'Despooling attributes', 'description' =>'SD despooling attributes'), + 'l' => (object)array('value' => 'Data despooling', 'description' =>'Doing data despooling'), + 'L' => (object)array('value' => 'Commiting data', 'description' =>'Committing data (last despool)') + ); + return array_key_exists($jobStateLetter, $jobstates) ? $jobstates[$jobStateLetter] : null; + } + + public function prepareData($forceReload = false) { + $allowedButtons = array('JobBtn', 'ReloadJobs', 'Run'); + if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { + if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { + $params = $this->getUrlParams('jobs', $this->getPage()->JobWindow->ID); + $jobs = $this->Application->getModule('api')->get($params); + $isDetailView = $_SESSION['view' . $this->getPage()->JobWindow->ID] == 'details'; + $this->RepeaterShow->Visible = !$isDetailView; + $this->Repeater->DataSource = $isDetailView == false ? $jobs->output : array(); + $this->Repeater->dataBind(); + $this->DataGridShow->Visible = $isDetailView; + $this->DataGrid->DataSource = $isDetailView === true ? $this->Application->getModule('misc')->objectToArray($jobs->output) : array(); + $this->DataGrid->dataBind(); + } + } + } + + public function sortDataGrid($sender, $param) { + $params = $this->getUrlParams('jobs', $this->getPage()->JobWindow->ID); + $data = $this->Application->getModule('api')->get($params)->output; + $data = $this->Application->getModule('misc')->objectToArray($data); + $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); + $this->DataGrid->dataBind(); + } + + public function setShowID($ShowID) { + $this->ShowID = $this->getMaster()->ShowID = $ShowID; + } + + public function getShowID() { + return $this->ShowID; + } + + public function configure($sender, $param) { + if($this->Page->IsCallBack) { + $this->getPage()->JobConfiguration->configure($param->CallbackParameter); + } + } +} ?> diff --git a/gui/baculum/protected/Portlets/JobRunConfiguration.php b/gui/baculum/protected/Portlets/JobRunConfiguration.php index ff8ef6f929..4797ef886e 100644 --- a/gui/baculum/protected/Portlets/JobRunConfiguration.php +++ b/gui/baculum/protected/Portlets/JobRunConfiguration.php @@ -1,112 +1,112 @@ -Run->setActionClass($this); - $this->Estimate->setActionClass($this); - } - - public function configure($jobname) { - $this->JobName->Text = $jobname; - $this->Estimation->Text = ''; - - $this->Level->dataSource = $this->Application->getModule('misc')->getJobLevels(); - $this->Level->dataBind(); - - $clients = $this->Application->getModule('api')->get(array('clients'))->output; - $clientsList = array(); - foreach($clients as $client) { - $clientsList[$client->clientid] = $client->name; - } - $this->Client->dataSource = $clientsList; - $this->Client->dataBind(); - - $filesetsAll = $this->Application->getModule('api')->get(array('filesets'))->output; - $filesetsList = array(); - foreach($filesetsAll as $director => $filesets) { - $filesetsList = array_merge($filesets, $filesetsList); - } - $this->FileSet->dataSource = array_combine($filesetsList, $filesetsList); - $this->FileSet->dataBind(); - - $pools = $this->Application->getModule('api')->get(array('pools'))->output; - $poolList = array(); - foreach($pools as $pool) { - $poolList[$pool->poolid] = $pool->name; - } - $this->Pool->dataSource = $poolList; - $this->Pool->dataBind(); - - $storages = $this->Application->getModule('api')->get(array('storages'))->output; - $storagesList = array(); - foreach($storages as $storage) { - $storagesList[$storage->storageid] = $storage->name; - } - $this->Storage->dataSource = $storagesList; - $this->Storage->dataBind(); - - $this->Priority->Text = self::DEFAULT_JOB_PRIORITY; - } - - public function save($sender, $param) { - switch($sender->getParent()->ID) { - case $this->Estimate->ID: { - $params = array(); - $params['name'] = $this->JobName->Text; - $params['level'] = $this->Level->SelectedValue; - $params['fileset'] = $this->FileSet->SelectedValue; - $params['clientid'] = $this->Client->SelectedValue; - $params['accurate'] = (integer)$this->Accurate->Checked; - var_dump($params); - $result = $this->Application->getModule('api')->create(array('jobs', 'estimate'), $params)->output; - $this->Estimation->Text = implode(PHP_EOL, $result); - break; - } - case $this->Run->ID: { - if($this->PriorityValidator->IsValid === false) { - return false; - } - $params = array(); - $params['name'] = $this->JobName->Text; - $params['level'] = $this->Level->SelectedValue; - $params['fileset'] = $this->FileSet->SelectedValue; - $params['clientid'] = $this->Client->SelectedValue; - $params['storageid'] = $this->Storage->SelectedValue; - $params['poolid'] = $this->Pool->SelectedValue; - $params['priority'] = $this->Priority->Text; - $result = $this->Application->getModule('api')->create(array('jobs', 'run'), $params)->output; - $this->Estimation->Text = implode(PHP_EOL, $result); - break; - } - } - } - + parent::onInit($param); + $this->Run->setActionClass($this); + $this->Estimate->setActionClass($this); + } + + public function configure($jobname) { + $this->JobName->Text = $jobname; + $this->Estimation->Text = ''; + + $this->Level->dataSource = $this->Application->getModule('misc')->getJobLevels(); + $this->Level->dataBind(); + + $clients = $this->Application->getModule('api')->get(array('clients'))->output; + $clientsList = array(); + foreach($clients as $client) { + $clientsList[$client->clientid] = $client->name; + } + $this->Client->dataSource = $clientsList; + $this->Client->dataBind(); + + $filesetsAll = $this->Application->getModule('api')->get(array('filesets'))->output; + $filesetsList = array(); + foreach($filesetsAll as $director => $filesets) { + $filesetsList = array_merge($filesets, $filesetsList); + } + $this->FileSet->dataSource = array_combine($filesetsList, $filesetsList); + $this->FileSet->dataBind(); + + $pools = $this->Application->getModule('api')->get(array('pools'))->output; + $poolList = array(); + foreach($pools as $pool) { + $poolList[$pool->poolid] = $pool->name; + } + $this->Pool->dataSource = $poolList; + $this->Pool->dataBind(); + + $storages = $this->Application->getModule('api')->get(array('storages'))->output; + $storagesList = array(); + foreach($storages as $storage) { + $storagesList[$storage->storageid] = $storage->name; + } + $this->Storage->dataSource = $storagesList; + $this->Storage->dataBind(); + + $this->Priority->Text = self::DEFAULT_JOB_PRIORITY; + } + + public function save($sender, $param) { + switch($sender->getParent()->ID) { + case $this->Estimate->ID: { + $params = array(); + $params['name'] = $this->JobName->Text; + $params['level'] = $this->Level->SelectedValue; + $params['fileset'] = $this->FileSet->SelectedValue; + $params['clientid'] = $this->Client->SelectedValue; + $params['accurate'] = (integer)$this->Accurate->Checked; + var_dump($params); + $result = $this->Application->getModule('api')->create(array('jobs', 'estimate'), $params)->output; + $this->Estimation->Text = implode(PHP_EOL, $result); + break; + } + case $this->Run->ID: { + if($this->PriorityValidator->IsValid === false) { + return false; + } + $params = array(); + $params['name'] = $this->JobName->Text; + $params['level'] = $this->Level->SelectedValue; + $params['fileset'] = $this->FileSet->SelectedValue; + $params['clientid'] = $this->Client->SelectedValue; + $params['storageid'] = $this->Storage->SelectedValue; + $params['poolid'] = $this->Pool->SelectedValue; + $params['priority'] = $this->Priority->Text; + $result = $this->Application->getModule('api')->create(array('jobs', 'run'), $params)->output; + $this->Estimation->Text = implode(PHP_EOL, $result); + break; + } + } + } + public function priorityValidator($sender, $param) { - $isValid = preg_match('/^[0-9]+$/', $this->Priority->Text) === 1 && $this->Priority->Text > 0; + $isValid = preg_match('/^[0-9]+$/', $this->Priority->Text) === 1 && $this->Priority->Text > 0; $param->setIsValid($isValid); - } -} + } +} ?> \ No newline at end of file diff --git a/gui/baculum/protected/Portlets/JobRunList.php b/gui/baculum/protected/Portlets/JobRunList.php index c0af626398..307c4e9297 100644 --- a/gui/baculum/protected/Portlets/JobRunList.php +++ b/gui/baculum/protected/Portlets/JobRunList.php @@ -1,94 +1,94 @@ - 'Backup', 'M' => 'Migrated', 'V' => 'Verify', 'R' => 'Restore', 'I' => 'Internal', 'D' => 'Admin', 'A' => 'Archive', 'C' => 'Copy', 'g' => 'Migration'); - - private $jobStates; - + + public $ShowID, $windowTitle, $oldDirector; + + private $jobTypes = array('B' => 'Backup', 'M' => 'Migrated', 'V' => 'Verify', 'R' => 'Restore', 'I' => 'Internal', 'D' => 'Admin', 'A' => 'Archive', 'C' => 'Copy', 'g' => 'Migration'); + + private $jobStates; + public function onLoad($param) { - parent::onLoad($param); - $this->prepareData(); - } - - public function setWindowTitle($param) { - $this->windowTitle = $param; - } - - public function prepareData($forceReload = false) { - $allowedButtons = array('JobRunBtn'); - if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { - if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { - $params = $this->getUrlParams(array('jobs', 'tasks'), $this->getPage()->JobRunWindow->ID); - $jobTasks = $this->Application->getModule('api')->get($params)->output; - $jobs = $this->prepareJobs($jobTasks); - $isDetailView = $_SESSION['view' . $this->getPage()->JobRunWindow->ID] == 'details'; - $this->RepeaterShow->Visible = !$isDetailView; - $this->Repeater->DataSource = $isDetailView === false ? $jobs : array(); - $this->Repeater->dataBind(); - $this->DataGridShow->Visible = $isDetailView; - $this->DataGrid->DataSource = $isDetailView === true ? $jobs : array(); - $this->DataGrid->dataBind(); - } - } - } - + parent::onLoad($param); + $this->prepareData(); + } + + public function setWindowTitle($param) { + $this->windowTitle = $param; + } + + public function prepareData($forceReload = false) { + $allowedButtons = array('JobRunBtn'); + if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { + if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { + $params = $this->getUrlParams(array('jobs', 'tasks'), $this->getPage()->JobRunWindow->ID); + $jobTasks = $this->Application->getModule('api')->get($params)->output; + $jobs = $this->prepareJobs($jobTasks); + $isDetailView = $_SESSION['view' . $this->getPage()->JobRunWindow->ID] == 'details'; + $this->RepeaterShow->Visible = !$isDetailView; + $this->Repeater->DataSource = $isDetailView === false ? $jobs : array(); + $this->Repeater->dataBind(); + $this->DataGridShow->Visible = $isDetailView; + $this->DataGrid->DataSource = $isDetailView === true ? $jobs : array(); + $this->DataGrid->dataBind(); + } + } + } + private function prepareJobs($jobTasks) { - $jobs = array(); - foreach($jobTasks as $director => $tasks) { - for($i = 0; $i < count($tasks); $i++) { - $jobs[] = array('name' => $tasks[$i], 'director' => $director); - } - } + $jobs = array(); + foreach($jobTasks as $director => $tasks) { + for($i = 0; $i < count($tasks); $i++) { + $jobs[] = array('name' => $tasks[$i], 'director' => $director); + } + } return $jobs; - } - - public function sortDataGrid($sender, $param) { - $params = $this->getUrlParams(array('jobs', 'tasks'), $this->getPage()->JobRunWindow->ID); - $data = $this->Application->getModule('api')->get($params)->output; - $data = $this->prepareJobs($data); - $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); - $this->DataGrid->dataBind(); - } - - public function setShowID($ShowID) { - $this->ShowID = $this->getMaster()->ShowID = $ShowID; - } - - public function getShowID() { - return $this->ShowID; - } - - public function configure($sender, $param) { - if($this->Page->IsCallBack) { - $this->getPage()->JobRunConfiguration->configure($param->CallbackParameter); - } - } -} + } + + public function sortDataGrid($sender, $param) { + $params = $this->getUrlParams(array('jobs', 'tasks'), $this->getPage()->JobRunWindow->ID); + $data = $this->Application->getModule('api')->get($params)->output; + $data = $this->prepareJobs($data); + $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); + $this->DataGrid->dataBind(); + } + + public function setShowID($ShowID) { + $this->ShowID = $this->getMaster()->ShowID = $ShowID; + } + + public function getShowID() { + return $this->ShowID; + } + + public function configure($sender, $param) { + if($this->Page->IsCallBack) { + $this->getPage()->JobRunConfiguration->configure($param->CallbackParameter); + } + } +} ?> diff --git a/gui/baculum/protected/Portlets/PoolConfiguration.php b/gui/baculum/protected/Portlets/PoolConfiguration.php index ecf608cf26..12ec4d8e10 100644 --- a/gui/baculum/protected/Portlets/PoolConfiguration.php +++ b/gui/baculum/protected/Portlets/PoolConfiguration.php @@ -1,120 +1,120 @@ -Apply->setActionClass($this); - $this->RestoreConfiguration->setActionClass($this); - $this->UpdateVolumes->setActionClass($this); - } - - public function configure($poolId) { - $pooldata = $this->Application->getModule('api')->get(array('pools', $poolId))->output; - $this->PoolName->Text = $pooldata->name; - $this->PoolID->Text = $pooldata->poolid; - $this->Enabled->Checked = $pooldata->enabled == 1; - $this->MaxVolumes->Text = $pooldata->maxvols; - $this->MaxVolJobs->Text = $pooldata->maxvoljobs; - $this->MaxVolBytes->Text = $pooldata->maxvolbytes; - $this->UseDuration->Text = intval($pooldata->voluseduration / 3600); // conversion to hours; - $this->RetentionPeriod->Text = intval($pooldata->volretention / 3600); // conversion to hours; - $this->LabelFormat->Text = $pooldata->labelformat; - $pools = $this->Application->getModule('api')->get(array('pools'))->output; - $poolList = array('none' => Prado::localize('select pool')); - foreach($pools as $pool) { - $poolList[$pool->poolid] = $pool->name; - } - $this->ScratchPool->dataSource = $poolList; - $this->ScratchPool->SelectedValue = $pooldata->scratchpoolid; - $this->ScratchPool->dataBind(); - $this->RecyclePool->dataSource = $poolList; - $this->RecyclePool->SelectedValue = $pooldata->recyclepoolid; - $this->RecyclePool->dataBind(); - $this->Recycle->Checked = $pooldata->recycle == 1; - $this->AutoPrune->Checked = $pooldata->autoprune == 1; - $this->ActionOnPurge->Checked = $pooldata->actiononpurge == 1; - } - - public function save($sender, $param) { - if(($sender->getParent()->ID == $this->Apply->ID) || ($sender->getParent()->ID == $this->UpdateVolumes->ID)) { - if($this->MaxVolumesValidator->IsValid === false || $this->MaxVolJobsValidator->IsValid === false || $this->MaxVolBytesValidator->IsValid === false || $this->UseDurationValidator->IsValid === false || $this->RetentionPeriodValidator->IsValid === false || $this->LabelFormatValidator->IsValid === false) { - return false; - } - $pooldata = array(); - $pooldata['poolid'] = $this->PoolID->Text; - $pooldata['enabled'] = (integer)$this->Enabled->Checked; - $pooldata['maxvols'] = $this->MaxVolumes->Text; - $pooldata['maxvoljobs'] = $this->MaxVolJobs->Text; - $pooldata['maxvolbytes'] = $this->MaxVolBytes->Text; - $pooldata['voluseduration'] = $this->UseDuration->Text * 3600; // conversion to seconds - $pooldata['volretention'] = $this->RetentionPeriod->Text * 3600; // conversion to seconds - $pooldata['labelformat'] = $this->LabelFormat->Text; - $pooldata['scratchpoolid'] = (integer)$this->ScratchPool->SelectedValue; - $pooldata['recyclepoolid'] = (integer)$this->RecyclePool->SelectedValue; - $pooldata['recycle'] = (integer)$this->Recycle->Checked; - $pooldata['autoprune'] = (integer)$this->AutoPrune->Checked; - $pooldata['actiononpurge'] = (integer)$this->ActionOnPurge->Checked; - $this->Application->getModule('api')->set(array('pools', $this->PoolID->Text), $pooldata); - if($sender->getParent()->ID == $this->UpdateVolumes->ID) { - $this->Application->getModule('api')->set(array('pools', 'update', 'volumes', $this->PoolID->Text), array('')); - } - } elseif($sender->getParent()->ID == $this->RestoreConfiguration->ID) { - $this->Application->getModule('api')->set(array('pools', 'update', $this->PoolID->Text), array('')); - //@TOFIX $this->configure($this->PoolID->Text); - } - } - - public function maxVolumesValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->MaxVolumes->Text) && $this->MaxVolumes->Text >= 0; - $param->setIsValid($isValid); - } - - public function maxVolJobsValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->MaxVolJobs->Text) && $this->MaxVolJobs->Text >= 0; - $param->setIsValid($isValid); - } - - public function maxVolBytesValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->MaxVolBytes->Text) && $this->MaxVolBytes->Text >= 0; - $param->setIsValid($isValid); - } - - public function useDurationValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->UseDuration->Text) && $this->UseDuration->Text >= 0; - $param->setIsValid($isValid); - } - - public function retentionPeriodValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->RetentionPeriod->Text) && $this->RetentionPeriod->Text >= 0; - $param->setIsValid($isValid); - } - - public function labelFormatValidator($sender, $param) { - $value = trim($this->LabelFormat->Text); - $isValid = !empty($value); - $param->setIsValid($isValid); - } -} + parent::onInit($param); + $this->Apply->setActionClass($this); + $this->RestoreConfiguration->setActionClass($this); + $this->UpdateVolumes->setActionClass($this); + } + + public function configure($poolId) { + $pooldata = $this->Application->getModule('api')->get(array('pools', $poolId))->output; + $this->PoolName->Text = $pooldata->name; + $this->PoolID->Text = $pooldata->poolid; + $this->Enabled->Checked = $pooldata->enabled == 1; + $this->MaxVolumes->Text = $pooldata->maxvols; + $this->MaxVolJobs->Text = $pooldata->maxvoljobs; + $this->MaxVolBytes->Text = $pooldata->maxvolbytes; + $this->UseDuration->Text = intval($pooldata->voluseduration / 3600); // conversion to hours; + $this->RetentionPeriod->Text = intval($pooldata->volretention / 3600); // conversion to hours; + $this->LabelFormat->Text = $pooldata->labelformat; + $pools = $this->Application->getModule('api')->get(array('pools'))->output; + $poolList = array('none' => Prado::localize('select pool')); + foreach($pools as $pool) { + $poolList[$pool->poolid] = $pool->name; + } + $this->ScratchPool->dataSource = $poolList; + $this->ScratchPool->SelectedValue = $pooldata->scratchpoolid; + $this->ScratchPool->dataBind(); + $this->RecyclePool->dataSource = $poolList; + $this->RecyclePool->SelectedValue = $pooldata->recyclepoolid; + $this->RecyclePool->dataBind(); + $this->Recycle->Checked = $pooldata->recycle == 1; + $this->AutoPrune->Checked = $pooldata->autoprune == 1; + $this->ActionOnPurge->Checked = $pooldata->actiononpurge == 1; + } + + public function save($sender, $param) { + if(($sender->getParent()->ID == $this->Apply->ID) || ($sender->getParent()->ID == $this->UpdateVolumes->ID)) { + if($this->MaxVolumesValidator->IsValid === false || $this->MaxVolJobsValidator->IsValid === false || $this->MaxVolBytesValidator->IsValid === false || $this->UseDurationValidator->IsValid === false || $this->RetentionPeriodValidator->IsValid === false || $this->LabelFormatValidator->IsValid === false) { + return false; + } + $pooldata = array(); + $pooldata['poolid'] = $this->PoolID->Text; + $pooldata['enabled'] = (integer)$this->Enabled->Checked; + $pooldata['maxvols'] = $this->MaxVolumes->Text; + $pooldata['maxvoljobs'] = $this->MaxVolJobs->Text; + $pooldata['maxvolbytes'] = $this->MaxVolBytes->Text; + $pooldata['voluseduration'] = $this->UseDuration->Text * 3600; // conversion to seconds + $pooldata['volretention'] = $this->RetentionPeriod->Text * 3600; // conversion to seconds + $pooldata['labelformat'] = $this->LabelFormat->Text; + $pooldata['scratchpoolid'] = (integer)$this->ScratchPool->SelectedValue; + $pooldata['recyclepoolid'] = (integer)$this->RecyclePool->SelectedValue; + $pooldata['recycle'] = (integer)$this->Recycle->Checked; + $pooldata['autoprune'] = (integer)$this->AutoPrune->Checked; + $pooldata['actiononpurge'] = (integer)$this->ActionOnPurge->Checked; + $this->Application->getModule('api')->set(array('pools', $this->PoolID->Text), $pooldata); + if($sender->getParent()->ID == $this->UpdateVolumes->ID) { + $this->Application->getModule('api')->set(array('pools', 'update', 'volumes', $this->PoolID->Text), array('')); + } + } elseif($sender->getParent()->ID == $this->RestoreConfiguration->ID) { + $this->Application->getModule('api')->set(array('pools', 'update', $this->PoolID->Text), array('')); + //@TOFIX $this->configure($this->PoolID->Text); + } + } + + public function maxVolumesValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->MaxVolumes->Text) && $this->MaxVolumes->Text >= 0; + $param->setIsValid($isValid); + } + + public function maxVolJobsValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->MaxVolJobs->Text) && $this->MaxVolJobs->Text >= 0; + $param->setIsValid($isValid); + } + + public function maxVolBytesValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->MaxVolBytes->Text) && $this->MaxVolBytes->Text >= 0; + $param->setIsValid($isValid); + } + + public function useDurationValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->UseDuration->Text) && $this->UseDuration->Text >= 0; + $param->setIsValid($isValid); + } + + public function retentionPeriodValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->RetentionPeriod->Text) && $this->RetentionPeriod->Text >= 0; + $param->setIsValid($isValid); + } + + public function labelFormatValidator($sender, $param) { + $value = trim($this->LabelFormat->Text); + $isValid = !empty($value); + $param->setIsValid($isValid); + } +} ?> \ No newline at end of file diff --git a/gui/baculum/protected/Portlets/PoolList.php b/gui/baculum/protected/Portlets/PoolList.php index 240e63ca51..98d5147798 100644 --- a/gui/baculum/protected/Portlets/PoolList.php +++ b/gui/baculum/protected/Portlets/PoolList.php @@ -1,75 +1,75 @@ -prepareData(); - } - - public function setWindowTitle($param) { - $this->windowTitle = $param; - } - + parent::onLoad($param); + $this->prepareData(); + } + + public function setWindowTitle($param) { + $this->windowTitle = $param; + } + public function prepareData($forceReload = false) { - $allowedButtons = array('PoolBtn', 'ReloadPools'); - if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { - if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { - $params = $this->getUrlParams('pools', $this->getPage()->PoolWindow->ID); - $pools = $this->Application->getModule('api')->get($params); - $isDetailView = $_SESSION['view' . $this->getPage()->PoolWindow->ID] == 'details'; - $this->RepeaterShow->Visible = !$isDetailView; - $this->Repeater->DataSource = $isDetailView === false ? $pools->output : array(); - $this->Repeater->dataBind(); - $this->DataGridShow->Visible = $isDetailView; - $this->DataGrid->DataSource = $isDetailView === true ? $this->Application->getModule('misc')->objectToArray($pools->output) : array(); - $this->DataGrid->dataBind(); - } + $allowedButtons = array('PoolBtn', 'ReloadPools'); + if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { + if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { + $params = $this->getUrlParams('pools', $this->getPage()->PoolWindow->ID); + $pools = $this->Application->getModule('api')->get($params); + $isDetailView = $_SESSION['view' . $this->getPage()->PoolWindow->ID] == 'details'; + $this->RepeaterShow->Visible = !$isDetailView; + $this->Repeater->DataSource = $isDetailView === false ? $pools->output : array(); + $this->Repeater->dataBind(); + $this->DataGridShow->Visible = $isDetailView; + $this->DataGrid->DataSource = $isDetailView === true ? $this->Application->getModule('misc')->objectToArray($pools->output) : array(); + $this->DataGrid->dataBind(); + } } - } - - public function sortDataGrid($sender, $param) { - $params = $this->getUrlParams('pools', $this->getPage()->PoolWindow->ID); - $data = $this->Application->getModule('api')->get($params)->output; - $data = $this->Application->getModule('misc')->objectToArray($data); - $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); - $this->DataGrid->dataBind(); - } - - public function setShowID($ShowID) { - $this->ShowID = $this->getMaster()->ShowID = $ShowID; - } - - public function getShowID() { - return $this->ShowID; - } - - public function configure($sender, $param) { - if($this->Page->IsCallBack) { - $this->getPage()->PoolConfiguration->configure($param->CallbackParameter); - } - } -} + } + + public function sortDataGrid($sender, $param) { + $params = $this->getUrlParams('pools', $this->getPage()->PoolWindow->ID); + $data = $this->Application->getModule('api')->get($params)->output; + $data = $this->Application->getModule('misc')->objectToArray($data); + $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); + $this->DataGrid->dataBind(); + } + + public function setShowID($ShowID) { + $this->ShowID = $this->getMaster()->ShowID = $ShowID; + } + + public function getShowID() { + return $this->ShowID; + } + + public function configure($sender, $param) { + if($this->Page->IsCallBack) { + $this->getPage()->PoolConfiguration->configure($param->CallbackParameter); + } + } +} ?> \ No newline at end of file diff --git a/gui/baculum/protected/Portlets/StorageConfiguration.php b/gui/baculum/protected/Portlets/StorageConfiguration.php index ae9eb7b6da..32656c1bac 100644 --- a/gui/baculum/protected/Portlets/StorageConfiguration.php +++ b/gui/baculum/protected/Portlets/StorageConfiguration.php @@ -1,87 +1,87 @@ -Mount->setActionClass($this); - $this->Release->setActionClass($this); - $this->Umount->setActionClass($this); - $this->Status->setActionClass($this); - } - - public function configure($storageId) { - $storagedata = $this->Application->getModule('api')->get(array('storages', 'show', $storageId))->output; - $this->ShowStorage->Text = implode(PHP_EOL, $storagedata); - $storage = $this->Application->getModule('api')->get(array('storages', $storageId))->output; - $this->StorageName->Text = $storage->name; - $this->StorageID->Text = $storage->storageid; - $this->AutoChanger->Visible = (boolean)$storage->autochanger; - } - - public function save($sender, $param) { - $isValid = $this->DriveValidator->IsValid === true && $this->SlotValidator->IsValid === true; - switch($sender->getParent()->ID) { - case $this->Status->ID: { - $status = $this->Application->getModule('api')->get(array('storages', 'status', $this->StorageID->Text))->output; - $this->ShowStorage->Text = implode(PHP_EOL, $status); - break; - } - case $this->Mount->ID: { - if($isValid === false) { - return; - } - $drive = ($this->AutoChanger->Visible === true) ? intval($this->Drive->Text) : 0; - $slot = ($this->AutoChanger->Visible === true) ? intval($this->Slot->Text) : 0; - $mount = $this->Application->getModule('api')->get(array('storages', 'mount', $this->StorageID->Text, $drive, $slot))->output; - $this->ShowStorage->Text = implode(PHP_EOL, $mount); - break; - } - case $this->Umount->ID: { - if($isValid === false) { - return; - } - $drive = ($this->AutoChanger->Visible === true) ? intval($this->Drive->Text) : 0; - $umount = $this->Application->getModule('api')->get(array('storages', 'umount', $this->StorageID->Text, $drive))->output; - $this->ShowStorage->Text = implode(PHP_EOL, $umount); - break; - } - case $this->Release->ID: { - $release = $this->Application->getModule('api')->get(array('storages', 'release', $this->StorageID->Text))->output; - $this->ShowStorage->Text = implode(PHP_EOL, $release); - break; - } - } - } - - public function driveValidator($sender, $param) { + parent::onInit($param); + $this->Mount->setActionClass($this); + $this->Release->setActionClass($this); + $this->Umount->setActionClass($this); + $this->Status->setActionClass($this); + } + + public function configure($storageId) { + $storagedata = $this->Application->getModule('api')->get(array('storages', 'show', $storageId))->output; + $this->ShowStorage->Text = implode(PHP_EOL, $storagedata); + $storage = $this->Application->getModule('api')->get(array('storages', $storageId))->output; + $this->StorageName->Text = $storage->name; + $this->StorageID->Text = $storage->storageid; + $this->AutoChanger->Visible = (boolean)$storage->autochanger; + } + + public function save($sender, $param) { + $isValid = $this->DriveValidator->IsValid === true && $this->SlotValidator->IsValid === true; + switch($sender->getParent()->ID) { + case $this->Status->ID: { + $status = $this->Application->getModule('api')->get(array('storages', 'status', $this->StorageID->Text))->output; + $this->ShowStorage->Text = implode(PHP_EOL, $status); + break; + } + case $this->Mount->ID: { + if($isValid === false) { + return; + } + $drive = ($this->AutoChanger->Visible === true) ? intval($this->Drive->Text) : 0; + $slot = ($this->AutoChanger->Visible === true) ? intval($this->Slot->Text) : 0; + $mount = $this->Application->getModule('api')->get(array('storages', 'mount', $this->StorageID->Text, $drive, $slot))->output; + $this->ShowStorage->Text = implode(PHP_EOL, $mount); + break; + } + case $this->Umount->ID: { + if($isValid === false) { + return; + } + $drive = ($this->AutoChanger->Visible === true) ? intval($this->Drive->Text) : 0; + $umount = $this->Application->getModule('api')->get(array('storages', 'umount', $this->StorageID->Text, $drive))->output; + $this->ShowStorage->Text = implode(PHP_EOL, $umount); + break; + } + case $this->Release->ID: { + $release = $this->Application->getModule('api')->get(array('storages', 'release', $this->StorageID->Text))->output; + $this->ShowStorage->Text = implode(PHP_EOL, $release); + break; + } + } + } + + public function driveValidator($sender, $param) { $isValid = is_numeric($this->Drive->Text); $param->setIsValid($isValid); - } - - public function slotValidator($sender, $param) { - $isValid = is_numeric($this->Slot->Text); - $param->setIsValid($isValid); - } -} + } + + public function slotValidator($sender, $param) { + $isValid = is_numeric($this->Slot->Text); + $param->setIsValid($isValid); + } +} ?> \ No newline at end of file diff --git a/gui/baculum/protected/Portlets/StorageList.php b/gui/baculum/protected/Portlets/StorageList.php index 14c2309ad4..33050d93fb 100644 --- a/gui/baculum/protected/Portlets/StorageList.php +++ b/gui/baculum/protected/Portlets/StorageList.php @@ -1,75 +1,75 @@ -prepareData(); - } - + parent::onLoad($param); + $this->prepareData(); + } + public function setWindowTitle($param) { $this->windowTitle = $param; - } - + } + public function prepareData($forceReload = false) { - $allowedButtons = array('StorageBtn'); - if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { - if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { - $params = $this->getUrlParams('storages', $this->getPage()->StorageWindow->ID); - $storages = $this->Application->getModule('api')->get($params); - $isDetailView = $_SESSION['view' . $this->getPage()->StorageWindow->ID] == 'details'; - $this->RepeaterShow->Visible = !$isDetailView; - $this->Repeater->DataSource = $isDetailView === false ? $storages->output : array(); - $this->Repeater->dataBind(); - $this->DataGridShow->Visible = $isDetailView; - $this->DataGrid->DataSource = $isDetailView === true ? $this->Application->getModule('misc')->objectToArray($storages->output) : array(); - $this->DataGrid->dataBind(); - } + $allowedButtons = array('StorageBtn'); + if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { + if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { + $params = $this->getUrlParams('storages', $this->getPage()->StorageWindow->ID); + $storages = $this->Application->getModule('api')->get($params); + $isDetailView = $_SESSION['view' . $this->getPage()->StorageWindow->ID] == 'details'; + $this->RepeaterShow->Visible = !$isDetailView; + $this->Repeater->DataSource = $isDetailView === false ? $storages->output : array(); + $this->Repeater->dataBind(); + $this->DataGridShow->Visible = $isDetailView; + $this->DataGrid->DataSource = $isDetailView === true ? $this->Application->getModule('misc')->objectToArray($storages->output) : array(); + $this->DataGrid->dataBind(); + } } - } - - public function sortDataGrid($sender, $param) { - $params = $this->getUrlParams('storages', $this->getPage()->StorageWindow->ID); - $data = $this->Application->getModule('api')->get($params)->output; - $data = $this->Application->getModule('misc')->objectToArray($data); - $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); - $this->DataGrid->dataBind(); - } - - public function setShowID($ShowID) { - $this->ShowID = $this->getMaster()->ShowID = $ShowID; - } - - public function getShowID() { - return $this->ShowID; - } - - public function configure($sender, $param) { - if($this->Page->IsCallBack) { - $this->getPage()->StorageConfiguration->configure($param->CallbackParameter); - } - } -} + } + + public function sortDataGrid($sender, $param) { + $params = $this->getUrlParams('storages', $this->getPage()->StorageWindow->ID); + $data = $this->Application->getModule('api')->get($params)->output; + $data = $this->Application->getModule('misc')->objectToArray($data); + $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); + $this->DataGrid->dataBind(); + } + + public function setShowID($ShowID) { + $this->ShowID = $this->getMaster()->ShowID = $ShowID; + } + + public function getShowID() { + return $this->ShowID; + } + + public function configure($sender, $param) { + if($this->Page->IsCallBack) { + $this->getPage()->StorageConfiguration->configure($param->CallbackParameter); + } + } +} ?> diff --git a/gui/baculum/protected/Portlets/VolumeConfiguration.php b/gui/baculum/protected/Portlets/VolumeConfiguration.php index 0cb702a562..4c2aae8c53 100644 --- a/gui/baculum/protected/Portlets/VolumeConfiguration.php +++ b/gui/baculum/protected/Portlets/VolumeConfiguration.php @@ -1,143 +1,143 @@ -Apply->setActionClass($this); - $this->Prune->setActionClass($this); - $this->Purge->setActionClass($this); - } - - public function configure($mediaId) { - $voldata = $this->Application->getModule('api')->get(array('volumes', $mediaId))->output; - $this->VolumeID->Text = $voldata->mediaid; - $this->VolumeName->Text = $voldata->volumename; - $volstates = $this->getVolumeStates(true); - if (!in_array($voldata->volstatus, $volstates)) { - array_push($volstates, $voldata->volstatus); - } - $volstatesSelect = array(); - for($i = 0; $i < count($volstates); $i++) { - $volstatesSelect[$volstates[$i]] = $volstates[$i]; - } - $this->VolumeStatus->DataSource = $volstatesSelect; - $this->VolumeStatus->SelectedValue = $voldata->volstatus; - $this->VolumeStatus->dataBind(); - $this->RetentionPeriod->Text = intval($voldata->volretention / 3600); // conversion to hours - $this->UseDuration->Text = intval($voldata->voluseduration / 3600); // conversion to hours - $this->MaxVolJobs->Text = $voldata->maxvoljobs; - $this->MaxVolFiles->Text = $voldata->maxvolfiles; - $this->MaxVolBytes->Text = $voldata->maxvolbytes; - $this->Slot->Text = $voldata->slot; - $this->Recycle->Checked = ($voldata->recycle == 1); - $this->Enabled->Checked = ($voldata->enabled == 1); - $this->InChanger->Checked = ($voldata->inchanger == 1); - $pools = $this->Application->getModule('api')->get(array('pools'))->output; - $poolList = array(); - foreach($pools as $pool) { - $poolList[$pool->poolid] = $pool->name; - } - $this->Pool->dataSource = $poolList; - $this->Pool->SelectedValue = $voldata->poolid; - $this->Pool->dataBind(); - } - - public function save($sender, $param) { - switch($sender->getParent()->ID) { - case $this->Apply->ID: { + parent::onInit($param); + $this->Apply->setActionClass($this); + $this->Prune->setActionClass($this); + $this->Purge->setActionClass($this); + } + + public function configure($mediaId) { + $voldata = $this->Application->getModule('api')->get(array('volumes', $mediaId))->output; + $this->VolumeID->Text = $voldata->mediaid; + $this->VolumeName->Text = $voldata->volumename; + $volstates = $this->getVolumeStates(true); + if (!in_array($voldata->volstatus, $volstates)) { + array_push($volstates, $voldata->volstatus); + } + $volstatesSelect = array(); + for($i = 0; $i < count($volstates); $i++) { + $volstatesSelect[$volstates[$i]] = $volstates[$i]; + } + $this->VolumeStatus->DataSource = $volstatesSelect; + $this->VolumeStatus->SelectedValue = $voldata->volstatus; + $this->VolumeStatus->dataBind(); + $this->RetentionPeriod->Text = intval($voldata->volretention / 3600); // conversion to hours + $this->UseDuration->Text = intval($voldata->voluseduration / 3600); // conversion to hours + $this->MaxVolJobs->Text = $voldata->maxvoljobs; + $this->MaxVolFiles->Text = $voldata->maxvolfiles; + $this->MaxVolBytes->Text = $voldata->maxvolbytes; + $this->Slot->Text = $voldata->slot; + $this->Recycle->Checked = ($voldata->recycle == 1); + $this->Enabled->Checked = ($voldata->enabled == 1); + $this->InChanger->Checked = ($voldata->inchanger == 1); + $pools = $this->Application->getModule('api')->get(array('pools'))->output; + $poolList = array(); + foreach($pools as $pool) { + $poolList[$pool->poolid] = $pool->name; + } + $this->Pool->dataSource = $poolList; + $this->Pool->SelectedValue = $voldata->poolid; + $this->Pool->dataBind(); + } + + public function save($sender, $param) { + switch($sender->getParent()->ID) { + case $this->Apply->ID: { $isInvalid = $this->RetentionPeriodValidator->IsValid === false || $this->UseDurationValidator->IsValid === false || $this->MaxVolJobsValidator->IsValid === false || $this->MaxVolFilesValidator->IsValid === false || $this->MaxVolBytesValidator->IsValid === false || $this->SlotValidator->IsValid === false; - if($isInvalid) { - return false; - } - $voldata = array(); - $voldata['mediaid'] = $this->VolumeID->Text; - $voldata['volstatus'] = $this->VolumeStatus->SelectedValue; - $voldata['poolid'] = $this->Pool->SelectedValue; - $voldata['volretention'] = $this->RetentionPeriod->Text * 3600; // conversion to seconds - $voldata['voluseduration'] = $this->UseDuration->Text * 3600; // conversion to seconds - $voldata['maxvoljobs'] = $this->MaxVolJobs->Text; - $voldata['maxvolfiles'] = $this->MaxVolFiles->Text; - $voldata['maxvolbytes'] = $this->MaxVolBytes->Text; - $voldata['slot'] = $this->Slot->Text; - $voldata['recycle'] = (integer)$this->Recycle->Checked; - $voldata['enabled'] = (integer)$this->Enabled->Checked; - $voldata['inchanger'] = (integer)$this->InChanger->Checked; - $this->Application->getModule('api')->set(array('volumes', $voldata['mediaid']), $voldata); - break; - } - case $this->Prune->ID: { - $this->Application->getModule('api')->get(array('volumes', 'prune', $this->VolumeID->Text)); - break; - } - case $this->Purge->ID: { - $this->Application->getModule('api')->get(array('volumes', 'purge', $this->VolumeID->Text)); - break; - } - } - } - - public function getVolumeStates($forSetOnly = false) { - $states = ($forSetOnly === true ) ? $this->volumeStatesForSet : array_merge($this->volumeStatesByDirectorOnly, $this->volumeStatesForSet); - return $states; - } - - public function retentionPeriodValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->RetentionPeriod->Text) && $this->RetentionPeriod->Text >= 0; - $param->setIsValid($isValid); - } - - public function useDurationValidator($sender, $param) { + if($isInvalid) { + return false; + } + $voldata = array(); + $voldata['mediaid'] = $this->VolumeID->Text; + $voldata['volstatus'] = $this->VolumeStatus->SelectedValue; + $voldata['poolid'] = $this->Pool->SelectedValue; + $voldata['volretention'] = $this->RetentionPeriod->Text * 3600; // conversion to seconds + $voldata['voluseduration'] = $this->UseDuration->Text * 3600; // conversion to seconds + $voldata['maxvoljobs'] = $this->MaxVolJobs->Text; + $voldata['maxvolfiles'] = $this->MaxVolFiles->Text; + $voldata['maxvolbytes'] = $this->MaxVolBytes->Text; + $voldata['slot'] = $this->Slot->Text; + $voldata['recycle'] = (integer)$this->Recycle->Checked; + $voldata['enabled'] = (integer)$this->Enabled->Checked; + $voldata['inchanger'] = (integer)$this->InChanger->Checked; + $this->Application->getModule('api')->set(array('volumes', $voldata['mediaid']), $voldata); + break; + } + case $this->Prune->ID: { + $this->Application->getModule('api')->get(array('volumes', 'prune', $this->VolumeID->Text)); + break; + } + case $this->Purge->ID: { + $this->Application->getModule('api')->get(array('volumes', 'purge', $this->VolumeID->Text)); + break; + } + } + } + + public function getVolumeStates($forSetOnly = false) { + $states = ($forSetOnly === true ) ? $this->volumeStatesForSet : array_merge($this->volumeStatesByDirectorOnly, $this->volumeStatesForSet); + return $states; + } + + public function retentionPeriodValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->RetentionPeriod->Text) && $this->RetentionPeriod->Text >= 0; + $param->setIsValid($isValid); + } + + public function useDurationValidator($sender, $param) { $isValid = preg_match('/^\d+$/', $this->UseDuration->Text) && $this->UseDuration->Text >= 0; $param->setIsValid($isValid); - } - - public function maxVolJobsValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->MaxVolJobs->Text) && $this->MaxVolJobs->Text >= 0; - $param->setIsValid($isValid); - } - - public function maxVolFilesValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->MaxVolFiles->Text) && $this->MaxVolFiles->Text >= 0; - $param->setIsValid($isValid); - } - - public function maxVolBytesValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->MaxVolBytes->Text) && $this->MaxVolBytes->Text >= 0; - $param->setIsValid($isValid); - } - - public function slotValidator($sender, $param) { - $isValid = preg_match('/^\d+$/', $this->Slot->Text) && $this->Slot->Text >= 0; - $param->setIsValid($isValid); - } -} + } + + public function maxVolJobsValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->MaxVolJobs->Text) && $this->MaxVolJobs->Text >= 0; + $param->setIsValid($isValid); + } + + public function maxVolFilesValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->MaxVolFiles->Text) && $this->MaxVolFiles->Text >= 0; + $param->setIsValid($isValid); + } + + public function maxVolBytesValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->MaxVolBytes->Text) && $this->MaxVolBytes->Text >= 0; + $param->setIsValid($isValid); + } + + public function slotValidator($sender, $param) { + $isValid = preg_match('/^\d+$/', $this->Slot->Text) && $this->Slot->Text >= 0; + $param->setIsValid($isValid); + } +} ?> \ No newline at end of file diff --git a/gui/baculum/protected/Portlets/VolumeList.php b/gui/baculum/protected/Portlets/VolumeList.php index dbf7739322..c805e8cd15 100644 --- a/gui/baculum/protected/Portlets/VolumeList.php +++ b/gui/baculum/protected/Portlets/VolumeList.php @@ -1,101 +1,101 @@ -prepareData(); - } - - public function setWindowTitle($param) { - $this->windowTitle = $param; - } - - public function prepareData($forceReload = false) { - $allowedButtons = array('MediaBtn', 'ReloadVolumes'); - if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { - if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { - $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID); - array_push($params, '?showpools=1'); - $volumes = $this->Application->getModule('api')->get($params); - $isDetailView = $_SESSION['view' . $this->getPage()->VolumeWindow->ID] == 'details'; - $this->RepeaterShow->Visible = !$isDetailView; - $this->Repeater->DataSource = $volumes->output; - $this->Repeater->dataBind(); - $this->DataGridShow->Visible = $isDetailView; - $this->DataGrid->DataSource = $this->Application->getModule('misc')->objectToArray($volumes->output); - $this->DataGrid->dataBind(); - } - } - } - - protected function sortData($data, $key, $id) { - if($this->getSortOrder($id) == parent::SORT_DESC) { - if($key == 'pool') { - $key = 'name'; - $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] < $b["pool"]["'.$key.'"]) ? 1 : -1;}'); - } else { - $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] < $b["'.$key.'"]) ? 1 : -1;}'); - } - } else { - if($key == 'pool') { - $key = 'name'; - $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] > $b["pool"]["'.$key.'"]) ? 1 : -1;}'); - } else { - $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}'); - } - } - usort($data,$compare); - return $data; - } - - public function sortDataGrid($sender, $param) { - $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID); - array_push($params, '?showpools=1'); - $data = $this->Application->getModule('api')->get($params)->output; - $data = $this->Application->getModule('misc')->objectToArray($data); - $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); - $this->DataGrid->dataBind(); - } - - public function setShowID($ShowID) { - $this->ShowID = $this->getMaster()->ShowID = $ShowID; - } - - public function getShowID() { - return $this->ShowID; - } - - public function configure($sender, $param) { - if($this->Page->IsCallBack) { - $this->getPage()->VolumeConfiguration->configure($param->CallbackParameter); - } - } -} + parent::onLoad($param); + $this->prepareData(); + } + + public function setWindowTitle($param) { + $this->windowTitle = $param; + } + + public function prepareData($forceReload = false) { + $allowedButtons = array('MediaBtn', 'ReloadVolumes'); + if($this->Page->IsPostBack || $this->Page->IsCallBack || $forceReload) { + if(in_array($this->getPage()->CallBackEventTarget->ID, $allowedButtons) || $forceReload) { + $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID); + array_push($params, '?showpools=1'); + $volumes = $this->Application->getModule('api')->get($params); + $isDetailView = $_SESSION['view' . $this->getPage()->VolumeWindow->ID] == 'details'; + $this->RepeaterShow->Visible = !$isDetailView; + $this->Repeater->DataSource = $volumes->output; + $this->Repeater->dataBind(); + $this->DataGridShow->Visible = $isDetailView; + $this->DataGrid->DataSource = $this->Application->getModule('misc')->objectToArray($volumes->output); + $this->DataGrid->dataBind(); + } + } + } + + protected function sortData($data, $key, $id) { + if($this->getSortOrder($id) == parent::SORT_DESC) { + if($key == 'pool') { + $key = 'name'; + $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] < $b["pool"]["'.$key.'"]) ? 1 : -1;}'); + } else { + $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] < $b["'.$key.'"]) ? 1 : -1;}'); + } + } else { + if($key == 'pool') { + $key = 'name'; + $compare = create_function('$a,$b','if ($a["pool"]["'.$key.'"] == $b["pool"]["'.$key.'"]) {return 0;}else {return ($a["pool"]["'.$key.'"] > $b["pool"]["'.$key.'"]) ? 1 : -1;}'); + } else { + $compare = create_function('$a,$b','if ($a["'.$key.'"] == $b["'.$key.'"]) {return 0;}else {return ($a["'.$key.'"] > $b["'.$key.'"]) ? 1 : -1;}'); + } + } + usort($data,$compare); + return $data; + } + + public function sortDataGrid($sender, $param) { + $params = $this->getUrlParams('volumes', $this->getPage()->VolumeWindow->ID); + array_push($params, '?showpools=1'); + $data = $this->Application->getModule('api')->get($params)->output; + $data = $this->Application->getModule('misc')->objectToArray($data); + $this->DataGrid->DataSource = $this->sortData($data, $param->SortExpression, $sender->UniqueID); + $this->DataGrid->dataBind(); + } + + public function setShowID($ShowID) { + $this->ShowID = $this->getMaster()->ShowID = $ShowID; + } + + public function getShowID() { + return $this->ShowID; + } + + public function configure($sender, $param) { + if($this->Page->IsCallBack) { + $this->getPage()->VolumeConfiguration->configure($param->CallbackParameter); + } + } +} ?> -- 2.39.5