ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-6025 Convert UI code of Move Master Wizard to lazily load host and host component info. (atkach)
Date Thu, 05 Jun 2014 10:55:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 4830ddf5e -> 735e008fa


AMBARI-6025 Convert UI code of Move Master Wizard to lazily load host and host component info.
(atkach)


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

Branch: refs/heads/trunk
Commit: 735e008fa6179192ee2f8f43d40827e6f1aa8726
Parents: 4830ddf
Author: atkach <atkach@hortonworks.com>
Authored: Thu Jun 5 13:52:11 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Thu Jun 5 13:52:11 2014 +0300

----------------------------------------------------------------------
 .../main/service/reassign_controller.js         | 19 ++-------
 .../app/templates/main/service/reassign.hbs     | 10 +++--
 .../app/views/main/service/reassign_view.js     | 42 ++++++++++++++++++++
 3 files changed, 52 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/735e008f/ambari-web/app/controllers/main/service/reassign_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/reassign_controller.js b/ambari-web/app/controllers/main/service/reassign_controller.js
index 25916f3..5d12460 100644
--- a/ambari-web/app/controllers/main/service/reassign_controller.js
+++ b/ambari-web/app/controllers/main/service/reassign_controller.js
@@ -139,23 +139,10 @@ App.ReassignMasterController = App.WizardController.extend({
    */
   loadConfirmedHosts: function () {
     var hosts = App.db.getHosts();
-    if (!hosts || !hosts.length) {
-      var hosts = {};
-
-      App.Host.find().forEach(function (item) {
-        hosts[item.get('id')] = {
-          name: item.get('id'),
-          cpu: item.get('cpu'),
-          memory: item.get('memory'),
-          disk_info: item.get('diskInfo'),
-          bootStatus: "REGISTERED",
-          isInstalled: true
-        };
-      });
-      App.db.setHosts(hosts);
-    }
 
-    this.set('content.hosts', hosts);
+    if (hosts) {
+      this.set('content.hosts', hosts);
+    }
     console.log('ReassignMasterController.loadConfirmedHosts: loaded hosts', hosts);
   },
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/735e008f/ambari-web/app/templates/main/service/reassign.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/reassign.hbs b/ambari-web/app/templates/main/service/reassign.hbs
index 45ab9c7..cdebce2 100644
--- a/ambari-web/app/templates/main/service/reassign.hbs
+++ b/ambari-web/app/templates/main/service/reassign.hbs
@@ -36,9 +36,13 @@
             </ul>
           </div>
         </div>
-        <div class="wizard-content well span9">
-          {{outlet}}
-        </div>
+          <div class="wizard-content well span9">
+            {{#if view.isLoaded}}
+              {{outlet}}
+            {{else}}
+                <div class="spinner"></div>
+            {{/if}}
+          </div>
       </div>
     </div>
   </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/735e008f/ambari-web/app/views/main/service/reassign_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/reassign_view.js b/ambari-web/app/views/main/service/reassign_view.js
index 461903e..a90332a 100644
--- a/ambari-web/app/views/main/service/reassign_view.js
+++ b/ambari-web/app/views/main/service/reassign_view.js
@@ -49,6 +49,48 @@ App.ReassignMasterView = Em.View.extend({
 
   isStepDisabled: function (index) {
     return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
+  },
+
+  isLoaded: false,
+
+  willInsertElement: function() {
+    this.set('isLoaded', false);
+    this.loadHosts();
+  },
+
+  /**
+   * load hosts from server
+   */
+  loadHosts: function () {
+    App.ajax.send({
+      name: 'hosts.high_availability.wizard',
+      data: {},
+      sender: this,
+      success: 'loadHostsSuccessCallback',
+      error: 'loadHostsErrorCallback'
+    });
+  },
+
+  loadHostsSuccessCallback: function (data, opt, params) {
+    var hosts = {};
+
+    data.items.forEach(function (item) {
+      hosts[item.Hosts.host_name] = {
+        name: item.Hosts.host_name,
+        cpu: item.Hosts.cpu_count,
+        memory: item.Hosts.total_mem,
+        disk_info: item.Hosts.disk_info,
+        bootStatus: "REGISTERED",
+        isInstalled: true
+      };
+    });
+    App.db.setHosts(hosts);
+    this.set('controller.content.hosts', hosts);
+    this.set('isLoaded', true);
+  },
+
+  loadHostsErrorCallback: function(){
+    this.set('isLoaded', true);
   }
 
 });


Mime
View raw message