Repository: ambari Updated Branches: refs/heads/trunk 101be8eb3 -> 6bb70cc4a
AMBARI-11296. Enhanced Config pages take a long time to load - need to improve load time (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/6bb70cc4 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/6bb70cc4 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/6bb70cc4 Branch: refs/heads/trunk Commit: 6bb70cc4aad6f4d96bfbe5b086e78dac5bf17166 Parents: 101be8e Author: Oleg Nechiporenko <[email protected]> Authored: Thu May 21 14:25:07 2015 +0300 Committer: Oleg Nechiporenko <[email protected]> Committed: Thu May 21 14:25:07 2015 +0300 ---------------------------------------------------------------------- .../configs/objects/service_config_property.js | 40 +++++++ ambari-web/app/models/configs/tab.js | 1 + .../templates/common/configs/service_config.hbs | 22 ++-- .../common/configs/service_config_category.hbs | 113 ++++++++----------- .../views/common/configs/service_config_view.js | 14 ++- .../configs/service_configs_by_category_view.js | 18 +-- .../test/mappers/configs/themes_mapper_test.js | 6 +- .../service_config_container_view_test.js | 12 +- 8 files changed, 133 insertions(+), 93 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/6bb70cc4/ambari-web/app/models/configs/objects/service_config_property.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/objects/service_config_property.js b/ambari-web/app/models/configs/objects/service_config_property.js index a1e79ae..a4dffa4 100644 --- a/ambari-web/app/models/configs/objects/service_config_property.js +++ b/ambari-web/app/models/configs/objects/service_config_property.js @@ -234,6 +234,46 @@ App.ServiceConfigProperty = Em.Object.extend({ return ["masterHost", "slaveHosts", "masterHosts", "slaveHost", "radio button"].contains(this.get('displayType')); }.property('displayType'), + /** + * Used in <code>templates/common/configs/service_config_category.hbs</code> + * @type {boolean} + */ + undoAvailable: function () { + return this.get('cantBeUndone') && this.get('isNotDefaultValue'); + }.property('cantBeUndone', 'isNotDefaultValue'), + + /** + * Used in <code>templates/common/configs/service_config_category.hbs</code> + * @type {boolean} + */ + removeAvailable: function () { + return this.get('isRemovable') && !this.get('isComparison'); + }.property('isComparison', 'isRemovable'), + + /** + * Used in <code>templates/common/configs/service_config_category.hbs</code> + * @type {boolean} + */ + switchGroupAvailable: function () { + return !this.get('isEditable') && this.get('group'); + }.property('isEditable', 'group'), + + /** + * Used in <code>templates/common/configs/service_config_category.hbs</code> + * @type {boolean} + */ + setRecommendedAvailable: function () { + return this.get('isEditable') && this.get('recommendedValueExists'); + }.property('isEditable', 'recommendedValueExists'), + + /** + * Used in <code>templates/common/configs/service_config_category.hbs</code> + * @type {boolean} + */ + overrideAvailable: function () { + return !this.get('isComparison') && this.get('isPropertyOverridable'); + }.property('isPropertyOverridable', 'isComparison'), + isValid: function () { return this.get('errorMessage') === ''; }.property('errorMessage'), http://git-wip-us.apache.org/repos/asf/ambari/blob/6bb70cc4/ambari-web/app/models/configs/tab.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/tab.js b/ambari-web/app/models/configs/tab.js index fe3bd06..0940022 100644 --- a/ambari-web/app/models/configs/tab.js +++ b/ambari-web/app/models/configs/tab.js @@ -28,6 +28,7 @@ App.Tab = DS.Model.extend({ serviceName: DS.attr('string'), sections: DS.hasMany('App.Section'), isAdvancedHidden: DS.attr('boolean', {defaultValue: false}), + isRendered: DS.attr('boolean', {defaultValue: false}), /** * Number of the errors in all sections in the current tab http://git-wip-us.apache.org/repos/asf/ambari/blob/6bb70cc4/ambari-web/app/templates/common/configs/service_config.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/service_config.hbs b/ambari-web/app/templates/common/configs/service_config.hbs index ca35c09..8840a1e 100644 --- a/ambari-web/app/templates/common/configs/service_config.hbs +++ b/ambari-web/app/templates/common/configs/service_config.hbs @@ -116,15 +116,19 @@ {{#each tab in view.tabs}} <div {{bindAttr class=":tab-pane tab.isActive:active tab.id"}}> {{#if tab.isAdvanced}} - {{#each category in selectedService.configCategories}} - <div class="accordion"> - {{#if category.isCustomView}} - {{view category.customView categoryBinding="category" serviceBinding="selectedService" canEditBinding="view.canEdit" serviceConfigsBinding="selectedService.configs"}} - {{else}} - {{view App.ServiceConfigsByCategoryView categoryBinding="category" canEditBinding="view.canEdit" serviceBinding="selectedService" serviceConfigsBinding="selectedService.configs" supportsHostOverridesBinding="view.supportsHostOverrides"}} - {{/if}} - </div> - {{/each}} + {{#if tab.isRendered}} + {{#each category in selectedService.configCategories}} + <div class="accordion"> + {{#if category.isCustomView}} + {{view category.customView categoryBinding="category" serviceBinding="selectedService" canEditBinding="view.canEdit" serviceConfigsBinding="selectedService.configs"}} + {{else}} + {{view App.ServiceConfigsByCategoryView categoryBinding="category" canEditBinding="view.canEdit" serviceBinding="selectedService" serviceConfigsBinding="selectedService.configs" supportsHostOverridesBinding="view.supportsHostOverrides"}} + {{/if}} + </div> + {{/each}} + {{else}} + <div class="spinner"></div> + {{/if}} {{else}} {{! Render Enhanced Config Section }} {{view App.ServiceConfigLayoutTabView contentBinding="tab" canEditBinding="view.canEdit" }} http://git-wip-us.apache.org/repos/asf/ambari/blob/6bb70cc4/ambari-web/app/templates/common/configs/service_config_category.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/configs/service_config_category.hbs b/ambari-web/app/templates/common/configs/service_config_category.hbs index a69fca0..c6b4063 100644 --- a/ambari-web/app/templates/common/configs/service_config_category.hbs +++ b/ambari-web/app/templates/common/configs/service_config_category.hbs @@ -29,26 +29,25 @@ <div class="accordion-body collapse in" {{bindAttr style="view.isCategoryBodyVisible"}}> <div class="accordion-inner service-config-section"> <form class="form-horizontal" autocomplete="off"> - {{#each view.categoryConfigs}} - {{#unless widget}} {{! configs with widgets should be shown only on the EnhancedConfigs tabs }} + {{#unless widget}} {{! configs with widgets should be shown only on the EnhancedConfigs tabs }} <div {{bindAttr class=":entry-row isHiddenByFilter:hide isOverridden:overridden-property hasCompareDiffs:overridden-property"}}> {{#if showLabel}} <span {{bindAttr class="errorMessage:error: :control-group :control-label-span"}}> - <label class="control-label"> - {{formatWordBreak displayName}} - {{#if isSecureConfig}} - <a href="javascript:void(null);"><i class="icon-lock" rel="tooltip" data-toggle="tooltip" - title="security knob"></i></a> - {{/if}} - {{#if view.supportsHostOverrides}} - {{#if isRestartRequired}} - <i class="icon-refresh restart-required-property" - rel="tooltip" {{bindAttr title="restartRequiredMessage"}}></i> + <label class="control-label"> + {{formatWordBreak displayName}} + {{#if isSecureConfig}} + <a href="javascript:void(null);"><i class="icon-lock" rel="tooltip" data-toggle="tooltip" + title="security knob"></i></a> {{/if}} - {{/if}} - </label> - </span> + {{#if view.supportsHostOverrides}} + {{#if isRestartRequired}} + <i class="icon-refresh restart-required-property" + rel="tooltip" {{bindAttr title="restartRequiredMessage"}}></i> + {{/if}} + {{/if}} + </label> + </span> {{/if}} <div {{bindAttr class="showLabel:controls"}}> {{! Here serviceConfigBinding should ideally be serviceConfigPropertyBinding }} @@ -75,64 +74,48 @@ </a> {{/if}} {{#if view.canEdit}} - {{#if isPropertyOverridable}} - {{#if view.supportsHostOverrides}} - {{#isAccessible ADMIN}} - {{#unless this.isComparison}} - <a class="btn-small" href="#" data-toggle="tooltip" - {{action "createOverrideProperty" this target="view"}} - {{translateAttr data-original-title="common.override"}}> - <i class="icon-plus-sign"></i> - </a> - {{/unless}} - {{/isAccessible}} - {{/if}} - {{/if}} - {{#unless cantBeUndone}} - {{#if isNotDefaultValue}} - <a class="btn-small" href="#" data-toggle="tooltip" - {{action "doRestoreDefaultValue" this target="view"}} - {{translateAttr data-original-title="common.undo"}}> - <i class="icon-undo"></i> - </a> - {{/if}} - {{/unless}} - {{#if isRemovable}} + {{#if view.supportsHostOverrides}} {{#isAccessible ADMIN}} - {{#unless this.isComparison}} - <a class="btn-small" href="#" data-toggle="tooltip" - {{action "removeProperty" this target="view"}} - {{translateAttr data-original-title="common.remove"}}> - <i class="icon-minus-sign"></i> - </a> - {{/unless}} - {{/isAccessible}} - {{/if}} - {{#unless isEditable}} - {{#if group}} - <a rel='SwitchGroupTooltip' {{bindAttr data-original-title="this.group.switchGroupTextShort"}} - class="action" {{action selectConfigGroup group target="controller"}}> - {{group.switchGroupTextShort}} - </a> - {{/if}} - {{/unless}} - {{#if isEditable}} - {{#if recommendedValueExists}} - <a class="btn-small" href="#" data-toggle="tooltip" - {{action "setRecommendedValue" this target="view"}} - {{translateAttr data-original-title="services.service.config.setRecommendedValue"}}> - <i class="icon-repeat"></i> + <a href="#" data-toggle="tooltip" + {{action "createOverrideProperty" this target="view"}} + {{translateAttr data-original-title="common.override"}} + {{bindAttr class="overrideAvailable::hide :btn-small"}}> + <i class="icon-plus-sign"></i> </a> - {{/if}} + {{/isAccessible}} {{/if}} + <a href="#" data-toggle="tooltip" + {{action "doRestoreDefaultValue" this target="view"}} + {{translateAttr data-original-title="common.undo"}} + {{bindAttr class="undoAvailable::hide :btn-small"}}> + <i class="icon-undo"></i> + </a> + {{#isAccessible ADMIN}} + <a href="#" data-toggle="tooltip" + {{action "removeProperty" this target="view"}} + {{translateAttr data-original-title="common.remove"}} + {{bindAttr class="removeAvailable::hide :btn-small"}}> + <i class="icon-minus-sign"></i> + </a> + {{/isAccessible}} + <a rel='SwitchGroupTooltip' {{bindAttr data-original-title="this.group.switchGroupTextShort" class="switchGroupAvailable:show:hide :action"}} + {{action selectConfigGroup group target="controller"}}> + {{group.switchGroupTextShort}} + </a> + <a href="#" data-toggle="tooltip" + {{action "setRecommendedValue" this target="view"}} + {{translateAttr data-original-title="services.service.config.setRecommendedValue"}} + {{bindAttr class="setRecommendedAvailable::hide :btn-small"}}> + <i class="icon-repeat"></i> + </a> {{/if}} <span class="help-inline">{{errorMessage}}</span> <span class="help-inline">{{warnMessage}}</span> </div> {{#if this.isOverridden}} {{view App.ServiceConfigView.SCPOverriddenRowsView - serviceConfigPropertyBinding="this" - isDefaultGroupSelectedBinding="controller.selectedConfigGroup.isDefault" + serviceConfigPropertyBinding="this" + isDefaultGroupSelectedBinding="controller.selectedConfigGroup.isDefault" }} {{/if}} {{#if this.isComparison}} @@ -149,7 +132,7 @@ {{! For Advanced, Advanced Core Site, Advanced HDFS Site sections, show the 'Add Property' link.}} {{#isAccessible ADMIN}} {{#if view.canEdit}} - {{#if view.category.customCanAddProperty }} + {{#if view.category.customCanAddProperty}} <div> <a href="#" {{action "showAddPropertyWindow" this target="view" }} >{{t installer.step7.config.addProperty}} ...</a> http://git-wip-us.apache.org/repos/asf/ambari/blob/6bb70cc4/ambari-web/app/views/common/configs/service_config_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/service_config_view.js b/ambari-web/app/views/common/configs/service_config_view.js index 2d00bde..1070ada 100644 --- a/ambari-web/app/views/common/configs/service_config_view.js +++ b/ambari-web/app/views/common/configs/service_config_view.js @@ -114,6 +114,14 @@ App.ServiceConfigView = Em.View.extend({ this.checkCanEdit(); }, + willDestroyElement: function() { + this.get('tabs').setEach('isActive', false); + var advancedTab = this.get('tabs').findProperty('isAdvanced', true); + if (advancedTab) { + advancedTab.set('isRendered', false); + } + }, + /** * Check if we should show Custom Property category */ @@ -129,10 +137,7 @@ App.ServiceConfigView = Em.View.extend({ }); } - }.observes( - 'App.router.mainServiceInfoConfigsController.selectedConfigGroup.name', - 'App.router.wizardStep7Controller.selectedConfigGroup.name' - ), + }.observes('controller.selectedConfigGroup.name'), setActiveTab: function (event) { if (event.context.get('isHiddenByFilter')) return false; @@ -141,6 +146,7 @@ App.ServiceConfigView = Em.View.extend({ }); var currentTab = event.context; currentTab.set('isActive', true); + currentTab.set('isRendered', true); }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/6bb70cc4/ambari-web/app/views/common/configs/service_configs_by_category_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/service_configs_by_category_view.js b/ambari-web/app/views/common/configs/service_configs_by_category_view.js index 314822d..f4229ca 100644 --- a/ambari-web/app/views/common/configs/service_configs_by_category_view.js +++ b/ambari-web/app/views/common/configs/service_configs_by_category_view.js @@ -313,11 +313,20 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri */ onToggleBlock: function () { this.$('.accordion-body').toggle('blind', 500); - this.set('category.isCollapsed', !this.get('category.isCollapsed')); + this.toggleProperty('category.isCollapsed'); + }, + + /** + * Determines should accordion be collapsed by default + * @returns {boolean} + * @method calcIsCollapsed + */ + calcIsCollapsed: function() { + return Em.isNone(this.get('category.isCollapsed')) ? (this.get('category.name').indexOf('Advanced') != -1 || this.get('category.name').indexOf('CapacityScheduler') != -1 || this.get('category.name').indexOf('Custom') != -1) : this.get('category.isCollapsed'); }, didInsertElement: function () { - var isCollapsed = this.get('category.isCollapsed') == undefined ? (this.get('category.name').indexOf('Advanced') != -1 || this.get('category.name').indexOf('CapacityScheduler') != -1 || this.get('category.name').indexOf('Custom') != -1) : this.get('category.isCollapsed'); + var isCollapsed = this.calcIsCollapsed(); var self = this; this.set('category.isCollapsed', isCollapsed); if (isCollapsed) { @@ -345,11 +354,6 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri } }, - isOneOfAdvancedSections: function () { - var category = this.get('category'); - return category.indexOf("Advanced") != -1; - }, - /** * @returns {string} */ http://git-wip-us.apache.org/repos/asf/ambari/blob/6bb70cc4/ambari-web/test/mappers/configs/themes_mapper_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mappers/configs/themes_mapper_test.js b/ambari-web/test/mappers/configs/themes_mapper_test.js index aadaf71..63b937c 100644 --- a/ambari-web/test/mappers/configs/themes_mapper_test.js +++ b/ambari-web/test/mappers/configs/themes_mapper_test.js @@ -161,7 +161,8 @@ describe('App.themeMapper', function () { rows: "1", is_advanced: false, service_name: 'HDFS', - "is_advanced_hidden": false + is_advanced_hidden: false, + is_rendered: false }); //checking section @@ -220,7 +221,8 @@ describe('App.themeMapper', function () { "rows": 1, "is_advanced": true, "service_name": "HDFS", - "is_advanced_hidden": false + "is_advanced_hidden": false, + is_rendered: false }); }); }); http://git-wip-us.apache.org/repos/asf/ambari/blob/6bb70cc4/ambari-web/test/views/common/configs/service_config_container_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/service_config_container_view_test.js b/ambari-web/test/views/common/configs/service_config_container_view_test.js index abb977e..57c7fc2 100644 --- a/ambari-web/test/views/common/configs/service_config_container_view_test.js +++ b/ambari-web/test/views/common/configs/service_config_container_view_test.js @@ -42,30 +42,30 @@ describe('App.ServiceConfigContainerView', function () { describe('#selectedServiceObserver', function () { it('should add a child view', function () { - view.set('controller', { + view.set('controller', Em.Object.create({ selectedService: { configCategories: [] } - }); + })); expect(view.get('childViews')).to.have.length(1); }); it('should set controller for the view', function () { - view.set('controller', { + view.set('controller', Em.Object.create({ name: 'controller', selectedService: { configCategories: [] } - }); + })); expect(view.get('childViews.firstObject.controller.name')).to.equal('controller'); }); it('should add config categories', function () { - view.set('controller', { + view.set('controller', Em.Object.create({ selectedService: { configCategories: [Em.Object.create(), Em.Object.create()] } - }); + })); expect(view.get('childViews.firstObject.serviceConfigsByCategoryView.childViews')).to.have.length(2); });
