Skip to content
Snippets Groups Projects
Commit 95aca40e authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

add page for valuestore

parent 04637992
Branches
No related tags found
1 merge request!62V2.0
......@@ -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' => '&nbsp;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 = [
......
......@@ -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);
......@@ -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\
&nbsp;<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\
&nbsp;<span id="filterinfo"></span>\n\
</form><div style="clear: both;"></div>';
$(sForm).insertBefore($("table").first());
}
......
......@@ -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
<?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;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment