Просмотр исходного кода

AMBARI-6122. Explicitly tell the user to set up JDBC driver if an existing db option is selected for Hive / Oozie. (xiwang)

Xi Wang 11 лет назад
Родитель
Сommit
effb34ff84
2 измененных файлов с 30 добавлено и 5 удалено
  1. 3 0
      ambari-web/app/messages.js
  2. 27 5
      ambari-web/app/views/wizard/controls_view.js

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

@@ -1298,6 +1298,9 @@ Em.I18n.translations = {
   'services.service.config.database.connection.failed': 'Connection Failed',
   'services.service.config.database.btn.idle': 'Test Connection',
   'services.service.config.database.btn.connecting': 'Connecting...',
+  'services.service.config.database.msg.jdbcSetup': 'Be sure you have run:<br/>' +
+    '<b>ambari-server setup --jdbc-db={0} --jdbc-driver=/path/to/{1}/driver.jar</b> ' +
+    'on the Ambari Server host to make the JDBC driver available and to enable testing the database connection.',
 
   'services.add.header':'Add Service Wizard',
   'services.reassign.header':'Move Master Wizard',

+ 27 - 5
ambari-web/app/views/wizard/controls_view.js

@@ -337,25 +337,47 @@ App.ServiceConfigRadioButtons = Ember.View.extend({
 
   /**
    * `Observer` that add <code>additionalView</code> to <code>App.ServiceConfigProperty</code>
-   * that responsible for checking database connection.
+   * that responsible for (if existing db selected)
+   * 1. checking database connection
+   * 2. showing jdbc driver setup warning msg.
    *
    * @method handleDBConnectionProperty
    **/
   handleDBConnectionProperty: function() {
-    if (!App.supports.databaseConnection) return;
     if (!['addServiceController', 'installerController'].contains(App.clusterStatus.wizardControllerName)) return;
     var handledProperties = ['oozie_database', 'hive_database'];
     var currentValue = this.get('serviceConfig.value');
     var databases = /MySQL|PostgreSQL|Oracle|Derby/gi;
     var currentDB = currentValue.match(databases)[0];
+    var databasesTypes = /MySQL|PostgreS|Oracle|Derby/gi;
+    var currentDBType = currentValue.match(databasesTypes)[0];
     var existingDatabase = /existing/gi.test(currentValue);
-    var propertyAppendTo = this.get('categoryConfigsAll').findProperty('displayName', 'Database URL');
+    // db connection check button show up if existed db selected
+    if (App.supports.databaseConnection) {
+      var propertyAppendTo1 = this.get('categoryConfigsAll').findProperty('displayName', 'Database URL');
+      if (currentDB && existingDatabase) {
+        if (handledProperties.contains(this.get('serviceConfig.name'))) {
+          if (propertyAppendTo1) propertyAppendTo1.set('additionalView', App.CheckDBConnectionView.extend({databaseName: currentDB}));
+        }
+      } else {
+        propertyAppendTo1.set('additionalView', null);
+      }
+    }
+    // warning msg under database type radio buttons, to warn the user to setup jdbc driver if existed db selected
+    var propertyHive = this.get('categoryConfigsAll').findProperty('displayName', 'Hive Database');
+    var propertyOozie = this.get('categoryConfigsAll').findProperty('displayName', 'Oozie Database');
+    var propertyAppendTo2 = propertyHive ? propertyHive : propertyOozie;
     if (currentDB && existingDatabase) {
       if (handledProperties.contains(this.get('serviceConfig.name'))) {
-        if (propertyAppendTo) propertyAppendTo.set('additionalView', App.CheckDBConnectionView.extend({databaseName: currentDB}));
+        if (propertyAppendTo2) {
+          propertyAppendTo2.set('additionalView', Ember.View.extend({
+            template: Ember.Handlebars.compile('<div class="alert">{{{view.message}}}</div>'),
+            message: Em.I18n.t('services.service.config.database.msg.jdbcSetup').format(currentDBType.toLowerCase(), currentDBType.toLowerCase())
+          }));
+        }
       }
     } else {
-      propertyAppendTo.set('additionalView', null);
+      propertyAppendTo2.set('additionalView', null);
     }
   }.observes('serviceConfig.value', 'configs.@each.value'),