allow to add more tabs with log files with a selectable prefix

This commit is contained in:
Uwe Steinmann 2022-11-08 16:45:27 +01:00
parent e0cd3fb1e8
commit 7dee5cb767
2 changed files with 32 additions and 22 deletions

View File

@ -39,7 +39,7 @@ if (isset($_GET["logname"])) $logname=basename($_GET["logname"], '.log').'.log';
else $logname=NULL;
if (isset($_GET["mode"])) $mode=$_GET["mode"];
else $mode='web';
else $mode='default';
if($view) {
$view->setParam('logname', $logname);

View File

@ -98,41 +98,51 @@ $("input[type=checkbox]").each(function () { this.checked = !this.checked; });
$this->contentHeading(getMLText("log_management"));
$entries = array();
$wentries = array();
$sections = array(
array('default', 'Web'),
array('webdav', 'WebDAV'),
array('restapi', 'RestAPI'),
);
if($es = $this->callHook('extraSections'))
$sections = array_merge($sections, $es);
$entries = [];
foreach($sections as $section) {
$entries[$section[0]] = array();
}
$handle = opendir($this->logdir);
if($handle) {
while ($e = readdir($handle)){
if (is_dir($this->logdir.$e)) continue;
if (strpos($e,".log")==FALSE) continue;
if (strcmp($e,"current.log")==0) continue;
if(substr($e, 0, 6) == 'webdav') {
$wentries[] = $e;
} else {
$entries[] = $e;
}
$section = strtok($e, '-');
if(isset($entries[$section]))
$entries[$section][] = $e;
else
$entries['default'][] = $e;
}
closedir($handle);
sort($entries);
sort($wentries);
$entries = array_reverse($entries);
$wentries = array_reverse($wentries);
foreach($sections as $section) {
sort($entries[$section[0]]);
$entries[$section[0]] = array_reverse($entries[$section[0]]);
}
}
?>
<ul class="nav nav-pills" id="logtab" role="tablist">
<?php $this->showPaneHeader('web', 'web', (!$mode || $mode == 'web')); ?>
<?php $this->showPaneHeader('webdav', 'webdav', (!$mode || $mode == 'webdav')); ?>
<ul class="nav nav-pills" id="logtab" role="tablist">
<?php
foreach($sections as $section)
$this->showPaneHeader($section[0], $section[1], (!$mode || $mode == $section[0]));
?>
</ul>
<div class="tab-content">
<?php
$this->showStartPaneContent('web', (!$mode || $mode == 'web'));
$this->filelist($entries, 'web');
$this->showEndPaneContent('web', $mode);
$this->showStartPaneContent('webdav', (!$mode || $mode == 'webdav'));
$this->filelist($wentries, 'webdav');
$this->showEndPaneContent('webdav', $mode);
foreach($sections as $section) {
$this->showStartPaneContent($section[0], (!$mode || $mode == $section[0]));
$this->filelist($entries[$section[0]], $section[0]);
$this->showEndPaneContent($section[0], $mode);
}
?>
</div>
<?php