Skip to content

Commit

Permalink
webui: update job controller
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed Apr 7, 2022
1 parent 7b54d48 commit 53f344b
Showing 1 changed file with 67 additions and 3 deletions.
70 changes: 67 additions & 3 deletions webui/module/Job/src/Job/Controller/JobController.php
Expand Up @@ -536,6 +536,43 @@ public function runAction()
}
}

public function rerunAction()
{
$this->RequestURIPlugin()->setRequestURI();

if(!$this->SessionTimeoutPlugin()->isValid()) {
return $this->redirect()->toRoute(
'auth',
array(
'action' => 'login'
),
array(
'query' => array(
'req' => $this->RequestURIPlugin()->getRequestURI(),
'dird' => $_SESSION['bareos']['director']
)
)
);
}

$module_config = $this->getServiceLocator()->get('ModuleManager')->getModule('Application')->getConfig();
$invalid_commands = $this->CommandACLPlugin()->getInvalidCommands(
$module_config['console_commands']['Job']['optional']
);
if(count($invalid_commands) > 0 && in_array('rerun', $invalid_commands)) {
$this->acl_alert = true;
return new ViewModel(
array(
'acl_alert' => $this->acl_alert,
'invalid_commands' => 'rerun'
)
);
}

return new ViewModel();

}

public function timelineAction()
{
$this->RequestURIPlugin()->setRequestURI();
Expand Down Expand Up @@ -569,8 +606,6 @@ public function timelineAction()
);
}

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

return new ViewModel();
}

Expand Down Expand Up @@ -679,7 +714,36 @@ public function getDataAction()
echo $e->getMessage();
}
}
elseif($data="job-timeline") {
elseif($data == "jobs-to-rerun") {
try {
$result = $this->getJobModel()->getJobsToRerun($this->bsock, $period, null);
}
catch(Exception $e) {
echo $e->getMessages();
}
}
elseif($data == "job-rerun") {
try {
$result = [];
$j = explode(",", $jobs);
foreach($j as $job) {
array_push($result, $this->getJobModel()->rerunJob($this->bsock, $job));
}
}
catch(Exception $e) {
echo $e->getMessage();
}

$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'application/json');

if(isset($result)) {
$response->setContent(JSON::encode($result));
}

return $response;
}
elseif($data == "job-timeline") {
try {
$result = [];
$j = explode(",", $jobs);
Expand Down

0 comments on commit 53f344b

Please sign in to comment.