incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xiw...@apache.org
Subject git commit: AMBARI-3054. User Preference to show 'Background Operations'. (xiwang)
Date Thu, 31 Oct 2013 23:36:52 GMT
Updated Branches:
  refs/heads/trunk 93774ef86 -> 895fd88ec


AMBARI-3054. User Preference to show 'Background Operations'. (xiwang)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/895fd88e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/895fd88e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/895fd88e

Branch: refs/heads/trunk
Commit: 895fd88eca3564ac8417525c143d1c60442310c3
Parents: 93774ef
Author: Xi Wang <xiwang@apache.org>
Authored: Thu Oct 31 16:25:40 2013 -0700
Committer: Xi Wang <xiwang@apache.org>
Committed: Thu Oct 31 16:36:35 2013 -0700

----------------------------------------------------------------------
 ambari-web/app/controllers.js                   |  1 +
 .../global/background_operations_controller.js  |  4 +-
 .../app/controllers/main/admin/user_settings.js | 95 ++++++++++++++++++++
 ambari-web/app/controllers/main/host/details.js | 29 ++++--
 ambari-web/app/controllers/main/service.js      |  4 +-
 ambari-web/app/controllers/main/service/item.js | 16 +++-
 ambari-web/app/messages.js                      |  4 +
 ambari-web/app/routes/main.js                   |  8 +-
 ambari-web/app/styles/application.less          | 15 ++++
 .../app/templates/main/admin/userSettings.hbs   | 29 ++++++
 ambari-web/app/utils/host_progress_popup.js     | 11 +++
 ambari-web/app/views.js                         |  1 +
 ambari-web/app/views/common/modal_popup.js      |  2 +
 ambari-web/app/views/main/admin.js              |  5 ++
 .../app/views/main/admin/user_settings.js       | 34 +++++++
 15 files changed, 243 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/controllers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers.js b/ambari-web/app/controllers.js
index 80bfac9..78a5f45 100644
--- a/ambari-web/app/controllers.js
+++ b/ambari-web/app/controllers.js
@@ -44,6 +44,7 @@ require('controllers/main/admin/rollbackHA/step2_controller');
 require('controllers/main/admin/rollbackHA/step3_controller');
 require('controllers/main/admin/rollbackHA/rollback_wizard_controller');
 require('controllers/main/admin/cluster');
+require('controllers/main/admin/user_settings');
 require('controllers/main/admin/stack_upgrade_controller');
 require('controllers/main/admin/user');
 require('controllers/main/admin/misc_controller');

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/controllers/global/background_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js
index 323834f..3ad6a25 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/ambari-web/app/controllers/global/background_operations_controller.js
@@ -224,7 +224,9 @@ App.BackgroundOperationsController = Em.Controller.extend({
    */
   showPopup: function(){
     App.updater.immediateRun('requestMostRecent');
-    if(this.get('popupView') && App.HostPopup.get('isBackgroundOperations')){
+
+    if(this.get('popupView') && App.HostPopup.get('isBackgroundOperations') &&
App.HostPopup.get('showServices')){
+      this.set ('popupView.isNotShowBgChecked', !App.router.get('mainAdminUserSettingsController').loadShowBgChecked());
       this.set('popupView.isOpen', true);
       $(this.get('popupView.element')).appendTo('#wrapper');
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/controllers/main/admin/user_settings.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/user_settings.js b/ambari-web/app/controllers/main/admin/user_settings.js
new file mode 100644
index 0000000..19b1a21
--- /dev/null
+++ b/ambari-web/app/controllers/main/admin/user_settings.js
@@ -0,0 +1,95 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainAdminUserSettingsController = Em.Controller.extend({
+  name:'mainAdminUserSettingsController',
+  loadShowBgChecked: function () {
+    if (App.testMode) {
+      return true;
+    } else {
+      this.getUserPref(this.persistKey());
+      var currentPrefObject = this.get('currentPrefObject');
+      if (currentPrefObject != null) {
+        return currentPrefObject;
+      } else {
+        // post persist
+        this.postUserPref(this.persistKey(), true);
+        return true;
+      }
+    }
+  },
+
+  persistKey: function () {
+    var loginName = App.router.get('loginName');
+    return 'admin-settings-show-bg-' + loginName;
+  },
+  currentPrefObject: null,
+
+  /**
+   * get persist value from server with persistKey
+   */
+  getUserPref: function (key) {
+    var self = this;
+    var url = App.apiPrefix + '/persist/' + key;
+    jQuery.ajax(
+      {
+        url: url,
+        context: this,
+        async: false,
+        success: function (response) {
+          if (response) {
+            var value = jQuery.parseJSON(response);
+            console.log('Got persist value from server with key: ' + key + '. Value is: '
+ response);
+            self.set('currentPrefObject', value);
+            return value;
+          }
+        },
+        error: function (xhr) {
+          // this user is first time login
+          if (xhr.status == 404) {
+            console.log('Persist did NOT find the key: '+ key);
+            self.set('currentPrefObject', null);
+            return null;
+          }
+        },
+        statusCode: require('data/statusCodes')
+      }
+    );
+  },
+  /**
+   * post persist key/value to server, value is object
+   */
+  postUserPref: function (key, value) {
+    var url = App.apiPrefix + '/persist/';
+    var keyValuePair = {};
+    keyValuePair[key] = JSON.stringify(value);
+
+    jQuery.ajax({
+      async: false,
+      context: this,
+      type: "POST",
+      url: url,
+      data: JSON.stringify(keyValuePair),
+      beforeSend: function () {
+        console.log('BeforeSend to persist: persistKeyValues', keyValuePair);
+      }
+    });
+  }
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index 7cdb0c4..596eaba 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -239,7 +239,7 @@ App.MainHostDetailsController = Em.Controller.extend({
         deleted = {xhr: xhr, url: url, method: 'DELETE'};
       },
       statusCode: require('data/statusCodes')
-    });
+      });
     return deleted;
   },
 
@@ -278,7 +278,9 @@ App.MainHostDetailsController = Em.Controller.extend({
               App.router.get('clusterController').loadUpdatedStatusDelayed(500);
             }
 
-            App.router.get('backgroundOperationsController').showPopup();
+            if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+              App.router.get('backgroundOperationsController').showPopup();
+            }
 
           });
     });
@@ -349,10 +351,14 @@ App.MainHostDetailsController = Em.Controller.extend({
             component.set('workStatus', App.HostComponentStatus.stopped);
           },App.testModeDelayForActions);
         }
+
       } else {
         App.router.get('clusterController').loadUpdatedStatusDelayed(500);
       }
-      App.router.get('backgroundOperationsController').showPopup();
+
+      if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
     });
   },
 
@@ -465,8 +471,9 @@ App.MainHostDetailsController = Em.Controller.extend({
               App.router.get('clusterController').loadUpdatedStatusDelayed(500);
             }
 
-            App.router.get('backgroundOperationsController').showPopup();
-
+            if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+              App.router.get('backgroundOperationsController').showPopup();
+            }
           });
       });
   },
@@ -520,7 +527,9 @@ App.MainHostDetailsController = Em.Controller.extend({
               App.router.get('clusterController').loadUpdatedStatusDelayed(500);
             }
 
-            App.router.get('backgroundOperationsController').showPopup();
+            if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+              App.router.get('backgroundOperationsController').showPopup();
+            }
 
           });
       }
@@ -548,7 +557,9 @@ App.MainHostDetailsController = Em.Controller.extend({
         }
         self.doDatanodeDecommission(decommissionHostNames, true);
       }
-      App.router.get('backgroundOperationsController').showPopup();
+      if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
     });
   },
 
