Browse Source

AMBARI-12868. Improve calls to the localStorage (onechiporenko)

Oleg Nechiporenko 10 years ago
parent
commit
9b3fff2fc1

+ 2 - 2
ambari-web/app/controllers/installer.js

@@ -426,7 +426,7 @@ App.InstallerController = App.WizardController.extend({
   loadMasterComponentHosts: function () {
   loadMasterComponentHosts: function () {
     var props = this.getDBProperties(['masterComponentHosts', 'hosts']);
     var props = this.getDBProperties(['masterComponentHosts', 'hosts']);
     var masterComponentHosts = props.masterComponentHosts,
     var masterComponentHosts = props.masterComponentHosts,
-      hosts = props.hosts,
+      hosts = props.hosts || {},
       host_names = Em.keys(hosts);
       host_names = Em.keys(hosts);
     if (Em.isNone(masterComponentHosts)) {
     if (Em.isNone(masterComponentHosts)) {
       masterComponentHosts = [];
       masterComponentHosts = [];
@@ -458,7 +458,7 @@ App.InstallerController = App.WizardController.extend({
   loadSlaveComponentHosts: function () {
   loadSlaveComponentHosts: function () {
     var props = this.getDBProperties(['slaveComponentHosts', 'hosts']);
     var props = this.getDBProperties(['slaveComponentHosts', 'hosts']);
     var slaveComponentHosts = props.slaveComponentHosts,
     var slaveComponentHosts = props.slaveComponentHosts,
-      hosts = props.hosts,
+      hosts = props.hosts || {},
       host_names = Em.keys(hosts);
       host_names = Em.keys(hosts);
     if (!Em.isNone(slaveComponentHosts)) {
     if (!Em.isNone(slaveComponentHosts)) {
       slaveComponentHosts.forEach(function (component) {
       slaveComponentHosts.forEach(function (component) {

+ 1 - 1
ambari-web/app/controllers/main/host/add_controller.js

@@ -144,7 +144,7 @@ App.AddHostController = App.WizardController.extend({
    var props = this.getDBProperties(['slaveComponentHosts', 'hosts']);
    var props = this.getDBProperties(['slaveComponentHosts', 'hosts']);
     var slaveComponentHosts = props.slaveComponentHosts || [];
     var slaveComponentHosts = props.slaveComponentHosts || [];
     if (slaveComponentHosts.length) {
     if (slaveComponentHosts.length) {
-      var hosts = props.hosts,
+      var hosts = props.hosts || {},
           host_names = Em.keys(hosts);
           host_names = Em.keys(hosts);
       slaveComponentHosts.forEach(function (component) {
       slaveComponentHosts.forEach(function (component) {
         component.hosts.forEach(function (host) {
         component.hosts.forEach(function (host) {

+ 3 - 2
ambari-web/app/controllers/main/service/add_controller.js

@@ -322,8 +322,9 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
    * Load master component hosts data for using in required step controllers
    * Load master component hosts data for using in required step controllers
    */
    */
   loadSlaveComponentHosts: function () {
   loadSlaveComponentHosts: function () {
-    var slaveComponentHosts = this.getDBProperty('slaveComponentHosts'),
-      hosts = this.getDBProperty('hosts'),
+    var props = this.getDBProperties(['slaveComponentHosts', 'hosts']);
+    var slaveComponentHosts = props.slaveComponentHosts,
+      hosts = props.hosts || {},
       host_names = Em.keys(hosts);
       host_names = Em.keys(hosts);
     if (!Em.isNone(slaveComponentHosts)) {
     if (!Em.isNone(slaveComponentHosts)) {
       slaveComponentHosts.forEach(function (component) {
       slaveComponentHosts.forEach(function (component) {

+ 1 - 1
ambari-web/app/controllers/wizard.js

@@ -679,7 +679,7 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
   loadServiceConfigGroups: function () {
   loadServiceConfigGroups: function () {
     var props = this.getDBProperties(['serviceConfigGroups', 'hosts']);
     var props = this.getDBProperties(['serviceConfigGroups', 'hosts']);
     var serviceConfigGroups = props.serviceConfigGroups,
     var serviceConfigGroups = props.serviceConfigGroups,
-      hosts = props.hosts,
+      hosts = props.hosts || {},
       host_names = Em.keys(hosts);
       host_names = Em.keys(hosts);
     if (Em.isNone(serviceConfigGroups)) {
     if (Em.isNone(serviceConfigGroups)) {
       serviceConfigGroups = [];
       serviceConfigGroups = [];

+ 4 - 4
ambari-web/app/controllers/wizard/step7_controller.js

@@ -565,11 +565,11 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
    * @method resolveStormConfigs
    * @method resolveStormConfigs
    */
    */
   resolveStormConfigs: function (configs) {
   resolveStormConfigs: function (configs) {
-    var props = this.get('wizardController').getDBProperties(['masterComponentHosts', 'hosts']);
-    var dependentConfigs, gangliaServerHost, gangliaHostId,
-      masterComponentHosts = props.masterComponentHosts,
-      hosts = props.hosts;
+    var dependentConfigs, gangliaServerHost, gangliaHostId;
     dependentConfigs = ['nimbus.childopts', 'supervisor.childopts', 'worker.childopts'];
     dependentConfigs = ['nimbus.childopts', 'supervisor.childopts', 'worker.childopts'];
+    var props = this.get('wizardController').getDBProperties(['masterComponentHosts', 'hosts']);
+    var masterComponentHosts = props.masterComponentHosts;
+    var hosts = props.hosts;
     // if Ganglia selected or installed, set ganglia host to configs
     // if Ganglia selected or installed, set ganglia host to configs
     if (this.get('installedServiceNames').contains('STORM') && this.get('installedServiceNames').contains('GANGLIA')) return;
     if (this.get('installedServiceNames').contains('STORM') && this.get('installedServiceNames').contains('GANGLIA')) return;
     if (this.get('allSelectedServiceNames').contains('GANGLIA') || this.get('installedServiceNames').contains('GANGLIA')) {
     if (this.get('allSelectedServiceNames').contains('GANGLIA') || this.get('installedServiceNames').contains('GANGLIA')) {

+ 3 - 5
ambari-web/app/utils/db.js

@@ -145,11 +145,9 @@ App.db.getProperties = function (namespace, listOfProperties) {
     App.db.data[namespace] = {};
     App.db.data[namespace] = {};
   }
   }
   var ret = {};
   var ret = {};
-  for (var k in listOfProperties) {
-    if (listOfProperties.hasOwnProperty(k)) {
-      ret[k] = App.db.data[namespace][k];
-    }
-  }
+  listOfProperties.forEach(function (k) {
+    ret[k] = App.db.data[namespace][k];
+  });
   return ret;
   return ret;
 };
 };