You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by xi...@apache.org on 2013/11/12 00:43:29 UTC

git commit: AMBARI-3746. Some clean up for previous commits. (xiwang)

Updated Branches:
  refs/heads/trunk 52d1873a3 -> 5fe89e76b


AMBARI-3746. Some clean up for previous commits. (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/5fe89e76
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/5fe89e76
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/5fe89e76

Branch: refs/heads/trunk
Commit: 5fe89e76bac17cf6d53fa51d2ea106cfa9fbb54b
Parents: 52d1873
Author: Xi Wang <xi...@apache.org>
Authored: Mon Nov 11 15:41:38 2013 -0800
Committer: Xi Wang <xi...@apache.org>
Committed: Mon Nov 11 15:41:38 2013 -0800

----------------------------------------------------------------------
 ambari-web/app/controllers/application.js       | 75 ++++++++++----------
 .../app/controllers/wizard/step3_controller.js  |  2 +-
 ambari-web/app/messages.js                      |  3 +-
 ambari-web/app/templates/common/modal_popup.hbs |  2 +-
 ambari-web/app/utils/ajax.js                    | 23 +++++-
 5 files changed, 64 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/5fe89e76/ambari-web/app/controllers/application.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/application.js b/ambari-web/app/controllers/application.js
index 1b41900..ac7295f 100644
--- a/ambari-web/app/controllers/application.js
+++ b/ambari-web/app/controllers/application.js
@@ -58,58 +58,59 @@ App.ApplicationController = Em.Controller.extend({
   },
   persistKey: function () {
     var loginName = App.router.get('loginName');
-    return 'admin-settings-show-bg-' + loginName;
+    return 'app-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')
-      }
-    );
+  getUserPref: function(key){
+    App.ajax.send({
+      name: 'settings.get.user_pref',
+      sender: this,
+      data: {
+        key: key
+      },
+      success: 'getUserPrefSuccessCallback',
+      error: 'getUserPrefErrorCallback'
+    });
+  },
+  getUserPrefSuccessCallback: function (response, request, data) {
+    if (response != null) {
+      console.log('Got persist value from server with key ' + data.key + '. Value is: ' + response);
+      this.set('currentPrefObject', response);
+      return response;
+    }
+  },
+  getUserPrefErrorCallback: function (request, ajaxOptions, error) {
+    // this user is first time login
+    if (request.status == 404) {
+      console.log('Persist did NOT find the key');
+      this.set('currentPrefObject', null);
+      return null;
+    }
   },
