Skip to content
Snippets Groups Projects
Commit d30eabe2 authored by hahn's avatar hahn
Browse files

- added setup page to add a new project

parent 31855ceb
No related branches found
No related tags found
No related merge requests found
auxiliary.org-netbeans-modules-css-prep.less_2e_compiler_2e_options=
auxiliary.org-netbeans-modules-css-prep.less_2e_enabled=false
auxiliary.org-netbeans-modules-css-prep.less_2e_mappings=/less:/css
auxiliary.org-netbeans-modules-css-prep.sass_2e_compiler_2e_options=
auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=false
auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss:/css
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_create_2e_tests=false
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_path=
......@@ -5,6 +11,8 @@ auxiliary.org-netbeans-modules-php-phpunit.customSuite_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.phpUnit_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.test_2e_groups_2e_ask=false
auxiliary.org-netbeans-modules-php-phpunit.test_2e_run_2e_all=false
auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=public_html/deployment/bootstrap/js
browser.reload.on.save=true
ignore.path=
include.path=\
${php.global.include.path}
......
RewriteEngine on
# parse htm files
RewriteRule ^(.*)\.htm$ /deployment/shared/parse.php [PT,QSA]
# rewrite bootstrap-ressources
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /(css|js|img)/(.*)$ /deployment/gfranko-Document-Bootstrap-cf0730d/$1/$2
# RewriteRule /(css|js|img)/(.*)$ /deployment-gui/bootstrap/$1/$2
......@@ -5,13 +5,23 @@ require_once("./classes/project.class.php");
require_once("./inc_functions.php");
$sOut='';
$sOut.='<h2>Axels aktuelle Baustelle - Diese Seite noch ignorieren!!</h2>';
// --- Checks
if ($aParams["prj"]=="all"){
$sOut.='<h2>TODO: neues Projekt</h2>';
$oPrj=new project();
if (array_key_exists("setupaction", $aParams) && $aParams["setupaction"]=="create") {
// TODO - FORM Daten wurden gesendet... check - create ...
$sOut.="TODO FORM Daten wurden gesendet... check - create ... <br>";
} else {
$sOut.=$oPrj->renderNewProject();
}
} else {
$oPrj=new project($aParams["prj"]);
// $sOut.='<div style="float: right">aParams:<pre>'.print_r($aParams, true).'</pre></div>';
if (array_key_exists("setupaction", $aParams) && $aParams["setupaction"]=="save") {
......@@ -22,11 +32,10 @@ if (array_key_exists("setupaction", $aParams) && $aParams["setupaction"]=="save"
}
}
$oPrj=new project($aParams["prj"]);
$sOut.=$oPrj->renderSetup();
$sOut.=$oPrj->renderProjectSetup();
}
$sOut.='<hr>'.aPrjHome();
// -- Ausgabe
$sPhpOut=$sOut;
?>
......@@ -72,6 +72,7 @@
h2.action{
background: #e8f0f8 url("/deployment/images/nuvola64x64/apps/aktion.png") 10px 10px no-repeat;
background-repeat: no-repeat;
box-shadow: 0 30px 50px #fff inset;
padding: 20px 0 0 90px;
height: 70px;
margin: 0 0 1em 0;
......@@ -84,6 +85,7 @@
h2.deploy{background-image: url("/deployment/images/nuvola64x64/apps/iconthemes.png");}
h2.prjhome{background-image: url("/deployment/images/nuvola64x64/apps/kdict.png");}
h2.phase{background-image: url("/deployment/images/nuvola64x64/apps/kreversi.png");}
h2.setup{background-image: url("/deployment/images/nuvola64x64/apps/kcmsystem.png");}
h3{font-size: 14px; margin: 0;}
......@@ -140,16 +142,14 @@
border-radius: 0px;
margin-bottom: 0px;
}
ul.nav li.dropdown:hover ul.dropdown-menu{
display: block;
margin-top:0px
}
label.control-label{width: 300px; float: left; text-align: right; padding-right: 2em;}
input, textarea {
width: 400px; /* passt so in modal Box */
width: 400px;
height: none !important;
padding: 1px 2px !important;
}
......
......@@ -625,6 +625,20 @@ class project {
$sGitCmd="git ls-remote --heads " . $this->_aPrjConfig["build"]["ssh"] . " master | awk '{ print $1 }'";
$sRevision=shell_exec("export GIT_SSH=$sWrapper ; export PKEY=$sKeyfile; $sGitCmd");
$sReturn=trim($sRevision);
/*
$sGitCmd="export GIT_SSH=$sWrapper ; ";
$sGitCmd.="export PKEY=$sKeyfile ; ";
$sGitCmd.="export testdir=/tmp/test_\$\$ ; set -vx ; ";
$sGitCmd.="mkdir \$testdir && cd \$testdir && ";
$sGitCmd.="git init && ";
$sGitCmd.="git remote add origin " . $this->_aPrjConfig["build"]["ssh"] . " && ";
// $sGitCmd.="git clean -f && ";
// $sGitCmd.="git pull ; ";
// $sGitCmd.="sleep 1 ; ";
$sGitCmd.="git log -1 --format=fuller origin/master remote; ";
// $sGitCmd.="cd /tmp ; rm -rf \$testdir ";
$sReturn.= $this->_execAndSend($sGitCmd);
*/
$this->_aData["phases"]["source"]=$sReturn;
break;
default:
......@@ -1076,8 +1090,15 @@ class project {
}
// TODO: run puppet agent on target server(s) - for preview only
if (array_key_exists("puppethost", $this->_aPrjConfig["phases"][$sPhase])) {
$sReturn.="Run puppet agent.<br>";
$sReturn.=$this->_execAndSend("ssh imldeployment@".$this->_aPrjConfig["phases"][$sPhase]["puppethost"]." sudo puppet agent -t | fgrep -i Deploy");
} else {
$sReturn.="SKIP: no puppet host was defined. The deployment was done and will be installed soon (within 30min).<br>";
}
$sReturn.=$this->getBox("success", "SUCCESS: deployment was done and will be installed soon.");
$sReturn.="<br>";
$sReturn.=$this->getBox("success", "SUCCESS: deployment was done.");
return $sReturn;
}
......@@ -1123,9 +1144,17 @@ class project {
foreach (array("setupaction", "prj", "id") as $s){
if (array_key_exists($s, $aData)) unset ($aData[$s]);
}
// echo "SAVING: " . print_r($aData, true);
return file_put_contents($this->_getConfigFile($sId), json_encode($aData));
// echo "IST <pre>" . print_r($this->_aPrjConfig, true) . "</pre>"; echo "NEU <pre>" . print_r($aData, true) . "</pre>"; die();
// make a backup of a working config
$sCfgFile=$this->_getConfigFile($sId);
$sBakFile=$this->_getConfigFile($sId).".ok";
copy($sCfgFile, $sBakFile);
$bReturn=file_put_contents($sCfgFile, json_encode($aData));
$this->setProjectById($sId);
return $bReturn;
}
// ----------------------------------------------------------------------
// RENDERING
......@@ -1235,9 +1264,9 @@ class project {
if (array_key_exists("type", $this->_aPrjConfig["build"])){
$sReturn.='<tr><td>Quell-Repository:</td><td><strong>'.$this->_aPrjConfig["build"]["type"].'</strong><br>';
if (array_key_exists("ssh", $this->_aPrjConfig["build"])){
$sReturn.='Zugriff mit SSH-Protokoll auf <em>'.$this->_aPrjConfig["build"]["ssh"].'</em><br>';
$sReturn.='Zugriff mit SSH-Protokoll auf<br><em>'.$this->_aPrjConfig["build"]["ssh"].'</em><br>';
}
$sReturn.='Browserzugriff auf das Repo: ';
$sReturn.='Browserzugriff auf das Repo:<br>';
if (array_key_exists("webaccess", $this->_aPrjConfig["build"])){
$sReturn.='<a href="'.$this->_aPrjConfig["build"]["webaccess"].'">'.$this->_aPrjConfig["build"]["webaccess"].'</a><br>';
} else {
......@@ -1405,7 +1434,11 @@ class project {
$sRevision=$this->getRepoRevision();
$sReturn.=$this->getChecksumDiv($sRevision);
$sReturn.= '<i class="icon-tag"></i> Revision: '.$sRevision;
$sReturn.="<br>$sGitCmd";
$sReturn.="<br>$sGitCmd<br>";
if (array_key_exists("webaccess", $this->_aPrjConfig["build"])){
$sReturn.='<br>Web-GUI des Repositories:<br><a href="'.$this->_aPrjConfig["build"]["webaccess"].'">'.$this->_aPrjConfig["build"]["webaccess"].'</a><br>';
}
break;
......@@ -1487,7 +1520,12 @@ class project {
}
return $sReturn;
}
public function renderSetup(){
/**
* return html code for the setup form of an exsiting project
* @return string
*/
public function renderProjectSetup(){
require_once ("formgen.class.php");
$i=0;
......@@ -1624,22 +1662,41 @@ class project {
'input'.$i++ => array(
'type' => 'markup',
'value' => ' </div><div class="tab-pane" id="tab3">
<p>Gib die URLs der jeweiligen Phasen an. Wird keine URL eingetragen, ist die jeweilige Phase nicht aktiv.</p>
<p>
Gib die URLs der jeweiligen Phasen an. Wird keine URL eingetragen, ist die jeweilige Phase nicht aktiv.<br>
Der Puppet-Host ist optional nur für die erste Phase '.$this->getNextPhase().' anzugeben.
Der Sysadmin muss zudem diesen Host in Puppet konfigurieren.
</p>
',
),
),
),
);
foreach(array_keys($this->getPhases()) as $sPhase){
$aForms["setup"]["form"]['input'.$i++] = array(
'type' => 'markup',
'value' => 'Phase <span class="'.$sPhase.'">' . $sPhase . '</span>',
);
$sUrl=array_key_exists("url", $this->_aPrjConfig["phases"][$sPhase])?$this->_aPrjConfig["phases"][$sPhase]["url"]:"";
$aForms["setup"]["form"]['input'.$i++] = array(
'type' => 'text',
'name' => 'phases['.$sPhase.'][url]',
'label' => 'Phase <span class="'.$sPhase.'">' . $sPhase . '</span> - URL der Webseite',
'label' => 'URL der Webseite',
'value' => $sUrl,
// 'required' => 'required',
'validate' => 'isastring',
'size' => 100,
'placeholder' => 'http://[phase].[Projekt].iml.unibe.ch/',
);
$sPuppethost=array_key_exists("puppethost", $this->_aPrjConfig["phases"][$sPhase])?$this->_aPrjConfig["phases"][$sPhase]["puppethost"]:"";
$aForms["setup"]["form"]['input'.$i++] = array(
'type' => 'text',
'name' => 'phases['.$sPhase.'][puppethost]',
'label' => 'Hostname für puppet agent',
'value' => $sPuppethost,
// 'required' => 'required',
'validate' => 'isastring',
'size' => 100,
'placeholder' => '',
);
}
......@@ -1657,6 +1714,52 @@ class project {
$oForm=new formgen($aForms);
return $oForm->renderHtml("setup");
}
/**
* return html code for the setup form for a new project
* @return string
*/
public function renderNewProject(){
require_once ("formgen.class.php");
$i=0;
$aForms = array(
'setup' => array(
'meta' => array(
'method' => 'POST',
'action' => '?',
),
'validate' => array(),
'form' => array(
'input'.$i++ => array(
'type' => 'hidden',
'name' => 'setupaction',
'value' => 'create',
),
'input'.$i++ => array(
'type' => 'text',
'name' => 'label',
'label' => 'ID',
'value' => $this->_aPrjConfig["label"],
'required' => 'required',
'validate' => 'isastring',
'size' => 100,
'placeholder' => 'Projekt',
),
),
),
);
$aForms["setup"]["form"]['input'.$i++] = array(
'type' => 'submit',
'name' => 'btnsave',
'label' => 'Speichern',
'value' => 'Speichern',
);
$oForm=new formgen($aForms);
return $oForm->renderHtml("setup");
}
}
......
......@@ -52,6 +52,7 @@ function aHome($sClass="btn"){
function aPrjHome($sClass="btn"){
global $aParams;
if (!array_key_exists("prj", $aParams)) return false;
if ($aParams["prj"]=="all") return false;
// if (!array_key_exists("action", $aParams)) return false;
require_once("./config/inc_projects_config.php");
......@@ -68,7 +69,6 @@ function aPrjHome($sClass="btn"){
function getTopArea(){
global $aParams, $sImageBase, $aImages;
$sReturn='';
require_once("./config/inc_projects_config.php");
require_once("./classes/project.class.php");
require_once("./classes/projectlist.class.php");
......@@ -105,7 +105,7 @@ function getTopArea(){
$sReturn.='
</ul>
</li>';
if (array_key_exists("prj", $aParams)){
if (array_key_exists("prj", $aParams) && $aParams["prj"]<>"all"){
$oPrj=new project($aParams["prj"]);
$sReturn.='
<li style="border-left: 1px solid #ccc;">'.aPrjHome(" ").'</li>
......@@ -154,6 +154,7 @@ function getTopArea(){
$sReturn.='<img src="'.$sImageBase.$aImages['overview'].'" id="imgtop" alt="">'
. '<h1>&Uuml;bersicht</h1><span class="description">Alle Projekte und Versionen in den einzelnen Phasen</span>';
} else {
if ($aParams["prj"]<>"all") {
$oPrj=new project($aParams["prj"]);
$sReturn.='<img src="'.$sImageBase.$aImages['project'].'" id="imgtop" alt="">
<h1>'.$oPrj->getLabel().'</h1><span class="description">'.$oPrj->getDescription().'</span>';
......@@ -161,6 +162,7 @@ function getTopArea(){
// $sReturn.='<h2>Aktion: '.$aParams["action"].'</h2>';
}
}
}
$sReturn.='</div>';
return $sReturn;
......
......@@ -22,7 +22,6 @@ if (array_key_exists("action", $aParams)) {
$sActionFile=__DIR__ . '/act_' . $sAction . ".php";
include($sActionFile);
// ------ Ausgabe
$sPhpOut='
<div id="header" style="display: none;">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment