Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Job details: Native director connectivity
Browse files Browse the repository at this point in the history
Replaces database connection with native director connection.
  • Loading branch information
fbergkemper committed Aug 31, 2015
1 parent 195d967 commit 0a95aa6
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 99 deletions.
37 changes: 27 additions & 10 deletions module/Job/src/Job/Controller/JobController.php
Expand Up @@ -65,19 +65,19 @@ public function indexAction()
public function detailsAction()
{
if($_SESSION['bareos']['authenticated'] == true && $this->SessionTimeoutPlugin()->timeout()) {
$id = (int) $this->params()->fromRoute('id', 0);
if (!$id) {
return $this->redirect()->toRoute('job');
}

return new ViewModel(array(
'job' => $this->getJobTable()->getJob($id),
'log' => $this->getLogTable()->getLogsByJob($id),
));
$jobid = (int) $this->params()->fromRoute('id', 0);
$job = $this->getJob($jobid);
$joblog = $this->getJobLog($jobid);

return new ViewModel(array(
'job' => $job,
'joblog' => $joblog,
));
}
else {
return $this->redirect()->toRoute('auth', array('action' => 'login'));
}
return $this->redirect()->toRoute('auth', array('action' => 'login'));
}
}

public function runningAction()
Expand Down Expand Up @@ -250,6 +250,7 @@ public function queueAction()
}
}

/** TODO: RENAME TO => getBackups() **/
private function getJobs()
{
$director = $this->getServiceLocator()->get('director');
Expand All @@ -258,6 +259,22 @@ private function getJobs()
return $jobs['result']['jobs'];
}

private function getJob($jobid)
{
$director = $this->getServiceLocator()->get('director');
$result = $director->send_command('llist jobid="'.$jobid.'"', 2, null);
$jobs = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $jobs['result']['jobs'][0];
}

private function getJobLog($jobid)
{
$director = $this->getServiceLocator()->get('director');
$result = $director->send_command('list joblog jobid="'.$jobid.'"', 2, null);
$jobs = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $jobs['result']['joblog'];
}

