diff --git a/index.html b/index.html index e5cbe26..c987cc5 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,7 @@
-

Scanning your device for any prevoius installed vesions

+

Scanning your device for any previous installed vesions

diff --git a/install.php b/install.php index af6aabf..6e7de0b 100644 --- a/install.php +++ b/install.php @@ -94,9 +94,10 @@ function redirectToManage() { } function check_install() { + var url = 'scan.php?op=check_install&key='; $.get(url, function(data){ - console.log(data); + console.log('check_install:'+data+' counter: '+counter); if (data=='INSTALLED') { redirectToManage(); } @@ -108,17 +109,55 @@ function check_install() { }); } +function check_redis() { + var url = 'scan.php?op=redis'; $.get(url, function(data){ + console.log('check_redis: '+data); if (data=='OK') { $("#redis").html('Redis server - OK'); check_install(); } else { $("#redis").html('Redis server is not available...'); + setTimeout(check_redis, 1000); } }); +} +function check_directory() { + + var url = 'scan.php?op=directory'; + $.get(url, function(data){ + console.log('check_directory: '+data); + if (data=='OK') { + $("#redis").html('Connection is ready - OK'); + check_install(); + } + else { + $("#redis").html('Shared directory is not available...'); + } + }); +} + +function check_interface() { + + var url = 'scan.php?op=get_interface'; + $.get(url, function(data){ + console.log('check_interface: '+data); + if (data=='redis') { + check_redis(); + } + else if (data=='directory') { + check_directory(); + } + else { + $("#redis").html('Invalid interface definition...'); + } + }); +} + + check_interface(); counter=0; }); diff --git a/manage.html b/manage.html index 536dcc2..5aea92a 100644 --- a/manage.html +++ b/manage.html @@ -94,10 +94,13 @@ function check_repositories() { var url = 'scan.php?op=check_repositories'; jQuery.get(url, function(data) { - if (data!="") { - jQuery("#repositories").html(data); + console.log('check_repositories: '+data); + if (data=="WAIT" || data=="") { + setTimeout(check_repositories, 500); + } + else { + jQuery("#repositories").html(data); } - else setTimeout(check_repositories, 500); }); } @@ -107,6 +110,7 @@ function get_repositories() { if (data=="OK") { setTimeout(check_repositories, 500); } + else alert(data); }); } @@ -137,6 +141,7 @@ function get_system() { if (data=="OK") { setTimeout(check_system, 1000); } + else alert(data); }); } @@ -296,9 +301,9 @@ function get_containers() { jQuery(document).ready(function(){ + get_deployments(); get_system(); get_repositories(); - get_deployments(); get_services(); jQuery('#settings_btn').click(function() { diff --git a/scan.php b/scan.php index 1edfd90..22c1961 100644 --- a/scan.php +++ b/scan.php @@ -29,26 +29,12 @@ switch ($_GET["op"]) { echo "RedisException caught: " . $e->getMessage(); } break; - case "check_install": - $arr = check_redis("web_out",$_GET["key"]); - if (!empty($arr)) { - foreach ($arr as $key=>$data) { - //echo $key."-".$_GET["key"]; - if ($key==$_GET["key"]) { // if install key moved to web_out - if ($data["INSTALL_STATUS"]>0) { - redis_remove("$key"); - echo "INSTALLED"; - } - } - } - } - else echo "NOT EXISTS"; - break; case "system": $arr = array("STATUS" => 0); $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); - if (set_output("system",$json)) echo "OK"; // TODO? + if (set_output("system",$json)) echo "OK"; + else echo "ERROR"; break; case "check_system": $arr = check_response("system"); @@ -73,13 +59,27 @@ switch ($_GET["op"]) { } else echo "WAIT"; break; + case "check_install": // called in install.php - check if install process has finished + $arr = check_response($_GET["key"]); // TODO - replace key with "install", key can be "install*" + if (!empty($arr)) { + foreach ($arr as $key=>$data) { + //echo $key."-".$_GET["key"]; + if ($key==$_GET["key"]) { // if install key moved to web_out + if ($data["INSTALL_STATUS"]>0) { + remove_response("$key"); + echo "INSTALLED"; + } + } + } + } + else echo "NOT EXISTS"; // TODO - check if in progress or just not exists ??? + break; case "services": $arr = array("STATUS" => 0); $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); - $op = "services"; //"init:".date("YmdHis"); - redis_set($op,$json); - echo "OK"; // TODO? + if (set_output("services",$json)) echo "OK"; + else echo "ERROR"; break; case "check_services": $arr = check_redis("web_out","services"); @@ -131,9 +131,8 @@ switch ($_GET["op"]) { $arr = array("STATUS" => 0); $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); - $op = "deployments"; - redis_set($op,$json); - echo "OK"; // TODO? + if (set_output("deployments",$json)) echo "OK"; + else echo "ERROR"; break; case "check_deployments": $arr = check_redis("web_out","deployments"); @@ -307,11 +306,11 @@ switch ($_GET["op"]) { $json = json_encode($arr, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT); $op = "repositories"; - redis_set($op,$json); - echo "OK"; // TODO? + if (set_output("repositories",$json)) echo "OK"; + else echo "ERROR"; break; case "check_repositories": - $arr = check_redis("web_out","repositories"); + $arr = check_response("repositories"); if (!empty($arr)) { foreach ($arr as $key=>$data) { if ($key=="repositories") { @@ -319,12 +318,12 @@ switch ($_GET["op"]) { foreach ($repos->repositories as $repo) { echo $repo."
"; } - redis_remove("$key"); + remove_response("$key"); } } - redis_remove("add_repository"); + remove_response("add_repository"); } - else echo ""; + else echo "WAIT"; break; case "add_repository": redis_remove("add_repository");