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

add support for multiple instances

parent 0cbbd3b0
No related branches found
No related tags found
1 merge request!1add support for multiple instances
......@@ -217,6 +217,26 @@ class cronlogrenderer extends cronlog{
return $this->renderCronlogs($aData);
}
/**
* get html code for a switcher of multiple instances
*
* @param array $aData result of $oCL->getServerLogs()
* @return string
*/
public function renderInstances(){
if(count($this->_aInstances) < 2){
return false;
}
$sReturn='';
$sServer=isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : false;
foreach($this->_aInstances as $sInstance => $sUrl){
$sHost=parse_url($sUrl, PHP_URL_HOST);
$sClass=($sServer && $sServer==$sHost) ? 'active' : '';
$sReturn.='<a class="'.$sClass.'" href="'.$sUrl.'" title="'.$sUrl.'">'.$sInstance.'</a> ';
}
return $sReturn;
}
/**
* get html code for a table with history of executed cronjobs
*
......
......@@ -47,6 +47,8 @@ class cronlog {
protected $_iMinTtl = 0; // in sec
protected $_aSkipJoblogs = array();
protected $_aInstances = array();
protected $_aServers = array();
protected $_sActiveServer = false;
......@@ -71,6 +73,8 @@ class cronlog {
$this->_iMinTtl = isset($aCfgTemp['iMinTtl']) ? (int)$aCfgTemp['iMinTtl'] : $this->_iMinTtl;
$this->_iExpiredJobsFailAfter = isset($aCfgTemp['iExpiredJobsFailAfter']) ? (int)$aCfgTemp['iExpiredJobsFailAfter'] : $this->_iExpiredJobsFailAfter;
$this->_aSkipJoblogs = isset($aCfgTemp['aHidelogs']) && is_array($aCfgTemp['aHidelogs']) ? $aCfgTemp['aHidelogs'] : $this->_aSkipJoblogs;
$this->_aInstances = isset($aCfgTemp['instances']) ? $aCfgTemp['instances'] : [];
}
$this->_sDataDir = str_replace("__APPDIR__", dirname(dirname(__FILE__)), $this->_sDataDir);
$this->_sDataDir = str_replace('\\', '/', $this->_sDataDir);
......
......@@ -33,5 +33,14 @@ return array(
// hide these cronjob labels in the web gui tab "history"
'aHidelogs'=>array(
'copycronlogs',
)
),
// if you have multiple instances: add label and url for a switcher menu
/*
'instances'=>[
'Docker'=>'http://localhost:8006',
'Intern'=>'https://cronlogs.intern.example.com/',
'Extern'=>'https://cronlogs.extern.example.com/',
],
*/
);
......@@ -67,6 +67,9 @@ switch ($sItem){
$sHtml.=$oCL->renderJobGraph();
}
break;
case 'instances':
$sHtml.=$oCL->renderInstances($sServer);
break;
case 'selectserver':
$sHtml.=$oCL->renderServerlist($sServer);
break;
......
......@@ -22,7 +22,10 @@
</head>
<body>
<div id="errorlog"></div>
<header>
<div id="instances">...</div>
<h1><a href="?"><span class="imllogo"></span> CronjobViewer</a></h1>
</header>
<nav class="servers">
<div id="selectserver" class="active">...</div>
</nav>
......
......@@ -272,6 +272,14 @@ $(document).ready(function () {
'taskparam': 'item',
'tasks':{
'instances':{
domid: 'instances',
apimore: '?',
params: [
'instances'
],
interval: 0
},
'selectserverAll':{
domid: 'selectserver',
apimore: '?',
......@@ -299,6 +307,7 @@ $(document).ready(function () {
oAjaxHelper.setVar('server', sSELECTEDSERVER);
oAjaxHelper.setVar('tab', sACTIVESERVERTAB);
oAjaxHelper.execTask('selectserver');
oAjaxHelper.execTask('instances');
// oAjaxHelper.execTask('selectserverAll');
});
......
......@@ -19,9 +19,15 @@ button:active{box-shadow: none; }
footer{position: fixed; bottom: 1em; right: 1em; background: var(--bg-header); border-top: 1px solid var(--border); padding: 1em; text-align: right;}
h1{border-bottom: 1px solid var(--border); background:var(--bg-header); margin: 0 0 0.3em; padding: 1em 0.3em;}
header{border-bottom: 1px solid var(--border); background:var(--bg-header); margin: 0 0 0.3em; padding: 1.5em 1em;}
h1{margin: 0 0 0.3em; padding: 0; margin: 0;}
h1 a{color: #38a;}
h1 a:hover{text-decoration: none;}
#instances{float: right;}
#instances a{border: 0px solid; padding: 0.4em;}
#instances a:hover{background: var(--bg-main);}
#instances a.active{background: var(--bg-main);border-top: 1px solid var(--border); border-left: 1px solid var(--border);}
h2{color:#379;}
h2 i{color:#abc; font-size: 140%;}
h3{color: #39b;}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment