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

add missing permission for build button; fix ajax poll

parent 6b23e22d
No related branches found
No related tags found
No related merge requests found
......@@ -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",
......
......@@ -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;
?>
<?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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment