Browse Source

AMBARI-247. Replace index.php with clusters.php (Contributed by Varun)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/ambari-186@1346639 13f79535-47bb-0310-9956-ffa450edef68
Vikram Dixit K 13 years ago
parent
commit
f6f7190df2
5 changed files with 125 additions and 204 deletions
  1. 2 0
      CHANGES.txt
  2. 0 79
      hmc/html/clusters.php
  3. 22 17
      hmc/html/index.php
  4. 0 81
      hmc/js/clusters.js
  5. 101 27
      hmc/js/clustersList.js

+ 2 - 0
CHANGES.txt

@@ -6,6 +6,8 @@ characters wide.
 
 Release 0.1.x - unreleased
 
+  AMBARI-247. Replace index.php with clusters.php (Varun via Vikram)
+
   AMBARI-347. Redo master service assignment page (Yusaku via Vikram)
 
   AMBARI-339. Making transitionToNextStage more robust (Vikram)

+ 0 - 79
hmc/html/clusters.php

@@ -1,79 +0,0 @@
-<?php require_once "./head.inc" ?>
-<html>
-  <head>
-    <title id="pageTitleId"><?php echo $RES['page.title'] ?></title>
-
-    <!-- CSS -->
-    <link type="text/css" rel="stylesheet" href="../yui-3.5.1/build/cssreset/cssreset-min.css">
-    <link type="text/css" rel="stylesheet" href="../css/bootstrap.css" media="screen"/>
-    <link type="text/css" rel="stylesheet" href="../css/common.css" media="screen"/>
-    <link type="text/css" rel="stylesheet" href="../css/common2.css" media="screen"/>
-    <link type="text/css" rel="stylesheet" href="../css/common3.css" media="screen"/>
-    <link type="text/css" rel="stylesheet" href="../css/clusters.css" media="screen"/>
-    <link rel="shortcut icon" href="../images/logo-micro.gif">
-    <!-- End CSS -->
-  </head>
-
-  <body class="yui3-skin-sam">
-    <?php require "./topnav.htmli"; ?>
-
-    <h1> Cluster <?php echo $_GET['clusterName']; ?> </h1>
-
-    <br/>
-
-    <div id="contentDivId"> 
-
-      <?php require "./utils.htmli"; ?>
-
-      <!-- The Main Event -->
-      <div id="clustersCoreDivId">
-        <div id="clustersNavigationLinksDivId">
-          <ul id="clustersNavigationLinksListId">
-            <li class="clustersNavigationLinkEntry">
-              <a class="btn" href="../../hdp/dashboard/ui/home.html">
-                Monitoring
-              </a>
-            </li>
-            <li class="clustersNavigationLinkEntry">
-              <a class="btn" href="../html/manageServices.php?clusterName=<?php echo $_GET['clusterName']; ?>">
-                Manage Services
-              </a>
-            </li>
-            <li class="clustersNavigationLinkEntry">
-              <a class="btn" href="../html/uninstallWizard.php?clusterName=<?php echo $_GET['clusterName']; ?>">
-                Uninstall
-              </a>
-            </li>
-          </ul>
-        </div>
-
-        <br/>
-
-        <div id="clustersHostRoleMappingDynamicRenderDivId">
-        </div>
-      </div>
-      <!-- End of clustersCoreDivId -->
-
-      <?php require "./txnUtils.htmli"; ?>
-
-    </div>
-    <!-- End of contentDivId -->
-
-    <?php require "./footer.htmli"; ?>
-
-    <!-- Javascript Scaffolding -->
-    <script type="text/javascript">
-      /* Minimal data required to bootstrap clusters.js. */
-      var clusterName = '<?php echo $_GET['clusterName']; ?>';
-
-      var jsFilesToLoad = [ 
-        '../js/utils.js',
-        '../js/txnUtils.js',
-        '../js/clusters.js' 
-      ];
-    </script>
-
-    <?php require "./bootstrapJs.htmli"; ?>
-    <!-- End of Javascript Scaffolding -->
-  </body>
-</html> 

+ 22 - 17
hmc/html/index.php

