瀏覽代碼

AMBARI-14917. Edit WEB Alert issues (onechiporenko)

Oleg Nechiporenko 9 年之前
父節點
當前提交
74d5a01671

+ 6 - 7
ambari-web/app/controllers/main/alerts/definition_configs_controller.js

@@ -499,12 +499,8 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
       return c.get('name') !== 'parameter';
     });
     configs.forEach(function (property) {
-      var apiProperties = property.get('apiProperty');
-      var apiFormattedValues = property.get('apiFormattedValue');
-      if (!Em.isArray(property.get('apiProperty'))) {
-        apiProperties = [property.get('apiProperty')];
-        apiFormattedValues = [property.get('apiFormattedValue')];
-      }
+      var apiProperties = Em.makeArray(property.get('apiProperty'));
+      var apiFormattedValues = Em.makeArray(property.get('apiFormattedValue'));
       apiProperties.forEach(function (apiProperty, i) {
         if (apiProperty.contains('source.')) {
           if (!propertiesToUpdate['AlertDefinition/source']) {
@@ -531,7 +527,6 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
             }
             Ember.setFullPath(propertiesToUpdate['AlertDefinition/source'], apiProperty.replace('source.', ''), apiFormattedValues[i]);
           }
-
         }
         else {
           if (apiProperty) {
@@ -541,6 +536,10 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
       }, this);
     }, this);
 
+    if (Em.get(propertiesToUpdate, 'AlertDefinition/source.uri.id')) {
+      delete propertiesToUpdate['AlertDefinition/source'].uri.id;
+    }
+
     // `source.parameters` is an array and should be updated separately from other configs
     if (this.get('content.parameters.length')) {
       propertiesToUpdate['AlertDefinition/source/parameters'] = this.get('content.rawSourceData.parameters');

+ 1 - 0
ambari-web/app/models/alerts/alert_config.js

@@ -437,6 +437,7 @@ App.AlertConfigProperties = {
     displayType: 'textField',
     classNames: 'alert-connection-timeout',
     apiProperty: 'source.uri.connection_timeout',
+    unit: 'Seconds',
     isValid: function () {
       var value = this.get('value');
       return numericUtils.isPositiveNumber(value);

+ 1 - 1
ambari-web/app/styles/alerts.less

@@ -324,7 +324,7 @@
     padding-right: 13px;
   }
 
-  .alert-interval-input {
+  .alert-interval-input, .alert-connection-timeout {
     input {
       width: 20%;
     }

+ 0 - 1
ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js

@@ -18,7 +18,6 @@
 
 var App = require('app');
 require('controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller');
-var testHelpers = require('test/helpers');
 
 describe('App.ActivateHawqStandbyWizardStep2Controller', function () {
 

+ 26 - 0
ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js

@@ -482,6 +482,32 @@ describe('App.MainAlertDefinitionConfigsController', function () {
       });
     });
 
+    describe('Some fields should be removed', function () {
+
+      beforeEach(function () {
+        controller.set('content', Em.Object.create({
+          rawSourceData: {
+            uri: {
+              id: 123
+            }
+          }
+        }));
+        controller.set('configs', [
+          Em.Object.create({
+            apiProperty: 'source.uri.connection_timeout',
+            apiFormattedValue: 123,
+            wasChanged: true
+          })
+        ]);
+        this.result = controller.getPropertiesToUpdate();
+      });
+
+      it('`AlertDefinition/source.uri.id`', function () {
+        expect(this.result).to.not.have.deep.property('AlertDefinition/source.uri.id');
+      });
+
+    });
+
     describe('`source/parameters` for SCRIPT configs', function () {
 
       beforeEach(function () {