@@ -650,7 +661,9 @@ App.MainHostDetailsController = Em.Controller.extend({
         decommissionHostNames.splice(index, 1);
         self.doDatanodeDecommission(decommissionHostNames, false);
       }
-      App.router.get('backgroundOperationsController').showPopup();
+      if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
     });
   },
   

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/controllers/main/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service.js b/ambari-web/app/controllers/main/service.js
index 55e5fa8..979e4fb 100644
--- a/ambari-web/app/controllers/main/service.js
+++ b/ambari-web/app/controllers/main/service.js
@@ -109,7 +109,9 @@ App.MainServiceController = Em.ArrayController.extend({
     var requestId = data.Requests.id;
     console.log('requestId is: ' + requestId);
 
-    App.router.get('backgroundOperationsController').showPopup();
+    if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+      App.router.get('backgroundOperationsController').showPopup();
+    }
   },
   allServicesCallErrorCallback: function() {
     console.log("ERROR");

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index 898d4ef..8910f65 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -76,7 +76,9 @@ App.MainServiceItemController = Em.Controller.extend({
     else {
       App.router.get('clusterController').loadUpdatedStatusDelayed(500);// @todo check working
without param 500
     }
-    App.router.get('backgroundOperationsController').showPopup();
+    if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+      App.router.get('backgroundOperationsController').showPopup();
+    }
   },
   /**
    * Confirmation popup for start/stop services
@@ -140,7 +142,9 @@ App.MainServiceItemController = Em.Controller.extend({
     var self = this;
     App.showConfirmationPopup(function() {
       self.content.set('runRebalancer', true);
-      App.router.get('backgroundOperationsController').showPopup();
+      if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
     });
   },
 
@@ -152,7 +156,9 @@ App.MainServiceItemController = Em.Controller.extend({
     var self = this;
     App.showConfirmationPopup(function() {
       self.content.set('runCompaction', true);
-      App.router.get('backgroundOperationsController').showPopup();
+      if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
     });
   },
 
@@ -186,7 +192,9 @@ App.MainServiceItemController = Em.Controller.extend({
 
   runSmokeTestSuccessCallBack: function(data) {
     if (data.Requests.id) {
-      App.router.get('backgroundOperationsController').showPopup();
+      if (App.router.get('mainAdminUserSettingsController').loadShowBgChecked()) {
+        App.router.get('backgroundOperationsController').showPopup();
+      }
     }
     else {
       console.warn('error during runSmokeTestSuccessCallBack');

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 897f991..eb0e755 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -133,6 +133,7 @@ Em.I18n.translations = {
   'common.stats':'Stats',
   'common.abort': 'Abort',
   'common.misc': 'Misc',
+  'common.userSettings': 'User Settings',
   'common.operations': 'Operations',
   'common.reinstall': 'Re-Install',
   'common.errorPopup.header': 'An error has been encountered',
@@ -872,6 +873,9 @@ Em.I18n.translations = {
   'admin.cluster.upgradeAvailable':'Upgrade available',
   'admin.cluster.upgradeUnavailable':'Upgrade unavailable',
 
+  'admin.userSettings.header': 'Customize User Settings',
+  'admin.userSettings.showBgOperations': 'Show background operations dialog when an operation
is started',
+  'admin.userSettings.notShowBgOperations': 'Do not show this dialog again when starting
a background operation',
   'admin.misc.header': 'Service Users and Groups',
   'admin.misc.nothingToShow': 'No user accounts to display',
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index f0e1670..ec2dd9a 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -793,7 +793,13 @@ module.exports = Em.Route.extend({
         router.get('mainAdminController').connectOutlet('mainAdminAdvanced');
       }
     }),
-
+    adminUserSettings: Em.Route.extend({
+      route: '/userSettings',
+      connectOutlets: function (router) {
+        router.set('mainAdminController.category', "userSettings");
+        router.get('mainAdminController').connectOutlet('mainAdminUserSettings');
+      }
+    }),
     adminMisc: Em.Route.extend({
       route: '/misc',
       connectOutlets: function (router) {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 6568d9b..49c985e 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -1053,6 +1053,16 @@ a:focus {
     overflow: auto;
     width: 100%;
   }
+  .modal-footer {
+    #footer-checkbox {
+      text-align: left;
+      padding-top: 3px;
+      margin-left: 22px;
+      .checkbox {
+        margin: 0px;
+      }
+    }
+  }
 
   .modal-body {
 
@@ -3080,6 +3090,11 @@ table.graphs {
   }
 }
 
+.admin-user-settings {
+  .checkbox {
+    margin: 0px;
+  }
+}
 /*End Admin*/
 
 /*assign masters*/

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/templates/main/admin/userSettings.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/userSettings.hbs b/ambari-web/app/templates/main/admin/userSettings.hbs
new file mode 100644
index 0000000..9d87b9b
--- /dev/null
+++ b/ambari-web/app/templates/main/admin/userSettings.hbs
@@ -0,0 +1,29 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+<div class="admin-user-settings">
+  <div class="header">
+    <strong>{{t admin.userSettings.header}}</strong>
+  </div>
+  <div>
+    <label>
+      {{view Ember.Checkbox checkedBinding="view.isShowBgChecked" classNames="checkbox"}}
+      {{t admin.userSettings.showBgOperations}}
+    </label>
+  </div>
+</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/utils/host_progress_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js
index 9b3006f..5930ed3 100644
--- a/ambari-web/app/utils/host_progress_popup.js
+++ b/ambari-web/app/utils/host_progress_popup.js
@@ -479,6 +479,17 @@ App.HostPopup = Em.Object.create({
         template: Ember.Handlebars.compile('{{popupHeaderName}}')
       }),
       classNames: ['sixty-percent-width-modal'],
+      // for the checkbox: do not show this dialog again
+      hasFooterCheckbox: true,
+      isNotShowBgChecked : null,
+      updateNotShowBgChecked: function () {
+        var curVal = !this.get('isNotShowBgChecked');
+        var key = App.router.get('mainAdminUserSettingsController').persistKey();
+        if (!App.testMode) {
+          App.router.get('mainAdminUserSettingsController').postUserPref(key, curVal);
+        }
+      }.observes('isNotShowBgChecked'),
+
       autoHeight: false,
       closeModelPopup: function () {
         this.set('isOpen', false);

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index c7980cb..16be05b 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -72,6 +72,7 @@ require('views/main/admin/rollbackHA/step3_view');
 require('views/main/admin/rollbackHA/rollback_wizard_view');
 require('views/main/admin/cluster');
 require('views/main/admin/misc_view');
+require('views/main/admin/user_settings');
 require('views/main/admin/stack_upgrade');
 require('views/main/admin/advanced');
 require('views/main/admin/advanced/password');

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/views/common/modal_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js
index ecb8b5e..f231965 100644
--- a/ambari-web/app/views/common/modal_popup.js
+++ b/ambari-web/app/views/common/modal_popup.js
@@ -39,6 +39,8 @@ App.ModalPopup = Ember.View.extend({
     '{{#if footerClass}}{{view footerClass}}',
     '{{else}}',
     '<div class="modal-footer">',
+    '{{#if view.hasFooterCheckbox}} <label id="footer-checkbox" class="span8">  {{view
Ember.Checkbox classNames="checkbox" checkedBinding="view.isNotShowBgChecked"}} &nbsp;'
+
+      '{{t admin.userSettings.notShowBgOperations}}</label> {{/if}}',
     '{{#if view.secondary}}<a class="btn" {{action onSecondary target="view"}}>{{view.secondary}}</a>{{/if}}',
     '{{#if view.primary}}<a {{bindAttr class="view.enablePrimary::disabled :btn :btn-success"}}
{{action onPrimary target="view"}}>{{view.primary}}</a>{{/if}}',
     '</div>',

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/views/main/admin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin.js b/ambari-web/app/views/main/admin.js
index 0d6ec6c..33479a5 100644
--- a/ambari-web/app/views/main/admin.js
+++ b/ambari-web/app/views/main/admin.js
@@ -47,6 +47,11 @@ App.MainAdminView = Em.View.extend({
       label: Em.I18n.t('common.cluster')
     });
     items.push({
+      name: 'userSettings',
+      url: 'adminUserSettings',
+      label: Em.I18n.t('common.userSettings')
+    });
+    items.push({
       name: 'misc',
       url: 'adminMisc',
       label: Em.I18n.t('common.misc')

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/895fd88e/ambari-web/app/views/main/admin/user_settings.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/user_settings.js b/ambari-web/app/views/main/admin/user_settings.js
new file mode 100644
index 0000000..a4852b2
--- /dev/null
+++ b/ambari-web/app/views/main/admin/user_settings.js
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+App.MainAdminUserSettingsView = Em.View.extend({
+  templateName: require('templates/main/admin/userSettings'),
+  didInsertElement: function() {
+    this.set ('isShowBgChecked', this.get('controller').loadShowBgChecked());
+  },
+  isShowBgChecked: null,
+  updateShowBgchecked: function () {
+    var curVal = this.get('isShowBgChecked');
+    var key = this.get('controller').persistKey();
+    if (!App.testMode) {
+      this.get('controller').postUserPref(key, curVal);
+    }
+  }.observes('isShowBgChecked')
+});
\ No newline at end of file


Mime
View raw message