diff --git a/public_html/deployment/inc_functions.php b/public_html/deployment/inc_functions.php index 19d3f1e0e5875f53e8cee91226a8a2006dd97951..7a602e2153b2e8189f728aad4b81ee34141d77a4 100644 --- a/public_html/deployment/inc_functions.php +++ b/public_html/deployment/inc_functions.php @@ -150,11 +150,9 @@ function getTopNavLeft($aEmbed = []) $sBaseUrl = '/deployment/'; $sBaseUrl = '/deployment/'; - $sWikiBaseUrl = 'https://intranet.iml.unibe.ch/wiki/doku.php'; $sCurrentProject = (array_key_exists("prj", $aParams) && $aParams["prj"] <> "all") ? $aParams["prj"] : false; $sCurrentAction = (array_key_exists("action", $aParams) && $aParams["action"]) ? $aParams["action"] : false; $sCurrentPar3 = (array_key_exists("par3", $aParams) && $aParams["par3"]) ? $aParams["par3"] : false; - $sLiActive = ' class="active"'; // $aReturn[]=['label'=>'=' ]; $aReturn[] = ['href' => $sBaseUrl . '', 'label' => ' Deployment UI <small class="badge bg-info"><nobr>v' . APP_VERSION . '</nobr></small>', 'icon' => '', 'class' => 'imllogo topbrand']; @@ -179,12 +177,15 @@ function getTopNavLeft($aEmbed = []) */ $aReturn[] = [ - 'href' => $sBaseUrl, 'label' => t("menu"), 'class' => (array_key_exists("prj", $aParams) && $aParams['prj'] === 'all' ? 'active' : ''), + 'href' => $sBaseUrl, 'label' => t("menu"), 'icon' => 'fa-solid fa-chevron-right', + 'class' => ($sCurrentAction === 'setup' || $sCurrentAction === 'valuestore' ? 'active' : ''), 'children' => [ - ['href' => $sBaseUrl . 'all/setup/new/', 'label' => t("menu-new-project"), 'icon' => 'fa-regular fa-star'], - ['href' => $sBaseUrl . 'all/setup/actionlog/', 'label' => t("menu-logs"), 'icon' => 'fa-regular fa-rectangle-list'], - ['href' => $sBaseUrl . 'all/setup/checklang/', 'label' => t("menu-checklang"), 'icon' => 'fa-regular fa-comment'], + ['href' => $sBaseUrl . 'all/setup/new/', 'label' => t("menu-new-project"), 'icon' => 'fa-regular fa-star', 'class' => ($sCurrentPar3 === 'new' ? 'active' : ''),], + ['href' => $sBaseUrl . 'all/setup/actionlog/', 'label' => t("menu-logs"), 'icon' => 'fa-regular fa-rectangle-list', 'class' => ($sCurrentPar3 === 'actionlog' ? 'active' : ''),], + ['href' => $sBaseUrl . 'all/valuestore/', 'label' => t("menu-valuestore"), 'icon' => 'fa-solid fa-tags', 'class' => ($sCurrentAction === 'valuestore' ? 'active' : ''),], + ['href' => $sBaseUrl . 'all/setup/checklang/', 'label' => t("menu-checklang"), 'icon' => 'fa-regular fa-comment', 'class' => ($sCurrentPar3 === 'checklang' ? 'active' : ''),], + ['label' => '-'], ['href' => $sBaseUrl . 'all/setup/', 'label' => t("menu-settings"), 'icon' => 'fa-solid fa-gear'], ] ]; @@ -238,10 +239,7 @@ function getTopNavRight() $sBaseUrl = '/deployment/'; $sWikiBaseUrl = 'https://intranet.iml.unibe.ch/wiki/doku.php'; - $sCurrentProject = (array_key_exists("prj", $aParams) && $aParams["prj"] <> "all") ? $aParams["prj"] : false; $sCurrentAction = (array_key_exists("action", $aParams) && $aParams["action"]) ? $aParams["action"] : false; - $sCurrentPar3 = (array_key_exists("par3", $aParams) && $aParams["par3"]) ? $aParams["par3"] : false; - $sLiActive = ' class="active"'; if ($oUser->getUsername()) { $aReturn = [ @@ -263,7 +261,7 @@ function getTopNavRight() ['href' => $sWikiBaseUrl . '/it/entwicklung/continuous_deployment#konventionen', 'target' => '_help', 'label' => 'WIKI: Konventionen für Entwickler', 'icon' => ''], ['href' => $sWikiBaseUrl . '/it/infrastruktur/se/snippets/iml.deployment_profile', 'target' => '_help', 'label' => 'WIKI (Admin): Snippets für den Sysadmin', 'icon' => ''], ['href' => $sWikiBaseUrl . '/it/infrastruktur/dienste/imldeployment', 'target' => '_help', 'label' => 'WIKI (Admin): Verzeichnisse und Dateien', 'icon' => ''], - ['href' => $sBaseUrl . 'all/doc', 'label' => t('menu-help-classes'), 'icon' => ''], + ['href' => $sBaseUrl . 'all/doc', 'label' => t('menu-help-classes'), 'icon' => ''], ] ]; diff --git a/public_html/deployment/index.php b/public_html/deployment/index.php index 6b1887424b36eade5ccc69388fa6fcf7fef3ff98..083ed2b64687d077c961fe6d68dc0010e64131f3 100644 --- a/public_html/deployment/index.php +++ b/public_html/deployment/index.php @@ -133,6 +133,7 @@ if($oUser->getUsername()){ // ---------------------------------------------------------------------- $BODY=""; $TITLE=""; +$JS=''; $sBanner=isset($aConfig['banner']) && $aConfig['banner'] ? '<div class="alert alert-info">'.$aConfig['banner'].'</div>' : ''; @@ -280,9 +281,9 @@ if(!file_exists($sIncfile)){ // ---------- generate output $aReplace['{{PAGE_BODY}}']=$BODY; -$aReplace['{{PAGE_BODY}}']=$BODY; $aReplace['{{PAGE_HEADER_LEFT}}']='<h2>'.$TITLE.'</h2>'; $aReplace['{{PAGE_HEADER_RIGHT}}']=$oUser->getUsername() ? getBreadcrumb("link") : ''; +$aReplace['{{INJECT_JS}}']=$JS; $sTemplate=file_get_contents('ui/page.tpl.php'); echo $renderAdminLTE->render($sTemplate,$aReplace); diff --git a/public_html/deployment/js/functions.js b/public_html/deployment/js/functions.js index c2ce242eb680c4ec5b96692f6e4e279aeda9a955..f17fd271810902a05ff293bb9d01aa4b22d5c772 100644 --- a/public_html/deployment/js/functions.js +++ b/public_html/deployment/js/functions.js @@ -400,15 +400,13 @@ jQuery.fn.removeHighlight = function () { */ function addFilterToTable() { var sValue = localStorage.getItem(localStoreTablefilter) ? localStorage.getItem(localStoreTablefilter) : ''; - var sForm = '<form class="pure-form">\n\ - <fieldset>\n\ + var sForm = '<form class="form-inline">\n\ <label for="eFilter">\n\ - <i class="fa fa-filter"></i> Tabelle filtern\n\ + <i class="fas fa-filter"></i> Tabelle filtern\n\ </label>\n\ - <input type="text" id="eFilter" size="40" name="q" placeholder="Suchbegriff..." value="'+ sValue + '" onkeypress="filterTable(this);" onkeyup="filterTable(this);" onchange="filterTable(this);">\n\ - <button class="pure-button" onclick="$(\'#eFilter\').val(\'\'); filterTable(); return false;"><i class="fa fa-times"></i> </button>\n\ - <span id="filterinfo"></span>\n\ - </fieldset>\n\ + <input type="text" class="form-control" id="eFilter" size="40" name="q" placeholder="Suchbegriff..." value="'+ sValue + '" onkeypress="filterTable(this);" onkeyup="filterTable(this);" onchange="filterTable(this);">\n\ + <button class="btn btn-secondary" onclick="$(\'#eFilter\').val(\'\'); filterTable(); return false;"><i class="fa fa-times"></i> </button>\n\ + <span id="filterinfo"></span>\n\ </form><div style="clear: both;"></div>'; $(sForm).insertBefore($("table").first()); } diff --git a/public_html/deployment/main.css b/public_html/deployment/main.css index 4b73a0ee6fa04d6f92d474d89d472a31cd704803..a1b070215884755d827ffdf9cd511dc5b125000a 100644 --- a/public_html/deployment/main.css +++ b/public_html/deployment/main.css @@ -340,7 +340,7 @@ tr:hover td.prj>div { } td.prj>div.deployprogress { - border-top: 1px dashed #ccc; + border-top: 0px dashed #ccc; } .dev { @@ -681,19 +681,13 @@ div.logs { /* ----- valuestore browser ----- */ +#tbldata{ +} #tbldata th { - background: #ace; - border: none; float: none; } -#tbldata tr:hover { - background: #fec; -} - #tbldata td { border: none; padding: 0.2em; - margin: none; - float: none; } \ No newline at end of file diff --git a/public_html/deployment/pages/act_valuestore.php b/public_html/deployment/pages/act_valuestore.php new file mode 100644 index 0000000000000000000000000000000000000000..3a35881fa7aa8a92a5d1f5c4d574115d1214acd3 --- /dev/null +++ b/public_html/deployment/pages/act_valuestore.php @@ -0,0 +1,157 @@ +<?php + +/* ###################################################################### + + IML DEPLOYMENT + + VALUESTORE + + --------------------------------------------------------------------- + 2023-11-24 Axel <axel.hahn@unibe.ch> + ###################################################################### */ + + +$TITLE=t('menu-valuestore'); + +// ---------------------------------------------------------------------- +// functions +// ---------------------------------------------------------------------- + +/** + * show an error message and quit with http status code 400 (Bad request) + * @param string $sMessage message to show + * @return boolean + */ +function quit($sMessage) +{ + $sProtocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'); + header("$sProtocol 400: Bad request"); + die("<h1>Bad request</h1>" . $sMessage); + return false; +} + +/** + * get a request param from GET and POST scope (POST has priority) and + * verify it with execution of a cleanup array + * @param string $sKey key to search for in GET or POST + * @param string $sRegex4Cleanup regex for filtering + * @return type + */ +function getParam($sKey, $sRegex4Cleanup = false) +{ + $sValue = false; + if (array_key_exists($sKey, $_GET)) { + $sValue = $_GET[$sKey]; + } + if (array_key_exists($sKey, $_POST)) { + $sValue = $_POST[$sKey]; + } + if (!$sValue) { + return false; + } + $sReturn = $sRegex4Cleanup ? preg_replace($sRegex4Cleanup, '', $sValue) : $sValue; + + if ($sReturn !== $sValue) { + quit("ERROR: the parameter value in [$sKey = ...] has a wrong format."); + } + return $sReturn; +} + +// ---------------------------------------------------------------------- +// check required params +// ---------------------------------------------------------------------- +/* +if (!$_GET || !count($_GET)) { + quit("no parameter was found."); +} + +foreach (array("action", "project") as $sKey) { + if (!array_key_exists($sKey, $_GET)) { + quit("value required: $sKey="); + } +} +*/ + + +// ---------------------------------------------------------------------- +// get vars +// ---------------------------------------------------------------------- + + +$sAction = getParam('action', '/[^a-z]/'); + +$sProject = getParam('project', '/[^a-z\-0-9]/'); +$sPhase = getParam('phase', '/[^a-z]/'); +$sPlace = getParam('place', '/[^a-z]/'); +$sHost = getParam('host', '/[^a-z\.\-0-9]/'); + +if ($sHost && !$sPlace) { + $sPlace = 'installed'; +} + +$sVarname = getParam('variable', '/[^a-z]/'); +$sValue = getParam('value', ''); + + +// ---------------------------------------------------------------------- +// init class +// ---------------------------------------------------------------------- + +$sOut = ''; +$sHeader = ''; +$sOut .= '' + .'<p>'.t('page-valuestore-hint').'</p>' + ; +require './../valuestore/classes/valuestore.class.php'; + +$oVersion = new valuestore(); + +$aData = $oVersion->dumpdb(); +$sTable = ''; +$sTableHead = ''; +if (is_array($aData) && count($aData)) { + // echo '<pre>' . print_r($aData, 1); + $aMyColumns = ['time', 'package', 'phase', 'place', 'host', /*'variable',*/ 'data']; + foreach ($aData as $aRow) { + $sItemUrl = '/valuestore/index.php?action=show&project=' . $aRow['project'] . '&package=' . $aRow['package'] . '&phase=' . $aRow['phase'] . '&host=' . $aRow['host'] . '&variable=' . $aRow['variable'] . ''; + $sTable .= '<tr ondblclick="location.href=\'' . $sItemUrl . '\'">'; + // $sTable.='<tr>'; + // foreach ($aRow as $sKey=>$sValue){ + foreach ($aMyColumns as $sKey) { + $sValue = $aRow[$sKey]; + // $sTable.='<td class="'.$sKey.'"><a href="'.$sUrl.'">'.$sValue.'</a></td>'; + $sOnclick = ''; + $sLabel = strstr($sValue, '"') + ? '<small>'.htmlentities($sValue).'</small>' + : '<a href="#" onclick="$(\'#eFilter\').val(\'' . $sValue . '\');filterTable();" title="click to filter by [' . $sValue . ']">' . htmlentities($sValue) . '</a>'; + $sTable .= '<td class="' . $sKey . '" ' . $sOnclick . '>' . $sLabel . '</td>' . "\n"; + } + $sTable .= '<td>' + // . '<button onclick="location.href=\''.$sItemUrl.'&action=get\'">View</button>' + . '<form method="POST" action="' . $sItemUrl . '">' + . '<input type="hidden" name="action" value="delete">' + . '<button class="btn btn-secondary">Delete</button>' + . '</form>' + . '</td>' + . '</tr>' . "\n"; + } + foreach ($aMyColumns as $sKey) { + $sTableHead .= '<th class="' . $sKey . '">' . $sKey . '</th>'; + } + $sOut .= '' + . '<form method="POST" action="/valuestore/index.php">' + . '<input type="hidden" name="action" value="cleanupTEST">' + . '<button class="btn btn-secondary">Cleanup (older 1d)</button>' + . '</form><hr>' + + . '<table id="tbldata" class="table">' + . '<tr>' . $sTableHead . '<th>action</th></tr>' + . '</thead>' + . '<tbody>' . $sTable . '</tbody></table>'; + $JS .= 'addFilterToTable(); filterTable();'; +} else { + $sOut .= 'no data yet.'; +} + +// -- Ausgabe +echo $sOut;