Skip to content

Commit

Permalink
Fix to bugreport #684 and #693
Browse files Browse the repository at this point in the history
Fixes #684: Long logs aren't displayed
Fixes #693: bareos-webui generate error exception with certain messages
  • Loading branch information
fbergkemper committed Jan 31, 2017
1 parent 837d6a2 commit c3c7d6c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
8 changes: 4 additions & 4 deletions module/Job/src/Job/Controller/JobController.php
Expand Up @@ -153,17 +153,17 @@ public function detailsAction()

try {
$this->bsock = $this->getServiceLocator()->get('director');
$job = $this->getJobModel()->getJob($this->bsock, $jobid);
$joblog = $this->getJobModel()->getJobLog($this->bsock, $jobid);
//$job = $this->getJobModel()->getJob($this->bsock, $jobid);
//$joblog = $this->getJobModel()->getJobLog($this->bsock, $jobid);
$this->bsock->disconnect();
}
catch(Exception $e) {
echo $e->getMessage();
}

return new ViewModel(array(
'job' => $job,
'joblog' => $joblog,
//'job' => $job,
//'joblog' => $joblog,
'jobid' => $jobid
));
}
Expand Down
12 changes: 10 additions & 2 deletions module/Job/src/Job/Model/JobModel.php
Expand Up @@ -114,8 +114,16 @@ public function getJobLog(&$bsock=null, $id=null)
if(isset($bsock, $id)) {
$cmd = 'list joblog jobid='.$id.'';
$result = $bsock->send_command($cmd, 2, null);
$log = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $log['result']['joblog'];
if(preg_match('/Failed to send result as json. Maybe result message to long?/', $result)) {
//return false;
$error = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $error['result']['error'];
}
else {
$log = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $log['result']['joblog'];
}

}
else {
throw new \Exception('Missing argument.');
Expand Down
25 changes: 25 additions & 0 deletions module/Job/view/job/job/details.phtml
Expand Up @@ -109,6 +109,26 @@ $this->headTitle($title);
echo $this->headLink()->prependStylesheet($this->basePath() . '/css/datatables.min.css');
?>

<!-- modal-001 start -->
<div id="modal-001" class="modal fade modal-001" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel"><?php echo $this->translate("Failed to retrieve data from Bareos director"); ?></h4>
</div>
<div class="modal-body">
<p><?php echo $this->translate("Error message received from director:"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe the result message is too long?"); ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $this->translate("Close"); ?></button>
</div>
</div>
</div>
</div>
<!-- modal-001 end -->

<style>

td.details-control:after {
Expand Down Expand Up @@ -319,6 +339,11 @@ $(document).ready(function() {
$('#jobdetails tbody').on('mouseover', '#btn-1', function () {
$('[data-toggle="tooltip"]').tooltip();
});

$('#joblog').on('error.dt', function(e, settings, techNote, message) {
$("#modal-001").modal();
});

} );

</script>
Expand Down
2 changes: 1 addition & 1 deletion module/Job/view/job/job/index.phtml
Expand Up @@ -108,7 +108,7 @@ $this->headTitle($title);
<div class="modal-body">
<p><?php echo $this->translate("Please try to reduce the amount of data to display, e.g. reduce time period."); ?></p>
<p><?php echo $this->translate("Error message received from director:"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe result message to long?"); ?></p>
<p class="text-danger"><?php echo $this->translate("Failed to send result as json. Maybe the result message is too long?"); ?></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><?php echo $this->translate("Close"); ?></button>
Expand Down

0 comments on commit c3c7d6c

Please sign in to comment.