mirror of
https://github.com/unraid/webgui.git
synced 2026-01-23 18:09:02 -06:00
Fix docker log coloring for 6.2
This commit is contained in:
@@ -62,16 +62,28 @@ switch ($action) {
|
||||
if ($container) {
|
||||
$since = array_key_exists('since', $_REQUEST) ? $_REQUEST['since'] : '';
|
||||
$title = array_key_exists('title', $_REQUEST) ? $_REQUEST['title'] : '';
|
||||
require_once '/usr/local/emhttp/webGui/include/ColorCoding.php';
|
||||
if (!$since) {
|
||||
readfile("/usr/local/emhttp/plugins/dynamix.docker.manager/log.htm");
|
||||
echo "<script>document.title = '$title';</script>";
|
||||
echo "<script>addLog('".addslashes("<p style='text-align:center'><span class='error label'>Error</span><span class='warn label'>Warning</span><span class='system label'>System</span><span class='array label'>Array</span><span class='login label'>Login</span></p>")."');</script>";
|
||||
$tail = 350;
|
||||
} else {
|
||||
$tail = null;
|
||||
}
|
||||
$echo = function($s) {
|
||||
$s = addslashes(substr(trim($s), 8));
|
||||
echo "<script>addLog('".$s."');</script>";
|
||||
$echo = function($s) use ($match) {
|
||||
$line = substr(trim($s), 8);
|
||||
$span = "span";
|
||||
foreach ($match as $type) {
|
||||
foreach ($type['text'] as $text) {
|
||||
if (preg_match("/$text/i",$line)) {
|
||||
$span = "span class='{$type['class']}'";
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
echo "<script>addLog('".addslashes("<$span>".htmlentities($line)."</span>")."');</script>";
|
||||
@flush();
|
||||
};
|
||||
$DockerClient->getContainerLog($container, $echo, $tail, $since);
|
||||
|
||||
@@ -22,7 +22,18 @@ src:url('/webGui/styles/arimo-bold-italic.eot');src:url('/webGui/styles/arimo-bo
|
||||
font-family:'bitstream';font-weight:normal;font-style:normal;
|
||||
src:url('/webGui/styles/bitstream.eot');src:url('/webGui/styles/bitstream.eot?#iefix') format('embedded-opentype'),url('/webGui/styles/bitstream.woff') format('woff'),url('/webGui/styles/bitstream.ttf') format('truetype'),url('/webGui/styles/bitstream.svg#bitstream') format('svg');
|
||||
}
|
||||
.logLine{font-family:bitstream;font-size:11px;text-align:left;}
|
||||
.logLine{font-family:bitstream;font-size:10px;color:#505050;margin:0 8px;padding:0;}
|
||||
.logLine.spacing{margin:10px;}
|
||||
button[type=button],a.button{font-family:arimo;font-size:11px;position:relative;display:inline-block;padding:5px 10px;border:1px solid #E8E8E8;border-radius:5px;margin:7px 14px 0 0;text-decoration:none;white-space:nowrap;cursor:pointer;outline:none;color:#303030;background:-webkit-radial-gradient(#F0F0F0,#C8C8C8);background:linear-gradient(#F0F0F0,#C8C8C8);}
|
||||
button:hover[type=button],a.button:hover{border-color:#6AB034;text-shadow:-1px -1px 0 rgba(0,0,0,0.3);color:#FFFFFF;background:-webkit-radial-gradient(#5E9E2E,#8FD956);background:linear-gradient(#5E9E2E,#8FD956);}
|
||||
button:active[type=button]{border-color:#6AB034;box-shadow:inset 0 0 8px 4px #548C29,0 1px 0 0 #E0E0E0;}
|
||||
p.centered{text-align:center;}
|
||||
span.error{color:#D8000C;background-color:#FFBABA;display:block;width:100%;}
|
||||
span.warn{color:#9F6000;background-color:#FEEFB3;display:block;width:100%;}
|
||||
span.system{color:#00529B;background-color:#BDE5F8;display:block;width:100%;}
|
||||
span.array{color:#4F8A10;background-color:#DFF2BF;display:block;width:100%;}
|
||||
span.login{color:#D63301;background-color:#FFCCBA;display:block;width:100%;}
|
||||
span.label{padding:4px 8px;margin-right:10px;border-radius:4px;display:inline;width:auto;}
|
||||
legend{font-size:12px;font-weight:bold;}
|
||||
#content{margin:10;padding:0;}
|
||||
</style>
|
||||
|
||||
@@ -1,34 +1,3 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2015-2016, Bergware International.
|
||||
* Copyright 2015-2016, Lime Technology
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
require_once '/usr/local/emhttp/webGui/include/ColorCoding.php';
|
||||
|
||||
array_shift($argv);
|
||||
$colorize = ($argv[0] == 'logs');
|
||||
|
||||
if ($colorize) echo "<p style='text-align:center'><span class='error label'>Error</span><span class='warn label'>Warning</span><span class='system label'>System</span><span class='array label'>Array</span><span class='login label'>Login</span></p>\n";
|
||||
$handle = popen('/usr/bin/docker "'.implode('" "',$argv).'"','r');
|
||||
while (!feof($handle)) {
|
||||
$line = fgets($handle);
|
||||
if ($colorize) {
|
||||
$span = "span";
|
||||
foreach ($match as $type) foreach ($type['text'] as $text) if (preg_match("/$text/i",$line)) {$span = "span class='{$type['class']}'"; break 2;}
|
||||
echo "<$span>".htmlentities($line)."</span>";
|
||||
} else {
|
||||
echo $line;
|
||||
}
|
||||
flush();
|
||||
}
|
||||
pclose($handle);
|
||||
?>
|
||||
#!/bin/bash
|
||||
# Just a wrapper.
|
||||
exec /usr/bin/docker "$@"
|
||||
Reference in New Issue
Block a user