diff --git a/functions.php b/functions.php index 00001b2..c19a435 100644 --- a/functions.php +++ b/functions.php @@ -43,7 +43,7 @@ function check_deploy() { // is a deploy in progress $in_progress=0; foreach ($members as $member) { - if (substr($member,0,7)=="deploy") { + if (substr($member,0,10)=="deployment") { $in_progress=$member; break; } diff --git a/manage.html b/manage.html index cc0f5b0..cf3b901 100644 --- a/manage.html +++ b/manage.html @@ -106,6 +106,7 @@ function add_repository() { get_repositories(); }); } + function check_system() { var url = 'scan.php?op=check_system&services=1'; jQuery.get(url, function(data) { @@ -153,6 +154,22 @@ function load_template(additional) { }); } +function deploy(additional) { + pars = ''; + jQuery('input.additional_field').each(function(index) { + console.log('Field ' + $(this).attr('id') + ': ' + $(this).val()); + pars += '&'+$(this).attr('id') + '=' + $(this).val(); + }); + //console.log(pars); + var url = 'scan.php?op=deploy&additional='+additional+pars; + jQuery.get(url, function(data) { + if (data!="") { + jQuery("#"+additional).html(data); + setTimeout(check_deployment, 500, additional); + } + }); +} + function check_deployment(additional) { var url = 'scan.php?op=check_deployment'; jQuery.get(url, function(data) { diff --git a/scan.php b/scan.php index ebc1ed5..d819dbf 100644 --- a/scan.php +++ b/scan.php @@ -114,10 +114,31 @@ switch ($_GET["op"]) { foreach ($arr as $key=>$data) { if ($key=="deployment") { if ($data["STATUS"]=="0") { // ask - echo base64_decode($data["TEMPLATE"]); + $template = json_decode(base64_decode($data["TEMPLATE"])); + echo "

"; + foreach ($template->fields as $field) { + echo "
+ required=="true" ? "required" : "")." type=\"text\" value=\"{$field->value}\" name=\"{$field->key}\" id=\"{$field->key}\" class=\"additional_field\"> +
"; + } + echo " +
+
+ name}\" id=\"additional\"> + +
+
+
+ + "; } else { // deploy - echo $data["STATUS"]; + echo "DEPLOY:".$data["STATUS"]; } redis_remove("$key"); } @@ -131,9 +152,12 @@ switch ($_GET["op"]) { } else { $text="Installing in progress... Please wait..."; - $arr = array("NAME" => $_GET["additional"], "ACTION" => "deploy"); + $fields = $_GET; + unset($fields["op"]); + unset($fields["additional"]); + $payload = base64_encode(json_encode($fields, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT)); + $arr = array("NAME" => $_GET["additional"], "ACTION" => "deploy", "PAYLOAD" => $payload); $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); - $op = "deployment"; redis_set($op,$json); }