From cf6c496b34ce69d57b3f75e3a7a24fb7065f86f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Mon, 20 Jan 2020 20:44:39 +0100 Subject: [PATCH] show long error message in selftest admin panel --- www/data/css/styles.css | 26 ++++++++++++++++++- www/data/css/styles.min.css | 6 ++++- www/data/css/styles_admin.scss | 22 +++++++++++++++- www/data/css/styles_global.scss | 4 +++ www/data/javascript/admin.js | 41 +++++++++++++++++++++++------- www/internals/modules/selftest.php | 10 +++++--- www/internals/utils.php | 1 - www/pages/admin.php | 14 ++++++---- www/pages/error_servererror.php | 2 +- 9 files changed, 104 insertions(+), 22 deletions(-) diff --git a/www/data/css/styles.css b/www/data/css/styles.css index 4beadf0..7fed657 100644 --- a/www/data/css/styles.css +++ b/www/data/css/styles.css @@ -115,6 +115,10 @@ body { height: 0 !important; } +.generic_nodisplay { + display: none !important; +} + .boxedcontent { color: #333333; border: 1px solid #444444; @@ -853,12 +857,32 @@ html, body { 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 { - width: 500px; color: #222222; border: 1px solid #888; padding: 0 5px; margin: 1px 0; + flex-grow: 1; } .consistency_result:after { diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css index 5f4c5c8..dc128f2 100644 --- a/www/data/css/styles.min.css +++ b/www/data/css/styles.min.css @@ -18,6 +18,7 @@ .blockcontent{display:block;width:100%} .generic_hidden{visibility:hidden !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 .bc_header{background-color:#bbb;color:#222;padding:0 4px} .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_200 div span:first-child{min-width:200px} .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_ok{background:#0f0} .consistency_result_warn{background:#ff0} diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss index 462c48e..4e921de 100644 --- a/www/data/css/styles_admin.scss +++ b/www/data/css/styles_admin.scss @@ -41,12 +41,32 @@ .kvl_200 div span:first-child { min-width: 200px; } .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 { - width: 500px; color: $COL_ADMIN_STATUS_FG; border: $COL_ADMIN_STATUS_BORDER; padding: 0 5px; margin: 1px 0; + flex-grow: 1; } .consistency_result:after { content: '\00a0' } diff --git a/www/data/css/styles_global.scss b/www/data/css/styles_global.scss index 50e4a94..7f49e3a 100644 --- a/www/data/css/styles_global.scss +++ b/www/data/css/styles_global.scss @@ -85,6 +85,10 @@ body { height:0 !important; } +.generic_nodisplay { + display: none !important; +} + .boxedcontent { color: $LAYER1_FG; border: $LAYER1_BORDER; diff --git a/www/data/javascript/admin.js b/www/data/javascript/admin.js index 1cb4aba..369f565 100644 --- a/www/data/javascript/admin.js +++ b/www/data/javascript/admin.js @@ -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) { 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; const filter = $(apibutton).data('filter'); + const outdiv = $($(apibutton).data('stid')); $(apibutton).removeClass('consistency_result_intermed'); $(apibutton).addClass('consistency_result_running'); @@ -89,15 +106,17 @@ function refreshConsistencyDisplaySequential(skip) let json = JSON.parse(data); $(apibutton).removeClass('consistency_result_intermed'); $(apibutton).removeClass('consistency_result_running'); + $(apibutton).addClass('consistency_result_fin'); if (json.result === 0) $(apibutton).addClass('consistency_result_ok'); if (json.result === 1) $(apibutton).addClass('consistency_result_warn'); if (json.result === 2) $(apibutton).addClass('consistency_result_err'); $(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) => { @@ -105,17 +124,21 @@ function refreshConsistencyDisplaySequential(skip) $(apibutton).removeClass('consistency_result_running'); $(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'); @@ -149,6 +172,6 @@ function refreshConsistencyDisplayParallel(skip) $(function() { - //setTimeout(() => refreshConsistencyDisplaySequential(0), 200); - setTimeout(() => refreshConsistencyDisplayParallel(), 200); + for (let apibutton of $('.selftest_sequential').toArray()) setTimeout(() => refreshConsistencyDisplaySequential(0), 200); + for (let apibutton of $('.selftest_parallel').toArray()) setTimeout(() => refreshConsistencyDisplayParallel(), 200); }); \ No newline at end of file diff --git a/www/internals/modules/selftest.php b/www/internals/modules/selftest.php index 4152cc9..2af2bda 100644 --- a/www/internals/modules/selftest.php +++ b/www/internals/modules/selftest.php @@ -259,17 +259,21 @@ class SelfTest implements IWebsiteModule $message = ''; $count = 0; + $i = 0; foreach ($supdata as $d) { + $i++; + $sxname = $xname . '-' . $i; + $url = 'https://' . $_SERVER['HTTP_HOST'] . str_replace('{0}', $d, $path); $r = curl_http_request($url); $count++; - if ($r['statuscode'] === $status) { $message .= "{".$xname."} succeeded" . "\n"; continue; } + if ($r['statuscode'] === $status) { $message .= " {".$sxname."} succeeded" . "\n"; continue; } return [ '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". "URL: $url\n". "Redirect: " . $r['redirect'] . "\n" . @@ -282,7 +286,7 @@ class SelfTest implements IWebsiteModule return [ 'result' => self::STATUS_OK, - 'message' => "$count requests succeeded\n" . rtrim($message, "\n"), + 'message' => "$count requests succeeded\n" . trim($message, "\n"), 'long' => null, 'exception' => null, ]; diff --git a/www/internals/utils.php b/www/internals/utils.php index 58b2be5..6debb91 100644 --- a/www/internals/utils.php +++ b/www/internals/utils.php @@ -245,7 +245,6 @@ function formatException($e) $xdbg = str_replace('
', "\n", $xdbg); $xdbg = str_replace('><', "> <", $xdbg); $xdbg = strip_tags($xdbg); - $xdbg = htmlspecialchars($xdbg); $r .= $xdbg . "\n"; } return $r; diff --git a/www/pages/admin.php b/www/pages/admin.php index a9d9d92..231279a 100644 --- a/www/pages/admin.php +++ b/www/pages/admin.php @@ -11,8 +11,8 @@ $FRAME_OPTIONS->title = 'Admin'; $FRAME_OPTIONS->canonical_url = 'https://www.mikescher.com/admin'; $FRAME_OPTIONS->activeHeader = 'admin'; -$FRAME_OPTIONS->addScript('https://code.jquery.com/jquery-latest.min.js', true); -$FRAME_OPTIONS->addScript('/data/javascript/admin.js', true); +$FRAME_OPTIONS->addScript('https://code.jquery.com/jquery-latest.min.js', false); +$FRAME_OPTIONS->addScript('/data/javascript/admin.js', 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
Self test
-
- modules->SelfTest()->listMethodGroups() as $group): ?> -
 
+
+ modules->SelfTest()->listMethodGroups() as $group): $stid++; ?> +
+ + +
+
 

diff --git a/www/pages/error_servererror.php b/www/pages/error_servererror.php index 7e1439c..1f2a51c 100644 --- a/www/pages/error_servererror.php +++ b/www/pages/error_servererror.php @@ -22,6 +22,6 @@ $debuginfo = $ROUTE->parameter['debuginfo'];
500
0 && ($SITE != null && !$SITE->isProd())): ?> -

+

\ No newline at end of file