ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1485450 - in /incubator/ambari/trunk/ambari-web/app: assets/data/wizard/stack/HDPLocal_versions.json assets/data/wizard/stack/HDP_versions.json assets/data/wizard/stack/stacks2.json controllers/installer.js utils/ajax.js
Date Wed, 22 May 2013 21:47:31 GMT
Author: yusaku
Date: Wed May 22 21:47:31 2013
New Revision: 1485450

URL: http://svn.apache.org/r1485450
Log:
AMBARI-2167. Support for displaying various stacks and having the user select which stack
to install. (yusaku)

Added:
    incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDPLocal_versions.json
    incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDP_versions.json
    incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/stacks2.json
Modified:
    incubator/ambari/trunk/ambari-web/app/controllers/installer.js
    incubator/ambari/trunk/ambari-web/app/utils/ajax.js

Added: incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDPLocal_versions.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDPLocal_versions.json?rev=1485450&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDPLocal_versions.json
(added)
+++ incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDPLocal_versions.json
Wed May 22 21:47:31 2013
@@ -0,0 +1,32 @@
+{
+  "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDPLocal/versions?fields=Versions",
+  "items" : [
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDPLocal/versions/1.3.0",
+      "Versions" : {
+        "stack_version" : "1.3.0",
+        "active" : false,
+        "stack_name" : "HDPLocal",
+        "min_upgrade_version" : "1.2.0"
+      }
+    },
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDPLocal/versions/1.2.0",
+      "Versions" : {
+        "stack_version" : "1.2.0",
+        "active" : false,
+        "stack_name" : "HDPLocal",
+        "min_upgrade_version" : null
+      }
+    },
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDPLocal/versions/1.2.1",
+      "Versions" : {
+        "stack_version" : "1.2.1",
+        "active" : false,
+        "stack_name" : "HDPLocal",
+        "min_upgrade_version" : null
+      }
+    }
+  ]
+}

Added: incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDP_versions.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDP_versions.json?rev=1485450&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDP_versions.json (added)
+++ incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/HDP_versions.json Wed May
22 21:47:31 2013
@@ -0,0 +1,50 @@
+{
+  "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDP/versions?fields=Versions",
+  "items" : [
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDP/versions/0.1",
+      "Versions" : {
+        "stack_version" : "0.1",
+        "active" : false,
+        "stack_name" : "HDP",
+        "min_upgrade_version" : null
+      }
+    },
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDP/versions/2.0.1",
+      "Versions" : {
+        "stack_version" : "2.0.1",
+        "active" : false,
+        "stack_name" : "HDP",
+        "min_upgrade_version" : null
+      }
+    },
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDP/versions/1.3.0",
+      "Versions" : {
+        "stack_version" : "1.3.0",
+        "active" : true,
+        "stack_name" : "HDP",
+        "min_upgrade_version" : "1.2.0"
+      }
+    },
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDP/versions/1.2.1",
+      "Versions" : {
+        "stack_version" : "1.2.1",
+        "active" : true,
+        "stack_name" : "HDP",
+        "min_upgrade_version" : null
+      }
+    },
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDP/versions/1.2.0",
+      "Versions" : {
+        "stack_version" : "1.2.0",
+        "active" : false,
+        "stack_name" : "HDP",
+        "min_upgrade_version" : null
+      }
+    }
+  ]
+}

Added: incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/stacks2.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/stacks2.json?rev=1485450&view=auto
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/stacks2.json (added)
+++ incubator/ambari/trunk/ambari-web/app/assets/data/wizard/stack/stacks2.json Wed May 22
21:47:31 2013
@@ -0,0 +1,17 @@
+{
+  "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2",
+  "items" : [
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDP",
+      "Stacks" : {
+        "stack_name" : "HDP"
+      }
+    },
+    {
+      "href" : "http://dev.hortonworks.com:8080/api/v1/stacks2/HDPLocal",
+      "Stacks" : {
+        "stack_name" : "HDPLocal"
+      }
+    }
+  ]
+}

Modified: incubator/ambari/trunk/ambari-web/app/controllers/installer.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/installer.js?rev=1485450&r1=1485449&r2=1485450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/installer.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/installer.js Wed May 22 21:47:31 2013
@@ -91,12 +91,14 @@ App.InstallerController = App.WizardCont
     console.log('selected services ', servicesInfo.filterProperty('isSelected', true).mapProperty('serviceName'));
   },
 
