You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jo...@apache.org on 2016/11/14 15:46:31 UTC
[08/19] ambari git commit: AMBARI-18847. Issues after fast switching
service page tabs (akovalenko)
AMBARI-18847. Issues after fast switching service page tabs (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9e82fd10
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9e82fd10
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9e82fd10
Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 9e82fd10ca2b1615e08520881ad45d3d01ec24e6
Parents: 2d948db
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Fri Nov 11 15:28:56 2016 +0200
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Fri Nov 11 15:28:56 2016 +0200
----------------------------------------------------------------------
.../controllers/main/service/info/configs.js | 26 +++--------
.../app/controllers/wizard/step7_controller.js | 3 +-
ambari-web/app/mappers/configs/themes_mapper.js | 4 +-
ambari-web/app/mixins.js | 1 +
.../app/mixins/common/track_request_mixin.js | 47 ++++++++++++++++++++
.../app/mixins/common/widgets/widget_mixin.js | 8 ++--
.../app/mixins/main/service/groups_mapping.js | 4 +-
.../models/configs/objects/service_config.js | 1 +
ambari-web/app/utils/blueprint.js | 4 +-
ambari-web/app/utils/ember_reopen.js | 2 +-
.../configs/config_category_container_view.js | 4 +-
.../views/common/configs/config_history_flow.js | 2 +-
.../test/controllers/wizard/step7_test.js | 13 ++++++
13 files changed, 86 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 31ea248..946a1b9 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -21,7 +21,7 @@ var batchUtils = require('utils/batch_scheduled_requests');
App.MainServiceInfoConfigsController = Em.Controller.extend(App.AddSecurityConfigs, App.ConfigsLoader,
App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ThemesMappingMixin, App.ConfigsSaverMixin,
- App.ConfigsComparator, App.ComponentActionsByConfigs, {
+ App.ConfigsComparator, App.ComponentActionsByConfigs, App.TrackRequestMixin, {
name: 'mainServiceInfoConfigsController',
@@ -43,8 +43,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.AddSecurityConfi
selectedConfigGroup: null,
- requestsInProgress: [],
-
groupsStore: App.ServiceConfigGroup.find(),
/**
@@ -232,25 +230,11 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.AddSecurityConfi
},
/**
- * register request to view to track his progress
- * @param {$.ajax} request
- * @method trackRequest
- */
- trackRequest: function (request) {
- this.get('requestsInProgress').push(request);
- },
-
- /**
* clear and set properties to default value
* @method clearStep
*/
clearStep: function () {
- this.get('requestsInProgress').forEach(function(r) {
- if (r && r.readyState !== 4) {
- r.abort();
- }
- });
- this.get('requestsInProgress').clear();
+ this.abortRequests();
App.set('componentToBeAdded', {});
App.set('componentToBeDeleted', {});
this.clearLoadInfo();
@@ -305,14 +289,14 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.AddSecurityConfi
acc.push(i);
return Array.prototype.concat.apply(acc, App.StackService.find(i).get('dependentServiceNames').toArray()).without(serviceName).uniq();
}, []));
- this.loadConfigTheme(serviceName).always(function () {
+ this.trackRequest(this.loadConfigTheme(serviceName).always(function () {
if (self.get('preSelectedConfigVersion')) {
self.loadPreSelectedConfigVersion();
} else {
self.loadCurrentVersions();
}
- self.loadServiceConfigVersions();
- });
+ self.trackRequest(self.loadServiceConfigVersions());
+ }));
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index e466d4e..3d22fe9 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -42,7 +42,7 @@ var App = require('app');
* @property {?object[]} slaveComponentHosts
*/
-App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, {
+App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, App.TrackRequestMixin, {
name: 'wizardStep7Controller',
@@ -299,6 +299,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
* @method clearStep
*/
clearStep: function () {
+ this.abortRequests();
this.setProperties({
configValidationGlobalMessage: [],
submitButtonClicked: false,
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/mappers/configs/themes_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/themes_mapper.js b/ambari-web/app/mappers/configs/themes_mapper.js
index f141156..8ad51bd 100644
--- a/ambari-web/app/mappers/configs/themes_mapper.js
+++ b/ambari-web/app/mappers/configs/themes_mapper.js
@@ -329,8 +329,8 @@ App.themesMapper = App.QuickDataMapper.create({
var configProperty = App.configsCollection.getConfig(configId);
if (configProperty) {
- configProperty.widget = widget.widget;
- configProperty.widgetType = Em.get(widget, 'widget.type');
+ Em.set(configProperty, 'widget', widget.widget);
+ Em.set(configProperty, 'widgetType', Em.get(widget, 'widget.type'));
} else {
var split = widget.config.split("/");
var fileName = split[0] + '.xml';
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/mixins.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js
index 20d5a93..7b4d6b4 100644
--- a/ambari-web/app/mixins.js
+++ b/ambari-web/app/mixins.js
@@ -29,6 +29,7 @@ require('mixins/common/reload_popup');
require('mixins/common/serverValidator');
require('mixins/common/table_server_view_mixin');
require('mixins/common/table_server_mixin');
+require('mixins/common/track_request_mixin');
require('mixins/main/dashboard/widgets/editable');
require('mixins/main/dashboard/widgets/editable_with_limit');
require('mixins/main/dashboard/widgets/single_numeric_threshold');
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/mixins/common/track_request_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/track_request_mixin.js b/ambari-web/app/mixins/common/track_request_mixin.js
new file mode 100644
index 0000000..6fcc991
--- /dev/null
+++ b/ambari-web/app/mixins/common/track_request_mixin.js
@@ -0,0 +1,47 @@
+/**
+ * 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.TrackRequestMixin = Em.Mixin.create({
+
+ requestsInProgress: [],
+
+ /**
+ * register request to view to track his progress
+ * @param {$.ajax} request
+ * @method trackRequest
+ */
+ trackRequest: function (request) {
+ this.get('requestsInProgress').push(request);
+ },
+
+ /**
+ * abort all tracked requests
+ * @method abortRequest
+ */
+ abortRequests: function () {
+ this.get('requestsInProgress').forEach(function(r) {
+ if (r && r.readyState !== 4) {
+ r.abort();
+ }
+ });
+ this.get('requestsInProgress').clear();
+ }
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/mixins/common/widgets/widget_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js b/ambari-web/app/mixins/common/widgets/widget_mixin.js
index 0ccc93e..23df0c4 100644
--- a/ambari-web/app/mixins/common/widgets/widget_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js
@@ -458,9 +458,11 @@ App.WidgetMixin = Ember.Mixin.create({
if (this.get('isLoaded')) {
Em.run.next(function(){
- App.tooltip(self.$(".corner-icon > .glyphicon-copy"), {title: Em.I18n.t('common.clone')});
- App.tooltip(self.$(".corner-icon > .glyphicon-edit"), {title: Em.I18n.t('common.edit')});
- App.tooltip(self.$(".corner-icon > .glyphicon-save"), {title: Em.I18n.t('common.export')});
+ if (self.get('state') === 'inDOM') {
+ App.tooltip(self.$(".corner-icon > .glyphicon-copy"), {title: Em.I18n.t('common.clone')});
+ App.tooltip(self.$(".corner-icon > .glyphicon-edit"), {title: Em.I18n.t('common.edit')});
+ App.tooltip(self.$(".corner-icon > .glyphicon-save"), {title: Em.I18n.t('common.export')});
+ }
});
}
}.observes('isLoaded'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/mixins/main/service/groups_mapping.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/groups_mapping.js b/ambari-web/app/mixins/main/service/groups_mapping.js
index 3271714..df2fabf 100644
--- a/ambari-web/app/mixins/main/service/groups_mapping.js
+++ b/ambari-web/app/mixins/main/service/groups_mapping.js
@@ -37,7 +37,7 @@ App.GroupsMappingMixin = Em.Mixin.create({
this.set('configGroupsAreLoaded', true);
dfd.resolve();
} else {
- App.ajax.send({
+ this.trackRequest(App.ajax.send({
name: 'configs.config_groups.load.services',
sender: this,
data: {
@@ -45,7 +45,7 @@ App.GroupsMappingMixin = Em.Mixin.create({
dfd: dfd
},
success: 'saveConfigGroupsToModel'
- });
+ }));
}
return dfd.promise();
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/models/configs/objects/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/objects/service_config.js b/ambari-web/app/models/configs/objects/service_config.js
index a0800fa..7d07467 100644
--- a/ambari-web/app/models/configs/objects/service_config.js
+++ b/ambari-web/app/models/configs/objects/service_config.js
@@ -63,6 +63,7 @@ App.ServiceConfig = Ember.Object.extend({
}.observes('configs.@each.isActive', 'configs.@each.isRequiredByAgent', 'configs.@each.value'),
setActivePropertiesOnce: function() {
+ if (this.get('isDestroyed')) return false;
var activeProperties = this.get('configs').filter(function(c) {
return c.get('isActive') && (c.get('isRequiredByAgent') || c.get('isRequired'));
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/utils/blueprint.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/blueprint.js b/ambari-web/app/utils/blueprint.js
index 1216c3f..a7c9db5 100644
--- a/ambari-web/app/utils/blueprint.js
+++ b/ambari-web/app/utils/blueprint.js
@@ -355,7 +355,9 @@ module.exports = {
buildConfigsJSON: function (stepConfigs) {
var configurations = {};
stepConfigs.forEach(function (stepConfig) {
- stepConfig.get('configs').forEach(function (config) {
+ var configs = stepConfig.get('configs');
+ if (!configs) return false;
+ configs.forEach(function (config) {
var type = App.config.getConfigTagFromFileName(config.get('filename'));
if (!configurations[type]) {
configurations[type] = {properties: {}}
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/utils/ember_reopen.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ember_reopen.js b/ambari-web/app/utils/ember_reopen.js
index a616e49..4fd7cd4 100644
--- a/ambari-web/app/utils/ember_reopen.js
+++ b/ambari-web/app/utils/ember_reopen.js
@@ -232,7 +232,7 @@ Ember._HandlebarsBoundView.reopen({
if(!this.get('isDestroyed') && !this.get('isDestroying')){
this._super(buffer);
} else {
- console.debug('Calling set on destroyed view');
+ console.debug('Calling render on destroyed view');
}
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/views/common/configs/config_category_container_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/config_category_container_view.js b/ambari-web/app/views/common/configs/config_category_container_view.js
index 08cdb2c..73ded75 100644
--- a/ambari-web/app/views/common/configs/config_category_container_view.js
+++ b/ambari-web/app/views/common/configs/config_category_container_view.js
@@ -41,7 +41,9 @@ App.ConfigCategoryContainerView = Em.ContainerView.extend({
pushViews: function () {
var self = this;
var categoriesViews = [];
- this.get('categories').forEach(function (category) {
+ var categories = this.get('categories');
+ if (!categories) return false;
+ categories.forEach(function (category) {
var viewClass = category.isCustomView ? category.customView : App.ServiceConfigsByCategoryView;
categoriesViews.push(viewClass.create({
category: category,
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/app/views/common/configs/config_history_flow.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/config_history_flow.js b/ambari-web/app/views/common/configs/config_history_flow.js
index 931d994..c216890 100644
--- a/ambari-web/app/views/common/configs/config_history_flow.js
+++ b/ambari-web/app/views/common/configs/config_history_flow.js
@@ -240,7 +240,7 @@ App.ConfigHistoryFlowView = Em.View.extend({
}
});
// if there is no current version in selected group show current version from default group
- if (!currentIndex) {
+ if (!currentIndex && !Em.isNone(isCurrentInDefaultGroupIndex)) {
serviceVersions[isCurrentInDefaultGroupIndex].set('isDisplayed', true);
currentIndex = isCurrentInDefaultGroupIndex + 1;
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/9e82fd10/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index f2e917c..d6f2b00 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -372,6 +372,15 @@ describe('App.InstallerStep7Controller', function () {
});
describe('#clearStep', function () {
+
+ beforeEach(function () {
+ sinon.stub(installerStep7Controller, 'abortRequests');
+ });
+
+ afterEach(function () {
+ installerStep7Controller.abortRequests.restore();
+ });
+
it('should clear stepConfigs', function () {
installerStep7Controller.set('stepConfigs', [
{},
@@ -394,6 +403,10 @@ describe('App.InstallerStep7Controller', function () {
installerStep7Controller.clearStep();
expect(installerStep7Controller.get('filterColumns').everyProperty('selected', false)).to.equal(true);
});
+ it('should call abortRequests', function () {
+ installerStep7Controller.clearStep();
+ expect(installerStep7Controller.abortRequests.calledOnce).to.be.true;
+ });
});
describe('#getConfigTags', function () {