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

Commit

Permalink
adds a dird msg ticker to dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergkemper committed May 19, 2016
1 parent 8aca88f commit cc90c49
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
Expand Up @@ -112,7 +112,17 @@ public function getDataAction()
return $this->redirect()->toRoute('auth', array('action' => 'login'), array('query' => array('req' => $this->RequestURIPlugin()->getRequestURI())));
}

$result = $this->getDashboardModel()->getJobsLastStatus();
$data = $this->params()->fromQuery('data');

if($data == "jobslaststatus") {
$result = $this->getDashboardModel()->getJobsLastStatus();
}
elseif($data == "dirdmsg") {
$result = $this->getDashboardModel()->getLastDirectorMessages();
}
else {
$result = null;
}

$response = $this->getResponse();
$response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
Expand Down
9 changes: 9 additions & 0 deletions module/Dashboard/src/Dashboard/Model/DashboardModel.php
Expand Up @@ -79,4 +79,13 @@ public function getJobsLastStatus()
return $jobs['result']['jobs'];
}

public function getLastDirectorMessages()
{
$cmd = 'llist log limit=50';
$this->director = $this->getServiceLocator()->get('director');
$result = $this->director->send_command($cmd, 2, null);
$msg = \Zend\Json\Json::decode($result, \Zend\Json\Json::TYPE_ARRAY);
return $msg['result']['log'];
}

}
55 changes: 53 additions & 2 deletions module/Dashboard/view/dashboard/dashboard/index.phtml
Expand Up @@ -103,6 +103,31 @@ $this->headTitle($title);

</div>

<!-- DIRD MSG TICKER -->
<div class="row">

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

<div class="panel panel-default">

<div class="panel-heading">
<h3 class="panel-title"><?php echo $this->translate('Last Director messages'); ?></h3>
</div>

<div class="panel-body" style="overflow-x: auto;">

<div class="dird-msg-ticker" style="height: 250px;">
<div class="msg" id="0"></div>
</div>

</div>

</div>

</div>

</div>

<?php
echo $this->headScript()->prependFile($this->basePath() . '/js/jqplot.pointLabels.min.js');
echo $this->headScript()->prependFile($this->basePath() . '/js/jqplot.categoryAxisRenderer.min.js');
Expand Down Expand Up @@ -158,15 +183,40 @@ $this->headTitle($title);

}

var lastlogid = 0;

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.replace(/(?:\r\n|\r|\n)/g, '<br />')+'</div>');
msg.insertBefore('#'+lastlogid).fadeIn('slow');
lastlogid = data[i].logid;
}
}
}
});

}

$(document).ready(

function() {

chart1();

var table = $('#jobs-last-status').DataTable({
getDirectorMessages();

setInterval('getDirectorMessages()', 30000);

var table_jobs_last_status = $('#jobs-last-status').DataTable({
"ajax": {
"url": "<?php echo $this->url('dashboard', array('action' => 'getData'), null); ?>",
"url": "<?php echo $this->url('dashboard', array('action' => 'getData'), null) . '?data=jobslaststatus'; ?>",
"dataSrc": ""
},
"language": {
Expand Down Expand Up @@ -214,6 +264,7 @@ $this->headTitle($title);
}
]
});

}

);
Expand Down

0 comments on commit cc90c49

Please sign in to comment.