diff --git a/common.js b/common.js index bc83551..7f44ba7 100644 --- a/common.js +++ b/common.js @@ -155,27 +155,35 @@ function get_updates() { }); } -function check_upgrade() { - var url = 'scan.php?op=check_upgrade'; +function check_upgrade(service) { + var url = 'scan.php?op=check_upgrade&service='+service; jQuery.get(url, function(data) { - console.log('check_upgrade: '+data); - if (data=="WAIT" || data=="") { - setTimeout(check_upgrade, 1000); + console.log('check_upgrade '+service+': '+data); + if (data!="") { + jQuery("#status_"+service).html(data); + } + if (data!="OK") { + setTimeout(check_upgrade, 1000, service); } else { - // TODO + console.log('upgrade end: '+service); + jQuery("#status_"+service).html('Upgrade has finished'); + //get_updates(); } }); + } function upgrade(service) { var url = 'scan.php?op=upgrade&service='+service; + jQuery("#status_"+service).html('Upgrade has started'); console.log('upgrade start: '+service); jQuery.get(url, function(data) { - console.log('upgrade end: '+service); + console.log('check_upgrade '+service+': '+data); if (data=="OK") { - setTimeout(check_upgrade, 1000); + setTimeout(check_upgrade, 1000, service); } + else jQuery("#status_"+service).html(data); }); } diff --git a/functions.php b/functions.php index 319de95..5eb1d9d 100644 --- a/functions.php +++ b/functions.php @@ -148,7 +148,7 @@ function show_service_update($name, $update, $uptodate, $error) { if (!empty($update)) { $arr = explode(" ",$update); foreach ($arr as $container) { - $str .= " ".$container."UPDATE AVAILABLEUPDATE"; + $str .= " ".$container."
UPDATE AVAILABLE
UPDATE"; } } @@ -156,7 +156,7 @@ function show_service_update($name, $update, $uptodate, $error) { if (!empty($uptodate)) { $arr = explode(" ",$uptodate); foreach ($arr as $container) { - $str .= " ".$container."Already up to dateFORCE UPDATE"; + $str .= " ".$container."
Already up to date
FORCE UPDATE"; } } @@ -165,7 +165,7 @@ function show_service_update($name, $update, $uptodate, $error) { $arr = explode(" ",$error); foreach ($arr as $container) { //$str .= " ".$container."N/A"; - $str .= " ".$container."N/ATRY UPDATE"; + $str .= " ".$container."
N/A
TRY UPDATE"; } } diff --git a/manage.html b/manage.html index 767ffde..6eeb97a 100644 --- a/manage.html +++ b/manage.html @@ -152,6 +152,6 @@ - + diff --git a/scan.php b/scan.php index 25492c1..6cb2440 100644 --- a/scan.php +++ b/scan.php @@ -380,23 +380,51 @@ switch ($_GET["op"]) { echo $text; break; case "check_upgrade": - $arr = check_response("upgrade"); - if (!empty($arr)) { + $arr = check_deploy($_GET["service"]); + if (!empty($arr)) { // deployment in progress foreach ($arr as $key=>$data) { - if ($key=="upgrade") { - var_dump($arr); - //remove_response("$key"); + if ($key=="deploy-".$_GET["service"]) { + if ($data["STATUS"]=="1") { + echo "Install in progress... You can't uninstall while in progress..."; + } + elseif ($data["STATUS"]=="2") { + echo "Install has finished... You can upgrade now."; + //echo ""; + remove_response("$key"); + } } } } - else echo "WAIT"; + else { // no upgrade in progress -> upgrade + $key = "upgrade-".$_GET["service"]; + $arr = check_response($key); + if (!empty($arr)) { + $data = $arr[$key]; + if ($data["STATUS"]=="1") { + echo "Upgrade in progress... Please wait... ".date("Y-m-d H:i:s"); + } + elseif ($data["STATUS"]=="2") { + echo "OK"; + remove_response("$key"); + } + } + else echo "Upgrade in progress... Please wait..."; + } break; case "upgrade": - $arr = array("NAME" => $_GET["service"], "ACTION" => "upgrade"); - $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); + if ($key=check_deploy($_GET["service"])) { + $text="Deploy/uninstall of {$_GET["service"]} has started. Please wait..."; + } + else { + //$text="Deploy/uninstall of {$_GET["service"]} in progress... Please wait..."; - if (set_output("upgrade",$json)) echo "OK"; - else echo "ERROR"; + $arr = array("NAME" => $_GET["service"], "ACTION" => "upgrade"); + $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); + + if (set_output("upgrade",$json)) $text = "OK"; + else $text = "ERROR"; + } + echo $text; break; case "repositories": $arr = array("STATUS" => 0);