Browse Source

AMBARI-4886. Mirroring: mirroring data should be updated periodically. (akovalenko)

Aleksandr Kovalenko 11 years ago
parent
commit
3c2ec028d8

+ 1 - 2
ambari-web/app/controllers/main/mirroring/jobs_controller.js

@@ -27,9 +27,8 @@ App.MainDatasetJobsController = Em.Controller.extend({
 
 
   jobs: function () {
   jobs: function () {
     var datasetName = this.get('content.name');
     var datasetName = this.get('content.name');
-    var mainMirroringController = App.router.get('mainMirroringController');
     return (this.get('isLoaded') && datasetName) ?
     return (this.get('isLoaded') && datasetName) ?
-        mainMirroringController.get('datasets').findProperty('name', datasetName).get('datasetJobs') : [];
+        App.Dataset.find().findProperty('name', datasetName).get('datasetJobs') : [];
   }.property('content', 'isLoaded'),
   }.property('content', 'isLoaded'),
 
 
   actionDesc: function () {
   actionDesc: function () {

+ 2 - 6
ambari-web/app/controllers/main/mirroring_controller.js

@@ -33,8 +33,6 @@ App.MainMirroringController = Em.ArrayController.extend({
   // counter for target cluster load queries
   // counter for target cluster load queries
   clusterCount: 0,
   clusterCount: 0,
 
 
-  datasets: [],
-
   selectedDataset: null,
   selectedDataset: null,
 
 
   isDatasetsLoaded: false,
   isDatasetsLoaded: false,
@@ -45,14 +43,13 @@ App.MainMirroringController = Em.ArrayController.extend({
     return this.get('isDatasetsLoaded') && this.get('isTargetClustersLoaded');
     return this.get('isDatasetsLoaded') && this.get('isTargetClustersLoaded');
   }.property('isDatasetsLoaded', 'isTargetClustersLoaded'),
   }.property('isDatasetsLoaded', 'isTargetClustersLoaded'),
 
 
+  datasets: App.Dataset.find(),
+
   loadData: function () {
   loadData: function () {
-    this.set('isDatasetsLoaded', false);
-    this.set('isTargetClustersLoaded', false);
     this.get('datasetsData').clear();
     this.get('datasetsData').clear();
     this.set('clustersData', {});
     this.set('clustersData', {});
     this.set('datasetCount', 0);
     this.set('datasetCount', 0);
     this.set('clusterCount', 0);
     this.set('clusterCount', 0);
-    this.set('datasets', []);
     this.loadDatasets();
     this.loadDatasets();
     this.loadClusters();
     this.loadClusters();
   },
   },
@@ -169,7 +166,6 @@ App.MainMirroringController = Em.ArrayController.extend({
         if (a.get('name') > b.get('name'))  return 1;
         if (a.get('name') > b.get('name'))  return 1;
         return 0;
         return 0;
       });
       });
-      this.set('datasets', sortedDatasets);
       this.set('isDatasetsLoaded', true);
       this.set('isDatasetsLoaded', true);
       var selectedDataset = this.get('selectedDataset');
       var selectedDataset = this.get('selectedDataset');
       if (!selectedDataset) {
       if (!selectedDataset) {

+ 14 - 1
ambari-web/app/views/main/mirroring_view.js

@@ -24,6 +24,19 @@ App.MainMirroringView = Em.View.extend({
 
 
   didInsertElement: function () {
   didInsertElement: function () {
     var controller = this.get('controller');
     var controller = this.get('controller');
-    controller.loadData();
+    controller.set('isDatasetsLoaded', false);
+    controller.set('isTargetClustersLoaded', false);
+    this.loadDataPeriodically();
+  },
+
+  // updata datasets data, when Mirroring page is opened
+  loadDataPeriodically: function () {
+    if (this.get('isVisible')) {
+      var self = this;
+      this.get('controller').loadData();
+      setTimeout(function () {
+        self.loadDataPeriodically();
+      }, App.contentUpdateInterval);
+    }
   }
   }
 });
 });