You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by on...@apache.org on 2015/08/12 14:40:54 UTC
ambari git commit: AMBARI-12739. Switching alert group in the "manage
alert groups popup" is too slow (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk 0613c0a8a -> 4b07879b3
AMBARI-12739. Switching alert group in the "manage alert groups popup" is too slow (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4b07879b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4b07879b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4b07879b
Branch: refs/heads/trunk
Commit: 4b07879b3a3bde37319c4e8457088a588e70504f
Parents: 0613c0a
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Wed Aug 12 15:12:52 2015 +0300
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Wed Aug 12 15:40:17 2015 +0300
----------------------------------------------------------------------
.../alerts/manage_alert_groups_controller.js | 69 +++++++++++++-------
.../service/manage_config_groups_controller.js | 24 +++++--
2 files changed, 67 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4b07879b/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js b/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js
index 2ca2536..ed9a607 100644
--- a/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js
+++ b/ambari-web/app/controllers/main/alerts/manage_alert_groups_controller.js
@@ -107,7 +107,35 @@ App.ManageAlertGroupsController = Em.Controller.extend({
* observes if any group changed including: group name, newly created group, deleted group, group with definitions/notifications changed
* @type {{toDelete: App.AlertGroup[], toSet: App.AlertGroup[], toCreate: App.AlertGroup[]}}
*/
- defsModifiedAlertGroups: function () {
+ defsModifiedAlertGroups: {},
+
+ /**
+ * Determines if some group was edited/created/deleted
+ * @type {boolean}
+ */
+ isDefsModified: function () {
+ var modifiedGroups = this.get('defsModifiedAlertGroups');
+ if (!this.get('isLoaded')) {
+ return false;
+ }
+ return !!(modifiedGroups.toSet.length || modifiedGroups.toCreate.length || modifiedGroups.toDelete.length);
+ }.property('defsModifiedAlertGroups'),
+
+ /**
+ * Check when some config group was changed and updates <code>defsModifiedAlertGroups</code> once
+ * @method defsModifiedAlertGroupsObs
+ */
+ defsModifiedAlertGroupsObs: function() {
+ Em.run.once(this, this.defsModifiedAlertGroupsObsOnce);
+ }.observes('selectedAlertGroup.definitions.@each', 'selectedAlertGroup.definitions.length', 'selectedAlertGroup.notifications.@each', 'selectedAlertGroup.notifications.length', 'alertGroups', 'isLoaded'),
+
+ /**
+ * Update <code>defsModifiedAlertGroups</code>-value
+ * Called once in the <code>defsModifiedAlertGroupsObs</code>
+ * @method defsModifiedAlertGroupsObsOnce
+ * @returns {boolean}
+ */
+ defsModifiedAlertGroupsObsOnce: function() {
if (!this.get('isLoaded')) {
return false;
}
@@ -116,20 +144,28 @@ App.ManageAlertGroupsController = Em.Controller.extend({
var groupsToCreate = [];
var groups = this.get('alertGroups'); //current alert groups
var originalGroups = this.get('originalAlertGroups'); // original alert groups
+ var mappedOriginalGroups = {}; // map is faster than `originalGroups.findProperty('id', ...)`
+ originalGroups.forEach(function(group) {
+ mappedOriginalGroups[group.get('id')] = group;
+ });
var originalGroupsIds = originalGroups.mapProperty('id');
+
groups.forEach(function (group) {
- var originalGroup = originalGroups.findProperty('id', group.get('id'));
+ var originalGroup = mappedOriginalGroups[group.get('id')];
if (originalGroup) {
// should update definitions or notifications
- if (!(JSON.stringify(group.get('definitions').slice().sort()) === JSON.stringify(originalGroup.get('definitions').slice().sort()))
- || !(JSON.stringify(group.get('notifications').slice().sort()) === JSON.stringify(originalGroup.get('notifications').slice().sort()))) {
+ if (JSON.stringify(group.get('definitions').slice().sort()) !== JSON.stringify(originalGroup.get('definitions').slice().sort())
+ || JSON.stringify(group.get('notifications').slice().sort()) !== JSON.stringify(originalGroup.get('notifications').slice().sort())) {
groupsToSet.push(group.set('id', originalGroup.get('id')));
- } else if (group.get('name') !== originalGroup.get('name')) {
+ }
+ else
+ if (group.get('name') !== originalGroup.get('name')) {
// should update name
groupsToSet.push(group.set('id', originalGroup.get('id')));
}
originalGroupsIds = originalGroupsIds.without(group.get('id'));
- } else {
+ }
+ else {
// should add new group
groupsToCreate.push(group);
}
@@ -137,25 +173,14 @@ App.ManageAlertGroupsController = Em.Controller.extend({
// should delete groups
originalGroupsIds.forEach(function (id) {
groupsToDelete.push(originalGroups.findProperty('id', id));
- }, this);
- return {
+ });
+
+ this.set('defsModifiedAlertGroups', {
toDelete: groupsToDelete,
toSet: groupsToSet,
toCreate: groupsToCreate
- };
- }.property('selectedAlertGroup.definitions.@each', 'selectedAlertGroup.definitions.length', 'selectedAlertGroup.notifications.@each', 'selectedAlertGroup.notifications.length', 'alertGroups', 'isLoaded'),
-
- /**
- * Determines if some group was edited/created/deleted
- * @type {boolean}
- */
- isDefsModified: function () {
- var modifiedGroups = this.get('defsModifiedAlertGroups');
- if (!this.get('isLoaded')) {
- return false;
- }
- return !!(modifiedGroups.toSet.length || modifiedGroups.toCreate.length || modifiedGroups.toDelete.length);
- }.property('defsModifiedAlertGroups'),
+ });
+ },
/**
* Load all Alert Notifications from server
http://git-wip-us.apache.org/repos/asf/ambari/blob/4b07879b/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 b2da99b..30055c6 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
@@ -144,7 +144,23 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
* toCreate: App.ConfigGroup[]
* }}
*/
- hostsModifiedConfigGroups: function () {
+ hostsModifiedConfigGroups: {},
+
+ /**
+ * Check when some config group was changed and updates <code>hostsModifiedConfigGroups</code> once
+ * @method hostsModifiedConfigGroupsObs
+ */
+ hostsModifiedConfigGroupsObs: function() {
+ Em.run.once(this, this.hostsModifiedConfigGroupsObsOnce);
+ }.observes('selectedConfigGroup.hosts.@each', 'selectedConfigGroup.hosts.length', 'selectedConfigGroup.description', 'configGroups', 'isLoaded'),
+
+ /**
+ * Update <code>hostsModifiedConfigGroups</code>-value
+ * Called once in the <code>hostsModifiedConfigGroupsObs</code>
+ * @method hostsModifiedConfigGroupsObsOnce
+ * @returns {boolean}
+ */
+ hostsModifiedConfigGroupsObsOnce: function() {
if (!this.get('isLoaded')) {
return false;
}
@@ -181,14 +197,14 @@ App.ManageConfigGroupsController = Em.Controller.extend(App.ConfigOverridable, {
originalGroupsIds.forEach(function (id) {
groupsToDelete.push(originalGroupsMap[id]);
}, this);
- return {
+ this.set('hostsModifiedConfigGroups', {
toClearHosts: groupsToClearHosts,
toDelete: groupsToDelete,
toSetHosts: groupsToSetHosts,
toCreate: groupsToCreate,
initialGroups: originalGroupsCopy
- };
- }.property('selectedConfigGroup.hosts.@each', 'selectedConfigGroup.hosts.length', 'selectedConfigGroup.description', 'configGroups', 'isLoaded'),
+ });
+ },
/**
* Determines if some changes were done with config groups