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

Commit

Permalink
Browse files Browse the repository at this point in the history
Dashboard: Make jobtotals partial use bootstrap-table-extension
  • Loading branch information
fbergkemper committed May 30, 2017
1 parent 19cea23 commit 44a1ffb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 44 deletions.
63 changes: 21 additions & 42 deletions module/Dashboard/view/dashboard/dashboard/index.phtml
Expand Up @@ -56,23 +56,7 @@ $this->headTitle($title);

var lastlogid = 0;
var table_jobs_last_status = null;

function getDirectorMessages() {
$.ajax({
url : '<?php echo $this->url('dashboard', array('action' => 'getData'), null) . '?data=dirdmsg'; ?>',
dataType: 'json',
timeout: 10000,
success: function(data) {
for(var i in data) {
if(data[i].logid > lastlogid) {
var msg = $('<div class="msg" id="'+data[i].logid+'"><strong>'+data[i].time+'</strong>&nbsp;'+data[i].logtext+'</div>');
msg.insertBefore('#'+lastlogid).fadeIn('slow');
lastlogid = data[i].logid;
}
}
}
});
}
var table_job_totals = null;

$(document).ajaxStart(function() {
$('.waiting-jobs-field').empty();
Expand Down Expand Up @@ -112,30 +96,25 @@ $this->headTitle($title);
}

function getJobTotals() {
$.ajax({
url : '<?php echo $this->url('dashboard', array('action' => 'getData'), null) . '?data=jobtotals'; ?>',
table_job_totals = $('#job-totals').bootstrapTable({
locale: '<?php echo str_replace('_','-', $_SESSION['bareos']['locale']); ?>',
url: '<?php echo $this->url('dashboard', array('action' => 'getData'), null) . '?data=jobtotals'; ?>',
method: 'get',
dataType: 'json',
timeout: 10000,
success: function(data) {
$('.job-totals-container').empty();
$('.job-totals-container').append(
'<div class="row"><div class="col-xs-1"><strong><?php echo $this->translate("Jobs"); ?></strong></div><div class="col-xs-3"><span class="text-muted">'+data.jobs+'</span></div></div>' +
'<div class="row"><div class="col-xs-1"><strong><?php echo $this->translate("Files"); ?></strong></div><div class="col-xs-3"><span class="text-muted">'+data.files+'</span></div></div>' +
'<div class="row"><div class="col-xs-1"><strong><?php echo $this->translate("Bytes"); ?></strong></div><div class="col-xs-3"><span class="text-muted">'+formatBytes(data.bytes)+'</span></div></div>'
);
},
error: function() {
$('.job-totals-container').empty();
$('.job-totals-container').append('Error fetching data.');
},
timeout: function() {
$('.job-totals-container').empty();
$('.job-totals-container').append('Timeout fetching data.');
},
parsererror: function() {
$('.job-totals-container').empty();
$('.job-totals-container').append('Parsererror');
}
columns: [
{
field: 'jobs',
},
{
field: 'files',
},
{
field: 'bytes',
formatter: function(value) {
return formatBytes(value);
}
}
]
});
}

Expand Down Expand Up @@ -266,7 +245,7 @@ $this->headTitle($title);
function refreshPartials() {
getRunningJobs();
getJobsPast24h();
getJobTotals();
$('#job-totals').bootstrapTable('refresh');
$('#jobs-last-status').bootstrapTable('refresh');
}

Expand All @@ -282,7 +261,7 @@ $this->headTitle($title);
setInterval('getJobsPast24h()', <?php echo $_SESSION['bareos']['dashboard_autorefresh_interval']; ?>);

getJobTotals();
setInterval('getJobTotals()', <?php echo $_SESSION['bareos']['dashboard_autorefresh_interval']; ?>);
setInterval("$('#job-totals').bootstrapTable('refresh')", <?php echo $_SESSION['bareos']['dashboard_autorefresh_interval']; ?>);

getJobsLastStatus();
setInterval( "$('#jobs-last-status').bootstrapTable('refresh')", <?php echo $_SESSION['bareos']['dashboard_autorefresh_interval']; ?>);
Expand Down
10 changes: 9 additions & 1 deletion module/Dashboard/view/partial/JobTotals.phtml
Expand Up @@ -34,7 +34,15 @@
</div>

<div class="panel-body">
<div class="job-totals-container"></div>

<table class="table table-no-bordered" id="job-totals">
<thead class="bg-primary">
<th><?php echo $this->translate("Jobs"); ?></th>
<th><?php echo $this->translate("Files"); ?></th>
<th><?php echo $this->translate("Bytes"); ?></th>
</thead>
</table>

</div>

</div>
2 changes: 1 addition & 1 deletion module/Job/src/Job/Model/JobModel.php
Expand Up @@ -248,7 +248,7 @@ public function getJobTotals(&$bsock=null)
$cmd = 'list jobtotals';
$result = $bsock->send_command($cmd, 2, null);
$jobtotals = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $jobtotals['result']['jobtotals'];
return array(0 => $jobtotals['result']['jobtotals']);
}
else {
throw new \Exception('Missing argument.');
Expand Down

0 comments on commit 44a1ffb

Please sign in to comment.