ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [16/50] [abbrv] git commit: AMBARI-6910 IE doesn't handle download configs errors
Date Wed, 20 Aug 2014 15:30:17 GMT
AMBARI-6910 IE doesn't handle download configs errors


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

Branch: refs/heads/branch-alerts-dev
Commit: 6cfdd1cfdc43e9b1c4a69106693ebd5b0e31aaac
Parents: 388c52e
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Tue Aug 19 14:44:03 2014 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Tue Aug 19 14:44:03 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/messages.js         |  4 ++-
 ambari-web/app/utils/components.js | 55 +++++++++++++++++++++------------
 2 files changed, 39 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfdd1cf/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 5bd9a87..0a9fafd 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1187,7 +1187,9 @@ Em.I18n.translations = {
   'services.service.actions.downloadClientConfigs':'Download Client Configs',
   'services.service.actions.downloadClientConfigs.fail.noConfigFile':'No configuration files
defined for the component',
   'services.service.actions.downloadClientConfigs.fail.popup.header':'{0} Configs',
-  'services.service.actions.downloadClientConfigs.fail.popup.body':'Generation of {0} configurations
file has failed with {1} error: <br /><pre><span class="text-error">{2}</span></pre>Do
you want to try again?',
+  'services.service.actions.downloadClientConfigs.fail.popup.body.noErrorMessage':'Generation
of {0} configurations file has failed. ',
+  'services.service.actions.downloadClientConfigs.fail.popup.body.errorMessage':'Generation
of {0} configurations file has failed with {1} error: <br /><pre><span class="text-error">{2}</span></pre>',
+  'services.service.actions.downloadClientConfigs.fail.popup.body.question':'Do you want
to try again?',
   'services.service.actions.run.rebalancer':'Run Rebalancer',
   'services.service.actions.run.rebalanceHdfsNodes':'Rebalance HDFS',
   'services.service.actions.run.rebalanceHdfsNodes.title':'HDFS Rebalance',

http://git-wip-us.apache.org/repos/asf/ambari/blob/6cfdd1cf/ambari-web/app/utils/components.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/components.js b/ambari-web/app/utils/components.js
index 3fb8d87..e72cc04 100644
--- a/ambari-web/app/utils/components.js
+++ b/ambari-web/app/utils/components.js
@@ -95,28 +95,45 @@ module.exports = {
     var url = App.get('apiPrefix') + '/clusters/' + App.router.getClusterName() + '/' +
       (isForHost ? 'hosts/' + data.hostName + '/host_components/' : 'services/' + data.serviceName
+ '/components/') +
       data.componentName + '?format=client_config_tar';
-    var self = this;
-    $.fileDownload(url).fail(function (error) {
-      var errorObj = JSON.parse($(error).text());
-      var isNoConfigs = errorObj.message.contains(Em.I18n.t('services.service.actions.downloadClientConfigs.fail.noConfigFile'));
-      var errorMessage = isNoConfigs ? Em.I18n.t('services.service.actions.downloadClientConfigs.fail.noConfigFile')
:
-        Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body').format(data.displayName,
errorObj.status, errorObj.message);
-      App.ModalPopup.show({
-        header: Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.header').format(data.displayName),
-        bodyClass: Ember.View.extend({
-          template: Em.Handlebars.compile(errorMessage)
-        }),
-        secondary: isNoConfigs ? false : Em.I18n.t('common.cancel'),
-        onPrimary: function () {
-          this.hide();
-          if (!isNoConfigs) {
-            self.downloadClientConfigs({
-              context: Em.Object.create(data)
-            })
+    try {
+      var self = this;
+      $.fileDownload(url).fail(function (error) {
+        var errorMessage = '';
+        var isNoConfigs = false;
+        if (error && $(error).text()) {
+          var errorObj = JSON.parse($(error).text());
+          if (errorObj && errorObj.message && errorObj.status) {
+            isNoConfigs = errorObj.message.indexOf(Em.I18n.t('services.service.actions.downloadClientConfigs.fail.noConfigFile'))
!== -1;
+            errorMessage += isNoConfigs ? Em.I18n.t('services.service.actions.downloadClientConfigs.fail.noConfigFile')
:
+              Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.errorMessage').format(data.displayName,
errorObj.status, errorObj.message);
+          } else {
+            errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.noErrorMessage').format(data.displayName);
           }
+          errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.question');
+        } else {
+          errorMessage += Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.noErrorMessage').format(data.displayName)
+
+            Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body.question');
         }
+        App.ModalPopup.show({
+          header: Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.header').format(data.displayName),
+          bodyClass: Ember.View.extend({
+            template: Em.Handlebars.compile(errorMessage)
+          }),
+          secondary: isNoConfigs ? false : Em.I18n.t('common.cancel'),
+          onPrimary: function () {
+            this.hide();
+            if (!isNoConfigs) {
+              self.downloadClientConfigs({
+                context: Em.Object.create(data)
+              })
+            }
+          }
+        });
       });
-    });
+    } catch (err) {
+      var newWindow = window.open(url);
+      newWindow.focus();
+    }
   }
 
 };
\ No newline at end of file


Mime
View raw message