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

Commit

Permalink
Merge branch 'bareos-16.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed Feb 1, 2017
2 parents 49da0bd + c3c7d6c commit 46964f9
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 8 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
12 changes: 11 additions & 1 deletion module/Media/view/media/media/index.phtml
Expand Up @@ -163,7 +163,8 @@ $(document).ready(function() {
{ "data": null },
{ "type": "file-size", "data": "maxvolbytes" },
{ "type": "file-size", "data": "volbytes" },
{ "data": "lastwritten" }
{ "data": "lastwritten" },
{ "data": null }
],
"columnDefs": [
{
Expand All @@ -181,6 +182,7 @@ $(document).ready(function() {
},
{
"targets": 6,
"orderData": 10,
"render": function(data, type, full, meta) {
return formatExpiration(data.volstatus, data.lastwritten, data.volretention);
}
Expand All @@ -201,6 +203,14 @@ $(document).ready(function() {
"targets": 9,
"visible": false,
"searchable": false
},
{
"targets": 10,
"visible": false,
"searchable": false,
"render": function(data, type, full, meta) {
return formatHiddenRetExp(data.volstatus, data.lastwritten, data.volretention);
}
}
],
"buttons": [
Expand Down
25 changes: 25 additions & 0 deletions public/js/datatables.functions.js
Expand Up @@ -194,6 +194,31 @@ function formatExpiration(volstatus, lastwritten, volretention) {
}
}

function formatHiddenRetExp(volstatus, lastwritten, volretention) {
if(volstatus == iJS._("Used") || volstatus == iJS._("Full")) {
if(lastwritten == null || lastwritten == "") {
return 100000000000;
}
else {
var d = Date.now() / 1000;
var a = lastwritten.split(" ");
var b = new Date(a[0]).getTime() / 1000;
var interval = (d - b) / (3600 * 24);
var retention = Math.round(volretention / 60 / 60 / 24);
var expiration = (retention - interval).toFixed(2);
return Math.ceil(expiration);
}
}
else {
// This is kind of ugly but expiration can also be a negativ value, but somehow we need to sort numerical.
// As a workaround we move the area of unused volumes with a retention way down into the negativ by
// prepending a large negativ number out of the scope of the usual rentention times commonly used
// to avoid further problems.
// TODO: Find a better sorting solution for the Retention/Expiration column.
return Math.ceil('-1000000000000'+(volretention / 60 / 60 / 24));
}
}

function formatLastWritten(data) {
if(data == null || data == '' || data == 0) {
return iJS._('never');
Expand Down

0 comments on commit 46964f9

Please sign in to comment.