From 7622c67f714155c076d1433af170c282277051a9 Mon Sep 17 00:00:00 2001
From: hahn <axel.hahn@iml.unibe.ch>
Date: Wed, 10 Jun 2020 14:49:06 +0200
Subject: [PATCH] task#3859 - increase timeout for http checks

---
 config/lang/de.json                           |  2 ++
 config/lang/en.json                           |  2 ++
 .../deployment/classes/formgen.class.php      |  4 +--
 .../classes/htmlguielements.class.php         |  1 +
 .../deployment/classes/project.class.php      | 36 ++++++++++++++++---
 public_html/deployment/main.css               |  2 ++
 6 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/config/lang/de.json b/config/lang/de.json
index abfc36df..1a5ef39f 100644
--- a/config/lang/de.json
+++ b/config/lang/de.json
@@ -237,6 +237,8 @@
     "defaults-all-phases": "Default-Werte (f&uuml;r alle Phasen)",
     "delete": "L&ouml;schen",
     "deploy": "Deploy",
+    "deploy-configfile": "Konfiguration",
+    "deploy-configfile-hint": "Hier k&ouml;nnen Variablen in Bash-Syntax hinterlegt werden, die sich vom onbuild oder ondeploy Hook lesen lassen.",
     "deploy-hint": "Deploy der Queue von Phase [%s]",
     "deploy-impossible": "Deploy der Queue von Phase [%s] ist nicht m&ouml;glich.",
     "deploy-settings": "Deployment-Einstellungen",
diff --git a/config/lang/en.json b/config/lang/en.json
index 5f70dc24..969d944b 100644
--- a/config/lang/en.json
+++ b/config/lang/en.json
@@ -239,6 +239,8 @@
     "defaults-all-phases": "Default values (for all phases)",
     "delete": "Delete",
     "deploy": "Deploy",
+    "deploy-configfile": "Configuration",
+    "deploy-configfile-hint": "Here you can place variables in Bash syntax that onbuild oder ondeploy hook can read.",
     "deploy-hint": "Deploy queue of phase [%s]",
     "deploy-impossible": "Deploy queue of phase [%s] is not possible.",
     "deploy-settings": "Deployment settings",
diff --git a/public_html/deployment/classes/formgen.class.php b/public_html/deployment/classes/formgen.class.php
index 3b26e271..a8f38502 100644
--- a/public_html/deployment/classes/formgen.class.php
+++ b/public_html/deployment/classes/formgen.class.php
@@ -283,11 +283,11 @@ class formgen {
 
             case "textarea":
                 $this->_checkReqiredKeys($elementData, array("name"));
-                $sFormElement.='    <textarea id="' . $sId . '" ';
+                $sFormElement.='    <textarea id="' . $sId . '" class="form-control col-sm-10" ';
                 $aAllowedHtmlAttributes["text"] = explode(",", "");
                 $sFormElement.=$this->_addHtmlAtrributes(explode(",", "$sDefaultAttributes,name,onkeyup,onkeydown,onchange,placeholder,required,cols,rows"), $elementData);
                 // $sFormElement.=$this->_addHtmlAtrributes(array("name", "value", "size", "placeholder", "required"), $elementData);
-                $sFormElement.='></textarea>';
+                $sFormElement.='>'.$elementData['value'].'</textarea>';
                 $sFormElement.="\n";
 
                 $sLabelElement = $this->_addLabel($sLabelText, $sId, "control-label col-sm-2");
diff --git a/public_html/deployment/classes/htmlguielements.class.php b/public_html/deployment/classes/htmlguielements.class.php
index 970d8c14..7eb28ba7 100644
--- a/public_html/deployment/classes/htmlguielements.class.php
+++ b/public_html/deployment/classes/htmlguielements.class.php
@@ -151,6 +151,7 @@ class htmlguielements{
             'close'=>'fas fa-times',
             'delete'=>'fas fa-trash',
             'deploy'=>'fas fa-forward',
+            'deploy-configfile'=>'far fa-file-code',
             'filter'=>'fas fa-filter',
             'foreman'=>'fas fa-hard-hat',
             'gotop'=>'fas fa-arrow-up',
diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php
index 64ff53c6..2239bb96 100644
--- a/public_html/deployment/classes/project.class.php
+++ b/public_html/deployment/classes/project.class.php
@@ -784,7 +784,7 @@ class project extends base {
         }
 
         // keep a few
-        while (count($aDirlist) >= $this->_aConfig["builtsToKeep"]) {
+        while (count($aDirlist) > $this->_aConfig["builtsToKeep"]) {
             $sVersion = array_shift($aDirlist);
             $sDir2 = $sDir . '/' . $sVersion;
             if ($this->_rmdir($sDir2)) {
@@ -1633,6 +1633,14 @@ class project extends base {
             $sReturn.=$this->_execAndSend('chmod 755 ' . $filename);
             $sReturn.=$this->_execAndSend('ls -l ' . $filename);
         }
+        // --------------------------------------------------
+        $sCfgout=$sTempBuildDir . '/ci-custom-vars';
+        if (isset($this->_aPrjConfig['deploy']["configfile"]) && $this->_aPrjConfig['deploy']["configfile"]){
+            file_put_contents($sCfgout, $this->_aPrjConfig['deploy']["configfile"]);
+            $sReturn.=$this->_execAndSend('ls -l ' . $sCfgout);
+            $sReturn.=$this->_execAndSend('cat ' . $sCfgout);
+            return $this->_oHtml->getBox("error", 'Abbruch - zum Test von '.$sCfgout);
+        }
 
         $sReturn.=$this->_oHtml->getBox("success", t('class-project-info-build-checkout-ok'));
         $aActionList['iActive'] ++;
@@ -3345,8 +3353,10 @@ class project extends base {
                             <ul class="nav nav-tabs">
                                 <li class="active"><a href="#tab1" data-toggle="tab">' . $this->_oHtml->getIcon('list').t('setup-metadata') . '</a></li>
                                 <li><a href="#tab2" data-toggle="tab">' . $this->_oHtml->getIcon('repository').t('repositoryinfos') . '</a></li>
-                                <li><a href="#tab3" data-toggle="tab">' . $this->_oHtml->getIcon('phase').t('phases') . '</a></li>
-                                <li><a href="#tab4" data-toggle="tab">' . $this->_oHtml->getIcon('raw-data').t('raw-data') . '</a></li>
+
+                                <li><a href="#tab3" data-toggle="tab">' . $this->_oHtml->getIcon('deploy-configfile').t('deploy-configfile') . '</a></li>
+                                <li><a href="#tab4" data-toggle="tab">' . $this->_oHtml->getIcon('phase').t('phases') . '</a></li>
+                                <li><a href="#tab5" data-toggle="tab">' . $this->_oHtml->getIcon('raw-data').t('raw-data') . '</a></li>
                             </ul>
                             <div class="tab-content">
                             <div class="tab-pane active" id="tab1">
@@ -3475,11 +3485,27 @@ class project extends base {
                             ),
                         ),
                     ),
-                    
                     // --------------------------------------------------
                     'input' . $i++ => array(
                         'type' => 'markup',
                         'value' => ' </div><div class="tab-pane" id="tab3">
+                            <p>' . t('deploy-configfile-hint') . '</p>',
+                    ),
+                    'textarea' . $i++ => array(
+                        'type' => 'textarea',
+                        'name' => 'deploy[configfile]',
+                        'label' => t("deploy-configfile"),
+                        'value' => $this->_aPrjConfig['deploy']["configfile"],
+                        // 'required' => 'required',
+                        'validate' => 'isastring',  
+                        'cols' => 100,
+                        'rows' => 10,
+                        'placeholder' => 'export myvariable=&quot;hello world&quot;',
+                    ),                    
+                    // --------------------------------------------------
+                    'input' . $i++ => array(
+                        'type' => 'markup',
+                        'value' => ' </div><div class="tab-pane" id="tab4">
                             <p>' . sprintf(t("class-project-info-setup-phaseinfos"), $this->getNextPhase()) . '</p>',
                     ),
                 ),
@@ -3709,7 +3735,7 @@ class project extends base {
             'type' => 'markup',
             'value' => '</div>'
             
-                . '<div class="tab-pane" id="tab4">'
+                . '<div class="tab-pane" id="tab5">'
                 . '<br><pre>'.print_r($this->_aPrjConfig, 1).'</pre>'
                 . '</div>'
             
diff --git a/public_html/deployment/main.css b/public_html/deployment/main.css
index 3237c56c..0ccffde2 100644
--- a/public_html/deployment/main.css
+++ b/public_html/deployment/main.css
@@ -271,6 +271,8 @@ input[type="radio"]:checked+label, input[type="checkbox"]:checked+label{
     display: block;
 }
 
+.tab-pane p {margin: 1em 10px;}
+
 /* ----- visualized process ----- */
 .visualprocess{float: left; padding: 1em; box-shadow: 0 0 0em #ddd;}
 .visualprocess .process{float:left; text-align: center; padding: 0 0 5px; }
-- 
GitLab