Browse Source

AMBARI-6792. FE work for download client configurations. additional (alexantonenko)

Alex Antonenko 10 years ago
parent
commit
23c73e67a9

+ 1 - 1
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ClientConfigResourceProvider.java

@@ -143,7 +143,7 @@ public class ClientConfigResourceProvider extends AbstractControllerResourceProv
       List<ClientConfigFileDefinition> clientConfigFiles = componentInfo.getClientConfigFiles();
 
       if (clientConfigFiles == null) {
-        throw new SystemException("No cofiguration files defined for the component");
+        throw new SystemException("No configuration files defined for the component " + componentInfo.getName());
       }
 
       String stackRoot = managementController.getAmbariMetaInfo().getStackRoot().getAbsolutePath();

+ 3 - 1
ambari-web/app/messages.js

@@ -1179,7 +1179,9 @@ Em.I18n.translations = {
   'services.service.summary.clientCount': '{0} Client Hosts',
   'services.service.summary.historyServer': 'History Server Web UI',
   'services.service.actions.downloadClientConfigs':'Download Client Configs',
-  'services.service.actions.downloadClientConfigs.fail.popup.body':'Generation of {0} configurations file has failed. Do you want to try again?',
+  '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.run.rebalancer':'Run Rebalancer',
   'services.service.actions.run.rebalanceHdfsNodes':'Rebalance HDFS',
   'services.service.actions.run.rebalanceHdfsNodes.title':'HDFS Rebalance',

+ 20 - 7
ambari-web/app/utils/components.js

@@ -96,13 +96,26 @@ module.exports = {
       (isForHost ? 'hosts/' + data.hostName + '/host_components/' : 'services/' + data.serviceName + '/components/') +
       data.componentName + '?format=client_config_tar';
     var self = this;
-    $.fileDownload(url).fail(function () {
-      var popup = App.showConfirmationPopup(function () {
-        popup.hide();
-        self.downloadClientConfigs({
-          context: Em.Object.create(data)
-        });
-      }, Em.I18n.t('services.service.actions.downloadClientConfigs.fail.popup.body').format(data.displayName))
+    $.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)
+            })
+          }
+        }
+      });
     });
   }