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 2014/11/13 18:51:01 UTC
ambari git commit: AMBARI-8315. Alerts UI: Summary Page. Implement
logic for Enabled/Disabled buttons (last column in the table) (onechiporenko)
Repository: ambari
Updated Branches:
refs/heads/trunk f0a7a1be3 -> 90b77c72a
AMBARI-8315. Alerts UI: Summary Page. Implement logic for Enabled/Disabled buttons (last column in the table) (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/90b77c72
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/90b77c72
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/90b77c72
Branch: refs/heads/trunk
Commit: 90b77c72a5c214cd9171a2420a8752ece0133354
Parents: f0a7a1b
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Thu Nov 13 19:49:21 2014 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Thu Nov 13 19:49:21 2014 +0200
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
.../controllers/global/cluster_controller.js | 9 +++-
.../app/controllers/global/update_controller.js | 4 +-
.../main/alert_definitions_controller.js | 21 +++++++-
ambari-web/app/utils/ajax/ajax.js | 11 ++++
.../global/update_controller_test.js | 2 +-
.../main/alert_definitions_controller_test.js | 56 ++++++++++++++++++++
7 files changed, 98 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/90b77c72/ambari-web/app/assets/test/tests.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js
index 6e2a10c..b8b8387 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -44,6 +44,7 @@ var files = ['test/init_model_test',
'test/controllers/global/update_controller_test',
'test/controllers/global/configuration_controller_test',
'test/controllers/main/app_contoller_test',
+ 'test/controllers/main/alert_definitions_controller_test',
'test/controllers/main/admin/stack_and_upgrade_test',
'test/controllers/main/admin/serviceAccounts_controller_test',
'test/controllers/main/admin/highAvailability_controller_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/90b77c72/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 7469d5b..319ee95 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -341,9 +341,14 @@ App.ClusterController = Em.Controller.extend({
self.updateLoadStatus('serviceMetrics');
updater.updateAlertDefinitions(function () {
- updater.updateAlertDefinitionSummary(function() {
+ if (App.get('supports.alerts')) {
+ updater.updateAlertDefinitionSummary(function() {
+ self.updateLoadStatus('alertDefinitions');
+ });
+ }
+ else {
self.updateLoadStatus('alertDefinitions');
- });
+ }
});
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/90b77c72/ambari-web/app/controllers/global/update_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 711d994..1f1609f 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -129,7 +129,9 @@ App.UpdateController = Em.Controller.extend({
App.updater.run(this, 'graphsUpdate', 'isWorking');
App.updater.run(this, 'updateComponentConfig', 'isWorking');
App.updater.run(this, 'updateAlertDefinitions', 'isWorking', App.alertDefinitionsUpdateInterval);
- App.updater.run(this, 'updateAlertDefinitionSummary', 'isWorking', App.alertDefinitionsUpdateInterval);
+ if (App.get('supports.alerts')) {
+ App.updater.run(this, 'updateAlertDefinitionSummary', 'isWorking', App.alertDefinitionsUpdateInterval);
+ }
}
}.observes('isWorking'),
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/90b77c72/ambari-web/app/controllers/main/alert_definitions_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alert_definitions_controller.js b/ambari-web/app/controllers/main/alert_definitions_controller.js
index 64163f4..7ada3ba 100644
--- a/ambari-web/app/controllers/main/alert_definitions_controller.js
+++ b/ambari-web/app/controllers/main/alert_definitions_controller.js
@@ -17,7 +17,6 @@
*/
var App = require('app');
-var customDatePopup = require('/views/common/custom_date_popup');
App.MainAlertDefinitionsController = Em.ArrayController.extend({
@@ -50,6 +49,24 @@ App.MainAlertDefinitionsController = Em.ArrayController.extend({
App.ScriptAlertDefinition.find().toArray());
}.property('mapperTimestamp'),
- toggleState: Em.K
+ /**
+ * Enable/disable alertDefinition
+ * @param {object} e
+ * @returns {$.ajax}
+ * @method toggleState
+ */
+ toggleState: function(e) {
+ var alertDefinition = e.context;
+ return App.ajax.send({
+ name: 'alerts.update_alert_definition',
+ sender: this,
+ data: {
+ id: alertDefinition.get('id'),
+ data: {
+ "AlertDefinition/enabled": !alertDefinition.get('enabled')
+ }
+ }
+ });
+ }
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/90b77c72/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 a61b531..bcaecd3 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -319,6 +319,17 @@ var urls = {
'real': '/clusters/{clusterName}/alerts?fields=*&Alert/host_name={hostName}',
'mock': '/data/alerts/alert_instances.json'
},
+ 'alerts.update_alert_definition': {
+ 'real': '/clusters/{clusterName}/alert_definitions/{id}',
+ 'mock': '',
+ 'format': function (data) {
+ return {
+ type: 'PUT',
+ data: JSON.stringify(data.data)
+ }
+ }
+
+ },
'background_operations.get_most_recent': {
'real': '/clusters/{clusterName}/requests?to=end&page_size={operationsCount}&fields=Requests',
'mock': '/data/background_operations/list_on_start.json',
http://git-wip-us.apache.org/repos/asf/ambari/blob/90b77c72/ambari-web/test/controllers/global/update_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/global/update_controller_test.js b/ambari-web/test/controllers/global/update_controller_test.js
index 7b8c3a3..960a83f 100644
--- a/ambari-web/test/controllers/global/update_controller_test.js
+++ b/ambari-web/test/controllers/global/update_controller_test.js
@@ -62,7 +62,7 @@ describe('App.UpdateController', function () {
it('isWorking = true', function () {
controller.set('isWorking', true);
- expect(App.updater.run.callCount).to.equal(8);
+ expect(App.updater.run.callCount).to.equal(7);
});
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/90b77c72/ambari-web/test/controllers/main/alert_definitions_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alert_definitions_controller_test.js b/ambari-web/test/controllers/main/alert_definitions_controller_test.js
new file mode 100644
index 0000000..a605899
--- /dev/null
+++ b/ambari-web/test/controllers/main/alert_definitions_controller_test.js
@@ -0,0 +1,56 @@
+/**
+ * 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');
+
+require('controllers/main/alert_definitions_controller');
+require('models/alert_definition');
+
+var controller;
+describe('App.MainAlertDefinitionsController', function() {
+
+ beforeEach(function() {
+
+ controller = App.MainAlertDefinitionsController.create();
+
+ });
+
+ describe('#toggleState', function() {
+
+ beforeEach(function() {
+ sinon.stub(App.ajax, 'send', Em.K);
+ controller.reopen({
+ content: [
+ App.AlertDefinition.createRecord({id: 1, enabled: true})
+ ]
+ });
+ });
+
+ afterEach(function() {
+ App.ajax.send.restore();
+ });
+
+ it('should do ajax-request', function() {
+ var alertDefinition = controller.get('content')[0];
+ controller.toggleState({context: alertDefinition});
+ expect(App.ajax.send.calledOnce).to.be.true;
+ });
+
+ });
+
+});