Skip to content
Snippets Groups Projects
Commit f30ba66b authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'add-running-jobs' into 'master'

Add running jobs

See merge request !16
parents 923c342d 3cf0409e
No related branches found
No related tags found
1 merge request!16Add running jobs
...@@ -99,7 +99,7 @@ class cronlogrenderer extends cronlog{ ...@@ -99,7 +99,7 @@ class cronlogrenderer extends cronlog{
/** /**
* get html code for a table with events of executed cronjobs * get html code for a table with events of executed cronjobs
* *
* @param array $aData result of $oCL->getServerLogs() * @param array $aData result of $this->getServerLogs()
* @return string * @return string
*/ */
public function renderCronlogs($aData=false){ public function renderCronlogs($aData=false){
...@@ -195,16 +195,24 @@ class cronlogrenderer extends cronlog{ ...@@ -195,16 +195,24 @@ class cronlogrenderer extends cronlog{
$sTtlHr=$sTtlHr ? '('.$sTtlHr.')' : ''; $sTtlHr=$sTtlHr ? '('.$sTtlHr.')' : '';
$sColStatus=''; $sColStatus='';
$bIsRunning=false;
if($aEntry['SCRIPTRC']){
if (count($aErrors)){ if (count($aErrors)){
foreach($aErrors as $aErr){ foreach($aErrors as $aErr){
$sColStatus.='<li><abbr title="'.$aErr[1].'">'.$this->t('status-error').': '.$aErr[0].'</abbr></li>'; $sColStatus.='<li><abbr title="'.$aErr[1].'">'.$this->t('status-error').': '.$aErr[0].'</abbr></li>';
} }
$sColStatus='<ul>'.$sColStatus.'</ul>'; $sColStatus='<ul>'.$sColStatus.'</ul>';
} else { } else {
$sColStatus.=($aEntry['SCRIPTRC'] ? $this->t('status-ok') : ''); $sColStatus.=$this->t('status-ok');
}
} else {
$bIsRunning=true;
$sColStatus.=$this->t('status-running');
} }
// render table of last logfile per cron job // render table of last logfile per cron job
$sHtml.='<tr onclick="showFile(\''.$aEntry['logfile'].'\');" title="'.sprintf($this->t('row-click-show-logfile'), $aEntry['logfile']).'">' $sHtml.='<tr onclick="showFile(\''.$aEntry['logfile'].'\');" title="'.sprintf($this->t('row-click-show-logfile'), $aEntry['logfile']).'"'
.($bIsRunning ? ' class="message-running"' : '')
.'>'
. '<td>'.date("Y-m-d H:i:s", $aEntry['SCRIPTSTARTTIME']).'</td>' . '<td>'.date("Y-m-d H:i:s", $aEntry['SCRIPTSTARTTIME']).'</td>'
// . '<td>'.$aEntry['SCRIPTNAME'].'</td>' // . '<td>'.$aEntry['SCRIPTNAME'].'</td>'
. '<td>'.$aEntry['SCRIPTLABEL'].'</td>' . '<td>'.$aEntry['SCRIPTLABEL'].'</td>'
...@@ -246,7 +254,8 @@ class cronlogrenderer extends cronlog{ ...@@ -246,7 +254,8 @@ class cronlogrenderer extends cronlog{
. '<p class="hint">' . '<p class="hint">'
. $this->t('logs-hint') . $this->t('logs-hint')
. '</p>' . '</p>'
. '<div>' . (count($aData)
? '<div>'
. $this->_renderAccessAndAge($iLast) . $this->_renderAccessAndAge($iLast)
. ($iErrors ? '<a href="#" class="btn bg-danger" onclick="'.$this->_filterDatatable($sIdTable, $this->t('status-error')).'"><i class="fas fa-exclamation-circle"></i> &nbsp; ' . $iErrors.'</a> ' : '') . ($iErrors ? '<a href="#" class="btn bg-danger" onclick="'.$this->_filterDatatable($sIdTable, $this->t('status-error')).'"><i class="fas fa-exclamation-circle"></i> &nbsp; ' . $iErrors.'</a> ' : '')
. ( $iOK ? '<a href="#" class="btn bg-success" onclick="'.$this->_filterDatatable($sIdTable, $this->t('status-ok')).'"><i class="fas fa-check"></i> &nbsp; ' . $iOK.'</a>' : '') . ( $iOK ? '<a href="#" class="btn bg-success" onclick="'.$this->_filterDatatable($sIdTable, $this->t('status-ok')).'"><i class="fas fa-check"></i> &nbsp; ' . $iOK.'</a>' : '')
...@@ -258,8 +267,6 @@ class cronlogrenderer extends cronlog{ ...@@ -258,8 +267,6 @@ class cronlogrenderer extends cronlog{
.$sHtml .$sHtml
.'</tbody>' .'</tbody>'
. '</table>' . '</table>'
// init datatable
. '<script>' . '<script>'
. '$(document).ready( function () { $(\'#'.$sIdTable.'\').DataTable({ . '$(document).ready( function () { $(\'#'.$sIdTable.'\').DataTable({
"retrieve": true, "retrieve": true,
...@@ -269,6 +276,10 @@ class cronlogrenderer extends cronlog{ ...@@ -269,6 +276,10 @@ class cronlogrenderer extends cronlog{
}); });
});' });'
. '</script>' . '</script>'
: ''
)
// init datatable
. ' . '
<!-- ENDE '.__METHOD__.' --> <!-- ENDE '.__METHOD__.' -->
...@@ -278,11 +289,17 @@ class cronlogrenderer extends cronlog{ ...@@ -278,11 +289,17 @@ class cronlogrenderer extends cronlog{
return $sHtml; return $sHtml;
} }
/**
* get html code for a table with events of executed cronjobs for ALL servers
*
* @param array $aData result of $this->getServerLogs()
* @return string
*/
public function renderCronlogsOfAllServers(){ public function renderCronlogsOfAllServers(){
$aData=array(); $aData=array();
foreach (array_keys($this->getServers()) as $sServer){ foreach (array_keys($this->getServers()) as $sServer){
$this->setServer($sServer); $this->setServer($sServer);
$aData=array_merge($aData, $this->getServersLastLog()); $aData=array_merge($aData, $this->getRunningJobs(),$this->getServersLastLog());
} }
$this->setServer('ALL'); $this->setServer('ALL');
return $this->renderCronlogs($aData); return $this->renderCronlogs($aData);
...@@ -400,7 +417,8 @@ class cronlogrenderer extends cronlog{ ...@@ -400,7 +417,8 @@ class cronlogrenderer extends cronlog{
. '</table>' . '</table>'
// init datatable // init datatable
. '<script>' . (count($aData)
? '<script>'
. '$(document).ready( function () {$(\'#'.$sIdTable.'\').DataTable({ . '$(document).ready( function () {$(\'#'.$sIdTable.'\').DataTable({
"retrieve": true, "retrieve": true,
"aaSorting":[[0,"desc"]], "aaSorting":[[0,"desc"]],
...@@ -408,6 +426,8 @@ class cronlogrenderer extends cronlog{ ...@@ -408,6 +426,8 @@ class cronlogrenderer extends cronlog{
'.$this->_getDatatableLanguage().' '.$this->_getDatatableLanguage().'
});} );' });} );'
. '</script>' . '</script>'
: ''
)
. ' . '
<!-- ENDE '.__METHOD__.' --> <!-- ENDE '.__METHOD__.' -->
......
...@@ -54,7 +54,7 @@ class cronlog { ...@@ -54,7 +54,7 @@ class cronlog {
protected $_sFileFilter_serverjoblog = '*joblog*.done'; protected $_sFileFilter_serverjoblog = '*joblog*.done';
protected $_sFileFilter_joblog = '*.log'; protected $_sFileFilter_joblog = '*.log';
protected $_sFileFilter_jobrunning = '*.log.running'; protected $_sFileFilter_jobrunning = '*.log.running*';
protected $_sLang = ''; // language ... read from config file protected $_sLang = ''; // language ... read from config file
protected $_aLang = []; // language data protected $_aLang = []; // language data
......
...@@ -44,6 +44,7 @@ return [ ...@@ -44,6 +44,7 @@ return [
"col-rc" => "$?", "col-rc" => "$?",
"col-expired" => "veraltet?", "col-expired" => "veraltet?",
"col-status" => "Status", "col-status" => "Status",
"status-running" => "AKTIV",
"status-ok" => "OK", "status-ok" => "OK",
"status-error" => "FEHLER", "status-error" => "FEHLER",
......
...@@ -44,6 +44,7 @@ return [ ...@@ -44,6 +44,7 @@ return [
"col-rc" => "$?", "col-rc" => "$?",
"col-expired" => "Expired?", "col-expired" => "Expired?",
"col-status" => "Status", "col-status" => "Status",
"status-running" => "RUNNING",
"status-ok" => "OK", "status-ok" => "OK",
"status-error" => "ERROR", "status-error" => "ERROR",
......
<?php <?php
define("APP_VERSION", '2.1.2'); define("APP_VERSION", '2.1.3');
require_once('classes/render-adminlte.class.php'); require_once('classes/render-adminlte.class.php');
require_once('classes/cronlog-renderer.class.php'); require_once('classes/cronlog-renderer.class.php');
......
...@@ -41,6 +41,7 @@ table.dataTable tbody td{padding: 3px;} ...@@ -41,6 +41,7 @@ table.dataTable tbody td{padding: 3px;}
.message{border: 1px solid rgba(0,0,0,0.1); padding: 1em; float: right;} .message{border: 1px solid rgba(0,0,0,0.1); padding: 1em; float: right;}
table.dataTable tbody tr.message-ok, .message-ok{background:#cfc; color:#080 !important;} table.dataTable tbody tr.message-ok, .message-ok{background:#cfc; color:#080 !important;}
table.dataTable tbody tr.message-error, .message-error{background:#fdd; color:#800 !important;} table.dataTable tbody tr.message-error, .message-error{background:#fdd; color:#800 !important;}
table.dataTable tbody tr.message-running, .message-running{background:#f4e0f4; color:#808 !important;}
table.dataTable tbody tr.message-warning, .message-warning{background:#fec; color:#876 !important;} table.dataTable tbody tr.message-warning, .message-warning{background:#fec; color:#876 !important;}
table.dataTable tbody tr:hover{background:rgba(0,0,0,0.1);} table.dataTable tbody tr:hover{background:rgba(0,0,0,0.1);}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment