From 2c56ffb968b87343fd7ef1afc533ff3f7c4a0dda Mon Sep 17 00:00:00 2001 From: hahn <axel.hahn@iml.unibe.ch> Date: Thu, 21 Jul 2022 12:10:30 +0200 Subject: [PATCH] added feature: project groups --- config/lang/de.json | 1 + config/lang/en.json | 9 ++-- hooks/templates/inc_projects_config.php.erb | 6 +++ .../deployment/classes/project.class.php | 45 ++++++++++++++-- .../deployment/classes/projectlist.class.php | 51 ++++++++++++++++++- public_html/deployment/main.css | 11 ++-- 6 files changed, 109 insertions(+), 14 deletions(-) diff --git a/config/lang/de.json b/config/lang/de.json index 9a5672c2..6029c03e 100644 --- a/config/lang/de.json +++ b/config/lang/de.json @@ -309,6 +309,7 @@ "project": "Projekt", "project-home": "Projekt Startseite", "projectdescription": "Kurzbeschreibung", + "projectgroup": "Projektgruppe", "projectname": "Projektname", "projectmanager": "Projektleiter", "queue": "Queue", diff --git a/config/lang/en.json b/config/lang/en.json index 6af3553c..aad569c9 100644 --- a/config/lang/en.json +++ b/config/lang/en.json @@ -235,7 +235,7 @@ "build-failes-none": "No failed builds were recorded yet.", "change": "Change", "commitmessage": "Commit message", - "contact": "contact", + "contact": "Contact", "cleanup": "Cleanup", "creating-directory": "Creating directory %s", "creating-file": "Creating file %s", @@ -309,10 +309,11 @@ "progress-inprogress": "in progress", "progress-hasqueue": "waiting for installation", "project": "Project", - "project-home": "Projekt home", + "project-home": "Project home", "projectdescription": "Short description", + "projectgroup": "Project group", "projectname": "Project name", - "projectmanager": "Projekt manager", + "projectmanager": "Procekt manager", "queue": "Queue", "queue-hint-overview": "Install newest<br>package in the first<br>phase %s", "raw-data": "Raw data", @@ -323,7 +324,7 @@ "repositoryinfos": "Sourcecode Repository", "repository-access-browser": "Browser access to sources", "repository-auth": "Authentication/ filename of ssh private key", - "repository-has-public-dir": "Is it a web projekt with subdirectory <em>public</em> or <em>public_html</em>?", + "repository-has-public-dir": "Is it a web project with subdirectory <em>public</em> or <em>public_html</em>?", "repository-url": "URL to repository", "repository-urlwebgui": "URL zur Web GUI des Repositorys", "revision": "Revision", diff --git a/hooks/templates/inc_projects_config.php.erb b/hooks/templates/inc_projects_config.php.erb index 7dbb5f10..051b02b4 100644 --- a/hooks/templates/inc_projects_config.php.erb +++ b/hooks/templates/inc_projects_config.php.erb @@ -26,6 +26,9 @@ $aConfig = array( // plugins 'plugins'=>array( + // enabled build plugins + 'build'=>array( + ), // enabled rollout plugins 'rollout'=>array( 'default'=>array(), @@ -121,6 +124,9 @@ $aConfig = array( 'ignore-ssl-error'=><%= @replace["ignore-ssl-error"] %>, // 'varname-replace'=>'ci-replacement', ), + + 'projectgroups' => array(<%= @replace["projectgroups"] %>), + // where to store project data 'projects' => array( 'json' => array( diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php index 497eba09..2f3194ad 100644 --- a/public_html/deployment/classes/project.class.php +++ b/public_html/deployment/classes/project.class.php @@ -525,6 +525,22 @@ class project extends base { return $this->_getBuildfilesByDir($this->_getProjectArchiveDir() . '/' . $sVersion); } + /** + * get the group id of the project + * @return string + */ + public function getProjectGroup() { + return isset($this->_aPrjConfig["projectgroup"]) ? $this->_aPrjConfig["projectgroup"] : false; + } + /** + * get the group label of the project + * @return string + */ + public function getProjectGroupLabel() { + $sGroupid=$this->getProjectGroup(); + return isset($this->_aConfig["projectgroups"][$sGroupid]) ? $this->_aConfig["projectgroups"][$sGroupid] : false; + } + /** * get full path of a packed project archive * @param string $sVersion version number of the build @@ -1061,7 +1077,7 @@ class project extends base { /** * return array of all (active and inactive) phases - * @return type + * @return array */ public function getPhases() { return $this->_aConfig["phases"]; @@ -3353,7 +3369,28 @@ class project extends base { $sMessages = ''; require_once ("formgen.class.php"); - + + $aSelectProjectGroup = array( + 'type' => 'select', + 'name' => 'projectgroup', + 'label' => t("projectgroup"), + 'options' => array( + OPTION_NONE => array( + 'label' => t('none'), + ), + '' => array( + 'label' => '- - - - - - - - - - - - - - - - - - - - ', + ), + ), + ); + foreach($this->_aConfig['projectgroups'] as $sGroupid=>$sGroupLabel){ + $bActive=$this->getProjectGroup() === $sGroupid; + $aSelectProjectGroup['options'][$sGroupid] = array( + 'label' => $sGroupLabel, + 'selected' => $bActive ? 'selected' : false, + ); + } + $aSelectSlack = array( 'type' => 'hidden', 'name' => 'messenger[slack]', @@ -3606,7 +3643,9 @@ class project extends base { 'size' => 100, 'placeholder' => '', ), - + + 'input' . $i++ => $aSelectProjectGroup, + 'input' . $i++ => array( 'type' => 'markup', 'value' => '<p>' . t('messenger') . '</p>', diff --git a/public_html/deployment/classes/projectlist.class.php b/public_html/deployment/classes/projectlist.class.php index f750e99c..7ecdcc46 100644 --- a/public_html/deployment/classes/projectlist.class.php +++ b/public_html/deployment/classes/projectlist.class.php @@ -60,13 +60,16 @@ class projectlist extends base{ $oHtml=new htmlguielements(); $sPrjFilter = ''; + $sPrjGroupFilter = ''; $sPhaseFilter = ''; $sPrjFilter.='<option value="">' . t("all") . '</option>'; + $sPrjGroupFilter.='<option value="">' . t("all") . '</option>'; + $sPhaseFilter.='<option value="' . $sColClass . '">' . t("all") . '</option>'; $iInprogress=0; $iHasqueue=0; - + $aPrjGroups=[]; $sDivInprogress='<div class="progressinprogress" title="'.t("progress-inprogress").'">'.$oHtml->getIcon('refresh').t("progress-inprogress").'</div>'; $sDivHasqueue='<div class="progresshasqueue" title="'.t("progress-hasqueue").'">'.$oHtml->getIcon('waiting').t("progress-hasqueue").'</div>'; @@ -92,10 +95,13 @@ class projectlist extends base{ } } $aProgress=$oPrj->getProgress(); + $sPrjGroup=$oPrj->getProjectGroup(); + $sClasses=$sPrj . ' ' . $sTrClass . ' trprogress' .($aProgress['inprogress'] ? ' progressinprogress' : '') .($aProgress['hasQueue'] ? ' progresshasqueue' : '') + . ' group-'.$sPrjGroup ; if($aProgress['inprogress']){ @@ -107,6 +113,17 @@ class projectlist extends base{ $iHasqueue++; $sProgress.=$sDivHasqueue; } + + + if($sPrjGroup){ + if(!isset($aPrjGroups[$sPrjGroup])){ + $aPrjGroups[$sPrjGroup]=0; + $sPrjGroupFilter.='<option value="' . $sPrjGroup . '">' . $oPrj->getProjectGroupLabel() . '</option>'; + } else { + $aPrjGroups[$sPrjGroup]++; + } + } + $sOut2 .= '<div class="' . $sClasses . ' prjbox"><div class="title">' .$oHtml->getLink(array( 'href'=>'#', @@ -192,6 +209,7 @@ class projectlist extends base{ $(\'.' . $sTrClass . '\').removeClass("trproject-textfilter"); $(\'.' . $sTrClass . '\').removeClass("trproject-progressfilter"); $(\'.' . $sTrClass . '\').removeClass("trproject-projectfilter"); + $(\'.' . $sTrClass . '\').removeClass("trproject-projectgroupfilter"); $(\'.' . $sTrClass . '\').removeClass("trprojectfiltered"); $(\'button.prjprogress\').removeClass(\'selected\'); @@ -217,6 +235,10 @@ class projectlist extends base{ var sPrj=$("#prjfilter").val(); localStorage.setItem("selectedPrj", sPrj); + // --- get project group filter + var sPrjGroup=$("#prjgroupfilter").val(); + localStorage.setItem("selectedPrjGroup", sPrjGroup); + // --- get progress filter var sProgress=$("#progressfilter").val(); localStorage.setItem("progress", sProgress); @@ -236,6 +258,13 @@ class projectlist extends base{ $(this).addClass("trproject-projectfilter"); } } + if (sPrjGroup){ + if ($(this).hasClass("group-"+sPrjGroup)){ + $(this).addClass("trprojectgroupfiltered"); + } else { + $(this).addClass("trproject-projectgroupfilter"); + } + } if (sProgress && !$(this).hasClass("progress" + sProgress)){ $(this).addClass("trproject-progressfilter"); } @@ -314,6 +343,13 @@ class projectlist extends base{ $("#efilter").val(localStorage.getItem("efilter")); window.setTimeout("filterTableByTyping();", 10); } + + if(localStorage.getItem("selectedPrjGroup") && localStorage.getItem("selectedPrjGroup")!=\'null\'){ + $("#prjgroupfilter").val(localStorage.getItem("selectedPrjGroup")); + } else { + // $("#selectedPrjGroup").val($("#selectedPrjgroup option:first").val()); + } + // window.setTimeout("filterOverviewTable();", 10); filterOverviewTable(); @@ -348,6 +384,7 @@ class projectlist extends base{ function showResetbtn(){ var sVisible=$("#efilter").val()?"visible":"hidden"; if ($("#prjfilter").val()>"")sVisible="visible"; + if ($("#prjgroupfilter").val()>"")sVisible="visible"; // if ($("#phasefilter").val()!="' . $sColClass . '")sVisible="visible"; if ($("#rolefilter").val())sVisible="visible"; if ($("#progressfilter").val())sVisible="visible"; @@ -361,7 +398,8 @@ class projectlist extends base{ * Aktion des Filter reset: Filter zurücksetzen */ function resetFilter(){ - $(\'#prjfilter\').val(\'\'); + $("#prjfilter").val(""); + $("#prjgroupfilter").val(""); // $("#phasefilter").val(""); filterOverviewTable(); $("#efilter").val(""); @@ -421,6 +459,14 @@ class projectlist extends base{ <button id="btnProgressinprogress" class="btn btn-default prjprogress" onclick="$(\'#progressfilter\').val(\'inprogress\'); return setprogress();" >'.$sDivInprogress.'<span>'.$iInprogress.'</span></button> <button id="btnProgresshasqueue" class="btn btn-default prjprogress" onclick="$(\'#progressfilter\').val(\'hasqueue\'); return setprogress();" >'.$sDivHasqueue .'<span>'.$iHasqueue.'</span></button> + + <label for="prjgroupfilter"> + ' . t("projectgroup") . ': + </label> + <select id="prjgroupfilter" class="form-control" onchange="filterOverviewTable(); return false;"> + ' . $sPrjGroupFilter . ' + </select> + <span style="display: none;"> <span class="view viewextended"> @@ -431,6 +477,7 @@ class projectlist extends base{ ' . $sPrjFilter . ' </select> + <span style="display: none;"> <label for="phasefilter">Phasen:</label> diff --git a/public_html/deployment/main.css b/public_html/deployment/main.css index e4c64313..f40f2c59 100644 --- a/public_html/deployment/main.css +++ b/public_html/deployment/main.css @@ -43,11 +43,11 @@ body{padding-top: 0; #content{ background: #fff; margin: 0 2% 0; - padding: 1em; - box-shadow: 0 0 15px #eee; - padding: 0.5em; - box-shadow: 0 0 1em rgba(0,0,0,0.3); + border: 1px solid rgba(0,0,0,0.06); + /* + box-shadow: 1em 1em 2em #fff; + */ } div#navtop, div#navbuttom{background: #dde; padding: 0.5em;} @@ -134,7 +134,7 @@ tr:hover{background:#ddd; background: linear-gradient(#f4f4f4,#fff,#f4f4f4);} .trprojectfiltered a.btn, .trproject:hover a.btn{opacity: 1;} -.trproject{border-left:0.5em solid #eee;} +.trproject{border-left:0.5em solid rgba(0,0,0,0);} tr.progressinprogress{border-left:0.5em solid #8db;} div.progressinprogress{color: #6a9;} tr.progresshasqueue{border-left:0.5em solid #f81;} @@ -152,6 +152,7 @@ button.prjprogress.selected{background:#f4f4f4; box-shadow: 0 0 1em #ddd inset; .trproject-textfilter, .trproject-projectfilter, +.trproject-projectgroupfilter, .trproject-progressfilter { display: none; -- GitLab