ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject git commit: AMBARI-6220. Step 7. Create config group popup freeze UI. (onechiporenko)
Date Fri, 20 Jun 2014 15:05:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.1 156e4e8ef -> 64f2d5b6e


AMBARI-6220. Step 7. Create config group popup freeze UI. (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/64f2d5b6
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/64f2d5b6
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/64f2d5b6

Branch: refs/heads/branch-1.6.1
Commit: 64f2d5b6eb0c9a15dca2db38aac355eb7072e711
Parents: 156e4e8
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Fri Jun 20 17:59:19 2014 +0300
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Fri Jun 20 17:59:19 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/installer.js         | 47 +++++++++++++++-----
 .../app/controllers/main/host/add_controller.js | 17 ++++++-
 .../controllers/main/service/add_controller.js  | 20 ++++++++-
 ambari-web/app/controllers/wizard.js            | 43 +++++++++++++-----
 .../app/controllers/wizard/step7_controller.js  |  6 +--
 ambari-web/app/utils/component.js               |  5 ++-
 ambari-web/app/utils/config.js                  |  4 +-
 ambari-web/app/views/main/service/add_view.js   |  5 ++-
 8 files changed, 114 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/64f2d5b6/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index f70870a..d339433 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -391,11 +391,8 @@ App.InstallerController = App.WizardController.extend({
    * @param stepController App.WizardStep4Controller
    */
   saveServices: function (stepController) {
-    var serviceNames = [];
     this.setDBProperty('service', stepController.get('content'));
-    stepController.filterProperty('isSelected', true).forEach(function (item) {
-      serviceNames.push(item.serviceName);
-    });
+    var serviceNames = stepController.filterProperty('isSelected', true).mapProperty('serviceName');
     this.set('content.selectedServiceNames', serviceNames);
     this.setDBProperty('selectedServiceNames', serviceNames);
     console.log('installerController.saveServices: saved data ', serviceNames);
@@ -406,16 +403,18 @@ App.InstallerController = App.WizardController.extend({
    * @param stepController App.WizardStep5Controller
    */
   saveMasterComponentHosts: function (stepController) {
-    var obj = stepController.get('selectedServicesMasters');
+
+    var obj = stepController.get('selectedServicesMasters'),
+      hosts = this.getDBProperty('hosts');
 
     var masterComponentHosts = [];
     obj.forEach(function (_component) {
       masterComponentHosts.push({
         display_name: _component.get('display_name'),
         component: _component.get('component_name'),
-        hostName: _component.get('selectedHost'),
         serviceId: _component.get('serviceId'),
-        isInstalled: false
+        isInstalled: false,
+        host_id: hosts[_component.get('selectedHost')].id
       });
     });
 
@@ -428,16 +427,44 @@ App.InstallerController = App.WizardController.extend({
    * Load master component hosts data for using in required step controllers
    */
   loadMasterComponentHosts: function () {
-    var masterComponentHosts = this.getDBProperty('masterComponentHosts') || [];
+    var masterComponentHosts = this.getDBProperty('masterComponentHosts'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (Em.isNone(masterComponentHosts)) {
+      masterComponentHosts = [];
+    }
+    else {
+      masterComponentHosts.forEach(function(component) {
+        for (var i = 0; i < host_names.length; i++) {
+          if (hosts[host_names[i]].id === component.host_id) {
+            component.hostName = host_names[i];
+            break;
+          }
+        }
+      });
+    }
     this.set("content.masterComponentHosts", masterComponentHosts);
-    console.log("InstallerController.loadMasterComponentHosts: loaded hosts ", masterComponentHosts);
   },
 
   /**
    * Load master component hosts data for using in required step controllers
    */
   loadSlaveComponentHosts: function () {
-    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts') || null;
+    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (!Em.isNone(slaveComponentHosts)) {
+      slaveComponentHosts.forEach(function(component) {
+        component.hosts.forEach(function(host) {
+          for (var i = 0; i < host_names.length; i++) {
+            if (hosts[host_names[i]].id === host.host_id) {
+              host.hostName = host_names[i];
+              break;
+            }
+          }
+        });
+      });
+    }
     this.set("content.slaveComponentHosts", slaveComponentHosts);
     console.log("InstallerController.loadSlaveComponentHosts: loaded hosts ", slaveComponentHosts);
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/64f2d5b6/ambari-web/app/controllers/main/host/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/add_controller.js b/ambari-web/app/controllers/main/host/add_controller.js
index 86bba2d..33a21e6 100644
--- a/ambari-web/app/controllers/main/host/add_controller.js
+++ b/ambari-web/app/controllers/main/host/add_controller.js
@@ -143,7 +143,22 @@ App.AddHostController = App.WizardController.extend({
    * TODO move to mixin
    */
   loadSlaveComponentHosts: function () {
-    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts');
+    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (!Em.isNone(slaveComponentHosts)) {
+      slaveComponentHosts.forEach(function(component) {
+        component.hosts.forEach(function(host) {
+          //Em.set(host, 'hostName', hosts[host.host_id].name);
+          for (var i = 0; i < host_names.length; i++) {
+            if (hosts[host_names[i]].id === host.host_id) {
+              host.hostName = host_names[i];
+              break;
+            }
+          }
+        });
+      });
+    }
     if (!slaveComponentHosts) {
       slaveComponentHosts = this.getSlaveComponentHosts();
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/64f2d5b6/ambari-web/app/controllers/main/service/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js
index 5d1cf1e..080aba3 100644
--- a/ambari-web/app/controllers/main/service/add_controller.js
+++ b/ambari-web/app/controllers/main/service/add_controller.js
@@ -114,7 +114,8 @@ App.AddServiceController = App.WizardController.extend({
    * Save data to model
    * @param stepController App.WizardStep4Controller
    */
-  saveServices: function (stepController) {var serviceNames = [];
+  saveServices: function (stepController) {
+    var serviceNames = [];
     this.setDBProperty('service', stepController.get('content'));
     console.log('AddServiceController.saveServices: saved data', stepController.get('content'));
     stepController.filterProperty('isSelected', true).filterProperty('isInstalled', false).forEach(function
(item) {
@@ -211,7 +212,22 @@ App.AddServiceController = App.WizardController.extend({
    * Load master component hosts data for using in required step controllers
    */
   loadSlaveComponentHosts: function () {
-    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts');
+    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (!Em.isNone(slaveComponentHosts)) {
+      slaveComponentHosts.forEach(function(component) {
+        component.hosts.forEach(function(host) {
+          //Em.set(host, 'hostName', hosts[host.host_id].name);
+          for (var i = 0; i < host_names.length; i++) {
+            if (hosts[host_names[i]].id === host.host_id) {
+              host.hostName = host_names[i];
+              break;
+            }
+          }
+        });
+      });
+    }
     if(!slaveComponentHosts){
       slaveComponentHosts = this.getSlaveComponentHosts();
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/64f2d5b6/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 2914fad..2b93a05 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -590,7 +590,25 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * Load config groups from local DB
    */
   loadServiceConfigGroups: function () {
-    var serviceConfigGroups = this.getDBProperty('serviceConfigGroups') || [];
+    var serviceConfigGroups = this.getDBProperty('serviceConfigGroups'),
+      hosts = this.getDBProperty('hosts'),
+      host_names = Em.keys(hosts);
+    if (Em.isNone(serviceConfigGroups)) {
+      serviceConfigGroups = [];
+    }
+    else {
+      serviceConfigGroups.forEach(function(group) {
+        group.hosts.map(function(host_id) {
+          for (var i = 0; i < host_names.length; i++) {
+            if (hosts[host_names[i]].id === host_id) {
+              return host_names[i];
+            }
+          }
+          Em.assert('host is missing!!!!', false);
+        });
+        Em.set(group, 'hosts', host_names);
+      });
+    }
     this.set('content.configGroups', serviceConfigGroups);
     console.log("InstallerController.configGroups: loaded config ", serviceConfigGroups);
   },
@@ -611,7 +629,8 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * @param stepController App.WizardStep3Controller
    */
   saveConfirmedHosts: function (stepController) {
-    var hosts = this.get('content.hosts');
+    var hosts = this.get('content.hosts'),
+      indx = 1;
 
     //add previously installed hosts
     for (var hostName in hosts) {
@@ -631,7 +650,8 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
           os_arch: _host.os_arch,
           ip: _host.ip,
           bootStatus: _host.bootStatus,
-          isInstalled: false
+          isInstalled: false,
+          id: indx++
         };
       }
     });
@@ -667,9 +687,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * @param stepController
    */
   saveSlaveComponentHosts: function (stepController) {
-
-    var hosts = stepController.get('hosts');
-    var headers = stepController.get('headers');
+    var hosts = stepController.get('hosts'),
+      dbHosts = this.getDBProperty('hosts'),
+      headers = stepController.get('headers');
 
     var formattedHosts = Ember.Object.create();
     headers.forEach(function (header) {
@@ -683,9 +703,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
         var cb = checkboxes.findProperty('title', header.get('label'));
         if (cb.get('checked')) {
           formattedHosts.get(header.get('name')).push({
-            hostName: host.hostName,
             group: 'Default',
-            isInstalled: cb.get('isInstalled')
+            isInstalled: cb.get('isInstalled'),
+            host_id: dbHosts[host.hostName].id
           });
         }
       });
@@ -848,8 +868,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
    * @param stepController
    */
   saveServiceConfigGroups: function (stepController) {
-    var serviceConfigGroups = [];
-    var isForUpdate = false;
+    var serviceConfigGroups = [],
+      isForUpdate = false,
+      hosts = this.getDBProperty('hosts');
     stepController.get('stepConfigs').forEach(function (service) {
       // mark group of installed service
       if (service.get('selected') === false) isForUpdate = true;
@@ -868,7 +889,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, {
           id: configGroup.get('id'),
           name: configGroup.get('name'),
           description: configGroup.get('description'),
-          hosts: configGroup.get('hosts'),
+          hosts: configGroup.get('hosts').map(function(host_name) {return hosts[host_name].id;}),
           properties: properties,
           isDefault: configGroup.get('isDefault'),
           isForUpdate: isForUpdate,

http://git-wip-us.apache.org/repos/asf/ambari/blob/64f2d5b6/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index adfb669..506fbaf 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -690,9 +690,9 @@ App.WizardStep7Controller = Em.Controller.extend({
    */
   setStepConfigs: function (configs, storedConfigs) {
     var localDB = {
-      hosts: this.get('wizardController').getDBProperty('hosts'),
-      masterComponentHosts: this.get('wizardController').getDBProperty('masterComponentHosts'),
-      slaveComponentHosts: this.get('wizardController').getDBProperty('slaveComponentHosts')
+      hosts: this.get('wizardController.content.hosts'),
+      masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
+      slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
     };
     var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'),
this.get('installedServiceNames'), localDB);
     if (this.get('wizardController.name') === 'addServiceController') {

http://git-wip-us.apache.org/repos/asf/ambari/blob/64f2d5b6/ambari-web/app/utils/component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/component.js b/ambari-web/app/utils/component.js
index 7e61a49..fd2ef1b 100644
--- a/ambari-web/app/utils/component.js
+++ b/ambari-web/app/utils/component.js
@@ -46,7 +46,7 @@ module.exports = {
     this.clearStackModel();
     var serviceComponents = {items: []};
     data.items.forEach(function(item){
-      item.serviceComponents.forEach(function(_serviceComponent){
+      item.serviceComponents.forEach(function(_serviceComponent, indx){
         var stackServiceComponents =  _serviceComponent.StackServiceComponents;
         var serviceComponent = {
           component_name: stackServiceComponents.component_name,
@@ -55,7 +55,8 @@ module.exports = {
           is_master: stackServiceComponents.is_master,
           is_client: stackServiceComponents.is_client,
           stack_name: stackServiceComponents.stack_name,
-          stack_version: stackServiceComponents.stack_version
+          stack_version: stackServiceComponents.stack_version,
+          id: indx
         };
         serviceComponents.items.pushObject(serviceComponent);
       }, this);

http://git-wip-us.apache.org/repos/asf/ambari/blob/64f2d5b6/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 2447d55..2238b72 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1295,13 +1295,13 @@ App.config = Em.Object.create({
         selectedGroup.get('hosts').removeObject(hostName);
         if (!selectedGroup.get('isDefault')) {
           self.updateConfigurationGroup(selectedGroup, function () {
-          }, function () {});
+          }, Em.K);
         }
         newGroup.get('hosts').pushObject(hostName);
         callback(newGroup);
         if (!newGroup.get('isDefault')) {
           self.updateConfigurationGroup(newGroup, function () {
-          }, function () {});
+          }, Em.K);
         }
         this.hide();
       },

http://git-wip-us.apache.org/repos/asf/ambari/blob/64f2d5b6/ambari-web/app/views/main/service/add_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/add_view.js b/ambari-web/app/views/main/service/add_view.js
index da659aa..4cb4800 100644
--- a/ambari-web/app/views/main/service/add_view.js
+++ b/ambari-web/app/views/main/service/add_view.js
@@ -77,7 +77,7 @@ App.AddServiceView = Em.View.extend({
   loadHostsSuccessCallback: function (response) {
     var installedHosts = {};
 
-    response.items.forEach(function (item) {
+    response.items.forEach(function (item, indx) {
       installedHosts[item.Hosts.host_name] = {
         name: item.Hosts.host_name,
         cpu: item.Hosts.cpu_count,
@@ -85,7 +85,8 @@ App.AddServiceView = Em.View.extend({
         disk_info: item.Hosts.disk_info,
         bootStatus: "REGISTERED",
         isInstalled: true,
-        hostComponents: item.host_components
+        hostComponents: item.host_components,
+        id: indx++
       };
     });
     this.get('controller').setDBProperty('hosts', installedHosts);


Mime
View raw message