@@ -12,33 +12,38 @@
     <!-- End CSS -->
   </head>
 
-  <body>
+  <body class="yui3-skin-sam">
     <?php require "./topnav.htmli"; ?>
 
-    <div id="ContentDivId" class="yui3-skin-sam">
+    <div id="ContentDivId">
+
+      <?php require "./utils.htmli"; ?>
+
       <div id="welcomeDivId" style="display:none">
         <?php require "./welcome.inc" ?>           
       </div>
       <!-- List of clusters -->
       <div id="clustersListDivId" style="display:none">
       </div>
+
+      <div id="clusterHostRoleMappingDynamicRenderDivId">
+      </div>
+
     </div>        
+    <!-- End of contentDivId -->
     
-        <!--
-        <div name="installationSideBarDiv" id="installationSideBarDivId">
-          <div id="createClusterSideBarId">Create cluster</div>
-          <div id="selectServicesSideBarId">Select services</div>
-          <div id="masterHostsSideBarId">Select master hosts</div>
-          <div id="mountPointsSideBarId">Select mount points</div>
-          <div id="advancedConfigSideBarId">Advanced configuration</div>
-          <div id="reviewSettingsSideBarId">Review your settings</div>
-        </div>
-        -->
-
-    <script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>
-    <script src="../js/utils.js"></script>
-    <script src="../js/clustersList.js"></script>
-
     <?php require "./footer.htmli"; ?>
+
+    <!-- Javascript Scaffolding -->
+    <script type="text/javascript">
+
+      var jsFilesToLoad = [ 
+        '../js/utils.js',
+        '../js/clustersList.js' 
+      ];
+    </script>
+
+    <?php require "./bootstrapJs.htmli"; ?>
+    <!-- End of Javascript Scaffolding -->
   </body>
 </html> 

+ 0 - 81
hmc/js/clusters.js

@@ -1,81 +0,0 @@
-function generateClusterHostRoleMappingMarkup( clusterServices ) {
-
-  var clusterHostRoleMappingMarkup = 
-  '<fieldset id=clustersHostRoleMappingFieldsetId>' +
-    '<legend>' +
-      'Locations Of Service Masters' + 
-    '</legend>';
-
-  for (var serviceName in clusterServices) {
-    if (clusterServices.hasOwnProperty(serviceName)) {
-
-      if (clusterServices[serviceName].isEnabled == "1" && 
-          clusterServices[serviceName].attributes.runnable &&
-          !clusterServices[serviceName].attributes.noDisplay) {
-
-        globalYui.Array.each( clusterServices[serviceName].components, function (serviceComponent) {
-          
-          if (serviceComponent.isMaster) {
-            clusterHostRoleMappingMarkup += 
-              '<div>' + 
-                '<label>' + serviceComponent.displayName + '</label>' + 
-                ' : ' +
-                serviceComponent.hostName +
-              '</div>' + 
-              '<br/>';
-          }
-        });
-      }
-    }
-  }
-
-  clusterHostRoleMappingMarkup += 
-  '</fieldset>';
-
-  return clusterHostRoleMappingMarkup;
-}
-
-/* Main() */
-
-/* The clusterName variable is set in the Javascript scaffolding spit out by manageServices.php */
-globalYui.io( "../php/frontend/fetchClusterServices.php?clusterName=" + clusterName + "&getConfigs=true&getComponents=true", {
-  timeout: 10000,
-  on: {
-    success: function(x, o) {
-
-      hideLoadingImg();
-
-      globalYui.log("RAW JSON DATA: " + o.responseText);
-
-      var clusterServicesResponseJson;
-
-      try {
-        clusterServicesResponseJson = globalYui.JSON.parse(o.responseText);
-      }
-      catch (e) {
-        alert("JSON Parse failed");
-        return;
-      }
-
-      globalYui.log(globalYui.Lang.dump(clusterServicesResponseJson));
-
-      /* Check that clusterServicesResponseJson actually indicates success. */
-      if( clusterServicesResponseJson.result == 0 ) {
-        
-        var clusterServices = clusterServicesResponseJson.response.services;
-
-        /* Link the newly-generated markup into the DOM. */
-        globalYui.one("#clustersHostRoleMappingDynamicRenderDivId").setContent( generateClusterHostRoleMappingMarkup(clusterServices) );
-
-      }
-      else {
-        alert("Fetching Cluster Services failed");
-      }
-    },
-    failure: function(x, o) {
-      hideLoadingImg();
-      alert("Async call failed");
-    }
-  }
-});
-