+  stacks: [],
+
   /**
    * Load stacks data from server or take exist data from local db
    */
   loadStacks: function () {
     var stacks = App.db.getStacks();
-    if (stacks) {
+    if (stacks && stacks.length) {
       var convertedStacks = [];
       stacks.forEach(function (stack) {
         convertedStacks.pushObject(Ember.Object.create(stack));
@@ -114,39 +116,33 @@ App.InstallerController = App.WizardCont
   },
 
   /**
-   * Parse loaded data and create array of stacks objects
+   * Send queries to load versions for each stack
    */
   loadStacksSuccessCallback: function (data) {
-    var result = [];
     var stacks = data.items;
+    var result;
+    this.get('stacks').clear();
     stacks.forEach(function (stack) {
-      if (stack.Stacks.stack_name.indexOf('Local') === -1) {
-        stack.versions.sort(function (a, b) {
-          if (a.Versions.stack_version > b.Versions.stack_version) {
-            return -1;
-          }
-          if (a.Versions.stack_version < b.Versions.stack_version) {
-            return 1;
-          }
-          return 0;
-        });
-        stack.versions.forEach(function (version) {
-          if (version.Versions.active !== 'false') {
-            result.push(
-                Ember.Object.create({
-                  name: version.Versions.stack_name + "-" + version.Versions.stack_version,
-                  isSelected: false
-                })
-            );
-          }
-        }, this)
-      }
+      App.ajax.send({
+        name: 'wizard.stacks_versions',
+        sender: this,
+        data: {
+          stackName: stack.Stacks.stack_name
+        },
+        success: 'loadStacksVersionsSuccessCallback',
+        error: 'loadStacksVersionsErrorCallback'
+      });
     }, this);
-    var defaultStackVersion = result.findProperty('name', App.defaultStackVersion);
-    if (defaultStackVersion) {
-      defaultStackVersion.set('isSelected', true)
+    result = this.get('stacks');
+    if (!result.length) {
+      console.log('Error: therea are no active stacks');
     } else {
-      result.objectAt(0).set('isSelected', true);
+      var defaultStackVersion = result.findProperty('name', App.defaultStackVersion);
+      if (defaultStackVersion) {
+        defaultStackVersion.set('isSelected', true)
+      } else {
+        result.objectAt(0).set('isSelected', true);
+      }
     }
     App.db.setStacks(result);
     this.set('content.stacks', result);
@@ -160,6 +156,39 @@ App.InstallerController = App.WizardCont
   },
 
   /**
+   * Parse loaded data and create array of stacks objects
+   */
+  loadStacksVersionsSuccessCallback: function (data) {
+    var result = [];
+    var stackVersions = data.items.filterProperty('Versions.active');
+    stackVersions.sort(function (a, b) {
+      if (a.Versions.stack_version > b.Versions.stack_version) {
+        return -1;
+      }
+      if (a.Versions.stack_version < b.Versions.stack_version) {
+        return 1;
+      }
+      return 0;
+    });
+    stackVersions.forEach(function (version) {
+          result.push(
+              Ember.Object.create({
+                name: version.Versions.stack_name + "-" + version.Versions.stack_version,
+                isSelected: false
+              })
+          );
+    }, this);
+    this.get('stacks').pushObjects(result);
+  },
+
+  /**
+   * onError callback for loading stacks data
+   */
+  loadStacksVersionsErrorCallback: function () {
+    console.log('Error in loading stacks');
+  },
+
+  /**
    * Save data to model
    * @param stepController App.WizardStep4Controller
    */
@@ -265,7 +294,11 @@ App.InstallerController = App.WizardCont
    */
   saveStacks: function (stepController) {
     var stacks = stepController.get('content.stacks');
-    App.set('currentStackVersion', stacks.findProperty('isSelected').get('name'));
+    if (stacks.length) {
+      App.set('currentStackVersion', stacks.findProperty('isSelected').get('name'));
+    } else {
+      App.set('currentStackVersion', App.defaultStackVersion);
+    }
     App.db.setStacks(stacks);
     this.set('content.stacks', stacks);
   },

Modified: incubator/ambari/trunk/ambari-web/app/utils/ajax.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/ajax.js?rev=1485450&r1=1485449&r2=1485450&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/ajax.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/ajax.js Wed May 22 21:47:31 2013
@@ -656,8 +656,17 @@ var urls = {
     'mock': '/data/wizard/bootstrap/single_host_registration.json'
   },
   'wizard.stacks': {
-    'real': '/stacks2?fields=versions',
-    'mock': '/data/wizard/stack/versions.json',
+    'real': '/stacks2',
+    'mock': '/data/wizard/stack/stacks2.json',
+    'format': function (data) {
+      return {
+        async: false
+      };
+    }
+  },
+  'wizard.stacks_versions': {
+    'real': '/stacks2/{stackName}/versions?fields=Versions',
+    'mock': '/data/wizard/stack/{stackName}_versions.json',
     'format': function (data) {
       return {
         async: false



Mime
View raw message