Browse Source

AMBARI-4262. Mirroring: after refreshing popup "Create New Dataset", no target clusters are shown in dropdown (alexantonenko)

Alex Antonenko 11 years ago
parent
commit
5550a6452e

+ 16 - 0
ambari-web/app/controllers/main/mirroring/dataset_controller.js

@@ -112,6 +112,22 @@ App.MainMirroringDataSetController = Ember.Controller.extend({
     }
   ),
 
+  dataLoading: function () {
+    var dfd = $.Deferred();
+    this.connectOutlet('loading');
+    if (App.router.get('clusterController.isLoaded')) {
+      dfd.resolve();
+    } else {
+      var interval = setInterval(function () {
+        if (App.router.get('clusterController.isLoaded')) {
+          dfd.resolve();
+          clearInterval(interval);
+        }
+      }, 50);
+    }
+    return dfd.promise();
+  },
+
   isSubmitted: null,
 
   validate: function () {

+ 40 - 37
ambari-web/app/routes/main.js

@@ -145,48 +145,51 @@ module.exports = Em.Route.extend({
         controller.createNewDataSet();
       },
       enter: function (router) {
+        var self = this;
         var controller = router.get('mainMirroringDataSetController');
-        // if we are coming from closing AddCluster popup
-        if (controller.isReturning) {
-          controller.isReturning = false;
-          return;
-        }
+        controller.dataLoading().done(function () {
+          // if we are coming from closing AddCluster popup
+          if (controller.isReturning) {
+            controller.isReturning = false;
+            return;
+          }
 
-        controller.set('isPopupForEdit', false);
-        this.setupController(controller);
+          controller.set('isPopupForEdit', false);
+          self.setupController(controller);
 
-        var self = this;
-        controller.set('isSubmitted', false);
-        App.ModalPopup.show({
-          classNames: ['sixty-percent-width-modal', 'hideCloseLink'],
-          header: Em.I18n.t('mirroring.dataset.newDataset'),
-          primary: Em.I18n.t('mirroring.dataset.save'),
-          secondary: Em.I18n.t('common.cancel'),
-          onPrimary: function () {
-            controller.set('isSubmitted', true);
-            var isValid = controller.validate();
 
-            if (!isValid) {
-              return;
-            }
-            newDataSet = controller.getNewDataSet();
-            var schedule = newDataSet.get('schedule');
-            var targetCluster = newDataSet.get('targetCluster');
-            var scheduleRecord = App.Dataset.Schedule.createRecord(schedule);
-            var dataSetRecord = App.Dataset.createRecord(newDataSet);
-            scheduleRecord.set('dataset', dataSetRecord);
-            dataSetRecord.set('schedule', scheduleRecord);
+          controller.set('isSubmitted', false);
+          App.ModalPopup.show({
+            classNames: ['sixty-percent-width-modal', 'hideCloseLink'],
+            header: Em.I18n.t('mirroring.dataset.newDataset'),
+            primary: Em.I18n.t('mirroring.dataset.save'),
+            secondary: Em.I18n.t('common.cancel'),
+            onPrimary: function () {
+              controller.set('isSubmitted', true);
+              var isValid = controller.validate();
 
-            this.hide();
-            router.transitionTo('main.mirroring.index');
-          },
-          onSecondary: function () {
-            this.hide();
-            router.transitionTo('main.mirroring.index');
-          },
-          bodyClass: App.MainMirroringDataSetView.extend({
-            controller: router.get('mainMirroringDataSetController')
-          })
+              if (!isValid) {
+                return;
+              }
+              newDataSet = controller.getNewDataSet();
+              var schedule = newDataSet.get('schedule');
+              var targetCluster = newDataSet.get('targetCluster');
+              var scheduleRecord = App.Dataset.Schedule.createRecord(schedule);
+              var dataSetRecord = App.Dataset.createRecord(newDataSet);
+              scheduleRecord.set('dataset', dataSetRecord);
+              dataSetRecord.set('schedule', scheduleRecord);
+
+              this.hide();
+              router.transitionTo('main.mirroring.index');
+            },
+            onSecondary: function () {
+              this.hide();
+              router.transitionTo('main.mirroring.index');
+            },
+            bodyClass: App.MainMirroringDataSetView.extend({
+              controller: router.get('mainMirroringDataSetController')
+            })
+          });
         });
       }
     }),