Browse Source

AMBARI-13691 Allow use passwords references in custom actions - UI changes. (atkach)

Andrii Tkach 9 years ago
parent
commit
df693b7e1a

+ 23 - 0
ambari-web/app/utils/ajax/ajax.js

@@ -2363,6 +2363,29 @@ var urls = {
       }
       }
     }
     }
   },
   },
+
+  'cluster.custom_action.create': {
+    'real': '/clusters/{clusterName}/requests',
+    'mock': '',
+    'format': function (data) {
+      var requestInfo = {
+        context: 'Check host',
+        action: 'check_host',
+        parameters: {}
+      };
+      $.extend(true, requestInfo, data.requestInfo);
+      return {
+        type: 'POST',
+        data: JSON.stringify({
+          'RequestInfo': requestInfo,
+          'Requests/resource_filters': [{
+            hosts: data.filteredHosts.join(',')
+          }]
+        })
+      }
+    }
+  },
+
   'custom_action.request': {
   'custom_action.request': {
     'real': '/requests/{requestId}/tasks/{taskId}',
     'real': '/requests/{requestId}/tasks/{taskId}',
     'mock': '/data/requests/1.json',
     'mock': '/data/requests/1.json',

+ 2 - 1
ambari-web/app/views/common/configs/widgets/test_db_connection_widget_view.js

@@ -195,6 +195,7 @@ App.TestDbConnectionWidgetView = App.ConfigWidgetView.extend({
    **/
    **/
   createCustomAction: function () {
   createCustomAction: function () {
     var connectionProperties = this.getProperties('db_connection_url','user_name', 'user_passwd');
     var connectionProperties = this.getProperties('db_connection_url','user_name', 'user_passwd');
+    var isServiceInstalled = App.Service.find(this.get('config.serviceName')).get('isLoaded');
     for (var key in connectionProperties) {
     for (var key in connectionProperties) {
       if (connectionProperties.hasOwnProperty(key)) {
       if (connectionProperties.hasOwnProperty(key)) {
         connectionProperties[key] = connectionProperties[key].value;
         connectionProperties[key] = connectionProperties[key].value;
@@ -203,7 +204,7 @@ App.TestDbConnectionWidgetView = App.ConfigWidgetView.extend({
     var params = $.extend(true, {}, {db_name: this.get('db_type').toLowerCase()}, connectionProperties, this.get('ambariProperties'));
     var params = $.extend(true, {}, {db_name: this.get('db_type').toLowerCase()}, connectionProperties, this.get('ambariProperties'));
     var filteredHosts =  Array.isArray(this.get('masterHostName.value')) ? this.get('masterHostName.value') : [this.get('masterHostName.value')];
     var filteredHosts =  Array.isArray(this.get('masterHostName.value')) ? this.get('masterHostName.value') : [this.get('masterHostName.value')];
     App.ajax.send({
     App.ajax.send({
-      name: 'custom_action.create',
+      name: (isServiceInstalled) ? 'cluster.custom_action.create' : 'custom_action.create',
       sender: this,
       sender: this,
       data: {
       data: {
         requestInfo: {
         requestInfo: {