You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2018/11/08 13:08:35 UTC
[ambari] branch trunk updated: AMBARI-24868 JS error when changing
service auto-start toggle
This is an automated email from the ASF dual-hosted git repository.
atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new a46fd29 AMBARI-24868 JS error when changing service auto-start toggle
a46fd29 is described below
commit a46fd29294a64a8672d7e091ea4fb459e7299328
Author: Andrii Tkach <at...@apache.org>
AuthorDate: Thu Nov 8 13:13:16 2018 +0200
AMBARI-24868 JS error when changing service auto-start toggle
---
.../app/controllers/global/update_controller.js | 9 ++--
.../controllers/main/admin/service_auto_start.js | 44 +++++++++---------
.../controllers/global/update_controller_test.js | 4 +-
.../main/admin/service_auto_start_test.js | 53 +++++++++-------------
4 files changed, 52 insertions(+), 58 deletions(-)
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 5d6b15de..6ab57dd 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -685,10 +685,11 @@ App.UpdateController = Em.Controller.extend({
},
configsChangedHandler: function(event) {
- if (event.configs && event.configs.someProperty('type', 'cluster-env')) {
- this.updateClusterEnv();
- }
- App.router.get('configurationController').updateConfigTags();
+ App.router.get('configurationController').updateConfigTags().always(() => {
+ if (event.configs && event.configs.someProperty('type', 'cluster-env')) {
+ this.updateClusterEnv();
+ }
+ });
},
//TODO - update service auto-start to use this
diff --git a/ambari-web/app/controllers/main/admin/service_auto_start.js b/ambari-web/app/controllers/main/admin/service_auto_start.js
index 1eb4cc7..d5a4fd6 100644
--- a/ambari-web/app/controllers/main/admin/service_auto_start.js
+++ b/ambari-web/app/controllers/main/admin/service_auto_start.js
@@ -37,11 +37,11 @@ App.MainAdminServiceAutoStartController = Em.Controller.extend({
*/
componentsConfigsCachedMap: function() {
const map = {};
- this.get('componentsConfigsCached').mapProperty('ServiceComponentInfo').forEach((component) => {
+ this.get('componentsConfigsCached').forEach((component) => {
map[component.component_name] = component.recovery_enabled === 'true'
});
return map;
- }.property('componentsConfigsCached.@each.ServiceComponentInfo.recovery_enabled'),
+ }.property('componentsConfigsCached.@each.recovery_enabled'),
/**
* @type {Array}
@@ -94,23 +94,19 @@ App.MainAdminServiceAutoStartController = Em.Controller.extend({
}.property('componentsConfigsGrouped.@each.recoveryEnabled', 'componentsConfigsCachedMap'),
parseComponentConfigs: function(componentsConfigsCached) {
- componentsConfigsCached.sortPropertyLight('ServiceComponentInfo.service_name');
+ componentsConfigsCached.sortPropertyLight('service_name');
const componentsConfigsGrouped = [];
- const servicesMap = componentsConfigsCached
- .mapProperty('ServiceComponentInfo.service_name').uniq().toWickMap();
-
- componentsConfigsCached.mapProperty('ServiceComponentInfo').forEach((component) => {
- // Hide clients, as the are not restartable, components which are not installed
- if (App.StackServiceComponent.find(component.component_name).get('isRestartable') && component.total_count) {
- componentsConfigsGrouped.push(Em.Object.create({
- serviceDisplayName: App.format.role(component.service_name, true),
- isFirst: servicesMap[component.service_name],
- componentName: component.component_name,
- displayName: App.format.role(component.component_name, false),
- recoveryEnabled: component.recovery_enabled === 'true'
- }));
- servicesMap[component.service_name] = false;
- }
+ const servicesMap = componentsConfigsCached.mapProperty('service_name').uniq().toWickMap();
+
+ componentsConfigsCached.forEach((component) => {
+ componentsConfigsGrouped.push(Em.Object.create({
+ serviceDisplayName: App.format.role(component.service_name, true),
+ isFirst: servicesMap[component.service_name],
+ componentName: component.component_name,
+ displayName: App.format.role(component.component_name, false),
+ recoveryEnabled: component.recovery_enabled === 'true'
+ }));
+ servicesMap[component.service_name] = false;
});
return componentsConfigsGrouped;
},
@@ -140,8 +136,12 @@ App.MainAdminServiceAutoStartController = Em.Controller.extend({
},
loadComponentsConfigsSuccess: function (data) {
- this.set('componentsConfigsCached', data.items);
- this.set('componentsConfigsGrouped', this.parseComponentConfigs(data.items));
+ const restartableComponents = data.items.mapProperty('ServiceComponentInfo').filter((component) => {
+ // Hide clients, as the are not restartable, components which are not installed
+ return App.StackServiceComponent.find(component.component_name).get('isRestartable') && component.total_count > 0;
+ });
+ this.set('componentsConfigsCached', restartableComponents);
+ this.set('componentsConfigsGrouped', this.parseComponentConfigs(restartableComponents));
},
saveClusterConfigs: function (clusterConfigs, recoveryEnabled) {
@@ -172,9 +172,9 @@ App.MainAdminServiceAutoStartController = Em.Controller.extend({
syncStatus: function () {
const componentsConfigsGrouped = this.get('componentsConfigsGrouped');
this.set('isGeneralRecoveryEnabledCached', this.get('isGeneralRecoveryEnabled'));
- this.get('componentsConfigsCached').mapProperty('ServiceComponentInfo').forEach((component) => {
+ this.get('componentsConfigsCached').forEach((component) => {
const actualComponent = componentsConfigsGrouped.findProperty('componentName', component.component_name);
- component.recovery_enabled = String(actualComponent.get('recoveryEnabled'));
+ Ember.set(component, 'recovery_enabled', String(actualComponent.get('recoveryEnabled')));
});
this.propertyDidChange('componentsConfigsCached');
},
diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js
index dabb4e1..5ca5703 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -542,7 +542,9 @@ describe('App.UpdateController', function () {
describe('#configsChangedHandler', function() {
beforeEach(function() {
sinon.stub(c, 'updateClusterEnv');
- sinon.stub(App.router.get('configurationController'), 'updateConfigTags');
+ sinon.stub(App.router.get('configurationController'), 'updateConfigTags').returns({
+ always: Em.clb
+ });
});
afterEach(function() {
c.updateClusterEnv.restore();
diff --git a/ambari-web/test/controllers/main/admin/service_auto_start_test.js b/ambari-web/test/controllers/main/admin/service_auto_start_test.js
index 5e8983e..30c0c4d 100644
--- a/ambari-web/test/controllers/main/admin/service_auto_start_test.js
+++ b/ambari-web/test/controllers/main/admin/service_auto_start_test.js
@@ -31,31 +31,18 @@ describe('App.MainAdminServiceAutoStartController', function() {
describe('#parseComponentConfigs', function() {
var components = [
{
- ServiceComponentInfo: {
- service_name: 'S1',
- component_name: 'C1',
- recovery_enabled: 'true',
- category: 'SLAVE',
- total_count: 1
- }
- },
- {
- ServiceComponentInfo: {
- service_name: 'S1',
- component_name: 'C2',
- recovery_enabled: 'false',
- total_count: 2,
- category: 'SLAVE',
- }
+ service_name: 'S1',
+ component_name: 'C1',
+ recovery_enabled: 'true',
+ category: 'SLAVE',
+ total_count: 1
},
{
- ServiceComponentInfo: {
- category: 'SLAVE',
- service_name: 'S2',
- component_name: 'C1',
- recovery_enabled: 'false',
- total_count: 0
- }
+ service_name: 'S1',
+ component_name: 'C2',
+ recovery_enabled: 'false',
+ total_count: 2,
+ category: 'SLAVE',
}
];
it('should return parsed components, filter out not installed components', function() {
@@ -142,18 +129,24 @@ describe('App.MainAdminServiceAutoStartController', function() {
beforeEach(function() {
sinon.stub(controller, 'parseComponentConfigs').returns({});
+ sinon.stub(App.StackServiceComponent, 'find').returns(Em.Object.create({
+ isRestartable: true
+ }));
+ controller.loadComponentsConfigsSuccess({items: [
+ {ServiceComponentInfo:{total_count: 0}},
+ {ServiceComponentInfo:{total_count: 1}}
+ ]});
});
afterEach(function() {
controller.parseComponentConfigs.restore();
+ App.StackServiceComponent.find.restore();
});
it('componentsConfigsCached should be set', function() {
- controller.loadComponentsConfigsSuccess({items: [{prop1: 'val1'}]});
- expect(controller.get('componentsConfigsCached')).to.be.eql([{prop1: 'val1'}]);
+ expect(controller.get('componentsConfigsCached')).to.be.eql([{total_count: 1}]);
});
it('componentsConfigsGrouped should be set', function() {
- controller.loadComponentsConfigsSuccess({items: {prop1: 'val1'}});
expect(controller.get('componentsConfigsGrouped')).to.be.eql({});
});
});
@@ -204,10 +197,8 @@ describe('App.MainAdminServiceAutoStartController', function() {
controller.set('isGeneralRecoveryEnabled', true);
controller.set('componentsConfigsCached', [
{
- ServiceComponentInfo: {
- component_name: 'C1',
- recovery_enabled: 'false'
- }
+ component_name: 'C1',
+ recovery_enabled: 'false'
}
]);
controller.set('componentsConfigsGrouped', [
@@ -217,7 +208,7 @@ describe('App.MainAdminServiceAutoStartController', function() {
})
]);
controller.syncStatus();
- expect(controller.get('componentsConfigsCached')[0].ServiceComponentInfo.recovery_enabled).to.be.equal('true');
+ expect(controller.get('componentsConfigsCached')[0].recovery_enabled).to.be.equal('true');
expect(controller.get('isGeneralRecoveryEnabledCached')).to.be.true;
});
});