Selaa lähdekoodia

AMBARI-5102. Mirroring: instance table should be shown most recent first. (akovalenko)

Aleksandr Kovalenko 11 vuotta sitten
vanhempi
commit
d3e0602c49

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

@@ -199,7 +199,7 @@ App.MainMirroringEditDataSetController = Ember.Controller.extend({
 
   // Convert date to TZ format
   toTZFormat: function (date) {
-    return date.getFullYear() + '-' + this.addZero(date.getMonth() + 1) + '-' + this.addZero(date.getDate()) + 'T' + this.addZero(date.getHours()) + ':' + this.addZero(date.getMinutes()) + 'Z';
+    return date.toISOString().replace(/\:\d{2}\.\d{3}/,'');
   },
 
   // Converts hours value from 24-hours format to AM/PM format

+ 21 - 19
ambari-web/app/controllers/main/mirroring_controller.js

@@ -139,18 +139,23 @@ App.MainMirroringController = Em.ArrayController.extend({
           instances: []
         })
     );
-    App.ajax.send({
-      name: 'mirroring.dataset.get_all_instances',
-      sender: this,
-      data: {
-        dataset: parsedData.feed['@attributes'].name,
-        start: sourceCluster.validity['@attributes'].start,
-        end: sourceCluster.validity['@attributes'].end,
-        falconServer: App.get('falconServerURL')
-      },
-      success: 'onLoadDatasetInstancesSuccess',
-      error: 'onLoadDatasetsInstancesError'
-    });
+    var currentDate = new Date(App.dateTime());
+    if (currentDate > new Date(sourceCluster.validity['@attributes'].start)) {
+      App.ajax.send({
+        name: 'mirroring.dataset.get_all_instances',
+        sender: this,
+        data: {
+          dataset: parsedData.feed['@attributes'].name,
+          start: sourceCluster.validity['@attributes'].start,
+          end: App.router.get('mainMirroringEditDataSetController').toTZFormat(currentDate),
+          falconServer: App.get('falconServerURL')
+        },
+        success: 'onLoadDatasetInstancesSuccess',
+        error: 'onLoadDatasetsInstancesError'
+      });
+    } else {
+      this.saveDataset();
+    }
   },
 
   onLoadDatasetDefinitionError: function () {
@@ -173,8 +178,6 @@ App.MainMirroringController = Em.ArrayController.extend({
         });
       }, this);
       datasetsData.findProperty('name', opts.dataset).set('instances', datasetJobs);
-    } else {
-      datasetsData.findProperty('name', opts.dataset).set('instances', []);
     }
     this.saveDataset();
   },
@@ -194,8 +197,6 @@ App.MainMirroringController = Em.ArrayController.extend({
 
   onLoadDatasetsInstancesError: function () {
     console.error('Failed to load dataset instances.');
-    var datasetName = arguments[4].dataset;
-    this.get('datasetsData').findProperty('name', datasetName).set('instances', []);
     this.saveDataset();
   },
 
@@ -235,14 +236,15 @@ App.MainMirroringController = Em.ArrayController.extend({
       }, this);
     } else {
       var defaultFS = this.loadDefaultFS();
+      var clusterName = App.get('clusterName');
       var sourceCluster = Ember.Object.create({
-        name: App.get('clusterName'),
+        name: clusterName,
         execute: App.HostComponent.find().findProperty('componentName', 'RESOURCEMANAGER').get('host.hostName') + ':8050',
         readonly: 'hftp://' + App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('host.hostName') + ':50070',
         workflow: 'http://' + App.HostComponent.find().findProperty('componentName', 'OOZIE_SERVER').get('host.hostName') + ':11000/oozie',
         write: defaultFS,
-        staging: '/apps/falcon/sandbox/staging',
-        working: '/apps/falcon/sandbox/working',
+        staging: '/apps/falcon/' + clusterName + '/staging',
+        working: '/apps/falcon/' + clusterName + '/working',
         temp: '/tmp'
       });
       var sourceClusterData = App.router.get('mainMirroringManageClustersController').formatClusterXML(sourceCluster);

+ 17 - 0
ambari-web/app/views/common/sort_view.js

@@ -98,6 +98,23 @@ var wrapperView = Em.View.extend({
       this.set('content', content);
     }
   },
+
+  isSorting: false,
+
+  onContentChange: function () {
+    if (!this.get('isSorting') && this.get('content.length')) {
+      this.get('childViews').forEach(function (view) {
+        if (view.status !== 'sorting') {
+          var status = view.get('status');
+          this.set('isSorting', true);
+          this.sort(view, status == 'sorting_desc');
+          this.set('isSorting', false);
+          view.set('status', status);
+        }
+      }, this);
+    }
+  }.observes('content.length'),
+
   /**
    * reset all sorts fields
    */

+ 1 - 1
ambari-web/app/views/common/table_view.js

@@ -353,7 +353,7 @@ App.TableView = Em.View.extend(App.UserPref, {
     } else {
       this.set('filteredContent', content.toArray());
     }
-  }.observes('content'),
+  }.observes('content.length'),
 
   /**
    * Does any filter is used on the page

+ 11 - 1
ambari-web/app/views/main/mirroring/jobs_view.js

@@ -37,7 +37,17 @@ App.MainDatasetJobsView = App.TableView.extend({
     return this.get('controller.content');
   }.property('controller.content'),
 
-  sortView: sort.wrapperView,
+  sortView: sort.wrapperView.extend({
+    loadSortStatuses: function(){
+      this._super();
+      var statuses = App.db.getSortingStatuses(this.get('controller.name'));
+      if (!statuses || statuses.everyProperty('status', 'sorting')) {
+        var sorting = this.get('childViews').findProperty('name', 'startDate');
+        this.sort(sorting, true);
+        sorting.set('status', 'sorting_desc');
+      }
+    }.observes('parentView.filteringComplete')
+  }),
   idSort: sort.fieldView.extend({
     column: 1,
     name: 'name',