private function queueJob($jobname=null)
{
$result = "";
Expand Down
149 changes: 60 additions & 89 deletions module/Job/view/job/job/details.phtml
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-2014 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @copyright Copyright (c) 2013-2015 Bareos GmbH & Co. KG (http://www.bareos.org/)
* @license GNU Affero General Public License (http://www.gnu.org/licenses/)
* @author Frank Bergkemper
*
Expand All @@ -29,119 +29,90 @@ $this->headTitle($title);

?>

<h3 class="text-muted"><?php echo $title; ?></h3>
<hr />

<!-- Job -->
<div class="row">

<div class="col-md-12">

<div class="panel panel-default">

<div class="panel-heading">
<h3 class="panel-title">General Information</h3>
</div>
<div class="col-md-12">

<div class="panel-body">
<div class="panel panel-default">

<table class="table table-striped table-bordered" style="font-size: 9pt;">

<tr>
<td><b>Job</b></td><td><?php echo $this->escapeHtml($job->jobid); ?></td>
<td><b>Scheduled start</b></td><td><?php echo $this->printDate($job->schedtime, 'iso'); ?></td>
<td><b>Status</b></td><td><?php echo $this->printJobStatus($job->jobstatus); ?></td>
</tr>

<tr>
<td><b>Name</b></td><td><?php echo $this->escapeHtml($job->jobname); ?></td>
<td><b>Real start</b></td><td><?php echo $this->printDate($job->starttime, 'iso'); ?></td>
<td><b>Errors</b></td><td><?php echo $this->escapeHtml($job->joberrors); ?></td>
</tr>

<tr>
<td><b>Client</b></td><td><a href="<?php echo $this->url('client', array('action' => 'details', 'id' => $job->clientid)); ?>"><?php echo $this->escapeHtml($job->clientname); ?></a></td>
<td><b>End</b></td><td><?php echo $this->printDate($job->endtime, 'iso'); ?></td>
<td><b>Files</b></td><td><!--<a href="<?php /*echo $this->url('file', array('action' => 'jobid', 'id' => $job->jobid));*/ ?>">--><?php echo $this->escapeHtml($job->jobfiles); ?><!--</a>--></td>
</tr>

<tr>
<td><b>Type</b></td><td><?php echo $this->printJobType($job->type); ?></td>
<td><b>Fileset</b></td><td><a href="<?php echo $this->url('fileset', array('action' => 'details', 'id' => $job->filesetid)); ?>"><?php echo $this->escapeHtml($job->filesetid); ?></a></td>
<td><b>Bytes</b></td><td><?php echo $this->printBytes($job->jobbytes); ?></td>
</tr>
<div class="panel-heading">
<h3 class="panel-title">Job</h3>
</div>

<tr>
<td><b>Level</b></td><td><?php echo $this->printJobLevel($job->level); ?></td>
<td><b>Pool</b></td><td><a href="<?php echo $this->url('pool', array('action' => 'details', 'id' => $job->poolid)); ?>"><?php echo $this->escapeHtml($job->poolid); ?></a></td>
<div class="panel-body">

<table class="table table-bordered table-condensed">

<tr>
<td><b>Job</b></td><td><?php echo $this->escapeHtml($job['jobid']); ?></td>
<td><b>Scheduled start</b></td><td><?php echo $this->printDate($job['schedtime'], 'iso'); ?></td>
<td><b>Status</b></td><td><?php echo $this->printJobStatus($job['jobstatus']); ?></td>
</tr>

<tr>
<td><b>Name</b></td><td><?php echo $this->escapeHtml($job['job']); ?></td>
<td><b>Real start</b></td><td><?php echo $this->printDate($job['starttime'], 'iso'); ?></td>
<td><b>Errors</b></td><td><?php echo $this->escapeHtml($job['joberrors']); ?></td>
</tr>

<tr>
<td><b>Client</b></td><td><a href="<?php echo $this->url('client', array('action' => 'details', 'id' => $job['name'])); ?>"><?php echo $this->escapeHtml($job['name']); ?></a></td>
<td><b>End</b></td><td><?php echo $this->printDate($job['endtime'], 'iso'); ?></td>
<td><b>Files</b></td><td><?php echo $this->escapeHtml($job['jobfiles']); ?></td>
</tr>

<tr>
<td><b>Type</b></td><td><?php echo $this->printJobType($job['type']); ?></td>
<td><b>Fileset</b></td><td><a href="<?php echo $this->url('fileset', array('action' => 'details', 'id' => $job['filesetid'])); ?>"><?php echo $this->escapeHtml($job['filesetid']); ?></a></td>
<td><b>Bytes</b></td><td><?php echo $this->printBytes($job['jobbytes']); ?></td>
</tr>

<tr>
<td><b>Level</b></td><td><?php echo $this->printJobLevel($job['level']); ?></td>
<td><b>Pool</b></td><td><a href="<?php echo $this->url('pool', array('action' => 'details', 'id' => $job['poolname'])); ?>"><?php echo $this->escapeHtml($job['poolname']); ?></a></td>
<td></td><td></td>
</tr>

</table>

</div>

</div>
</tr>

</div>

<!--
<div class="col-md-6">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Placeholder</h3>
</div>
<div class="panel-body">
</div>
</div>
</div>
-->
</table>

</div>
</div>
</div>
</div>

<!-- Log -->
<div class="row">

<div class="col-md-12">
<div class="panel panel-default">
<div class="col-md-12">

<div class="panel-heading">
<h3 class="panel-title">Messages</h3>
</div>
<div class="panel panel-default">

<div class="panel-heading">
<h3 class="panel-title">Messages</h3>
</div>

<div class="panel-body">
<div class="panel-body">

<table class="table table-striped table-hover" style="font-size: 9pt;">
<table class="table table-bordered table-condensed">

<tr>
<th>Timestamp</th>
<th>Log</th>
<th>Job</th>
<th>Message</th>
<th class="bg-primary">Timestamp</th>
<th class="bg-primary">Message</th>
</tr>

<?php foreach($this->log as $logitem) : ?>
<?php foreach($this->joblog as $log) : ?>

<tr>
<td><?php echo $this->escapeHtml($logitem->time); ?></td>
<td><?php echo $this->escapeHtml($logitem->logid); ?></td>
<td><?php echo $this->escapeHtml($logitem->jobid); ?></td>
<td><?php echo nl2br($this->escapeHtml($logitem->logtext)); ?></td>
<td><?php echo $this->escapeHtml($log['time']); ?></td>
<td><?php echo nl2br($this->escapeHtml($log['logtext'])); ?></td>
</tr>

<?php endforeach; ?>

</table>

</div>

</div>
</div>

</div>
</div>
</div>
</div>

0 comments on commit 0a95aa6

Please sign in to comment.