فهرست منبع

AMBARI-6110. Show dropdown doesn't work on Background ops popup. (akovalenko)

Aleksandr Kovalenko 11 سال پیش
والد
کامیت
6492d0ec45

+ 2 - 46
ambari-web/app/controllers/main/host.js

@@ -21,7 +21,7 @@ var validator = require('utils/validator');
 var componentHelper = require('utils/component');
 var componentHelper = require('utils/component');
 var batchUtils = require('utils/batch_scheduled_requests');
 var batchUtils = require('utils/batch_scheduled_requests');
 
 
-App.MainHostController = Em.ArrayController.extend(App.UserPref, {
+App.MainHostController = Em.ArrayController.extend({
   name: 'mainHostController',
   name: 'mainHostController',
 
 
   dataSource: App.Host.find(),
   dataSource: App.Host.find(),
@@ -137,15 +137,8 @@ App.MainHostController = Em.ArrayController.extend(App.UserPref, {
       getValue: function (controller) {
       getValue: function (controller) {
         var name = controller.get('name');
         var name = controller.get('name');
         var dbValue = App.db.getDisplayLength(name);
         var dbValue = App.db.getDisplayLength(name);
-
         if (Em.isNone(this.get('viewValue'))) {
         if (Em.isNone(this.get('viewValue'))) {
-          if (dbValue) {
-            this.set('viewValue', dbValue);
-          } else {
-            controller.set('makeRequestAsync', false);
-            controller.getUserPref(controller.displayLengthKey());
-            App.db.setDisplayLength(name, this.get('viewValue'));
-          }
+          this.set('viewValue', dbValue || '25'); //25 is default displayLength value for hosts page
         }
         }
         return this.get('viewValue');
         return this.get('viewValue');
       },
       },
@@ -385,43 +378,6 @@ App.MainHostController = Em.ArrayController.extend(App.UserPref, {
     App.db.setFilterConditions(this.get('name'), [filterForComponent]);
     App.db.setFilterConditions(this.get('name'), [filterForComponent]);
   },
   },
 
 
-  /**
-   * Persist-key of current table displayLength property
-   * @param {String} loginName current user login name
-   * @returns {String}
-   */
-  displayLengthKey: function (loginName) {
-    if (App.get('testMode')) {
-      return 'pagination_displayLength';
-    }
-    loginName = loginName ? loginName : App.router.get('loginName');
-    return this.get('name') + '-pagination-displayLength-' + loginName;
-  },
-
-  /**
-   * Set received from server value to <code>displayLengthOnLoad</code>
-   * @param {Number} response
-   * @param {Object} request
-   * @param {Object} data
-   * @returns {*}
-   */
-  getUserPrefSuccessCallback: function (response, request, data) {
-    console.log('Got DisplayLength value from server with key ' + data.key + '. Value is: ' + response);
-    this.get('viewProperties').findProperty('key', 'displayLength').set('viewValue', response);
-  },
-
-  /**
-   * Set default value to <code>displayLengthOnLoad</code> (and send it on server) if value wasn't found on server
-   * @returns {Number}
-   */
-  getUserPrefErrorCallback: function () {
-    // this user is first time login, so set default value - '25'
-    console.log('Persist did NOT find the key');
-    this.get('viewProperties').findProperty('key', 'displayLength').set('viewValue', '25');
-    if (App.get('isAdmin')) {
-      this.postUserPref(this.displayLengthKey(), '25');
-    }
-  },
   /**
   /**
    * On click callback for delete button
    * On click callback for delete button
    */
    */

+ 2 - 3
ambari-web/app/mixins/common/tableServerProvider.js

@@ -59,15 +59,14 @@ App.TableServerProvider = Em.Mixin.create({
    */
    */
   resetFilterByColumns: function (columns) {
   resetFilterByColumns: function (columns) {
     var filterConditions = this.get('filterConditions');
     var filterConditions = this.get('filterConditions');
-
     columns.forEach(function (iColumn) {
     columns.forEach(function (iColumn) {
       var filterCondition = filterConditions.findProperty('iColumn', iColumn);
       var filterCondition = filterConditions.findProperty('iColumn', iColumn);
 
 
       if (filterCondition) {
       if (filterCondition) {
         filterCondition.value = '';
         filterCondition.value = '';
+        this.saveFilterConditions(filterCondition.iColumn, filterCondition.value, filterCondition.type, filterCondition.skipFilter);
       }
       }
-    });
-    this.saveFilterConditions();
+    }, this);
   },
   },
   /**
   /**
    * Apply each filter to each row
    * Apply each filter to each row

+ 2 - 1
ambari-web/app/utils/host_progress_popup.js

@@ -25,6 +25,8 @@ var date = require('utils/date');
  */
  */
 App.HostPopup = Em.Object.create({
 App.HostPopup = Em.Object.create({
 
 
+  name: 'hostPopup',
+
   servicesInfo: null,
   servicesInfo: null,
   hosts: null,
   hosts: null,
   inputData: null,
   inputData: null,
@@ -546,7 +548,6 @@ App.HostPopup = Em.Object.create({
 
 
         pagination: true,
         pagination: true,
         isPaginate: false,
         isPaginate: false,
-        displayLength: "25",
         content: function() {
         content: function() {
           return this.get('hosts') || [];
           return this.get('hosts') || [];
         }.property('hosts.length', 'isHostListHidden'),
         }.property('hosts.length', 'isHostListHidden'),

+ 43 - 6
ambari-web/app/views/common/table_view.js

@@ -46,12 +46,6 @@ App.TableView = Em.View.extend(App.UserPref, {
    */
    */
   startIndexOnLoad: null,
   startIndexOnLoad: null,
 
 
-  /**
-   * Loaded from server persist value
-   * @type {Number}
-   */
-  displayLengthOnLoad: null,
-
   /**
   /**
    * The number of rows to show on every page
    * The number of rows to show on every page
    * The value should be a number converted into string type in order to support select element API
    * The value should be a number converted into string type in order to support select element API
@@ -85,6 +79,8 @@ App.TableView = Em.View.extend(App.UserPref, {
     if (!this.get('displayLength')) {
     if (!this.get('displayLength')) {
       if (App.db.getDisplayLength(name)) {
       if (App.db.getDisplayLength(name)) {
         this.set('displayLength', App.db.getDisplayLength(name));
         this.set('displayLength', App.db.getDisplayLength(name));
+      } else {
+        this.getUserPref(this.displayLengthKey());
       }
       }
     }
     }
 
 
@@ -109,6 +105,47 @@ App.TableView = Em.View.extend(App.UserPref, {
     self.set('tableFilteringComplete', true);
     self.set('tableFilteringComplete', true);
   },
   },
 
 
+  /**
+   * Persist-key of current table displayLength property
+   * @param {String} loginName current user login name
+   * @returns {String}
+   */
+  displayLengthKey: function (loginName) {
+    if (App.get('testMode')) {
+      return 'pagination_displayLength';
+    }
+    loginName = loginName ? loginName : App.router.get('loginName');
+    return this.get('controller.name') + '-pagination-displayLength-' + loginName;
+  },
+
+  /**
+   * Set received from server value to <code>displayLengthOnLoad</code>
+   * @param {Number} response
+   * @param {Object} request
+   * @param {Object} data
+   * @returns {*}
+   */
+  getUserPrefSuccessCallback: function (response, request, data) {
+    console.log('Got DisplayLength value from server with key ' + data.key + '. Value is: ' + response);
+    this.set('displayLength', response);
+    return response;
+  },
+
+  /**
+   * Set default value to <code>displayLength</code> (and send it on server) if value wasn't found on server
+   * @returns {Number}
+   */
+  getUserPrefErrorCallback: function () {
+    // this user is first time login
+    console.log('Persist did NOT find the key');
+    var displayLengthDefault = this.get('defaultDisplayLength');
+    this.set('displayLength', displayLengthDefault);
+    if (App.get('isAdmin')) {
+      this.postUserPref(this.displayLengthKey(), displayLengthDefault);
+    }
+    return displayLengthDefault;
+  },
+
   /**
   /**
    * Do pagination after filtering and sorting
    * Do pagination after filtering and sorting
    * Don't call this method! It's already used where it's need
    * Don't call this method! It's already used where it's need

+ 1 - 12
ambari-web/app/views/main/host.js

@@ -97,7 +97,7 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
    * Restore filter properties in view
    * Restore filter properties in view
    */
    */
   willInsertElement: function () {
   willInsertElement: function () {
-    this.set('displayLength', this.get('controller.viewProperties').findProperty('key', 'displayLength').getValue(this.get('controller')));
+    this._super();
     var filterConditions = App.db.getFilterConditions(this.get('controller.name'));
     var filterConditions = App.db.getFilterConditions(this.get('controller.name'));
     if (filterConditions) {
     if (filterConditions) {
 
 
@@ -131,17 +131,6 @@ App.MainHostView = App.TableView.extend(App.TableServerProvider, {
   filter: function () {
   filter: function () {
     //Since filtering moved to server side, function is empty
     //Since filtering moved to server side, function is empty
   },
   },
-  /**
-   * save display length to local DB and server
-   */
-  saveDisplayLength: function() {
-    App.db.setDisplayLength(this.get('controller.name'), this.get('displayLength'));
-    if (!App.testMode) {
-      if (App.get('isAdmin')) {
-        this.get('controller').postUserPref(this.get('controller').displayLengthKey(), this.get('displayLength'));
-      }
-    }
-  },
 
 
   didInsertElement: function() {
   didInsertElement: function() {
     this.addObserver('controller.clearFilters', this, this.clearFiltersObs);
     this.addObserver('controller.clearFilters', this, this.clearFiltersObs);

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

@@ -45,6 +45,7 @@ App.MainJobsView = App.TableView.extend({
   }.observes("controller.content.length"),
   }.observes("controller.content.length"),
 
 
   willInsertElement: function () {
   willInsertElement: function () {
+    this._super();
     var self = this;
     var self = this;
     var name = this.get('controller.name');
     var name = this.get('controller.name');
     var colPropAssoc = this.get('colPropAssoc');
     var colPropAssoc = this.get('colPropAssoc');