Bläddra i källkod

AMBARI-352. Add flow control - force redirects to appropriate pages based on cluster configuration status for better usability (Contributed by Yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1346649 13f79535-47bb-0310-9956-ffa450edef68
Vikram Dixit K 13 år sedan
förälder
incheckning
cf104cfeb8
3 ändrade filer med 58 tillägg och 0 borttagningar
  1. 2 0
      CHANGES.txt
  2. 4 0
      hmc/css/common.css
  3. 52 0
      hmc/html/head.inc

+ 2 - 0
CHANGES.txt

@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-352. Add flow control - force redirects to appropriate pages based on cluster configuration status for better usability (Yusaku via Vikram)
+
   AMBARI-351.  Monitoring dashboard should auto refresh as regular interval (Vitthal Gogate via Vikram)
 
   AMBARI-349. Logging in case of error during uninstall needs to be fixed. (Vikram)

+ 4 - 0
hmc/css/common.css

@@ -276,6 +276,10 @@ td {
 	margin:40px 0 0 40px;
 }
 
+div.formElement {
+	clear:both;
+}
+
 #configureClusterAdvancedCoreDivId label,
 #deployDynamicRenderDivId label,
 #deployCoreDivId label {

+ 52 - 0
hmc/html/head.inc

@@ -0,0 +1,52 @@
+<?php
+require_once '../php/conf/MessageResources-en.inc';
+require_once '../php/util/Logger.php';
+require_once '../php//conf/Config.inc';
+require_once "../php/util/lock.php";
+require_once '../php/db/HMCDBAccessor.php';
+require_once "../php/util/clusterState.php";
+
+$logger = new HMCLogger("Interceptor");
+$db = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+
+$res = $db->getAllClusters();
+$clusters = $res['clusters'];
+$baseUrl = basename(preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']));
+$logger->log_trace('basename='.$baseUrl);
+$appDir = "/hmc/html";
+
+$logger->log_trace('basename='.$baseUrl);
+if (sizeof($clusters) == 0) {
+  if ($baseUrl != 'welcome.php' && $baseUrl != 'initializeCluster.php') {
+    header("Location: $appDir/welcome.php");
+    return;
+  }
+} else {
+  foreach ($clusters as $cluster) {
+    $state = json_decode($cluster['state'], true);    
+    $logger->log_trace('cluster state='.print_r($state,1));
+    switch ($state['state']) {
+      case 'DEPLOYED':
+        if ($state['context']['status']) {
+          return;
+        } else {
+          if ($baseUrl != "reinstall.php" && $baseUrl != "uninstallWizard.php") {
+            header("Location: $appDir/reinstall.php");
+            return;
+          }
+        }
+        break;
+      case 'CONFIGURATION_IN_PROGRESS':
+        if ($baseUrl != 'initializeCluster.php') {
+          header("Location: $appDir/initializeCluster.php");
+        }
+        break;      
+      case 'DEPLOYMENT_IN_PROGRESS':
+        if ($baseUrl != 'showDeployProgress.php') {
+          header("Location: $appDir/showDeployProgress.php?clusterName=" . $cluster['clusterName']);          
+        }
+        break;
+    } 
+  }  
+}
+?>