Repository: ambari Updated Branches: refs/heads/trunk 7d39d63ff -> 1272108d9
AMBARI-10298. YARN service configs should be displayed in the new format (onechiporenko via srimanth) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1272108d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1272108d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1272108d Branch: refs/heads/trunk Commit: 1272108d97e60a0f927ef92d553bda2a87ca0d90 Parents: 7d39d63 Author: Srimanth Gunturi <[email protected]> Authored: Thu Apr 2 13:56:09 2015 -0700 Committer: Srimanth Gunturi <[email protected]> Committed: Thu Apr 2 14:25:12 2015 -0700 ---------------------------------------------------------------------- ambari-web/app/assets/img/icons.png | Bin 0 -> 1896 bytes ambari-web/app/assets/licenses/NOTICE.txt | 3 + ambari-web/app/styles/application.less | 12 +- ambari-web/app/styles/widgets.less | 26 +- .../configs/widgets/checkbox_config_widget.hbs | 54 +++- .../checkbox_config_widget_comparison.hbs | 34 +++ .../configs/widgets/list_config_widget.hbs | 2 +- .../checkbox_config_widget_override.hbs | 61 +++++ .../overrides/slider_config_widget_override.hbs | 63 +++-- .../configs/widgets/slider_config_widget.hbs | 4 +- ambari-web/app/views.js | 2 + .../widgets/checkbox_config_widget_view.js | 26 +- .../checkbox_config_widget_comparison_view.js | 24 ++ .../configs/widgets/config_widget_view.js | 19 ++ .../checkbox_config_widget_override_view.js | 25 ++ ambari-web/config.coffee | 2 + ambari-web/vendor/scripts/bootstrap-checkbox.js | 274 +++++++++++++++++++ ambari-web/vendor/styles/bootstrap-checkbox.css | 116 ++++++++ 18 files changed, 702 insertions(+), 45 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/assets/img/icons.png ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/img/icons.png b/ambari-web/app/assets/img/icons.png new file mode 100644 index 0000000..1663a0b Binary files /dev/null and b/ambari-web/app/assets/img/icons.png differ http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/assets/licenses/NOTICE.txt ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/licenses/NOTICE.txt b/ambari-web/app/assets/licenses/NOTICE.txt index 7c00e58..9d6c66b 100644 --- a/ambari-web/app/assets/licenses/NOTICE.txt +++ b/ambari-web/app/assets/licenses/NOTICE.txt @@ -51,3 +51,6 @@ Copyright (C) 2015 by Kyle Kemp, Rohit Kalkur, and contributors This product includes bootstrap-slider 3.3.2 (https://github.com/nostalgiaz/bootstrap-switch - Apache License, Version 2.0) Copyright (C) 2015 by Mattia Larentis (mattia [at] larentis [*dot*] eu) + +This product includes bootstrap-checkbox v.1.0.1 (https://github.com/montrezorro/bootstrap-checkbox - Apache License, Version 2.0) +Copyright (C) 2014 Roberto Montresor (info [at] robertomontresor [*dot*] it) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/styles/application.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less index 8993e21..bfed2d9 100644 --- a/ambari-web/app/styles/application.less +++ b/ambari-web/app/styles/application.less @@ -483,7 +483,10 @@ h1 { .hide { visibility: hidden; } - +// some where in the vendor.css "display: none;" is added to ".hide" +.not-show { + visibility: hidden; +} .show { visibility: visible; } @@ -5576,6 +5579,13 @@ input[type="checkbox"].align-checkbox { .config-section { padding: 10px; border: 1px solid #aaa; + vertical-align: top; + + h4 { + font-size: 22px; + font-weight: 400; + } + td:not(:first-of-type) { border-left: 2px solid #ccc; // horizontal splitter padding-left: 20px; http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/styles/widgets.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/widgets.less b/ambari-web/app/styles/widgets.less index 8088bef..ac5b45e 100644 --- a/ambari-web/app/styles/widgets.less +++ b/ambari-web/app/styles/widgets.less @@ -20,11 +20,9 @@ @undo-btn-margin: 10px; @combo-widget-width: 100px; -.widget { +.widget-config { - margin-bottom: 30px; - - .widget { + .widget-config { margin-bottom: 0; } @@ -77,6 +75,7 @@ border: 1px solid @slider-widget-border-color; } .slider-tick-label { + color: #aaa; font-size: 10px; } .slider-selection { @@ -93,12 +92,18 @@ margin-right: 10px; } .ui-slider-label { + color: #aaa; line-height: 35px; } } } .slider-disabled { + .slider-track-high { + background-color: #ccc; + border-bottom-right-radius: 12px; + border-top-right-radius: 12px; + } .slider-selection { background-color: @gray-blue; } @@ -183,4 +188,17 @@ .widget-config-label { margin-left: 10px; } + + .bootstrap-checkbox { + &>button.btn { + padding: 0; + margin-top: -7px; + &:focus { + border-color: none; + box-shadow: 0; + outline: 0 none; + } + } + } + } http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/templates/common/configs/widgets/checkbox_config_widget.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/checkbox_config_widget.hbs b/ambari-web/app/templates/common/configs/widgets/checkbox_config_widget.hbs index 9d19223..d68b02e 100644 --- a/ambari-web/app/templates/common/configs/widgets/checkbox_config_widget.hbs +++ b/ambari-web/app/templates/common/configs/widgets/checkbox_config_widget.hbs @@ -16,9 +16,51 @@ * limitations under the License. }} -<label class="pull-left"> - {{view view.configView class="pull-left"}} - <span class="widget-config-label">{{view.configLabel}}</span> -</label> -{{view App.RestoreConfigView}} -<div class="clearfix"></div> +<div> + <label> + {{view view.configView class="pull-left"}} + {{#if view.isOriginalSCP}} + <span class="widget-config-label">{{view.configLabel}}</span> + {{/if}} + </label> +</div> +<div {{bindAttr class="view.isHover:show:not-show :clearfix"}}> + {{#if view.isOriginalSCP}} + {{view App.RestoreConfigView visibleBinding="view.undoAllowed"}} + {{/if}} + {{#if view.overrideAllowed}} + {{#isAccessible ADMIN}} + <div class="pull-left action-button"> + <a class="btn btn-small" href="#" data-toggle="tooltip" + {{action "createOverrideProperty" view.config target="view.parentView"}} + {{translateAttr data-original-title="common.override"}}> + <i class="icon-plus-sign"></i> + </a> + </div> + {{/isAccessible}} + {{/if}} +</div> + +{{#if view.isComparison}} + {{#if controller.selectedConfigGroup.isDefault}} + <span + class="label label-info">{{t dashboard.configHistory.table.version.prefix}}{{controller.selectedVersion}}</span> + {{#if controller.isCurrentSelected}} + <span class="label label-success">{{t common.current}}</span> + {{/if}} + {{else}} + <span class="label label-info">{{t common.default}} + {{t services.service.config.configHistory.configGroup}}</span> + {{/if}} +{{/if}} + +{{#if view.isOriginalSCP}} + {{view App.CheckboxConfigWidgetOverrideView + serviceConfigPropertyBinding="view.config" + isDefaultGroupSelectedBinding="controller.selectedConfigGroup.isDefault" + }} +{{/if}} + +{{#if view.isComparison}} + {{view App.CheckboxConfigWidgetComparisonView serviceConfigPropertyBinding="view.config"}} +{{/if}} http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/templates/common/configs/widgets/comparison/checkbox_config_widget_comparison.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/comparison/checkbox_config_widget_comparison.hbs b/ambari-web/app/templates/common/configs/widgets/comparison/checkbox_config_widget_comparison.hbs new file mode 100644 index 0000000..67e06c9 --- /dev/null +++ b/ambari-web/app/templates/common/configs/widgets/comparison/checkbox_config_widget_comparison.hbs @@ -0,0 +1,34 @@ +{{! +* 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. +}} + +{{#each compareConfig in view.serviceConfigProperty.compareConfigs}} + <div {{bindAttr class=":control-group :overrideField"}}> + {{view App.CheckboxConfigWidgetView configBinding="compareConfig" categoryConfigsAllBinding="view.parentView.categoryConfigsAll" isPopoverEnabled="false"}} + <span class="label label-info">{{compareConfig.serviceVersion.versionText}}</span> + {{#if compareConfig.serviceVersion.isCurrent}} + <span class="label label-success">{{t common.current}}</span> + {{/if}} + {{#unless compareConfig.isMock}} + {{#if compareConfig.supportsFinal}} + <a disabled="disabled" {{bindAttr class=":btn :btn-small :btn-final compareConfig.isFinal:active compareConfig.hideFinalIcon:hidden" }}> + <i class="icon-lock"></i> + </a> + {{/if}} + {{/unless}} + </div> +{{/each}} http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs b/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs index 9268b24..e8e2aa2 100644 --- a/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs +++ b/ambari-web/app/templates/common/configs/widgets/list_config_widget.hbs @@ -16,7 +16,7 @@ * limitations under the License. }} -<div {{bindAttr class="view.config.isHiddenByFilter:hide :widget :list-widget"}}> +<div {{bindAttr class="view.config.isHiddenByFilter:hide :widget-config :list-widget"}}> <p class="widget-config-label">{{view.configLabel}}</p> <div class="btn-group"> <a class="btn dropdown-toggle" data-toggle="dropdown">{{view.displayVal}} <span class="caret"></span></a> http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/templates/common/configs/widgets/overrides/checkbox_config_widget_override.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/overrides/checkbox_config_widget_override.hbs b/ambari-web/app/templates/common/configs/widgets/overrides/checkbox_config_widget_override.hbs new file mode 100644 index 0000000..1b77cba --- /dev/null +++ b/ambari-web/app/templates/common/configs/widgets/overrides/checkbox_config_widget_override.hbs @@ -0,0 +1,61 @@ +{{! +* 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. +}} +{{#each overriddenSCP in view.serviceConfigProperty.overrides}} +{{! Here serviceConfigBinding should ideally be serviceConfigPropertyBinding }} + <div {{bindAttr class="overriddenSCP.errorMessage:error: :control-group :overrideField"}}> + {{view App.CheckboxConfigWidgetView configBinding="overriddenSCP" isPopoverEnabled="false"}} + <div {{bindAttr class="view.parentView.isHover:show:not-show"}}> + {{#if overriddenSCP.supportsFinal}} + <a href="#" data-toggle="tooltip" + {{bindAttr class=":btn :btn-small :btn-final overriddenSCP.isFinal:active overriddenSCP.hideFinalIcon:hidden" disabled="overriddenSCP.isNotEditable"}} + {{action "toggleFinalFlag" overriddenSCP target="view"}} + {{translateAttr data-original-title="services.service.config.final"}}> + <i class="icon-lock"></i> + </a> + {{/if}} + {{#if view.isDefaultGroupSelected}} + {{#if overriddenSCP.group}} + <a href="#" data-toggle="tooltip" {{bindAttr data-original-title="overriddenSCP.group.switchGroupTextFull" }} + class="action" {{action selectConfigGroup overriddenSCP.group target="controller"}}> + {{overriddenSCP.group.switchGroupTextShort}} + </a> + {{/if}} + {{else}} + {{#if overriddenSCP.isEditable}} + {{#if isNotDefaultValue}} + <a class="btn btn-small" href="#" data-toggle="tooltip" + {{action "doRestoreDefaultValue" overriddenSCP target="view"}} + {{translateAttr data-original-title="common.undo"}}> + <i class="icon-undo"></i> + </a> + {{/if}} + {{#isAccessible ADMIN}} + <a class="btn btn-small" href="#" data-toggle="tooltip" + {{action "removeOverride" overriddenSCP target="view"}} + {{translateAttr data-original-title="common.remove"}}> + <i class="icon-minus-sign"></i> + </a> + {{/isAccessible}} + <span class="help-inline">{{overriddenSCP.errorMessage}}</span> + {{else}} + <a class="action">{{overriddenSCP.group.switchGroupTextShort}}</a> <i class="icon-spinner"></i> + {{/if}} + {{/if}} + </div> + </div> +{{/each}} http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/templates/common/configs/widgets/overrides/slider_config_widget_override.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/overrides/slider_config_widget_override.hbs b/ambari-web/app/templates/common/configs/widgets/overrides/slider_config_widget_override.hbs index 1ea0404..565e305 100644 --- a/ambari-web/app/templates/common/configs/widgets/overrides/slider_config_widget_override.hbs +++ b/ambari-web/app/templates/common/configs/widgets/overrides/slider_config_widget_override.hbs @@ -19,40 +19,43 @@ {{! Here serviceConfigBinding should ideally be serviceConfigPropertyBinding }} <div {{bindAttr class="overriddenSCP.errorMessage:error: :control-group :overrideField"}}> {{view App.SliderConfigWidgetView configBinding="overriddenSCP" isPopoverEnabled="false"}} - {{#if overriddenSCP.supportsFinal}} - <a href="#" data-toggle="tooltip" - {{bindAttr class=":btn :btn-small :btn-final overriddenSCP.isFinal:active overriddenSCP.hideFinalIcon:hidden" disabled="overriddenSCP.isNotEditable"}} - {{action "toggleFinalFlag" overriddenSCP target="view"}} - {{translateAttr data-original-title="services.service.config.final"}}> - <i class="icon-lock"></i> - </a> - {{/if}} - {{#if view.isDefaultGroupSelected}} - {{#if overriddenSCP.group}} - <a href="#" data-toggle="tooltip" {{bindAttr data-original-title="overriddenSCP.group.switchGroupTextFull" }} class="action" {{action selectConfigGroup overriddenSCP.group target="controller"}}> - {{overriddenSCP.group.switchGroupTextShort}} + <div {{bindAttr class="view.parentView.isHover:show:not-show"}}> + {{#if overriddenSCP.supportsFinal}} + <a href="#" data-toggle="tooltip" + {{bindAttr class=":btn :btn-small :btn-final overriddenSCP.isFinal:active overriddenSCP.hideFinalIcon:hidden" disabled="overriddenSCP.isNotEditable"}} + {{action "toggleFinalFlag" overriddenSCP target="view"}} + {{translateAttr data-original-title="services.service.config.final"}}> + <i class="icon-lock"></i> </a> {{/if}} - {{else}} - {{#if overriddenSCP.isEditable}} - {{#if isNotDefaultValue}} - <a class="btn btn-small" href="#" data-toggle="tooltip" - {{action "doRestoreDefaultValue" overriddenSCP target="view"}} - {{translateAttr data-original-title="common.undo"}}> - <i class="icon-undo"></i> + {{#if view.isDefaultGroupSelected}} + {{#if overriddenSCP.group}} + <a href="#" data-toggle="tooltip" {{bindAttr data-original-title="overriddenSCP.group.switchGroupTextFull" }} + class="action" {{action selectConfigGroup overriddenSCP.group target="controller"}}> + {{overriddenSCP.group.switchGroupTextShort}} </a> {{/if}} - {{#isAccessible ADMIN}} - <a class="btn btn-small" href="#" data-toggle="tooltip" - {{action "removeOverride" overriddenSCP target="view"}} - {{translateAttr data-original-title="common.remove"}}> - <i class="icon-minus-sign"></i> - </a> - {{/isAccessible}} - <span class="help-inline">{{overriddenSCP.errorMessage}}</span> {{else}} - <a class="action">{{overriddenSCP.group.switchGroupTextShort}}</a> <i class="icon-spinner"></i> + {{#if overriddenSCP.isEditable}} + {{#if isNotDefaultValue}} + <a class="btn btn-small" href="#" data-toggle="tooltip" + {{action "doRestoreDefaultValue" overriddenSCP target="view"}} + {{translateAttr data-original-title="common.undo"}}> + <i class="icon-undo"></i> + </a> + {{/if}} + {{#isAccessible ADMIN}} + <a class="btn btn-small" href="#" data-toggle="tooltip" + {{action "removeOverride" overriddenSCP target="view"}} + {{translateAttr data-original-title="common.remove"}}> + <i class="icon-minus-sign"></i> + </a> + {{/isAccessible}} + <span class="help-inline">{{overriddenSCP.errorMessage}}</span> + {{else}} + <a class="action">{{overriddenSCP.group.switchGroupTextShort}}</a> <i class="icon-spinner"></i> + {{/if}} {{/if}} - {{/if}} + </div> </div> -{{/each}} +{{/each}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs b/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs index dbcf076..57c10c6 100644 --- a/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs +++ b/ambari-web/app/templates/common/configs/widgets/slider_config_widget.hbs @@ -17,7 +17,7 @@ }} -<div {{bindAttr class="view.config.isHiddenByFilter:hide :widget :slider-widget"}}> +<div {{bindAttr class="view.config.isHiddenByFilter:hide :widget-config :slider-widget"}}> {{#if view.isOriginalSCP}} <p class="widget-config-label">{{formatWordBreak view.configLabel}}</p> {{/if}} @@ -25,7 +25,7 @@ <div class="pull-left ui-slider-wrapper-inner">{{view Ember.TextField valueBinding="view.config.value" class="input-mini slider-input"}}</div> <div class="pull-right ui-slider-label">{{view.mirrorValue}} {{view.config.stackConfigProperty.valueAttributes.unit}}</div> </div> - <div class="clearfix"> + <div {{bindAttr class="view.isHover:show:not-show :clearfix"}}> {{#if view.isOriginalSCP}} {{view App.RestoreConfigView visibleBinding="view.undoAllowed"}} {{/if}} http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index f4e83de..78daf4f 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -65,7 +65,9 @@ require('views/common/configs/widgets/slider_config_widget_view'); require('views/common/configs/widgets/string_config_widget_view'); require('views/common/configs/widgets/time_interval_spinner_view'); require('views/common/configs/widgets/toggle_config_widget_view'); +require('views/common/configs/widgets/overrides/checkbox_config_widget_override_view'); require('views/common/configs/widgets/overrides/slider_config_widget_override_view'); +require('views/common/configs/widgets/comparison/checkbox_config_widget_comparison_view'); require('views/common/configs/widgets/comparison/slider_config_widget_comparison_view'); require('views/common/configs/service_config_layout_tab_view'); require('views/common/filter_combobox'); http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/views/common/configs/widgets/checkbox_config_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/checkbox_config_widget_view.js b/ambari-web/app/views/common/configs/widgets/checkbox_config_widget_view.js index a0d928a..326ad2f 100644 --- a/ambari-web/app/views/common/configs/widgets/checkbox_config_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/checkbox_config_widget_view.js @@ -27,9 +27,33 @@ App.CheckboxConfigWidgetView = App.ConfigWidgetView.extend({ templateName: require('templates/common/configs/widgets/checkbox_config_widget'), classNames: ['widget-config', 'checkbox-widget'], + didInsertElement: function () { + var self = this; + this._super(arguments); + Em.run.next(function () { + if (self.$()) + self.$('input[type="checkbox"]:eq(0)').checkbox({ + defaultState: self.get('config.value'), + buttonStyle: 'btn-link btn-large', + checkedClass: 'icon-check', + uncheckedClass: 'icon-check-empty' + }); + }); + }, + configView: App.ServiceConfigCheckbox.extend({ serviceConfigBinding: 'parentView.config', // @TODO maybe find use case of this method for widget focusIn: function() {} - }) + }), + + /** + * Manually reset bootstrap-checkbox + * @method restoreValue + */ + restoreValue: function () { + this.$('input[type="checkbox"]:eq(0)').checkbox('click'); + this._super(); + } + }); http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/views/common/configs/widgets/comparison/checkbox_config_widget_comparison_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/comparison/checkbox_config_widget_comparison_view.js b/ambari-web/app/views/common/configs/widgets/comparison/checkbox_config_widget_comparison_view.js new file mode 100644 index 0000000..62a0351 --- /dev/null +++ b/ambari-web/app/views/common/configs/widgets/comparison/checkbox_config_widget_comparison_view.js @@ -0,0 +1,24 @@ +/** + * 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'); + +App.CheckboxConfigWidgetComparisonView = App.ServiceConfigView.SCPComparisonRowsView.extend({ + + templateName: require('templates/common/configs/widgets/comparison/checkbox_config_widget_comparison') + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/views/common/configs/widgets/config_widget_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/config_widget_view.js b/ambari-web/app/views/common/configs/widgets/config_widget_view.js index 03d25e9..ba441b5 100644 --- a/ambari-web/app/views/common/configs/widgets/config_widget_view.js +++ b/ambari-web/app/views/common/configs/widgets/config_widget_view.js @@ -30,6 +30,12 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo config: null, /** + * Determines if user hover on widget-view + * @type {boolean} + */ + isHover: false, + + /** * Alias to <code>config.isOriginalSCP</code> * Should be used in the templates * Don't use original <code>config.isOriginalSCP</code> in the widget-templates!!! @@ -101,11 +107,24 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo /** * sync widget value with config value when dependent properties * have been loaded or changed + * @method syncValueWithConfig */ syncValueWithConfig: function() { this.setValue(this.get('config.value')); }.observes('controller.recommendationTimeStamp'), + didInsertElement: function () { + var self = this; + var element = this.$(); + if (element) { + element.hover(function() { + self.set('isHover', true); + }, function() { + self.set('isHover', false); + }); + } + }, + /** * set widget value same as config value * useful for widgets that work with intermediate config value, not original http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/app/views/common/configs/widgets/overrides/checkbox_config_widget_override_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/widgets/overrides/checkbox_config_widget_override_view.js b/ambari-web/app/views/common/configs/widgets/overrides/checkbox_config_widget_override_view.js new file mode 100644 index 0000000..93e7f75 --- /dev/null +++ b/ambari-web/app/views/common/configs/widgets/overrides/checkbox_config_widget_override_view.js @@ -0,0 +1,25 @@ +/** + * 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'); + +App.CheckboxConfigWidgetOverrideView = App.ServiceConfigView.SCPOverriddenRowsView.extend({ + + templateName: require('templates/common/configs/widgets/overrides/checkbox_config_widget_override') + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/config.coffee ---------------------------------------------------------------------- diff --git a/ambari-web/config.coffee b/ambari-web/config.coffee index 25e1766..ec10ade 100644 --- a/ambari-web/config.coffee +++ b/ambari-web/config.coffee @@ -40,6 +40,7 @@ exports.config = 'vendor/scripts/ember-i18n-1.4.1.js', 'vendor/scripts/bootstrap.js', 'vendor/scripts/bootstrap-combobox.js', + 'vendor/scripts/bootstrap-checkbox.js', 'vendor/scripts/bootstrap-slider.min.js', 'vendor/scripts/d3.v2.js', 'vendor/scripts/cubism.v1.js', @@ -76,6 +77,7 @@ exports.config = 'vendor/styles/cubism.css', 'vendor/styles/rickshaw.css' 'vendor/styles/bootstrap-combobox.css', + 'vendor/styles/bootstrap-checkbox.css', 'vendor/styles/bootstrap-slider.min.css' ] http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/vendor/scripts/bootstrap-checkbox.js ---------------------------------------------------------------------- diff --git a/ambari-web/vendor/scripts/bootstrap-checkbox.js b/ambari-web/vendor/scripts/bootstrap-checkbox.js new file mode 100644 index 0000000..3399fc1 --- /dev/null +++ b/ambari-web/vendor/scripts/bootstrap-checkbox.js @@ -0,0 +1,274 @@ +/* =========================================================== + * bootstrap-checkbox - v.1.0.1 + * =========================================================== + * Copyright 2014 Roberto Montresor + * + * Licensed 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. + * ========================================================== */ + +!function($) { + var Checkbox = function(element, options, e) { + if (e) { + e.stopPropagation(); + e.preventDefault(); + } + this.$element = $(element); + this.$newElement = null; + this.button = null; + this.label = null; + this.labelPrepend = null; + this.options = $.extend({}, $.fn.checkbox.defaults, this.$element.data(), typeof options == 'object' && options); + this.init(); + }; + + Checkbox.prototype = { + + constructor: Checkbox, + + init: function (e) { + this.$element.hide(); + this.$element.attr('autocomplete', 'off'); + + this._createButtons(); + }, + + _createButtons: function(){ + var classList = this.$element.attr('class') !== undefined ? this.$element.attr('class').split(/\s+/) : ''; + var template = this.getTemplate(); + this.$element.after(template); + this.$newElement = this.$element.next('.bootstrap-checkbox'); + this.button = this.$newElement.find('button'); + this.label = this.$newElement.find('span.label-checkbox'); + this.labelPrepend = this.$newElement.find('span.label-prepend-checkbox'); + for (var i = 0; i < classList.length; i++) { + if(classList[i] != 'checkbox') { + this.$newElement.addClass(classList[i]); + } + } + this.button.addClass(this.options.buttonStyle); + + if (this.$element.data('default-state') != undefined){ + this.options.defaultState = this.$element.data('default-state'); + } + if (this.$element.data('default-enabled') != undefined){ + this.options.defaultEnabled = this.$element.data('default-enabled'); + } + if (this.$element.data('display-as-button') != undefined){ + this.options.displayAsButton = this.$element.data('display-as-button'); + } + + if (this.options.indeterminate) + this.$element.prop('indeterminate', true); + + this.checkEnabled(); + this.checkChecked(); + this.checkTabIndex(); + this.clickListener(); + }, + + getTemplate: function() { + var additionalButtonStyle = this.options.displayAsButton ? ' displayAsButton' : '', + label = this.$element.data('label') ? '<span class="label-checkbox">'+this.$element.data('label')+'</span>' : '', + labelPrepend = this.$element.data('label-prepend') ? '<span class="label-prepend-checkbox">'+this.$element.data('label-prepend')+'</span>' : ''; + + var template = + '<span class="button-checkbox bootstrap-checkbox">' + + '<button type="button" class="btn clearfix'+additionalButtonStyle+'">' + + ((this.$element.data('label-prepend') && this.options.displayAsButton) ? labelPrepend : '')+ + '<span class="icon '+this.options.checkedClass+'" style="display:none;"></span>' + + '<span class="icon '+this.options.uncheckedClass+'"></span>' + + '<span class="icon '+this.options.indeterminateClass+'" style="display:none;"></span>' + + ((this.$element.data('label') && this.options.displayAsButton) ? label : '')+ + '</button>' + + '</span>'; + + if (!this.options.displayAsButton && (this.$element.data('label') || this.$element.data('label-prepend'))) { + template = + '<label class="'+this.options.labelClass+'">' + + labelPrepend + template + label+ + '</label>'; + } + return template; + }, + + checkEnabled: function() { + this.button.attr('disabled', this.$element.is(':disabled')); + this.$newElement.toggleClass('disabled', this.$element.is(':disabled')); + }, + + checkTabIndex: function() { + if (this.$element.is('[tabindex]')) { + var tabindex = this.$element.attr("tabindex"); + this.button.attr('tabindex', tabindex); + } + }, + + checkChecked: function() { + var whitePattern = /\s/g, replaceChar = '.'; + if (this.$element.prop('indeterminate') == true){ + this.button.find('span.'+this.options.checkedClass.replace(whitePattern, replaceChar)).hide(); + this.button.find('span.'+this.options.uncheckedClass.replace(whitePattern, replaceChar)).hide(); + this.button.find('span.'+this.options.indeterminateClass.replace(whitePattern, replaceChar)).show(); + } else { + if (this.$element.is(':checked')) { + this.button.find('span.'+this.options.checkedClass.replace(whitePattern, replaceChar)).show(); + this.button.find('span.'+this.options.uncheckedClass.replace(whitePattern, replaceChar)).hide(); + } else { + this.button.find('span.'+this.options.checkedClass.replace(whitePattern, replaceChar)).hide(); + this.button.find('span.'+this.options.uncheckedClass.replace(whitePattern, replaceChar)).show(); + } + this.button.find('span.'+this.options.indeterminateClass.replace(whitePattern, replaceChar)).hide(); + } + + if (this.$element.is(':checked')) { + if (this.options.buttonStyleChecked){ + this.button.removeClass(this.options.buttonStyle); + this.button.addClass(this.options.buttonStyleChecked); + } + } else { + if (this.options.buttonStyleChecked){ + this.button.removeClass(this.options.buttonStyleChecked); + this.button.addClass(this.options.buttonStyle); + } + } + + if (this.$element.is(':checked')) { + if (this.options.labelClassChecked){ + $(this.$element).next("label").addClass(this.options.labelClassChecked); + } + } else { + if (this.options.labelClassChecked){ + $(this.$element).next("label").removeClass(this.options.labelClassChecked); + } + } + }, + + clickListener: function() { + var _this = this; + this.button.on('click', function(e){ + e.preventDefault(); + _this.$element.prop("indeterminate", false); + _this.$element[0].click(); + _this.checkChecked(); + }); + this.$element.on('change', function(e) { + _this.checkChecked(); + }); + this.$element.parents('form').on('reset', function(e) { + if (_this.options.defaultState == null){ + _this.$element.prop('indeterminate', true); + } else { + _this.$element.prop('checked', _this.options.defaultState); + } + _this.$element.prop('disabled', !_this.options.defaultEnabled); + _this.checkEnabled(); + _this.checkChecked(); + e.preventDefault(); + }); + }, + + setOptions: function(option, event){ + if (option.checked != undefined) { + this.setChecked(option.checked); + } + if (option.enabled != undefined) { + this.setEnabled(option.enabled); + } + if (option.indeterminate != undefined) { + this.setIndeterminate(option.indeterminate); + } + }, + + setChecked: function(checked){ + this.$element.prop("checked", checked); + this.$element.prop("indeterminate", false); + this.checkChecked(); + }, + + setIndeterminate: function(indeterminate){ + this.$element.prop("indeterminate", indeterminate); + this.checkChecked(); + }, + + + click: function(event){ + this.$element.prop("indeterminate", false); + this.$element[0].click(); + this.checkChecked(); + }, + + change: function(event){ + this.$element.change(); + }, + + setEnabled: function(enabled){ + this.$element.attr('disabled', !enabled); + this.checkEnabled(); + }, + + toggleEnabled: function(event){ + this.$element.attr('disabled', !this.$element.is(':disabled')); + this.checkEnabled(); + }, + + refresh: function(event){ + this.checkEnabled(); + this.checkChecked(); + }, + + update: function(options){ + if (!this.$element.next().find('.bootstrap-checkbox')) + return; + + this.options = $.extend({}, this.options, options); + this.$element.next().remove(); + this._createButtons(); + } + }; + + $.fn.checkbox = function(option, event) { + return this.each(function () { + var $this = $(this), + data = $this.data('checkbox'), + options = typeof option == 'object' && option; + if (!data) { + $this.data('checkbox', (data = new Checkbox(this, options, event))); + if (data.options.constructorCallback != undefined){ + data.options.constructorCallback(data.$element, data.button, data.label, data.labelPrepend); + } + } else { + if (typeof option == 'string') { + data[option](event); + } else if (typeof option != 'undefined') { + data.setOptions(option, event); + } + } + }); + }; + + $.fn.checkbox.defaults = { + displayAsButton: false, + indeterminate: false, + buttonStyle: 'btn-link', + buttonStyleChecked: null, + checkedClass: 'cb-icon-check', + uncheckedClass: 'cb-icon-check-empty', + indeterminateClass: 'cb-icon-check-indeterminate', + defaultState: false, + defaultEnabled: true, + constructorCallback: null, + labelClass: "checkbox bootstrap-checkbox", + labelClassChecked: "active" + }; + +}(window.jQuery); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/1272108d/ambari-web/vendor/styles/bootstrap-checkbox.css ---------------------------------------------------------------------- diff --git a/ambari-web/vendor/styles/bootstrap-checkbox.css b/ambari-web/vendor/styles/bootstrap-checkbox.css new file mode 100644 index 0000000..2ed0bcc --- /dev/null +++ b/ambari-web/vendor/styles/bootstrap-checkbox.css @@ -0,0 +1,116 @@ +/* =========================================================== + * bootstrap-checkbox - v.1.0.1 + * =========================================================== + * Copyright 2014 Roberto Montresor + * + * Licensed 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. + * ========================================================== */ + +@CHARSET "ISO-8859-1"; + +.bootstrap-checkbox > button.btn{ + padding:7px 0 4px 2px; + width:28px; +} +.bootstrap-checkbox > button.btn.displayAsButton{ + width:auto; +} +.bootstrap-checkbox > button.btn.displayAsButton > span.label-checkbox{ + padding:0 8px 0 4px; +} +.bootstrap-checkbox > button.btn.displayAsButton > span.icon{ + margin: 2px 4px; +} +.bootstrap-checkbox > button.btn.displayAsButton > span.label-prepend-checkbox{ + padding:0 4px 0 8px; +} +.bootstrap-checkbox > button.btn.btn-large{ + padding:10px 0 6px 2px; + width:36px; +} +.bootstrap-checkbox > button.btn.btn-small{ + padding:5px 0 3px 1px; + width:24px; +} +.bootstrap-checkbox > button.btn.btn-mini{ + padding:4px 0 1px 1px; + width:20px; +} + +.bootstrap-checkbox > .btn.btn-link{ + text-decoration:none; +} + +label.bootstrap-checkbox.disabled{ + cursor:default; + color:#666; +} + +.bootstrap-checkbox > .label-prepend-checkbox{ + padding-right:4px; +} + +.bootstrap-checkbox > .label-checkbox{ + padding-left:4px; +} + +.bootstrap-checkbox.disabled > [class^="label-"], +.bootstrap-checkbox > .btn[disabled]{ + cursor:not-allowed; +} + +[class^="cb-icon-"], +[class*=" cb-icon-"] { + display: inline-block; + width: 14px; + height: 14px; + margin-top: 1px; + *margin-right: .3em; + line-height: 14px; + vertical-align: text-top; + background-image: url("../img/icons.png"); + background-position: 14px 14px; + background-repeat: no-repeat; +} + +.bootstrap-checkbox button.btn > span.cb-icon-check, +.bootstrap-checkbox.disabled button.btn:hover > span.cb-icon-check, +.bootstrap-checkbox.disabled button.btn:active > span.cb-icon-check{ + background-position: 0 -1px; +} +.bootstrap-checkbox button.btn:hover > span.cb-icon-check, +.bootstrap-checkbox button.btn:focus > span.cb-icon-check, +.bootstrap-checkbox button.btn:active > span.cb-icon-check{ + background-position: 0 -25px; +} +.bootstrap-checkbox button.btn > span.cb-icon-check-empty, +.bootstrap-checkbox.disabled button.btn:hover > span.cb-icon-check-empty, +.bootstrap-checkbox.disabled button.btn:active > span.cb-icon-check-empty{ + background-position: -24px -1px; +} +.bootstrap-checkbox button.btn:hover > span.cb-icon-check-empty, +.bootstrap-checkbox button.btn:focus > span.cb-icon-check-empty, +.bootstrap-checkbox button.btn:active > span.cb-icon-check-empty{ + background-position: -24px -25px; +} + +.bootstrap-checkbox button.btn > span.cb-icon-check-indeterminate, +.bootstrap-checkbox.disabled button.btn:hover > span.cb-icon-check-indeterminate, +.bootstrap-checkbox.disabled button.btn:active > span.cb-icon-check-indeterminate{ + background-position: -48px -1px; +} +.bootstrap-checkbox button.btn:hover > span.cb-icon-check-indeterminate, +.bootstrap-checkbox button.btn:focus > span.cb-icon-check-indeterminate, +.bootstrap-checkbox button.btn:active > span.cb-icon-check-indeterminate{ + background-position: -48px -25px; +} \ No newline at end of file
