1
0

show long error message in selftest admin panel

This commit is contained in:
Mike Schwörer 2020-01-20 20:44:39 +01:00
parent 96494c9f55
commit cf6c496b34
Signed by: Mikescher
GPG Key ID: D3C7172E0A70F8CF
9 changed files with 104 additions and 22 deletions

View File

@ -115,6 +115,10 @@ body {
height: 0 !important; height: 0 !important;
} }
.generic_nodisplay {
display: none !important;
}
.boxedcontent { .boxedcontent {
color: #333333; color: #333333;
border: 1px solid #444444; border: 1px solid #444444;
@ -853,12 +857,32 @@ html, body {
min-width: 300px; min-width: 300px;
} }
.selftest_parent {
width: 800px;
max-width: 100%;
}
.selftest_outputchild {
border: 1px solid #888;
background: #F8F8F8;
color: #000000;
font-family: Consolas, Monaco, "Courier New", Menlo, monospace;
white-space: pre;
max-height: 600px;
overflow-x: auto;
overflow-y: auto;
}
.consistency_result_fin {
cursor: pointer;
}
.consistency_result { .consistency_result {
width: 500px;
color: #222222; color: #222222;
border: 1px solid #888; border: 1px solid #888;
padding: 0 5px; padding: 0 5px;
margin: 1px 0; margin: 1px 0;
flex-grow: 1;
} }
.consistency_result:after { .consistency_result:after {

View File

@ -18,6 +18,7 @@
.blockcontent{display:block;width:100%} .blockcontent{display:block;width:100%}
.generic_hidden{visibility:hidden !important} .generic_hidden{visibility:hidden !important}
.generic_collapsed{visibility:collapse !important;display:none !important;width:0 !important;height:0 !important} .generic_collapsed{visibility:collapse !important;display:none !important;width:0 !important;height:0 !important}
.generic_nodisplay{display:none !important}
.boxedcontent{color:#333;border:1px solid #444;background:#e0e0e0;width:100%;margin-left:auto;margin-right:auto} .boxedcontent{color:#333;border:1px solid #444;background:#e0e0e0;width:100%;margin-left:auto;margin-right:auto}
.boxedcontent .bc_header{background-color:#bbb;color:#222;padding:0 4px} .boxedcontent .bc_header{background-color:#bbb;color:#222;padding:0 4px}
.boxedcontent .bc_data{padding:8px} .boxedcontent .bc_data{padding:8px}
@ -167,7 +168,10 @@ html,body{margin:0;padding:0;height:100%}
.kvl_100 div span:first-child{min-width:100px} .kvl_100 div span:first-child{min-width:100px}
.kvl_200 div span:first-child{min-width:200px} .kvl_200 div span:first-child{min-width:200px}
.kvl_300 div span:first-child{min-width:300px} .kvl_300 div span:first-child{min-width:300px}
.consistency_result{width:500px;color:#222;border:1px solid #888;padding:0 5px;margin:1px 0} .selftest_parent{width:800px;max-width:100%}
.selftest_outputchild{border:1px solid #888;background:#f8f8f8;color:#000;font-family:Consolas,Monaco,"Courier New",Menlo,monospace;white-space:pre;max-height:600px;overflow-x:auto;overflow-y:auto}
.consistency_result_fin{cursor:pointer}
.consistency_result{color:#222;border:1px solid #888;padding:0 5px;margin:1px 0;flex-grow:1}
.consistency_result:after{content:" "} .consistency_result:after{content:" "}
.consistency_result_ok{background:#0f0} .consistency_result_ok{background:#0f0}
.consistency_result_warn{background:#ff0} .consistency_result_warn{background:#ff0}

View File

@ -41,12 +41,32 @@
.kvl_200 div span:first-child { min-width: 200px; } .kvl_200 div span:first-child { min-width: 200px; }
.kvl_300 div span:first-child { min-width: 300px; } .kvl_300 div span:first-child { min-width: 300px; }
.selftest_parent {
width: 800px;
max-width: 100%;
}
.selftest_outputchild {
border: $COL_ADMIN_STATUS_BORDER;
background: $LAYER2_CODE_BG;
color: $LAYER2_CODE_FG;
font-family: $FONT_CODE;
white-space: pre;
max-height: 600px;
overflow-x: auto;
overflow-y: auto;
}
.consistency_result_fin {
cursor: pointer;
}
.consistency_result { .consistency_result {
width: 500px;
color: $COL_ADMIN_STATUS_FG; color: $COL_ADMIN_STATUS_FG;
border: $COL_ADMIN_STATUS_BORDER; border: $COL_ADMIN_STATUS_BORDER;
padding: 0 5px; padding: 0 5px;
margin: 1px 0; margin: 1px 0;
flex-grow: 1;
} }
.consistency_result:after { content: '\00a0' } .consistency_result:after { content: '\00a0' }

View File

@ -85,6 +85,10 @@ body {
height:0 !important; height:0 !important;
} }
.generic_nodisplay {
display: none !important;
}
.boxedcontent { .boxedcontent {
color: $LAYER1_FG; color: $LAYER1_FG;
border: $LAYER1_BORDER; border: $LAYER1_BORDER;

View File

@ -71,14 +71,31 @@ function startAjaxReplace(target, url)
}); });
} }
function showSelfTestOutput(id1, id2)
{
if (!$(id1).hasClass('consistency_result_fin')) return;
if ($(id2).hasClass('generic_nodisplay'))
{
$('.selftest_outputchild').addClass('generic_nodisplay');
$(id2).removeClass('generic_nodisplay');
}
else
{
$('.selftest_outputchild').addClass('generic_nodisplay');
}
}
function refreshConsistencyDisplaySequential(skip) function refreshConsistencyDisplaySequential(skip)
{ {
let i = 0; let i = 0;
for (let apibutton of $('.consistence_ajax_handler').toArray()) for (let apibutton of $('.selftest_sequential .consistence_ajax_handler').toArray())
{ {
if (i++ !== skip) continue; if (i++ !== skip) continue;
const filter = $(apibutton).data('filter'); const filter = $(apibutton).data('filter');
const outdiv = $($(apibutton).data('stid'));
$(apibutton).removeClass('consistency_result_intermed'); $(apibutton).removeClass('consistency_result_intermed');
$(apibutton).addClass('consistency_result_running'); $(apibutton).addClass('consistency_result_running');
@ -89,15 +106,17 @@ function refreshConsistencyDisplaySequential(skip)
let json = JSON.parse(data); let json = JSON.parse(data);
$(apibutton).removeClass('consistency_result_intermed'); $(apibutton).removeClass('consistency_result_intermed');
$(apibutton).removeClass('consistency_result_running'); $(apibutton).removeClass('consistency_result_running');
$(apibutton).addClass('consistency_result_fin');
if (json.result === 0) $(apibutton).addClass('consistency_result_ok'); if (json.result === 0) $(apibutton).addClass('consistency_result_ok');
if (json.result === 1) $(apibutton).addClass('consistency_result_warn'); if (json.result === 1) $(apibutton).addClass('consistency_result_warn');
if (json.result === 2) $(apibutton).addClass('consistency_result_err'); if (json.result === 2) $(apibutton).addClass('consistency_result_err');
$(apibutton).text(json.message); $(apibutton).text(json.message);
$(apibutton).attr('title', json.long); //$(apibutton).attr('title', json.long);
outdiv.text(json.long);
setTimeout(() => refreshConsistencyDisplay(skip+1), 10); setTimeout(() => refreshConsistencyDisplaySequential(skip+1), 10);
}) })
.fail((xhr, status, err) => .fail((xhr, status, err) =>
{ {
@ -105,17 +124,21 @@ function refreshConsistencyDisplaySequential(skip)
$(apibutton).removeClass('consistency_result_running'); $(apibutton).removeClass('consistency_result_running');
$(apibutton).addClass('consistency_result_err'); $(apibutton).addClass('consistency_result_err');
$(apibutton).text(err); $(apibutton).addClass('consistency_result_fin');
$(apibutton).text(("" + err).substr(0, 48));
setTimeout(() => refreshConsistencyDisplay(skip+1), 10); //$(apibutton).attr('title', json.long);
outdiv.text(err);
setTimeout(() => refreshConsistencyDisplaySequential(skip+1), 10);
}); });
} }
} }
function refreshConsistencyDisplayParallel(skip) function refreshConsistencyDisplayParallel()
{ {
for (let apibutton of $('.consistence_ajax_handler').toArray()) for (let apibutton of $('.selftest_parallel .consistence_ajax_handler').toArray())
{ {
const filter = $(apibutton).data('filter'); const filter = $(apibutton).data('filter');
@ -149,6 +172,6 @@ function refreshConsistencyDisplayParallel(skip)
$(function() $(function()
{ {
//setTimeout(() => refreshConsistencyDisplaySequential(0), 200); for (let apibutton of $('.selftest_sequential').toArray()) setTimeout(() => refreshConsistencyDisplaySequential(0), 200);
setTimeout(() => refreshConsistencyDisplayParallel(), 200); for (let apibutton of $('.selftest_parallel').toArray()) setTimeout(() => refreshConsistencyDisplayParallel(), 200);
}); });

View File

@ -259,17 +259,21 @@ class SelfTest implements IWebsiteModule
$message = ''; $message = '';
$count = 0; $count = 0;
$i = 0;
foreach ($supdata as $d) foreach ($supdata as $d)
{ {
$i++;
$sxname = $xname . '-' . $i;
$url = 'https://' . $_SERVER['HTTP_HOST'] . str_replace('{0}', $d, $path); $url = 'https://' . $_SERVER['HTTP_HOST'] . str_replace('{0}', $d, $path);
$r = curl_http_request($url); $r = curl_http_request($url);
$count++; $count++;
if ($r['statuscode'] === $status) { $message .= "{".$xname."} succeeded" . "\n"; continue; } if ($r['statuscode'] === $status) { $message .= " {".$sxname."} succeeded" . "\n"; continue; }
return return
[ [
'result' => self::STATUS_ERROR, 'result' => self::STATUS_ERROR,
'message' => '{'.$xname.'} failed: Request returned wrong statuscode', 'message' => '{'.$sxname.'} failed: Request returned wrong statuscode',
'long' => 'Wrong HTTP Statuscode (Expected: ['.$status.']; Found: ['.$r['statuscode'].'])' . "\n". 'long' => 'Wrong HTTP Statuscode (Expected: ['.$status.']; Found: ['.$r['statuscode'].'])' . "\n".
"URL: $url\n". "URL: $url\n".
"Redirect: " . $r['redirect'] . "\n" . "Redirect: " . $r['redirect'] . "\n" .
@ -282,7 +286,7 @@ class SelfTest implements IWebsiteModule
return return
[ [
'result' => self::STATUS_OK, 'result' => self::STATUS_OK,
'message' => "$count requests succeeded\n" . rtrim($message, "\n"), 'message' => "$count requests succeeded\n" . trim($message, "\n"),
'long' => null, 'long' => null,
'exception' => null, 'exception' => null,
]; ];

View File

@ -245,7 +245,6 @@ function formatException($e)
$xdbg = str_replace('<br>', "\n", $xdbg); $xdbg = str_replace('<br>', "\n", $xdbg);
$xdbg = str_replace('><', "> <", $xdbg); $xdbg = str_replace('><', "> <", $xdbg);
$xdbg = strip_tags($xdbg); $xdbg = strip_tags($xdbg);
$xdbg = htmlspecialchars($xdbg);
$r .= $xdbg . "\n"; $r .= $xdbg . "\n";
} }
return $r; return $r;

View File

@ -11,8 +11,8 @@ $FRAME_OPTIONS->title = 'Admin';
$FRAME_OPTIONS->canonical_url = 'https://www.mikescher.com/admin'; $FRAME_OPTIONS->canonical_url = 'https://www.mikescher.com/admin';
$FRAME_OPTIONS->activeHeader = 'admin'; $FRAME_OPTIONS->activeHeader = 'admin';
$FRAME_OPTIONS->addScript('https://code.jquery.com/jquery-latest.min.js', true); $FRAME_OPTIONS->addScript('https://code.jquery.com/jquery-latest.min.js', false);
$FRAME_OPTIONS->addScript('/data/javascript/admin.js', true); $FRAME_OPTIONS->addScript('/data/javascript/admin.js', false);
$connected = true; try { $SITE->modules->Database(); } catch (Exception $e) { $connected = false; } $connected = true; try { $SITE->modules->Database(); } catch (Exception $e) { $connected = false; }
@ -54,9 +54,13 @@ $connected = true; try { $SITE->modules->Database(); } catch (Exception $e) { $c
<div class="bc_header">Self test</div> <div class="bc_header">Self test</div>
<div class="bc_data"> <div class="bc_data">
<div class="keyvaluelist kvl_200"> <div class="keyvaluelist kvl_200 selftest_parent <?php echo $SITE->isProd() ? 'selftest_parallel' : 'selftest_sequential' ?>">
<?php foreach ($SITE->modules->SelfTest()->listMethodGroups() as $group): ?> <?php $stid=1000; foreach ($SITE->modules->SelfTest()->listMethodGroups() as $group): $stid++; ?>
<div><span><?php echo $group['name']; ?></span><span class='consistency_result consistency_result_intermed consistence_ajax_handler' data-filter="<?php echo $group['filter']; ?>">&nbsp;</span></div> <div class="selftest_tabchild" onclick="showSelfTestOutput('#selftest_tab_<?php echo $stid; ?>', '#selftest_out_<?php echo $stid; ?>')">
<span><?php echo $group['name']; ?></span>
<span class='consistency_result consistency_result_intermed consistence_ajax_handler' id="selftest_tab_<?php echo $stid; ?>" data-filter="<?php echo $group['filter']; ?>" data-stid="#selftest_out_<?php echo $stid; ?>"></span>
</div>
<div class="selftest_outputchild generic_nodisplay" id="selftest_out_<?php echo $stid; ?>">&nbsp;</div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<br/> <br/>

View File

@ -22,6 +22,6 @@ $debuginfo = $ROUTE->parameter['debuginfo'];
<div class="ev_code">500</div> <div class="ev_code">500</div>
<div class="ev_msg"><?php echo $message; ?></div> <div class="ev_msg"><?php echo $message; ?></div>
<?php if ($debuginfo !== null && strlen($debuginfo)>0 && ($SITE != null && !$SITE->isProd())): ?> <?php if ($debuginfo !== null && strlen($debuginfo)>0 && ($SITE != null && !$SITE->isProd())): ?>
<p class="ev_statusmore"><?php echo nl2br($debuginfo); ?></p> <p class="ev_statusmore"><?php echo nl2br(htmlspecialchars($debuginfo)); ?></p>
<?php endif; ?> <?php endif; ?>
</div> </div>