+
   /**
    * 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);
+    App.ajax.send({
+      'name': 'settings.post.user_pref',
+      'sender': this,
+      'beforeSend': 'postUserPrefBeforeSend',
+      'data': {
+        'keyValuePair': keyValuePair
       }
     });
   },
+  postUserPrefBeforeSend: function(request, ajaxOptions, data){
+    console.log('BeforeSend to persist: persistKeyValues', data.keyValuePair);
+  },
+
   showSettingsPopup: function() {
     var self = this;
     var initValue = this.loadShowBgChecked();

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/5fe89e76/ambari-web/app/controllers/wizard/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js
index 1078d06..bb2b556 100644
--- a/ambari-web/app/controllers/wizard/step3_controller.js
+++ b/ambari-web/app/controllers/wizard/step3_controller.js
@@ -562,7 +562,7 @@ App.WizardStep3Controller = Em.Controller.extend({
     });
     if (hostsContext.length > 0) { // warning exist
       var repoWarning = {
-        name: 'Repository for OS not available',
+        name:  Em.I18n.t('installer.step3.hostWarningsPopup.repositories.name'),
         hosts: hostsContext,
         category: 'repositories',
         onSingleHost: false

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/5fe89e76/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index b8de0ae..da1a4d3 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -348,7 +348,7 @@ Em.I18n.translations = {
   'installer.step3.hosts.remove.popup.body':'Are you sure you want to remove the selected host(s)?',
   'installer.step3.hostInformation.popup.header':'Error in retrieving host Information',
   'installer.step3.hostInformation.popup.body' : 'All bootstrapped hosts registered but unable to retrieve cpu and memory related information',
-  'installer.step3.hostOsTypeCheck.popup.body' : 'Host registered successfully, but the host operating system type NOT match the selected group in step 1:Advanced Repository Option.<br> You can go back to step 1 OR remove this host. <br>' +
+  'installer.step3.hostOsTypeCheck.popup.body' : 'Host registered successfully, but the host operating system type NOT match the selected group in "Select Stack" step: Advanced Repository Option. You can go back to "Select Stack" step OR remove this host.' +
     'The host type is {0}, but you selected group {1} in step 1.',
   'installer.step3.hostWarningsPopup.report':'Show Report',
   'installer.step3.hostWarningsPopup.report.header': '<p style="font-family: monospace">######################################<br># Host Checks Report<br>#<br># Generated: ',
@@ -366,6 +366,7 @@ Em.I18n.translations = {
     '<div class="alert alert-warn"><b>Note</b>: To clean up in interactive mode, remove <b>--silent</b> option. To clean up all resources, including <i>users</i>, remove <b>--skip=users</b> option. Use <b>--help</b> for a list of available options.</div>',
   'installer.step3.hostWarningsPopup.summary':'{0} on {1}',
   'installer.step3.hostWarningsPopup.firewall':'Firewall Issues',
+  'installer.step3.hostWarningsPopup.repositories.name':'Repository for OS not available',
   'installer.step3.hostWarningsPopup.repositories':'Repositories Issues',
   'installer.step3.hostWarningsPopup.repositories.context':'Host ({0}) has a {1} OS type, But the repositories chosen in "Select Stack" step was {2}.',
   'installer.step3.hostWarningsPopup.repositories.message':'The following registered hosts have different Operating System types from the local repositories chosen in "Select Stack" step. You can go back to "Select Stack" step to select another os group OR remove related host.',

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/5fe89e76/ambari-web/app/templates/common/modal_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/modal_popup.hbs b/ambari-web/app/templates/common/modal_popup.hbs
index a846231..1d7a0f8 100644
--- a/ambari-web/app/templates/common/modal_popup.hbs
+++ b/ambari-web/app/templates/common/modal_popup.hbs
@@ -49,7 +49,7 @@
       <div class="modal-footer">
         {{#if view.hasFooterCheckbox}}
           <label id="footer-checkbox">{{view Ember.Checkbox classNames="checkbox" checkedBinding="view.isNotShowBgChecked"}} &nbsp;
-          {{t admin.userSettings.notShowBgOperations}}</label>
+          {{t app.settings.notShowBgOperations}}</label>
         {{/if}}
         {{#if view.secondary}}
           <a class="btn" {{action onSecondary target="view"}}>{{view.secondary}}</a>

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/5fe89e76/ambari-web/app/utils/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax.js b/ambari-web/app/utils/ajax.js
index 27655ce..a06b7c3 100644
--- a/ambari-web/app/utils/ajax.js
+++ b/ambari-web/app/utils/ajax.js
@@ -556,7 +556,7 @@ var urls = {
     'type': 'GET',
     'format': function (data, opt) {
       return {
-        async: false
+        data: data.data
       };
     }
   },
@@ -856,6 +856,27 @@ var urls = {
     'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/*',
     'mock': '/data/wizard/{mock}'
   },
+  'settings.get.user_pref': {
+    'real': '/persist/{key}',
+    'mock': '',
+    'type': 'GET',
+    'format': function (data, opt) {
+      return {
+        async: false
+      };
+    }
+  },
+  'settings.post.user_pref': {
+    'real': '/persist',
+    'mock': '',
+    'type': 'POST',
+    'format': function (data) {
+      return {
+        async: false,
+        data: JSON.stringify(data.keyValuePair)
+      }
+    }
+  },
   'wizard.advanced_repositories.valid_url': {
     'real': '/stacks2/{stackName}/versions/{stackVersion}/operatingSystems/{osType}/repositories/{nameVersionCombo}',
     'mock': '',