From 2b8e01a157de076dd02ad0b276193fe3a3a90d86 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Mon, 28 Aug 2023 15:14:59 +0200 Subject: [PATCH] admin: show a welcome message after install --- public_html/admin/index.php | 113 +++++++++++++++++++++--------------- public_html/admin/main.css | 1 + 2 files changed, 68 insertions(+), 46 deletions(-) diff --git a/public_html/admin/index.php b/public_html/admin/index.php index 9b52942..d73dcf8 100644 --- a/public_html/admin/index.php +++ b/public_html/admin/index.php @@ -13,6 +13,7 @@ * ---------------------------------------------------------------------- * 2022-02-03 v0.1 <axel.hahn@iml.unibe.ch> initial version * 2022-05-31 v0.2 <axel.hahn@iml.unibe.ch> optical changes; use debugredirect=1 if url is a local domain + * 2023-08-28 v1.0 <axel.hahn@unibe.ch> Welcome message if there is no config yet * ---------------------------------------------------------------------- */ @@ -37,6 +38,7 @@ $aIco=[ 'type_alias'=>'◻️', 'url'=>'🌐', + 'welcome'=>'🪄', ]; // ---------------------------------------------------------------------- @@ -99,32 +101,7 @@ if (!$oR->isEnabled()){ // ---------- LOOP OVER ALL ENTRIES - - $sHtml.=' - <!-- - <h2>'.$aIco['h2_head'].' Http head tester</h2> - <div class="content"> - <form> - '.$aIco['url'].' <input type="text" name="url" size="100" value="'.$sUrl.'" placeholder="Enter url or click a link in the table below."/> - <button>Http HEAD</button> - </form> - </div> - <br> - --> - <h2>'.$aIco['h2_config'].' Domains and their redirects</h2> - <div class="content"> - - <table class="mydatatable"><thead> - <tr> - <th>Host</th> - <th>Ip address</th> - <th>Setup</th> - <th>Type</th> - <th>From</th> - <th>Code</th> - <th>Target</th> - </tr> - </thead><tbody>'; + $sTable=''; foreach($aHosts as $sHost => $aCfg){ $sTdFirst='<tr class="cfgtype-'.$aCfg['type'].'">' .'<td>' @@ -159,7 +136,7 @@ if (!$oR->isEnabled()){ if (count($aCfg['redirects'][$sType])){ foreach($aCfg['redirects'][$sType] as $sFrom=>$aTo){ $iCount++; - $sHtml.=$sTdFirst + $sTable.=$sTdFirst .'<td class="type-'.$sType.'">'.$sType.'</td>' .'<td class="type-'.$sType.'">' .($sType == 'direct' @@ -177,29 +154,26 @@ if (!$oR->isEnabled()){ } else { // type = alias // $sHtml.='<tr>'.$sTdFirst.'<td></td><td></td><td></td><td>'.(isset($aCfg['target']) ? 'see config for <a href="#'.getId($aCfg['target']).'">'.$aCfg['target'].'</a>' : '').'</td></tr>'; - $sHtml.=$sTdFirst.'<td></td><td></td><td></td><td>'.(isset($aCfg['target']) ? 'see config for <em>'.$aCfg['target'].'</em>' : '').'</td></tr>'; + $sTable.=$sTdFirst.'<td></td><td></td><td></td><td>'.(isset($aCfg['target']) ? 'see config for <em>'.$aCfg['target'].'</em>' : '').'</td></tr>'; } } - $sHtml.='</tbody></table></div>' - /* - .'<h2>Config array</h2> - <pre>'.print_r($aHosts, 1).'</pre>' - */ - ; - $sErrors = $sErrors - ? '<h2>'.$aIco['h2_err'].' Found errors</h2>' - .'<div class="content">' - .'<ol class="error">' - .$sErrors - .'</ol>' - .'</div>' - : '' - ; + $sTable=''; - $sHtml.='' - .'<br><br>' + $sTable=$sTable + ? '<table class="mydatatable"><thead> + <tr> + <th>Host</th> + <th>Ip address</th> + <th>Setup</th> + <th>Type</th> + <th>From</th> + <th>Code</th> + <th>Target</th> + </tr> + </thead><tbody>'.$sTable.'</tbody></table></div>' + . '<br><br>' .'<div class="content legend">' . '<strong>Legend</strong>:<br>' . '<table><tbody>' @@ -230,7 +204,54 @@ if (!$oR->isEnabled()){ .'</tbody></table>' .'</div>' - .'<footer><a href="'.$oR->urlRepo.'">Source</a> | <a href="'.$oR->urlDocs.'">Docs</a></footer>' + : '<h3>'.$aIco['welcome'].' Welcome!</h3> + <p> + Thank you for the installation!<br> + Now is a good moment to create your first config. + </p> + <ul> + <li>Go to the directory ./config/</li> + <li>Watch the *.dist files - make a copy of them to *.json (without .dist)</li> + <li>Relaod this page</li> + </ul> + <p> + See the <a href="'.$oR->urlDocs.'Configuration.html" target="_blank">Docs</a> for details. + </p> + ' + ; + + $sHtml.=' + <!-- + <h2>'.$aIco['h2_head'].' Http head tester</h2> + <div class="content"> + <form> + '.$aIco['url'].' <input type="text" name="url" size="100" value="'.$sUrl.'" placeholder="Enter url or click a link in the table below."/> + <button>Http HEAD</button> + </form> + </div> + <br> + --> + <h2>'.$aIco['h2_config'].' Domains and their redirects</h2> + <div class="content">' + + /* + .'<h2>Config array</h2> + <pre>'.print_r($aHosts, 1).'</pre>' + */ + .$sTable + ; + + $sErrors = $sErrors + ? '<h2>'.$aIco['h2_err'].' Found errors</h2>' + .'<div class="content">' + .'<ol class="error">' + .$sErrors + .'</ol>' + .'</div>' + : '' + ; + + $sHtml.='<footer><a href="'.$oR->urlRepo.'">Source</a> | <a href="'.$oR->urlDocs.'">Docs</a></footer>' ; } diff --git a/public_html/admin/main.css b/public_html/admin/main.css index a09355a..8e5e4da 100644 --- a/public_html/admin/main.css +++ b/public_html/admin/main.css @@ -3,6 +3,7 @@ body{background: #f8f8f8; color: #234; font-family: arial; margin: 0;} h1{background:rgba(0,0,0,0.05); margin: 0 0 1em;; padding: 0.5em;} h1 a{color:#234; text-decoration: none;} h2{background: #d0e0e8; color:#458; margin: 1em 0 0.5em; border-top: 2px solid #fff; border-left: 5px solid #fff; border-top-left-radius: 0.5em; padding: 0.5em; margin: 0 0 1em;} +h3{color:#ccc; font-size: 250%} pre{background: rgba(0,0,0,0.02);padding: 0.3em 1em; border: 1px solid rgba(0,0,0,0.1); margin: 2em 0 3em;; border-bottom: 2px solid rgba(0,0,0,0.2);} -- GitLab