diff --git a/config/inc_roles.php b/config/inc_roles.php index 9c3135e54b031a4952def6e2b75dab263d1de500..8cade3cb00a2f7f68b42ebedbf68557f96dd0a33 100644 --- a/config/inc_roles.php +++ b/config/inc_roles.php @@ -23,6 +23,7 @@ return array( // see $oProject->renderLink() and $oProject->[äction] "project-action-default", + "project-action-accept", // see project->canAcceptPhase (used for build button) "project-action-accept-preview", "project-action-build", "project-action-cleanup", diff --git a/public_html/deployment/pages/act_build.php b/public_html/deployment/pages/act_build.php index a3c292681cbbf6794df7a09ed14d7a0a515547bf..49a540cc317f2933b5a894dbf704ce8b2ba21c6a 100644 --- a/public_html/deployment/pages/act_build.php +++ b/public_html/deployment/pages/act_build.php @@ -119,6 +119,8 @@ if (!array_key_exists("confirm", $aParams)) { // the ajax polling request reads tmpfile // read produced content from tempfile + // remark: this part was moved to ../webservice/getfile.php + /* if (array_key_exists("ajax", $aParams)) { $sLine = "<h2 class=\"warning\">" . t("page-build-info-processing") . "</h2>"; $sProcesses = t("page-build-info-load") . ": " @@ -136,31 +138,34 @@ if (!array_key_exists("confirm", $aParams)) { } die(); } + */ // html code after pressing build button: // initiate one request to start the build and one to fetch preocess output // $sTmpFile = basename(tempnam("", "out_".$aParams["prj"]."_".$aParams["action"])."_"); - $sTmpFile = $aParams["prj"] . "_" . $aParams["action"]; + $sAjaxFile = $aParams["prj"] . "_" . $aParams["action"]; $sDivname = "outAjax"; - $sUrl = "/deployment/?" + $sUrlStartAction = "/deployment/?" . "&prj=" . $aParams["prj"] . "&action=" . $aParams["action"] . "&confirm=" . $aParams["confirm"] . "&branchname=" . $aParams["branchname"] - . "&ajax=" . $sTmpFile + . "&ajax=" . $sAjaxFile + . "&run=1" ; - $sUrlStartAction = $sUrl . "&run=1"; - $sOut.='<div id="' . $sDivname . '"></div>' + $sUrlFile = "/webservice/getfile.php?". "&ajax=" . $sAjaxFile; + + $sOut.= '<div id="' . $sDivname . '"></div>' . '<script> var iRepeat=3000; - // init build process + // start build process $.post( "' . $sUrlStartAction . '", function( data ) { $( "#' . $sDivname . '" ).html( data ); - iRepeat=false; // stop polling + iRepeat=false; // stop polling if build is finished }); - // polling result so far ... + // polling result during progress... function AjaxPolling(sUrl, sDivname){ if (!iRepeat) return false; $.post( sUrl, function( data ) { @@ -174,7 +179,7 @@ if (!array_key_exists("confirm", $aParams)) { } // init polling - AjaxPolling("' . $sUrl . '", "' . $sDivname . '"); + AjaxPolling("' . $sUrlFile . '", "' . $sDivname . '"); </script>'; } @@ -183,4 +188,3 @@ $sOut.= '<div id="navbuttom">' . aPrjHome() . '</div>'; // -- Ausgabe echo $sOut; -?> diff --git a/public_html/webservice/getfile.php b/public_html/webservice/getfile.php new file mode 100644 index 0000000000000000000000000000000000000000..61298d6c4a2c9ff25671852973b66f5771b838b5 --- /dev/null +++ b/public_html/webservice/getfile.php @@ -0,0 +1,29 @@ +<?php +/* + * script to be used as ajax poll request to get current status of an action + */ +if (array_key_exists("ajax", $_GET)) { + + // see pages/act_build.php + $sOutDir = sys_get_temp_dir(); // ... is /tmp + $sTmpFile = $sOutDir . "/" + . preg_replace('/[^a-z0-9\-\_]/', '_', $_GET["ajax"]); + + // ---------------------------------------------------------------------- + + $sProcesses = "<h2 class=\"warning\">please wait ...</h2>" + . shell_exec("uptime") . "<br><pre>" + . shell_exec("ps -f | egrep -v '/(apache|httpd)' | fgrep -v 'ps -f' | fgrep -v grep") + . "</pre>"; + + $sOut = file_exists($sTmpFile) ? file_get_contents($sTmpFile) : "waiting for " . $sTmpFile; + + // ---------------------------------------------------------------------- + // output + // ---------------------------------------------------------------------- + echo $sProcesses + . '<div style="margin-left: 3em; border-left: 5px dotted #eee; padding-left: 1em;">' + . $sOut + . '</div><div style="clear: both;"></div>' + ; +} \ No newline at end of file