deploy
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
root
2024-08-27 17:15:14 +02:00
parent 1d6ad6785d
commit ed1008397d
3 changed files with 46 additions and 5 deletions

View File

@@ -43,7 +43,7 @@ function check_deploy() { // is a deploy in progress
$in_progress=0; $in_progress=0;
foreach ($members as $member) { foreach ($members as $member) {
if (substr($member,0,7)=="deploy") { if (substr($member,0,10)=="deployment") {
$in_progress=$member; $in_progress=$member;
break; break;
} }

View File

@@ -106,6 +106,7 @@ function add_repository() {
get_repositories(); get_repositories();
}); });
} }
function check_system() { function check_system() {
var url = 'scan.php?op=check_system&services=1'; var url = 'scan.php?op=check_system&services=1';
jQuery.get(url, function(data) { 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) { function check_deployment(additional) {
var url = 'scan.php?op=check_deployment'; var url = 'scan.php?op=check_deployment';
jQuery.get(url, function(data) { jQuery.get(url, function(data) {

View File

@@ -114,10 +114,31 @@ switch ($_GET["op"]) {
foreach ($arr as $key=>$data) { foreach ($arr as $key=>$data) {
if ($key=="deployment") { if ($key=="deployment") {
if ($data["STATUS"]=="0") { // ask if ($data["STATUS"]=="0") { // ask
echo base64_decode($data["TEMPLATE"]); $template = json_decode(base64_decode($data["TEMPLATE"]));
echo "<fieldset><form action=\"#\" method=\"post\" id=\"deploy_form\"><br>";
foreach ($template->fields as $field) {
echo "<div class=\"row\"><div class=\"mb-3\"><label>".$field->description."</label>
<input ".($field->required=="true" ? "required" : "")." type=\"text\" value=\"{$field->value}\" name=\"{$field->key}\" id=\"{$field->key}\" class=\"additional_field\">
</div></div>";
}
echo "
<div class=\"row\">
<div class=\"mb-3\">
<input type=\"hidden\" value=\"{$template->name}\" id=\"additional\">
<button class=\"btn btn-lg btn-primary btn-block\" type=\"submit\" id=\"deploy_btn\">Install</button>
</div>
</div>
</form></fieldset>
<script>
jQuery('#deploy_form').submit(function() {
deploy(jQuery('#additional').val());
return false;
});
</script>
";
} }
else { // deploy else { // deploy
echo $data["STATUS"]; echo "DEPLOY:".$data["STATUS"];
} }
redis_remove("$key"); redis_remove("$key");
} }
@@ -131,9 +152,12 @@ switch ($_GET["op"]) {
} }
else { else {
$text="Installing in progress... Please wait..."; $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); $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
$op = "deployment"; $op = "deployment";
redis_set($op,$json); redis_set($op,$json);
} }