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/10/21 17:20:14 UTC
[26/30] ambari git commit: AMBARI-18659 Renavigating back to
"Customize Services" page from "Review" page on installer/ASW loses all
static attributes of properties (ababiichuk)
AMBARI-18659 Renavigating back to "Customize Services" page from "Review" page on installer/ASW loses all static attributes of properties (ababiichuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/562bac81
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/562bac81
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/562bac81
Branch: refs/heads/branch-feature-AMBARI-18456
Commit: 562bac816c90fcdecc11d6f6a4cc19cbe4e484a9
Parents: 18a88eb
Author: ababiichuk <ab...@hortonworks.com>
Authored: Fri Oct 21 16:16:40 2016 +0300
Committer: ababiichuk <ab...@hortonworks.com>
Committed: Fri Oct 21 16:16:40 2016 +0300
----------------------------------------------------------------------
ambari-web/app/controllers/installer.js | 26 ++---
.../main/admin/kerberos/step4_controller.js | 2 +-
.../main/admin/kerberos/wizard_controller.js | 26 ++---
.../controllers/main/service/add_controller.js | 46 +++++----
ambari-web/app/controllers/wizard.js | 29 ++++--
.../app/controllers/wizard/step7_controller.js | 6 +-
.../app/controllers/wizard/step8_controller.js | 2 +-
ambari-web/app/mixins.js | 1 +
ambari-web/app/mixins/common/persist_mixin.js | 45 +++++++++
ambari-web/app/routes/add_kerberos_routes.js | 72 +++++++------
ambari-web/app/routes/add_service_routes.js | 20 ++--
ambari-web/app/routes/installer.js | 24 +++--
ambari-web/app/utils/ajax/ajax.js | 21 ++++
ambari-web/app/utils/persist.js | 101 +++++++++++++++++++
ambari-web/test/controllers/installer_test.js | 8 +-
.../kerberos/kerberos_wizard_controler_test.js | 16 ---
.../admin/kerberos/step4_controller_test.js | 6 +-
.../test/controllers/wizard/step8_test.js | 6 +-
ambari-web/test/controllers/wizard_test.js | 19 +++-
19 files changed, 338 insertions(+), 138 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/controllers/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js
index ab1dbd4..e2c60c4 100644
--- a/ambari-web/app/controllers/installer.js
+++ b/ambari-web/app/controllers/installer.js
@@ -555,13 +555,6 @@ App.InstallerController = App.WizardController.extend({
},
/**
- * Load serviceConfigProperties to model
- */
- loadServiceConfigProperties: function () {
- var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
- this.set('content.serviceConfigProperties', serviceConfigProperties);
- },
- /**
* Generate clients list for selected services and save it to model
* @param stepController step4WizardController
*/
@@ -1015,12 +1008,18 @@ App.InstallerController = App.WizardController.extend({
{
type: 'async',
callback: function () {
- this.loadServiceConfigGroups();
- this.loadServiceConfigProperties();
- this.loadCurrentHostGroups();
- this.loadRecommendationsConfigs();
- this.loadComponentsFromConfigs();
- return this.loadConfigThemes();
+ var dfd = $.Deferred();
+ var self = this;
+ this.loadServiceConfigProperties().always(function() {
+ self.loadServiceConfigGroups();
+ self.loadCurrentHostGroups();
+ self.loadRecommendationsConfigs();
+ self.loadComponentsFromConfigs();
+ self.loadConfigThemes().then(function() {
+ dfd.resolve();
+ });
+ });
+ return dfd.promise();
}
}
]
@@ -1047,6 +1046,7 @@ App.InstallerController = App.WizardController.extend({
finish: function () {
this.setCurrentStep('0');
this.clearStorageData();
+ this.clearServiceConfigProperties();
App.router.get('userSettingsController').postUserPref('show_bg', true);
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
index 29cbfff..e43dd02 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
@@ -208,7 +208,7 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
prepareConfigProperties: function(configs) {
var self = this;
// stored configs from previous steps (Configure Kerberos or Customize Services for ASW)
- var storedServiceConfigs = this.get('wizardController').getDBProperty('serviceConfigProperties');
+ var storedServiceConfigs = this.get('wizardController.content.serviceConfigProperties');
var installedServiceNames = ['Cluster'].concat(App.Service.find().mapProperty('serviceName'));
var configProperties = configs.slice(0);
var siteProperties = App.configsCollection.getAll();
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js b/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
index 5fc1633..918742d 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/wizard_controller.js
@@ -139,14 +139,6 @@ App.KerberosWizardController = App.WizardController.extend(App.InstallComponent,
this.set('content.kerberosOption', stepController.get('selectedItem'));
},
- /**
- * Load serviceConfigProperties to model
- */
- loadServiceConfigProperties: function () {
- var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
- this.set('content.serviceConfigProperties', serviceConfigProperties);
- },
-
loadKerberosDescriptorConfigs: function () {
var kerberosDescriptorConfigs = this.getDBProperty('kerberosDescriptorConfigs');
this.set('kerberosDescriptorConfigs', kerberosDescriptorConfigs);
@@ -287,15 +279,19 @@ App.KerberosWizardController = App.WizardController.extend(App.InstallComponent,
],
'2': [
{
- type: 'sync',
+ type: 'async',
callback: function () {
var self = this;
- this.loadServiceConfigProperties();
- if (!this.get('stackConfigsLoaded')) {
- App.config.loadConfigsFromStack(['KERBEROS']).complete(function() {
- self.set('stackConfigsLoaded', true);
- }, this);
- }
+ var dfd = $.Deferred();
+ this.loadServiceConfigProperties().always(function() {
+ if (!self.get('stackConfigsLoaded')) {
+ App.config.loadConfigsFromStack(['KERBEROS']).complete(function() {
+ self.set('stackConfigsLoaded', true);
+ }, self);
+ }
+ dfd.resolve();
+ });
+ return dfd.promise();
}
}
],
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/controllers/main/service/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js
index fb4ab19..04427a2 100644
--- a/ambari-web/app/controllers/main/service/add_controller.js
+++ b/ambari-web/app/controllers/main/service/add_controller.js
@@ -123,12 +123,13 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
var self = this;
var dfd = $.Deferred();
this.loadKerberosDescriptorConfigs().done(function() {
+ self.loadServiceConfigGroups();
self.loadConfigThemes().then(function() {
- dfd.resolve();
+ self.loadServiceConfigProperties().always(function() {
+ self.loadCurrentHostGroups();
+ dfd.resolve();
+ });
});
- self.loadServiceConfigGroups();
- self.loadServiceConfigProperties();
- self.loadCurrentHostGroups();
});
return dfd.promise();
}
@@ -301,14 +302,19 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
},
loadServiceConfigProperties: function () {
- this._super();
- if (!this.get('content.services')) {
- this.loadServices();
- }
- if (this.get('currentStep') > 1 && this.get('currentStep') < 6) {
- this.set('content.skipConfigStep', this.skipConfigStep());
- this.get('isStepDisabled').findProperty('step', 4).set('value', this.get('content.skipConfigStep'));
- }
+ var self = this;
+ var dfd = $.Deferred();
+ this._super().always(function() {
+ if (!self.get('content.services')) {
+ self.loadServices();
+ }
+ if (self.get('currentStep') > 1 && self.get('currentStep') < 6) {
+ self.set('content.skipConfigStep', self.skipConfigStep());
+ self.get('isStepDisabled').findProperty('step', 4).set('value', self.get('content.skipConfigStep'));
+ }
+ dfd.resolve();
+ });
+ return dfd.promise();
},
/**
@@ -331,11 +337,16 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
},
saveServiceConfigProperties: function (stepController) {
- this._super(stepController);
- if (this.get('currentStep') > 1 && this.get('currentStep') < 6) {
- this.set('content.skipConfigStep', this.skipConfigStep());
- this.get('isStepDisabled').findProperty('step', 4).set('value', this.get('content.skipConfigStep'));
- }
+ var dfd = $.Deferred();
+ var self = this;
+ this._super(stepController).always(function() {
+ if (self.get('currentStep') > 1 && self.get('currentStep') < 6) {
+ self.set('content.skipConfigStep', self.skipConfigStep());
+ self.get('isStepDisabled').findProperty('step', 4).set('value', self.get('content.skipConfigStep'));
+ }
+ dfd.resolve();
+ });
+ return dfd.promise();
},
/**
@@ -413,6 +424,7 @@ App.AddServiceController = App.WizardController.extend(App.AddSecurityConfigs, {
finish: function () {
this.clearAllSteps();
this.clearStorageData();
+ this.clearServiceConfigProperties();
this.resetDbNamespace();
App.router.get('updateController').updateAll();
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 05cd35c..8b979cd 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -18,9 +18,11 @@
var App = require('app');
+var persistUtils = require('utils/persist');
+
require('models/host');
-App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingMixin, {
+App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingMixin, App.Persist, {
isStepDisabled: null,
@@ -907,11 +909,19 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
},
/**
- * Load serviceConfigProperties to model
+ * Load serviceConfigProperties from persist
+ * @return {$.Deferred}
*/
loadServiceConfigProperties: function () {
- var serviceConfigProperties = this.getDBProperty('serviceConfigProperties');
- this.set('content.serviceConfigProperties', serviceConfigProperties);
+ var dfd = $.Deferred();
+ var self = this;
+ this.getPersistentProperty('serviceConfigProperties').always(function(data) {
+ if (data && !data.error) {
+ self.set('content.serviceConfigProperties', data);
+ }
+ dfd.resolve();
+ });
+ return dfd.promise();
},
/**
* Save config properties
@@ -951,11 +961,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
}
}
}, this);
- this.setDBProperties({
- fileNamesToUpdate: fileNamesToUpdate,
- serviceConfigProperties: serviceConfigProperties
- });
this.set('content.serviceConfigProperties', serviceConfigProperties);
+ this.setDBProperty('fileNamesToUpdate', fileNamesToUpdate);
+ return this.setPersistentProperty('serviceConfigProperties', serviceConfigProperties);
},
isExcludedConfig: function (configProperty) {
@@ -1375,6 +1383,11 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
this.setDBProperty(stepController.name + "-sc", null);
},
+ clearServiceConfigProperties: function() {
+ this.get('content.serviceConfigProperties', null);
+ return this.removePersistentProperty('serviceConfigProperties');
+ },
+
saveTasksStatuses: function (tasksStatuses) {
this.set('content.tasksStatuses', tasksStatuses);
this.setDBProperty('tasksStatuses', tasksStatuses);
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/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 d5cbe67..0bb06d1 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -475,13 +475,13 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
this.clearStep();
var self = this;
-
App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
- var configs = this.getInitialConfigs(this.get('content.serviceConfigProperties'));
+ var storedConfigs = this.get('content.serviceConfigProperties');
+ var configs = storedConfigs && storedConfigs.length ? storedConfigs : App.configsCollection.getAll();
this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
- if (this.get('wizardController.name') === 'addServiceController' && !this.get('content.serviceConfigProperties.length')) {
+ if (this.get('wizardController.name') === 'addServiceController' && !storedConfigs) {
App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags')).done(function (loadedConfigs) {
configs = self.setInstalledServiceConfigs(configs, loadedConfigs, self.get('installedServiceNames'));
self.applyServicesConfigs(configs);
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 0ad68ed..644885b 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -522,7 +522,7 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
* @method loadHiveDbValue
*/
loadDbValue: function (serviceName) {
- var serviceConfigProperties = this.get('wizardController').getDBProperty('serviceConfigProperties');
+ var serviceConfigProperties = this.get('content.serviceConfigProperties');
var dbFull = serviceConfigProperties.findProperty('name', serviceName.toLowerCase() + '_database');
//db = serviceConfigProperties.findProperty('name', serviceName.toLowerCase() + '_ambari_database');
//since db.value contains the intial default value of <service>_admin_database (MySQL) and not the actual db type selected,
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/mixins.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js
index ee232db..016b3c8 100644
--- a/ambari-web/app/mixins.js
+++ b/ambari-web/app/mixins.js
@@ -23,6 +23,7 @@ require('mixins/common/blueprint');
require('mixins/common/kdc_credentials_controller_mixin');
require('mixins/common/localStorage');
require('mixins/common/infinite_scroll_mixin');
+require('mixins/common/persist_mixin');
require('mixins/common/userPref');
require('mixins/common/reload_popup');
require('mixins/common/serverValidator');
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/mixins/common/persist_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/persist_mixin.js b/ambari-web/app/mixins/common/persist_mixin.js
new file mode 100644
index 0000000..0b81364
--- /dev/null
+++ b/ambari-web/app/mixins/common/persist_mixin.js
@@ -0,0 +1,45 @@
+/**
+ * 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');
+var persistUtils = require('utils/persist');
+
+App.Persist = Em.Mixin.create({
+
+ persistNamespace: function() {
+ var name = this.get('name');
+ if (Em.isNone(name)) {
+ name = this.get('controller.name');
+ }
+ return name.capitalize().replace('Controller', '');
+ }.property('name'),
+
+ getPersistentProperty: function(key) {
+ return persistUtils.get(this.get('persistNamespace') + '__' + key);
+ },
+
+ setPersistentProperty: function(key, value) {
+ return persistUtils.put(this.get('persistNamespace') + '__' + key, value);
+ },
+
+ removePersistentProperty: function(key) {
+ return persistUtils.remove(this.get('persistNamespace') + '__' + key);
+ }
+
+
+});
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/routes/add_kerberos_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_kerberos_routes.js b/ambari-web/app/routes/add_kerberos_routes.js
index 64ed3a3..fe21dae 100644
--- a/ambari-web/app/routes/add_kerberos_routes.js
+++ b/ambari-web/app/routes/add_kerberos_routes.js
@@ -118,8 +118,9 @@ module.exports = App.WizardRoute.extend({
var controller = router.get('kerberosWizardController');
controller.dataLoading().done(function () {
router.get('kerberosWizardController').setCurrentStep('1');
- controller.loadAllPriorSteps();
- controller.connectOutlet('kerberosWizardStep1', controller.get('content'));
+ controller.loadAllPriorSteps().done(function() {
+ controller.connectOutlet('kerberosWizardStep1', controller.get('content'));
+ });
});
},
@@ -132,8 +133,9 @@ module.exports = App.WizardRoute.extend({
var kerberosStep1controller = router.get('kerberosWizardStep1Controller');
kerberosWizardController.saveKerberosOption(kerberosStep1controller);
- kerberosWizardController.setDBProperty('serviceConfigProperties', null);
- router.transitionTo('step2');
+ kerberosWizardController.clearServiceConfigProperties().always(function() {
+ router.transitionTo('step2');
+ });
}
}),
@@ -144,10 +146,11 @@ module.exports = App.WizardRoute.extend({
var controller = router.get('kerberosWizardController');
controller.dataLoading().done(function () {
router.get('kerberosWizardController').setCurrentStep('2');
- controller.loadAllPriorSteps();
- var kerberosWizardStep2Controller = router.get('kerberosWizardStep2Controller');
- kerberosWizardStep2Controller.set('wizardController', controller);
- controller.connectOutlet('kerberosWizardStep2', controller.get('content'));
+ controller.loadAllPriorSteps().done(function() {
+ var kerberosWizardStep2Controller = router.get('kerberosWizardStep2Controller');
+ kerberosWizardStep2Controller.set('wizardController', controller);
+ controller.connectOutlet('kerberosWizardStep2', controller.get('content'));
+ });
});
},
unroutePath: function () {
@@ -172,14 +175,15 @@ module.exports = App.WizardRoute.extend({
kerberosWizardStep2Controller.get('stepConfigs')[0].get('configs').findProperty('name', 'manage_krb5_conf').set('value', 'false');
}
- kerberosWizardController.saveServiceConfigProperties(kerberosWizardStep2Controller);
- kerberosWizardController.clearTasksData();
- if (kerberosWizardController.get('skipClientInstall')) {
- kerberosWizardController.setDBProperty('kerberosDescriptorConfigs', null);
- router.transitionTo('step4');
- } else {
- router.transitionTo('step3');
- }
+ kerberosWizardController.saveServiceConfigProperties(kerberosWizardStep2Controller).always(function() {
+ kerberosWizardController.clearTasksData();
+ if (kerberosWizardController.get('skipClientInstall')) {
+ kerberosWizardController.setDBProperty('kerberosDescriptorConfigs', null);
+ router.transitionTo('step4');
+ } else {
+ router.transitionTo('step3');
+ }
+ });
}
}),
@@ -190,8 +194,9 @@ module.exports = App.WizardRoute.extend({
var controller = router.get('kerberosWizardController');
controller.dataLoading().done(function () {
router.get('kerberosWizardController').setCurrentStep('3');
- controller.loadAllPriorSteps();
- controller.connectOutlet('kerberosWizardStep3', controller.get('content'));
+ controller.loadAllPriorSteps().done(function() {
+ controller.connectOutlet('kerberosWizardStep3', controller.get('content'));
+ });
});
},
unroutePath: function () {
@@ -215,10 +220,11 @@ module.exports = App.WizardRoute.extend({
controller.setCurrentStep(4);
controller.dataLoading().done(function () {
router.get('kerberosWizardController').setCurrentStep('4');
- controller.loadAllPriorSteps();
- controller.setLowerStepsDisable(4);
- step4Controller.set('wizardController', controller);
- controller.connectOutlet('kerberosWizardStep4', controller.get('content'));
+ controller.loadAllPriorSteps().done(function() {
+ controller.setLowerStepsDisable(4);
+ step4Controller.set('wizardController', controller);
+ controller.connectOutlet('kerberosWizardStep4', controller.get('content'));
+ });
});
},
unroutePath: function () {
@@ -254,8 +260,9 @@ module.exports = App.WizardRoute.extend({
controller.dataLoading().done(function () {
router.get('kerberosWizardController').setCurrentStep('5');
controller.setLowerStepsDisable(5);
- controller.loadAllPriorSteps();
- controller.connectOutlet('kerberosWizardStep5', controller.get('content'));
+ controller.loadAllPriorSteps().done(function() {
+ controller.connectOutlet('kerberosWizardStep5', controller.get('content'));
+ });
});
},
@@ -293,8 +300,9 @@ module.exports = App.WizardRoute.extend({
controller.dataLoading().done(function () {
router.get('kerberosWizardController').setCurrentStep('6');
controller.setLowerStepsDisable(6);
- controller.loadAllPriorSteps();
- controller.connectOutlet('kerberosWizardStep6', controller.get('content'));
+ controller.loadAllPriorSteps().done(function() {
+ controller.connectOutlet('kerberosWizardStep6', controller.get('content'));
+ });
});
},
unroutePath: function () {
@@ -320,9 +328,10 @@ module.exports = App.WizardRoute.extend({
controller.dataLoading().done(function () {
router.get('kerberosWizardController').setCurrentStep('7');
controller.setLowerStepsDisable(7);
- controller.loadAllPriorSteps();
- step7Controller.setRequest();
- controller.connectOutlet('kerberosWizardStep7', controller.get('content'));
+ controller.loadAllPriorSteps().done(function() {
+ step7Controller.setRequest();
+ controller.connectOutlet('kerberosWizardStep7', controller.get('content'));
+ });
});
},
unroutePath: function () {
@@ -342,8 +351,9 @@ module.exports = App.WizardRoute.extend({
controller.dataLoading().done(function () {
router.get('kerberosWizardController').setCurrentStep('8');
controller.setLowerStepsDisable(8);
- controller.loadAllPriorSteps();
- controller.connectOutlet('kerberosWizardStep8', controller.get('content'));
+ controller.loadAllPriorSteps().done(function() {
+ controller.connectOutlet('kerberosWizardStep8', controller.get('content'));
+ });
});
},
unroutePath: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/routes/add_service_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js
index 0dafdb7..73b0cef 100644
--- a/ambari-web/app/routes/add_service_routes.js
+++ b/ambari-web/app/routes/add_service_routes.js
@@ -223,7 +223,6 @@ module.exports = App.WizardRoute.extend({
addServiceController.saveSlaveComponentHosts(wizardStep6Controller);
addServiceController.get('content').set('serviceConfigProperties', null);
addServiceController.setDBProperties({
- serviceConfigProperties: null,
groupsToDelete: null,
recommendationsHostGroups: wizardStep6Controller.get('content.recommendationsHostGroups'),
recommendationsConfigs: null
@@ -231,7 +230,9 @@ module.exports = App.WizardRoute.extend({
router.get('wizardStep7Controller').set('recommendationsConfigs', null);
router.get('wizardStep7Controller').clearAllRecommendations();
addServiceController.setDBProperty('serviceConfigGroups', undefined);
- router.transitionTo('step4');
+ addServiceController.clearServiceConfigProperties().always(function() {
+ router.transitionTo('step4');
+ });
});
});
}
@@ -273,14 +274,15 @@ module.exports = App.WizardRoute.extend({
next: function (router) {
var addServiceController = router.get('addServiceController');
var wizardStep7Controller = router.get('wizardStep7Controller');
- addServiceController.saveServiceConfigProperties(wizardStep7Controller);
addServiceController.saveServiceConfigGroups(wizardStep7Controller, true);
- if (App.get('isKerberosEnabled')) {
- addServiceController.clearCachedStepConfigValues(router.get('kerberosWizardStep4Controller'));
- router.transitionTo('step5');
- return;
- }
- router.transitionTo('step6');
+ addServiceController.saveServiceConfigProperties(wizardStep7Controller).always(function() {
+ if (App.get('isKerberosEnabled')) {
+ addServiceController.clearCachedStepConfigValues(router.get('kerberosWizardStep4Controller'));
+ router.transitionTo('step5');
+ return;
+ }
+ router.transitionTo('step6');
+ });
}
}),
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/routes/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js
index 0cfbf20..b4aa799 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -360,14 +360,15 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
controller.get('content').set('serviceConfigProperties', null);
controller.get('content').set('componentsFromConfigs', []);
controller.setDBProperties({
- serviceConfigProperties: null,
serviceConfigGroups: null,
recommendationsHostGroups: wizardStep6Controller.get('content.recommendationsHostGroups'),
recommendationsConfigs: null,
componentsFromConfigs: []
});
- router.transitionTo('step7');
- console.timeEnd('step6 next');
+ controller.clearServiceConfigProperties().then(function() {
+ router.transitionTo('step7');
+ console.timeEnd('step6 next');
+ });
}
});
}
@@ -418,14 +419,15 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
App.set('router.nextBtnClickInProgress', true);
var controller = router.get('installerController');
var wizardStep7Controller = router.get('wizardStep7Controller');
- controller.saveServiceConfigProperties(wizardStep7Controller);
- controller.saveServiceConfigGroups(wizardStep7Controller);
- controller.setDBProperty('recommendationsConfigs', wizardStep7Controller.get('recommendationsConfigs'));
- controller.saveComponentsFromConfigs(controller.get('content.componentsFromConfigs'));
- controller.setDBProperty('recommendationsHostGroup', wizardStep7Controller.get('content.recommendationsHostGroup'));
- controller.setDBProperty('masterComponentHosts', wizardStep7Controller.get('content.masterComponentHosts'));
- router.transitionTo('step8');
- console.timeEnd('step7 next');
+ controller.saveServiceConfigProperties(wizardStep7Controller).always(function() {
+ controller.saveServiceConfigGroups(wizardStep7Controller);
+ controller.setDBProperty('recommendationsConfigs', wizardStep7Controller.get('recommendationsConfigs'));
+ controller.saveComponentsFromConfigs(controller.get('content.componentsFromConfigs'));
+ controller.setDBProperty('recommendationsHostGroup', wizardStep7Controller.get('content.recommendationsHostGroup'));
+ controller.setDBProperty('masterComponentHosts', wizardStep7Controller.get('content.masterComponentHosts'));
+ router.transitionTo('step8');
+ console.timeEnd('step7 next');
+ });
}
}
}),
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index b761a14..6c7ed88 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2180,6 +2180,27 @@ var urls = {
'mock': '/data/requests/host_check/1.json'
},
+ 'persist.get': {
+ 'real': '/persist/{key}',
+ 'mock': '',
+ 'type': 'GET',
+ 'format': function() {
+ return {
+ dataType: 'text'
+ }
+ }
+ },
+ 'persist.put': {
+ 'real': '/persist',
+ 'mock': '',
+ 'type': 'POST',
+ 'format': function (data) {
+ return {
+ data: JSON.stringify(data.keyValuePair)
+ }
+ }
+ },
+
'wizard.step3.rerun_checks': {
'real': '/hosts?fields=Hosts/last_agent_env',
'mock': '/data/wizard/bootstrap/two_hosts_information.json',
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/app/utils/persist.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/persist.js b/ambari-web/app/utils/persist.js
new file mode 100644
index 0000000..3d3164f
--- /dev/null
+++ b/ambari-web/app/utils/persist.js
@@ -0,0 +1,101 @@
+/**
+ * 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 LZString = require('utils/lz-string');
+/**
+ * Persist storage managing utils. It helps to put and get values from persisted storage
+ * by api (/api/v1/persist).
+ * @type {Object}
+ */
+module.exports = {
+ /**
+ * Get item from persist storage by key and optional path.
+ *
+ * @param {String} key persist key to get e.g 'CLUSTER_STATUS', will fetch data from
+ * /api/v1/persist/CLUSTER_STATUS
+ * @param {String} [path=null] Em.get compatible attributes path
+ * @return {$.Deferred}
+ */
+ get: function(key, path) {
+ var dfd = $.Deferred();
+ App.ajax.send({
+ name: 'persist.get',
+ sender: this,
+ data: {
+ deferred: dfd,
+ key: key || '',
+ path: path
+ },
+ success: 'getSuccessCallback',
+ error: 'getErrorCallback'
+ });
+ return dfd.promise();
+ },
+
+ getSuccessCallback: function(data, xhr, params) {
+ var extracted, response = data;
+ try {
+ response = JSON.parse(response);
+ } catch(e) { }
+ if (Em.isEmpty(data)) {
+ params.deferred.resolve(null);
+ return;
+ }
+ if (typeof response === 'string') {
+ extracted = JSON.parse(LZString.decompressFromBase64(response));
+ params.deferred.resolve(params.path ? Em.get(extracted, params.path) : extracted);
+ } else {
+ params.deferred.resolve(response);
+ }
+ },
+
+ getErrorCallback: function(request, ajaxOptions, error, opt, params) {
+ params.deferred.reject({
+ request: request,
+ error: error
+ });
+ },
+
+ /**
+ * Update key value.
+ *
+ * @param {String} key
+ * @param {Object} value value to save
+ * @return {$.Deferred}
+ */
+ put: function(key, value) {
+ var kv = {};
+ kv[key] = !Em.isEmpty(value) ? LZString.compressToBase64(JSON.stringify(value)) : '';
+ return App.ajax.send({
+ name: 'persist.put',
+ sender: this,
+ data: {
+ keyValuePair: kv
+ },
+ success: 'putSuccessCallback',
+ error: 'putErrorCallback'
+ });
+ },
+
+ putSuccessCallback: function() {},
+ putErrorCallback: function() {},
+
+ remove: function(key) {
+ return this.put(key, '');
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/test/controllers/installer_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/installer_test.js b/ambari-web/test/controllers/installer_test.js
index 3b77b9a..441af87 100644
--- a/ambari-web/test/controllers/installer_test.js
+++ b/ambari-web/test/controllers/installer_test.js
@@ -608,6 +608,7 @@ describe('App.InstallerController', function () {
},
loadServiceConfigProperties: function() {
loadServiceConfigProperties = true;
+ return $.Deferred().resolve().promise();
},
loadCurrentHostGroups: function() {
loadCurrentHostGroups = true;
@@ -620,6 +621,7 @@ describe('App.InstallerController', function () {
},
loadConfigThemes: function() {
loadConfigThemes = true;
+ return $.Deferred().resolve().promise();
}
};
@@ -785,12 +787,12 @@ describe('App.InstallerController', function () {
describe('#loadServiceConfigProperties', function() {
beforeEach(function () {
- sinon.stub(installerController, 'getDBProperty').returns({
+ sinon.stub(installerController, 'getPersistentProperty').returns($.Deferred().resolve({
value: 2
- });
+ }).promise());
});
afterEach(function () {
- installerController.getDBProperty.restore();
+ installerController.getPersistentProperty.restore();
});
it ('Should load service config property', function() {
installerController.loadServiceConfigProperties();
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js b/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
index 2d792f2..f6754d5 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/kerberos_wizard_controler_test.js
@@ -193,22 +193,6 @@ describe('App.KerberosWizardController', function() {
});
});
- describe("#loadServiceConfigProperties()", function () {
-
- beforeEach(function() {
- sinon.stub(controller, 'getDBProperty').returns([{}]);
- });
-
- afterEach(function() {
- controller.getDBProperty.restore();
- });
-
- it("serviceConfigProperties should be set", function() {
- controller.loadServiceConfigProperties();
- expect(controller.get('content.serviceConfigProperties')).to.be.eql([{}]);
- });
- });
-
describe("#loadKerberosDescriptorConfigs()", function () {
beforeEach(function() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
index 1713e9c..96f89f4 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
@@ -147,10 +147,10 @@ describe('App.KerberosWizardStep4Controller', function() {
before(function() {
var controller = App.KerberosWizardStep4Controller.create({
wizardController: {
- getDBProperty: function() {
- return Em.A([
+ content: {
+ serviceConfigProperties: Em.A([
Em.Object.create({ name: 'realm', value: 'realm_value' })
- ]);
+ ])
},
loadCachedStepConfigValues: function() {
return null;
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js b/ambari-web/test/controllers/wizard/step8_test.js
index 9214631..217900f 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -900,11 +900,9 @@ describe('App.WizardStep8Controller', function () {
installerStep8Controller.set('wizardController', Em.Object.create({
getDBProperty: Em.K
}));
- this.mock = sinon.stub(installerStep8Controller.get('wizardController'), 'getDBProperty');
});
afterEach(function() {
- this.mock.restore();
});
var tests = [
@@ -928,10 +926,10 @@ describe('App.WizardStep8Controller', function () {
tests.forEach(function(test) {
it(test.it, function() {
- this.mock.returns(test.serviceConfigProperties);
+ installerStep8Controller.set('content.serviceConfigProperties', test.serviceConfigProperties);
var dbComponent = installerStep8Controller.loadDbValue(test.serviceName);
expect(dbComponent).to.equal(test.result);
- })
+ });
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/562bac81/ambari-web/test/controllers/wizard_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index 6854c42..a2bdfae 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -1052,14 +1052,18 @@ describe('App.WizardController', function () {
beforeEach(function () {
c.set('content', {});
+ sinon.stub(c, 'setDBProperty', Em.K);
sinon.stub(c, 'setDBProperties', Em.K);
sinon.stub(c, 'getDBProperty').withArgs('fileNamesToUpdate').returns([]);
+ sinon.stub(c, 'setPersistentProperty', Em.K);
sinon.stub(App.config, 'shouldSupportFinal').returns(true);
});
afterEach(function () {
+ c.setDBProperty.restore();
c.setDBProperties.restore();
c.getDBProperty.restore();
+ c.setPersistentProperty.restore();
App.config.shouldSupportFinal.restore();
});
@@ -1100,7 +1104,7 @@ describe('App.WizardController', function () {
value: 'value',
serviceName: 'serviceName',
isFinal: true,
- filename: 'hdfs-site',
+ filename: 'hdfs-site'
}),
Em.Object.create({
name: 'name2',
@@ -1119,7 +1123,16 @@ describe('App.WizardController', function () {
value: 'value',
serviceName: 'serviceName',
isFinal: true,
- filename: 'filename'
+ filename: 'filename',
+ defaultIsFinal: true,
+ supportsFinal: true,
+ displayType: 'string',
+ isRequiredByAgent: true,
+ hasInitialValue: true,
+ isRequired: true,
+ group: {name: 'group'},
+ showLabel: true,
+ category: 'some_category'
})
]
})
@@ -1128,7 +1141,7 @@ describe('App.WizardController', function () {
it('should save configs from default config group to content.serviceConfigProperties', function () {
c.saveServiceConfigProperties(stepController);
var saved = c.get('content.serviceConfigProperties');
- expect(saved.length).to.equal(3);
+ expect(saved.length).to.equal(2);
});
it('should not save admin_principal or admin_password to the localStorage', function () {