You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2016/04/12 18:06:56 UTC
ambari git commit: AMBARI-15839: Wrong config group names after
renaming and creating group with the same name (akovalenko)
Repository: ambari
Updated Branches:
refs/heads/trunk ba610b5cf -> 7256ef0b9
AMBARI-15839: Wrong config group names after renaming and creating group with the same name (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7256ef0b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7256ef0b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7256ef0b
Branch: refs/heads/trunk
Commit: 7256ef0b9b0da1fa4b3207c390261871ca9e2ced
Parents: ba610b5
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Tue Apr 12 18:16:28 2016 +0300
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Tue Apr 12 19:06:46 2016 +0300
----------------------------------------------------------------------
.../controllers/main/service/info/configs.js | 9 +-
.../service/manage_config_groups_controller.js | 21 ++--
ambari-web/app/controllers/wizard.js | 4 +-
.../app/controllers/wizard/step7_controller.js | 4 +-
.../app/controllers/wizard/step8_controller.js | 3 +-
.../app/mappers/configs/config_groups_mapper.js | 18 ++--
.../configs/service_config_version_mapper.js | 3 +-
ambari-web/app/mixins.js | 1 -
.../app/mixins/common/configs/configs_loader.js | 2 +-
.../app/mixins/common/configs/configs_saver.js | 8 +-
.../main/service/configs/config_overridable.js | 51 ++++-----
.../app/mixins/main/service/versions_mapping.js | 107 -------------------
ambari-web/app/models/configs/config_group.js | 37 ++++---
.../models/configs/service_config_version.js | 2 +-
ambari-web/app/utils/ajax/ajax.js | 2 +-
.../views/common/configs/config_history_flow.js | 2 +-
.../test/controllers/wizard/step7_test.js | 18 ++--
.../test/models/configs/config_group_test.js | 2 -
18 files changed, 95 insertions(+), 199 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/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 738d235..abe1469 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -18,9 +18,8 @@
var App = require('app');
var batchUtils = require('utils/batch_scheduled_requests');
-var databaseUtils = require('utils/configs/database');
-App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ThemesMappingMixin, App.VersionsMappingMixin, App.ConfigsSaverMixin, App.ConfigsComparator, App.ComponentActionsByConfigs, {
+App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ThemesMappingMixin, App.ConfigsSaverMixin, App.ConfigsComparator, App.ComponentActionsByConfigs, {
name: 'mainServiceInfoConfigsController',
@@ -221,7 +220,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A
* @method isVersionDefault
*/
isVersionDefault: function(version) {
- return (App.ServiceConfigVersion.find(this.get('content.serviceName') + "_" + version).get('groupId') == -1);
+ return (App.ServiceConfigVersion.find(this.get('content.serviceName') + "_" + version).get('groupName') === 'default');
},
/**
@@ -735,9 +734,9 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ConfigsLoader, A
*/
doSelectConfigGroup: function (event) {
App.loadTimer.start('Service Configs Page');
- var configGroupVersions = App.ServiceConfigVersion.find().filterProperty('groupId', event.context.get('configGroupId'));
+ var configGroupVersions = App.ServiceConfigVersion.find().filterProperty('groupId', event.context.get('id'));
//check whether config group has config versions
- if (event.context.get('configGroupId') == -1) {
+ if (event.context.get('isDefault')) {
this.loadCurrentVersions();
} else if (configGroupVersions.length > 0) {
this.loadSelectedVersion(configGroupVersions.findProperty('isCurrent').get('version'), event.context);
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
index 514b546..d8bfa32 100644
--- a/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
+++ b/ambari-web/app/controllers/main/service/manage_config_groups_controller.js
@@ -187,7 +187,6 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
} else {
groupsToCreate.push({
id: groupRecord.get('id'),
- config_group_id: groupRecord.get('configGroupId'),
name: groupRecord.get('name'),
description: groupRecord.get('description'),
hosts: groupRecord.get('hosts').slice(0),
@@ -419,7 +418,6 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
createOriginalRecord: function (configGroup) {
return {
id: configGroup.get('id'),
- config_group_id: configGroup.get('configGroupId'),
name: configGroup.get('name'),
service_name: configGroup.get('serviceName'),
description: configGroup.get('description'),
@@ -638,12 +636,10 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
}.property('warningMessage', 'configGroupName', 'configGroupDesc'),
onPrimary: function () {
- var renamedGroup = self.createOriginalRecord(self.get('selectedConfigGroup'));
- renamedGroup.name = this.get('configGroupName');
- renamedGroup.description = this.get('configGroupDesc');
- App.store.load(App.ServiceConfigGroup, renamedGroup);
- App.store.commit();
- App.configGroupsMapper.deleteRecord(self.get('selectedConfigGroup'));
+ self.get('selectedConfigGroup').setProperties({
+ name: this.get('configGroupName'),
+ description: this.get('configGroupDesc')
+ });
this.hide();
}
});
@@ -699,7 +695,7 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
var defaultConfigGroup = self.get('configGroups').findProperty('isDefault'),
properties = [], serviceName = self.get('serviceName'),
groupName = this.get('configGroupName').trim(),
- newGroupId = App.ServiceConfigGroup.groupId(serviceName, groupName);
+ newGroupId = (new Date()).getTime();
if (duplicated) {
self.get('selectedConfigGroup.properties').forEach(function (item) {
@@ -711,15 +707,16 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
App.store.load(App.ServiceConfigGroup, {
id: newGroupId,
- name: this.get('configGroupName').trim(),
+ name: groupName,
description: this.get('configGroupDesc'),
isDefault: false,
- parent_config_group_id: App.ServiceConfigGroup.getParentConfigGroupId(serviceName),
+ parent_config_group_id: serviceName + '_default',
service_id: serviceName,
service_name: serviceName,
hosts: [],
desired_configs: duplicated ? self.get('selectedConfigGroup.desiredConfigs') : [],
- properties: duplicated ? properties : []
+ properties: duplicated ? properties : [],
+ is_temporary: true
});
App.store.commit();
var childConfigGroups = defaultConfigGroup.get('childConfigGroups').mapProperty('id');
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 27bef23..81f9609 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -971,9 +971,9 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
service_name: configGroup.get('serviceName'),
service_id: configGroup.get('serviceName'),
desired_configs: configGroup.get('desiredConfigs'),
- config_group_id: configGroup.get('configGroupId'),
child_config_groups: configGroup.get('childConfigGroups') ? configGroup.get('childConfigGroups').mapProperty('id') : [],
- parent_config_group_id: configGroup.get('parentConfigGroup.id')
+ parent_config_group_id: configGroup.get('parentConfigGroup.id'),
+ is_temporary: configGroup.get('isTemporary')
});
}, this)
}, this);
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/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 0520c8f..786b990 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -992,9 +992,9 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
setGroupsToDelete: function (groups) {
var groupsToDelete = this.get('groupsToDelete');
groups.forEach(function (group) {
- if (group.get('configGroupId'))
+ if (!group.get('isTemporary'))
groupsToDelete.push({
- configGroupId: group.get('configGroupId')
+ id: group.get('id')
});
});
this.get('wizardController').setDBProperty('groupsToDelete', groupsToDelete);
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/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 f708a5f..ad53291 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1447,10 +1447,11 @@ App.WizardStep8Controller = Em.Controller.extend(App.AddSecurityConfigs, App.wiz
this.removeInstalledServicesConfigurationGroups(groupsToDelete);
}
configGroups.forEach(function (configGroup) {
- if (configGroup.is_for_update || !configGroup.config_group_id) {
+ if (configGroup.is_for_update || configGroup.is_temporary) {
this.saveGroup(configGroup.properties, configGroup, this.getServiceConfigNote('', configGroup.service_id));
}
}, this);
+ App.ServiceConfigGroup.deleteTemporaryRecords();
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/mappers/configs/config_groups_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/config_groups_mapper.js b/ambari-web/app/mappers/configs/config_groups_mapper.js
index 2e710f4..545cbb1 100644
--- a/ambari-web/app/mappers/configs/config_groups_mapper.js
+++ b/ambari-web/app/mappers/configs/config_groups_mapper.js
@@ -25,8 +25,7 @@ var App = require('app');
App.configGroupsMapper = App.QuickDataMapper.create({
model: App.ServiceConfigGroup,
config: {
- id: 'id',
- config_group_id: 'ConfigGroup.id',
+ id: 'ConfigGroup.id',
name: 'ConfigGroup.group_name',
service_name: 'ConfigGroup.tag',
description: 'ConfigGroup.description',
@@ -39,8 +38,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
* using this config when saving group from config_version api
*/
config2: {
- id: 'id',
- config_group_id: 'group_id',
+ id: 'group_id',
name: 'group_name',
service_name: 'service_name',
hosts: 'hosts',
@@ -93,7 +91,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
hostNamesForService[configGroup.service_name].splice(hostNamesForService[configGroup.service_name].indexOf(host), 1);
});
configGroup = this.parseIt(configGroup, (mapFromVersions ? this.get('config2') : this.get('config')));
- configGroup.parent_config_group_id = App.ServiceConfigGroup.getParentConfigGroupId(configGroup.service_name);
+ configGroup.parent_config_group_id = configGroup.service_name + '_default';
configGroups.push(configGroup);
}
}, this);
@@ -108,7 +106,7 @@ App.configGroupsMapper = App.QuickDataMapper.create({
configGroups.sort(function (configGroupA, configGroupB) {
- return configGroupA.config_group_id == -1 || (configGroupA.name > configGroupB.name);
+ return configGroupA.is_default || (configGroupA.name > configGroupB.name);
});
App.store.loadMany(this.get('model'), configGroups);
App.store.commit();
@@ -121,12 +119,11 @@ App.configGroupsMapper = App.QuickDataMapper.create({
* @param {string} serviceName
* @param {string[]} [hostNames=null]
* @param {Array} childConfigGroups
- * @returns {{id: string, config_group_id: string, name: string, service_name: string, description: string, host_names: [string], service_id: string}}
+ * @returns {{id: string, name: string, service_name: string, description: string, host_names: [string], service_id: string, is_default: boolean}}
*/
generateDefaultGroup: function (serviceName, hostNames, childConfigGroups) {
return {
- id: App.ServiceConfigGroup.getParentConfigGroupId(serviceName),
- config_group_id: -1,
+ id: serviceName + '_' + 'default',
name: 'Default',
service_name: serviceName,
description: 'Default cluster level ' + App.format.role(serviceName, true) + ' configuration',
@@ -134,7 +131,8 @@ App.configGroupsMapper = App.QuickDataMapper.create({
child_config_groups: childConfigGroups ? childConfigGroups.uniq() : [],
service_id: serviceName,
desired_configs: [],
- properties: []
+ properties: [],
+ is_default: true
}
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/mappers/configs/service_config_version_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/service_config_version_mapper.js b/ambari-web/app/mappers/configs/service_config_version_mapper.js
index 2a459de..780c368 100644
--- a/ambari-web/app/mappers/configs/service_config_version_mapper.js
+++ b/ambari-web/app/mappers/configs/service_config_version_mapper.js
@@ -53,6 +53,7 @@ App.serviceConfigVersionsMapper = App.QuickDataMapper.create({
json.items.forEach(function (item, index) {
var parsedItem = this.parseIt(item, this.get('config'));
parsedItem.id = this.makeId(parsedItem.service_name, parsedItem.version);
+ parsedItem.group_id = parsedItem.group_id === -1 ? parsedItem.service_name + '_default' : parsedItem.group_id;
parsedItem.is_requested = true;
parsedItem.create_time = App.dateTimeWithTimeZone(parsedItem.create_time);
itemIds[parsedItem.id] = true;
@@ -86,7 +87,7 @@ App.serviceConfigVersionsMapper = App.QuickDataMapper.create({
defaultHostNames = defaultHostNames.without(serviceToHostMap[sName][i]);
}
var defVer = result.find(function(v) {
- return v.is_current && v.group_id == -1 && v.service_name == sName;
+ return v.is_current && v.group_name === 'default' && v.service_name == sName;
});
if (defVer) {
defVer.hosts = defaultHostNames;
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/mixins.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js
index 23d447b..cf8cef6 100644
--- a/ambari-web/app/mixins.js
+++ b/ambari-web/app/mixins.js
@@ -36,7 +36,6 @@ require('mixins/main/host/details/actions/install_new_version');
require('mixins/main/host/details/support_client_configs_download');
require('mixins/main/service/groups_mapping');
require('mixins/main/service/themes_mapping');
-require('mixins/main/service/versions_mapping');
require('mixins/main/service/configs/config_overridable');
require('mixins/main/service/configs/widget_popover_support');
require('mixins/main/service/configs/component_actions_by_configs');
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/mixins/common/configs/configs_loader.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_loader.js b/ambari-web/app/mixins/common/configs/configs_loader.js
index 5fc44a9..2cd6ea2 100644
--- a/ambari-web/app/mixins/common/configs/configs_loader.js
+++ b/ambari-web/app/mixins/common/configs/configs_loader.js
@@ -62,7 +62,7 @@ App.ConfigsLoader = Em.Mixin.create(App.GroupsMappingMixin, {
loadServiceConfigVersionsSuccess: function (data) {
if (Em.get(data, 'items.length')) {
App.serviceConfigVersionsMapper.map(data);
- var currentDefault = data.items.filterProperty('group_id', -1).findProperty('is_current');
+ var currentDefault = data.items.filterProperty('group_name', 'default').findProperty('is_current');
if (currentDefault) {
this.set('currentDefaultVersion', currentDefault.service_config_version);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/mixins/common/configs/configs_saver.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js
index c78c3de..f5dd841 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -534,11 +534,11 @@ App.ConfigsSaverMixin = Em.Mixin.create({
}
};
- if (group.config_group_id) {
- groupData.ConfigGroup.id = group.config_group_id;
- this.updateConfigGroup(groupData, successCallback);
- } else {
+ if (group.is_temporary) {
this.createConfigGroup(groupData, successCallback);
+ } else {
+ groupData.ConfigGroup.id = group.id;
+ this.updateConfigGroup(groupData, successCallback);
}
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/mixins/main/service/configs/config_overridable.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/configs/config_overridable.js b/ambari-web/app/mixins/main/service/configs/config_overridable.js
index 9706061..ec2191f 100644
--- a/ambari-web/app/mixins/main/service/configs/config_overridable.js
+++ b/ambari-web/app/mixins/main/service/configs/config_overridable.js
@@ -118,9 +118,10 @@ App.ConfigOverridable = Em.Mixin.create({
return !(this.get('optionSelectConfigGroup') || (this.get('newConfigGroupName').trim().length > 0 && !this.get('isWarning')));
}.property('newConfigGroupName', 'optionSelectConfigGroup', 'warningMessage'),
onPrimary: function () {
+ var popup = this;
if (this.get('optionSelectConfigGroup')) {
var selectedConfigGroup = this.get('selectedConfigGroup');
- this.hide();
+ popup.hide();
callback(selectedConfigGroup);
if (!isInstaller) {
App.get('router.mainServiceInfoConfigsController').doSelectConfigGroup({context: selectedConfigGroup});
@@ -128,10 +129,10 @@ App.ConfigOverridable = Em.Mixin.create({
} else {
var newConfigGroupName = this.get('newConfigGroupName').trim();
var newConfigGroup = {
- id: App.ServiceConfigGroup.groupId(serviceId, newConfigGroupName),
+ id: (new Date()).getTime(),
name: newConfigGroupName,
is_default: false,
- parent_config_group_id: App.ServiceConfigGroup.getParentConfigGroupId(serviceId),
+ parent_config_group_id: serviceId + '_default',
description: Em.I18n.t('config.group.description.default').format(new Date().toDateString()),
service_id: serviceId,
service_name: serviceId,
@@ -139,20 +140,22 @@ App.ConfigOverridable = Em.Mixin.create({
desired_configs: [],
properties: []
};
- App.store.load(App.ServiceConfigGroup, newConfigGroup);
- App.store.commit();
if (!isInstaller) {
- self.postNewConfigurationGroup(newConfigGroup);
- }
- newConfigGroup = App.ServiceConfigGroup.find(newConfigGroup.id);
- configGroups.pushObject(newConfigGroup);
- if (isInstaller) {
- self.persistConfigGroups();
+ self.postNewConfigurationGroup(newConfigGroup, function () {
+ newConfigGroup = App.ServiceConfigGroup.find().filterProperty('serviceName', serviceId).findProperty('name', newConfigGroupName);
+ self.saveGroupConfirmationPopup(newConfigGroupName);
+ callback(newConfigGroup);
+ popup.hide();
+ });
} else {
- self.saveGroupConfirmationPopup(newConfigGroupName);
+ App.store.load(App.ServiceConfigGroup, newConfigGroup);
+ App.store.commit();
+ newConfigGroup = App.ServiceConfigGroup.find(newConfigGroup.id);
+ configGroups.pushObject(newConfigGroup);
+ self.persistConfigGroups();
+ callback(newConfigGroup);
+ popup.hide();
}
- this.hide();
- callback(newConfigGroup);
}
},
onSecondary: function () {
@@ -253,12 +256,17 @@ App.ConfigOverridable = Em.Mixin.create({
var sendData = {
name: 'config_groups.create',
data: {
- data: [newGroupData]
+ data: [newGroupData],
+ modelData: newConfigGroupData
},
success: 'successFunction',
error: 'errorFunction',
successFunction: function (response, opt, params) {
- App.configGroupsMapper.map(response, false, [params.service_id]);
+ var modelData = params.modelData;
+ modelData.id = response.resources[0].ConfigGroup.id;
+ App.store.load(App.ServiceConfigGroup, modelData);
+ App.store.commit();
+ App.ServiceConfigGroup.deleteTemporaryRecords();
if (callback) {
callback();
}
@@ -305,15 +313,10 @@ App.ConfigOverridable = Em.Mixin.create({
}
};
- if (Em.isNone(configGroup.get('configGroupId'))) {
- Em.assert('Config Group missing server side "id"', false);
- return null;
- }
-
var sendData = {
name: 'config_groups.update',
data: {
- id: configGroup.get('configGroupId'),
+ id: configGroup.get('id'),
data: putConfigGroup
},
success: 'successFunction',
@@ -392,12 +395,12 @@ App.ConfigOverridable = Em.Mixin.create({
name: 'common.delete.config_group',
sender: this,
data: {
- id: configGroup.get('configGroupId')
+ id: configGroup.get('id')
},
success: 'successFunction',
error: 'errorFunction',
successFunction: function (data, xhr, params) {
- var groupFromModel = App.ServiceConfigGroup.find().findProperty('configGroupId', params.id);
+ var groupFromModel = App.ServiceConfigGroup.find().findProperty('id', params.id);
if (groupFromModel) {
App.configGroupsMapper.deleteRecord(groupFromModel);
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/mixins/main/service/versions_mapping.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/versions_mapping.js b/ambari-web/app/mixins/main/service/versions_mapping.js
deleted file mode 100644
index a6a3dcf..0000000
--- a/ambari-web/app/mixins/main/service/versions_mapping.js
+++ /dev/null
@@ -1,107 +0,0 @@
-/**
- * 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');
-
-/**
- * Provide methods for config-versions loading from server and saving them into models
- *
- * @type {Em.Mixin}
- */
-App.VersionsMappingMixin = Em.Mixin.create({
-
- /**
- * load config groups
- * @param {string} [serviceName=null]
- * @param {number} [configGroupId=null]
- * @param {number} [configVersion=null]
- * @param {boolean} [isForCompare=false]
- * @returns {$.ajax}
- * @method loadConfigVersions
- */
- loadConfigVersions: function (serviceName, configGroupId, configVersion, isForCompare) {
- var info = this._generateAjaxDataForVersions(serviceName, configGroupId, configVersion, isForCompare);
- return App.ajax.send($.extend({sender: this, success: 'saveConfigVersionsToModel'}, info));
- },
-
- /**
- * Generate ajax info
- * @param {string} [serviceName=null]
- * @param {number} [configGroupId=null]
- * @param {number} [configVersion=null]
- * @param {boolean} [isForCompare=false]
- * @returns {{name: string, data: {}}}
- * @private
- * @method generateAjaxDataForVersions
- */
- _generateAjaxDataForVersions: function (serviceName, configGroupId, configVersion, isForCompare) {
- var result = {
- name: 'configs.config_versions.load.all.min',
- data: {}
- };
- if (serviceName) {
- result.data.serviceName = serviceName;
- if (configVersion) {
- result.name = 'configs.config_versions.load';
- result.data.configVersion = configVersion;
- result.data.isForCompare = isForCompare;
- }
- else {
- if (configGroupId) {
- result.name = 'configs.config_versions.load.group';
- result.data.configGroupId = configGroupId;
- }
- else {
- result.name = 'configs.config_versions.load.service.min';
- }
- }
- }
- return result;
- },
-
- /**
- *
- * @param {string[]} serviceNames
- * @returns {$.ajax}
- * @method loadConfigCurrentVersions
- */
- loadConfigCurrentVersions: function (serviceNames) {
- Em.assert('`serviceNames` should not be empty array', Em.isArray(serviceNames) && serviceNames.length > 0);
- return App.ajax.send({
- name: 'configs.config_versions.load.current_versions',
- sender: this,
- data: {
- serviceNames: serviceNames.join(",")
- },
- success: '_saveConfigVersionsToModel'
- });
- },
-
- /**
- * Runs <code>configGroupsMapper<code>
- * @param {object} data
- * @param {object} opt
- * @param {object} params
- * @method _saveConfigVersionsToModel
- * @private
- */
- _saveConfigVersionsToModel: function (data, opt, params) {
- App.configVersionsMapper.map(data, params.isForCompare);
- }
-
-});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/models/configs/config_group.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/config_group.js b/ambari-web/app/models/configs/config_group.js
index 20e99b5..a2a64d3 100644
--- a/ambari-web/app/models/configs/config_group.js
+++ b/ambari-web/app/models/configs/config_group.js
@@ -20,19 +20,10 @@ var App = require('app');
App.ServiceConfigGroup = DS.Model.extend({
/**
- * unique id generated as <code>serviceName<code><code>configGroupId<code>
- * in case default configGroup <code>serviceName<code><code>0<code>
* @property {string}
*/
id: DS.attr('string'),
- /**
- * original id for config group that is get from server
- * for default groups -1
- * @property {number}
- */
- configGroupId: DS.attr('number'),
-
name: DS.attr('string'),
serviceName: DS.attr('string'),
description: DS.attr('string'),
@@ -42,6 +33,18 @@ App.ServiceConfigGroup = DS.Model.extend({
desiredConfigs: DS.attr('array', {defaultValue: []}),
/**
+ * define if group is persisted on server or is just UI representation
+ * temporary groups are deleted from store after persisting on server by <code>App.ServiceConfigGroup.deleteTemporaryRecords</code> method
+ * @property {boolean}
+ */
+ isTemporary: DS.attr('boolean', {defaultValue: false}),
+
+ /**
+ * define if group is default
+ * @type {boolean}
+ */
+ isDefault: DS.attr('boolean', {defaultValue: false}),
+ /**
* this flag is used for installed services' config groups
* if user make changes to them - mark this flag to true
* @default [false]
@@ -60,12 +63,6 @@ App.ServiceConfigGroup = DS.Model.extend({
clusterHostsBinding: 'App.router.manageConfigGroupsController.clusterHosts',
/**
- * defines if group is default
- * @type {boolean}
- */
- isDefault: Em.computed.equal('configGroupId', -1),
-
- /**
* list of group names that shows which config
* groups should be updated as dependent when current is changed
* @type App.ServiceConfigGroup[]
@@ -160,3 +157,13 @@ App.ServiceConfigGroup.getParentConfigGroupId = function(serviceName) {
App.ServiceConfigGroup.groupId = function(serviceName, groupName) {
return serviceName + "_" + groupName;
};
+
+/**
+ * Delete all records with isTemporary:true
+ * @method
+ */
+App.ServiceConfigGroup.deleteTemporaryRecords = function () {
+ App.ServiceConfigGroup.find().filterProperty('isTemporary').forEach(function(record){
+ App.configGroupsMapper.deleteRecord(record);
+ }, this);
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/app/models/configs/service_config_version.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/service_config_version.js b/ambari-web/app/models/configs/service_config_version.js
index 9c83df8..9b73fca 100644
--- a/ambari-web/app/models/configs/service_config_version.js
+++ b/ambari-web/app/models/configs/service_config_version.js
@@ -26,7 +26,7 @@ App.ServiceConfigVersion = DS.Model.extend({
serviceName: DS.attr('string'),
displayName: Em.computed.formatRole('serviceName', true),
groupName: DS.attr('string'),
- groupId: DS.attr('number'),
+ groupId: DS.attr('string'),
version: DS.attr('number'),
createTime: DS.attr('number'),
rawCreateTime: DS.attr('number'),
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/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 72fdb00..a1d3f5f 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -722,7 +722,7 @@ var urls = {
},
'configs.config_versions.load.group': {
- 'real': '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&group_id={configGroupId}&fields=*',
+ 'real': '/clusters/{clusterName}/configurations/service_config_versions?service_name={serviceName}&group_id={id}&fields=*',
'mock': '/data/configurations/config_versions.json'
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/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 1c19a60..b16634b 100644
--- a/ambari-web/app/views/common/configs/config_history_flow.js
+++ b/ambari-web/app/views/common/configs/config_history_flow.js
@@ -84,7 +84,7 @@ App.ConfigHistoryFlowView = Em.View.extend({
serviceVersions: function () {
var groupName = this.get('controller.selectedConfigGroup.isDefault') ? 'default'
: this.get('controller.selectedConfigGroup.name');
- var groupId = this.get('controller.selectedConfigGroup.configGroupId');
+ var groupId = this.get('controller.selectedConfigGroup.id');
var self = this;
this.get('allServiceVersions').forEach(function (version) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/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 c6123e0..292fef5 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -424,19 +424,19 @@ describe('App.InstallerStep7Controller', function () {
});
it('should add new groups to groupsToDelete', function () {
var groupsToDelete = [
- {configGroupId: '1'},
- {configGroupId: '2'}
+ {id: '1'},
+ {id: '2'}
],
groups = [
- Em.Object.create({configGroupId: '3'}),
- Em.Object.create(),
- Em.Object.create({configGroupId: '5'})
+ Em.Object.create({id: '3', isTemporary: false}),
+ Em.Object.create({id: '4', isTemporary: true}),
+ Em.Object.create({id: '5', isTemporary: false})
],
expected = [
- {configGroupId: "1"},
- {configGroupId: "2"},
- {configGroupId: "3"},
- {configGroupId: "5"}
+ {id: "1"},
+ {id: "2"},
+ {id: "3"},
+ {id: "5"}
];
installerStep7Controller.set('groupsToDelete', groupsToDelete);
installerStep7Controller.setGroupsToDelete(groups);
http://git-wip-us.apache.org/repos/asf/ambari/blob/7256ef0b/ambari-web/test/models/configs/config_group_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/config_group_test.js b/ambari-web/test/models/configs/config_group_test.js
index d1ef208..1d254c3 100644
--- a/ambari-web/test/models/configs/config_group_test.js
+++ b/ambari-web/test/models/configs/config_group_test.js
@@ -33,8 +33,6 @@ describe('App.ServiceConfigGroup', function () {
model = getModel();
});
- App.TestAliases.testAsComputedEqual(getModel(), 'isDefault', 'configGroupId', -1);
-
describe("#displayName", function() {
before(function () {