+ 101 - 27
hmc/js/clustersList.js

@@ -1,21 +1,57 @@
-function renderClusterList(Y) {
-  Y.io("../php/frontend/listClusters.php", {
+function generateClusterHostRoleMappingMarkup( clusterServices ) {
+
+  var clusterHostRoleMappingMarkup = 
+  '<fieldset id=clustersHostRoleMappingFieldsetId>' +
+    '<legend>' +
+      'Locations Of Service Masters' + 
+    '</legend>';
+
+  for (var serviceName in clusterServices) {
+    if (clusterServices.hasOwnProperty(serviceName)) {
+
+      if (clusterServices[serviceName].isEnabled == "1" && 
+          clusterServices[serviceName].attributes.runnable &&
+          !clusterServices[serviceName].attributes.noDisplay) {
+
+        globalYui.Array.each( clusterServices[serviceName].components, function (serviceComponent) {
+          
+          if (serviceComponent.isMaster) {
+            clusterHostRoleMappingMarkup += 
+              '<div class=formElement>' + 
+                '<label>' + serviceComponent.displayName + ': ' + '</label>' + 
+                serviceComponent.hostName +
+              '</div>' + 
+              '<br/>';
+          }
+        });
+      }
+    }
+  }
+
+  clusterHostRoleMappingMarkup += 
+  '</fieldset>';
+
+  return clusterHostRoleMappingMarkup;
+}
+
+function renderClusterList() {
+  globalYui.io("../php/frontend/listClusters.php", {
     method: 'GET',
     timeout : 10000,
     on: {
       success: function (x,o) {
-        Y.log("RAW JSON DATA: " + o.responseText);
+        globalYui.log("RAW JSON DATA: " + o.responseText);
 
         // Process the JSON data returned from the server
         try {
-          clusterListInfoJson = Y.JSON.parse(o.responseText);
+          clusterListInfoJson = globalYui.JSON.parse(o.responseText);
         }
         catch (e) {
           alert("JSON Parse failed!");
           return;
         }
         
-        Y.log("PARSED DATA: " + Y.Lang.dump(clusterListInfoJson));
+        globalYui.log("PARSED DATA: " + globalYui.Lang.dump(clusterListInfoJson));
 
         if (clusterListInfoJson.result != 0) {
           // Error!
@@ -46,17 +82,18 @@ function renderClusterList(Y) {
             var clusterName; var clusterInfo;
             for (clusterId in clusterListInfoJson) {
               clusterName = clusterId;
-              clusterInfo = clusterListInfoJson[clusterName];
+              clusterInfo = globalYui.JSON.parse(clusterListInfoJson[clusterName]);
+              globalYui.log( "Cluster Info: " + globalYui.Lang.dump(clusterInfo.displayName));
             }
             clustersListMarkup = '<h3>Cluster information</h3>';
             clustersListMarkup += '<div class="clusterDiv">' +
                                    '<div class="formElement">' +
                                      '<label>Cluster Name</label>' +
-                                     '<input type=text readonly=readonly value=' + clusterName + '>' +
+                                     '<input type=text readonly=readonly value="' + clusterName + '">' +
                                    '</div>' +
                                    '<div class="formElement">' +
                                      '<label>State</label>' +
-                                     '<input type=text readonly=readonly value=' + clusterInfo + '>' +
+                                     '<input type=text readonly=readonly value="' + clusterInfo['displayName'] + '">' +
                                    '</div>' +
                                    '<div class="formElement">' +
                                      '<a class="btn" href="/hdp/dashboard/ui/home.html">Monitoring Dashboard</a>' +
@@ -71,34 +108,77 @@ function renderClusterList(Y) {
         var newClusterLinkHTML = "";
         if (multipleClustersSupported || numClusters == 0) {
           clustersListMarkup += newClusterLinkHTML;
-          Y.one("#welcomeDivId").setStyle('display','block');
+          globalYui.one("#welcomeDivId").setStyle('display','block');
           return;
         }
 
-        Y.one("#clustersListDivId").setContent( clustersListMarkup );
-        Y.one("#clustersListDivId").setStyle('display', 'block');
+        /* Beginning of adding Role Topology information. */
+        globalYui.io( "../php/frontend/fetchClusterServices.php?clusterName=" + clusterName + "&getConfigs=true&getComponents=true", {
+          timeout: 10000,
+          on: {
+            success: function(x1, o1) {
+
+              hideLoadingImg();
+
+              globalYui.log("RAW JSON DATA: " + o1.responseText);
+
+              var clusterServicesResponseJson;
+
+              try {
+                clusterServicesResponseJson = globalYui.JSON.parse(o1.responseText);
+              }
+              catch (e) {
+                alert("JSON Parse failed");
+                return;
+              }
+
+              globalYui.log(globalYui.Lang.dump(clusterServicesResponseJson));
+
+              /* Check that clusterServicesResponseJson actually indicates success. */
+              if( clusterServicesResponseJson.result == 0 ) {
+                
+                var clusterServices = clusterServicesResponseJson.response.services;
+
+                /* Link the newly-generated markup into the DOM. */
+                globalYui.one("#clusterHostRoleMappingDynamicRenderDivId").setContent
+                  ( generateClusterHostRoleMappingMarkup(clusterServices) );
+              }
+              else {
+                alert("Fetching Cluster Services failed");
+              }
+            },
+            failure: function(x1, o1) {
+              hideLoadingImg();
+              alert("Async call failed");
+            }
+          }
+        });
+        /* End of adding Role Topology information. */
 
-        if (Y.one('#newClusterLinkDivId') != null) {
-          Y.one('#newClusterLinkDivId').on('click',function (e) {
+        globalYui.one("#clustersListDivId").setContent( clustersListMarkup );
+        globalYui.one("#clustersListDivId").setStyle('display', 'block');
+
+        if (globalYui.one('#newClusterLinkDivId') != null) {
+          globalYui.one('#newClusterLinkDivId').on('click',function (e) {
             /* Done with this stage, hide it. */
-            Y.one("#clustersListDivId").setStyle('display','none');
-            // Y.one("#installationWizardDivId").setStyle('display','block');
+            globalYui.one("#clustersListDivId").setStyle('display','none');
+            // globalYui.one("#installationWizardDivId").setStyle('display','block');
         });
         }
 
         if(numClusters !=0) {
-          Y.one('#existingClusterLinkDivId').on('click',function (e) {
+          globalYui.one('#existingClusterLinkDivId').on('click',function (e) {
 
             e.target.set('disabled', true);
 
             /* Done with this stage, hide it. */
-            Y.one("#clustersListDivId").setStyle('display','none');
+            globalYui.one("#clustersListDivId").setStyle('display','none');
 
             /* Render the next stage. */
-            getServicesStatus(Y, clusterId);
+            getServicesStatus(globalYui, clusterId);
 
             /* Show off our rendering. */
-            Y.one("#displayServiceStatusCoreDivId").setStyle('display','block');
+            globalYui.one("#displayServiceStatusCoreDivId").setStyle('display','block');
           });
        }
 
@@ -111,12 +191,6 @@ function renderClusterList(Y) {
   });
 }
 
-// Create business logic in a YUI sandbox using the 'io' and 'json' modules
-YUI().use("node", "io", "dump", "json", "arraysort", "panel", function (Y) {
-
-  Y.log( Y.one("#pageTitleId").get('innerHTML') );
-
-  // Y.one('#createClusterSubmitButtonId').on('click',function (e) {
-    renderClusterList(Y);
 
-});
+/* Main() */
+renderClusterList();