You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2017/02/01 11:20:28 UTC

ambari git commit: AMBARI-19814. 'num_llap_nodes' should show up as non-editable property when non-ambari managed queue is selected (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 4e689afe5 -> b55ba18ed


AMBARI-19814. 'num_llap_nodes' should show up as non-editable property when non-ambari managed queue is selected (onechiporenko)


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

Branch: refs/heads/trunk
Commit: b55ba18edd107a9439e24aafbe2167a76916b07f
Parents: 4e689af
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Wed Feb 1 11:43:37 2017 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Wed Feb 1 13:15:45 2017 +0200

----------------------------------------------------------------------
 ambari-web/app/mixins.js                        |  1 +
 .../configs/widgets/unique/num_llap_nodes.js    | 70 ++++++++++++++++++++
 .../common/configs/widgets/controls.hbs         |  2 +
 .../configs/service_config_layout_tab_view.js   | 23 ++++++-
 4 files changed, 93 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b55ba18e/ambari-web/app/mixins.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js
index 7b4d6b4..9d833b5 100644
--- a/ambari-web/app/mixins.js
+++ b/ambari-web/app/mixins.js
@@ -53,6 +53,7 @@ require('mixins/wizard/addSecurityConfigs');
 require('mixins/wizard/wizard_menu_view');
 require('mixins/wizard/assign_master_components');
 require('mixins/wizard/wizardHostsLoading');
+require('mixins/common/configs/widgets/unique/num_llap_nodes');
 require('mixins/common/configs/config_recommendations');
 require('mixins/common/configs/config_recommendation_parser');
 require('mixins/common/configs/config_with_override_recommendation_parser');

http://git-wip-us.apache.org/repos/asf/ambari/blob/b55ba18e/ambari-web/app/mixins/common/configs/widgets/unique/num_llap_nodes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/widgets/unique/num_llap_nodes.js b/ambari-web/app/mixins/common/configs/widgets/unique/num_llap_nodes.js
new file mode 100644
index 0000000..a2df0fa
--- /dev/null
+++ b/ambari-web/app/mixins/common/configs/widgets/unique/num_llap_nodes.js
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+var App = require('app');
+
+/**
+ * Slider for `num_llap_nodes` should have unique widget
+ *
+ * @type {Em.Mixin}
+ */
+App.NumLlapNodesWidgetMixin = Em.Mixin.create({
+
+  /**
+   * @type {boolean}
+   */
+  readOnly: Em.computed.alias('config.stackConfigProperty.valueAttributes.read_only'),
+
+  /**
+   * @type {boolean}
+   */
+  doNotShowWidget: function () {
+    if (this.get('readOnly')) {
+      return false;
+    }
+    return this.get('isPropertyUndefined') || this.get('config.showAsTextBox');
+  }.property('isPropertyUndefined', 'config.showAsTextBox', 'readOnly'),
+
+  handleReadOnlyAttribute: function () {
+    var readOnly = this.get('readOnly');
+    this.set('disabled', readOnly);
+    this.set('supportSwitchToTextBox', !readOnly);
+    if (readOnly) {
+      this.toggleSlider('disable');
+    }
+  }.observes('readOnly'),
+
+  toggleWidgetView: function() {
+    this._super();
+    var action = !this.get('config.showAsTextBox') && this.get('readOnly') ? 'disable' : 'enable';
+    this.toggleSlider(action);
+  },
+
+  toggleWidgetState: function () {
+    this.set('disabled', !this.get('config.isEditable'));
+  }.observes('config.isEditable'),
+
+  toggleSlider: function (action) {
+    var self = this;
+    Em.run.next(function () {
+      self.get('slider')[action]();
+    });
+  }
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/b55ba18e/ambari-web/app/templates/common/configs/widgets/controls.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/widgets/controls.hbs b/ambari-web/app/templates/common/configs/widgets/controls.hbs
index 351d8ed..b7aff8e 100644
--- a/ambari-web/app/templates/common/configs/widgets/controls.hbs
+++ b/ambari-web/app/templates/common/configs/widgets/controls.hbs
@@ -33,6 +33,7 @@
   {{/unless}}
 {{/if}}
 {{#if view.canEdit}}
+  {{#unless view.readOnly}}
   <div {{bindAttr class=":widget-config-controls view.referToSelectedGroup::clear-min-height"}}>
     <div {{bindAttr class=":widget-col :left view.config.isNotDefaultValue::hidden"}}>
       <a href="#"
@@ -98,6 +99,7 @@
       {{/if}}
     </div>
   </div>
+  {{/unless}}
 {{/if}}
 
 {{#if controller.selectedConfigGroup.isDefault}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b55ba18e/ambari-web/app/views/common/configs/service_config_layout_tab_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/service_config_layout_tab_view.js b/ambari-web/app/views/common/configs/service_config_layout_tab_view.js
index 30ffadf..466a88d 100644
--- a/ambari-web/app/views/common/configs/service_config_layout_tab_view.js
+++ b/ambari-web/app/views/common/configs/service_config_layout_tab_view.js
@@ -67,6 +67,10 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
     'test-db-connection': App.TestDbConnectionWidgetView
   },
 
+  configNameWidgetMixinMap: {
+    num_llap_nodes: App.NumLlapNodesWidgetMixin
+  },
+
   /**
    * Prepare configs for render
    * <code>subsection.configs</code> is an array of App.StackConfigProperty, but not App.ConfigProperty,
@@ -108,9 +112,9 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
       if (!configProperty) return;
 
       containerObject.get('configs').pushObject(configProperty);
-      var configWidgetType = Em.get(config, 'widgetType');
-      var widget = self.get('widgetTypeMap')[configWidgetType];
-      Em.assert('Unknown config widget view for config ' + configProperty.get('id') + ' with type ' + configWidgetType, widget);
+
+      var widget = self.getWidgetView(config);
+      Em.assert('Unknown config widget view for config ' + configProperty.get('id') + ' with type ' +  Em.get(config, 'widgetType'), widget);
 
       var additionalProperties = {
         widget: widget,
@@ -161,6 +165,19 @@ App.ServiceConfigLayoutTabView = Em.View.extend(App.ConfigOverridable, {
   },
 
   /**
+   *
+   * @param {object} config
+   * @returns {Em.View}
+   */
+  getWidgetView: function (config) {
+    var configWidgetType = Em.get(config, 'widgetType');
+    var name = Em.get(config, 'name');
+    var mixin = this.get('configNameWidgetMixinMap')[name];
+    var viewClass = this.get('widgetTypeMap')[configWidgetType];
+    return Em.isNone(mixin) ? viewClass : viewClass.extend(mixin);
+  },
+
+  /**
    * changes active subsection tab
    * @param event
    */