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 2015/06/07 18:18:12 UTC
ambari git commit: AMBARI-11768. Alerts: click on host with an alert
does not show crit first (akovalenko)
Repository: ambari
Updated Branches:
refs/heads/trunk ca87af1ce -> c05cec264
AMBARI-11768. Alerts: click on host with an alert does not show crit first (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c05cec26
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c05cec26
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c05cec26
Branch: refs/heads/trunk
Commit: c05cec26482ad52e74f09a46bb2d05ea706494ae
Parents: ca87af1
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Sun Jun 7 16:32:31 2015 +0300
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Sun Jun 7 19:17:52 2015 +0300
----------------------------------------------------------------------
ambari-web/app/assets/test/tests.js | 1 +
.../app/views/main/host/host_alerts_view.js | 22 +++-
.../views/main/host/host_alerts_view_test.js | 117 +++++++++++++++++++
3 files changed, 139 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/c05cec26/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 7338dbf..e86647b 100644
--- a/ambari-web/app/assets/test/tests.js
+++ b/ambari-web/app/assets/test/tests.js
@@ -228,6 +228,7 @@ var files = ['test/init_model_test',
'test/views/main/host/summary_test',
'test/views/main/host/menu_test',
'test/views/main/host/stack_versions_view_test',
+ 'test/views/main/host/host_alerts_view_test',
'test/views/main/host/details/host_component_view_test',
'test/views/main/host/details/host_component_views/decommissionable_test',
'test/views/main/host/details/host_component_views/datanode_view_test',
http://git-wip-us.apache.org/repos/asf/ambari/blob/c05cec26/ambari-web/app/views/main/host/host_alerts_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/host_alerts_view.js b/ambari-web/app/views/main/host/host_alerts_view.js
index 80731a7..54b4e7c 100644
--- a/ambari-web/app/views/main/host/host_alerts_view.js
+++ b/ambari-web/app/views/main/host/host_alerts_view.js
@@ -24,7 +24,27 @@ App.MainHostAlertsView = App.TableView.extend({
templateName: require('templates/main/host/host_alerts'),
content: function () {
- return this.get('controller.content');
+ var criticalAlerts = [];
+ var warningAlerts = [];
+ var otherAlerts = [];
+ var content = this.get('controller.content');
+ if (content) {
+ content.forEach(function (alert) {
+ switch (alert.get('state')) {
+ case 'CRITICAL':
+ criticalAlerts.push(alert);
+ break;
+ case 'WARNING':
+ warningAlerts.push(alert);
+ break;
+ default:
+ otherAlerts.push(alert);
+ }
+ });
+ return [].concat(criticalAlerts, warningAlerts, otherAlerts);
+ } else {
+ return [];
+ }
}.property('controller.content.@each'),
willInsertElement: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/c05cec26/ambari-web/test/views/main/host/host_alerts_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/host/host_alerts_view_test.js b/ambari-web/test/views/main/host/host_alerts_view_test.js
new file mode 100644
index 0000000..6574309
--- /dev/null
+++ b/ambari-web/test/views/main/host/host_alerts_view_test.js
@@ -0,0 +1,117 @@
+/**
+ * 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('views/main/host/host_alerts_view');
+
+var view;
+
+describe('App.MainHostAlertsView', function () {
+
+ beforeEach(function () {
+ view = App.MainHostAlertsView.create({
+ controller: Em.Object.create()
+ });
+ });
+
+ describe('#content', function () {
+ var cases = [
+ {
+ m: 'return empty array',
+ c: null,
+ r: []
+ },
+ {
+ m: 'return empty array',
+ c: undefined,
+ r: []
+ },
+ {
+ m: 'sort CRITICAL and WARNING to be first',
+ c: [
+ Em.Object.create({
+ state: 'OK'
+ }),
+ Em.Object.create({
+ state: 'WARNING'
+ }),
+ Em.Object.create({
+ state: 'CRITICAL'
+ }),
+ Em.Object.create({
+ state: 'OK'
+ })
+ ],
+ r: [
+ Em.Object.create({
+ state: 'CRITICAL'
+ }),
+ Em.Object.create({
+ state: 'WARNING'
+ }),
+ Em.Object.create({
+ state: 'OK'
+ }),
+ Em.Object.create({
+ state: 'OK'
+ })
+ ]
+ },
+ {
+ m: 'sort CRITICAL and WARNING to be first',
+ c: [
+ Em.Object.create({
+ state: 'OTHER'
+ }),
+ Em.Object.create({
+ state: 'WARNING'
+ }),
+ Em.Object.create({
+ state: 'OK'
+ }),
+ Em.Object.create({
+ state: 'CRITICAL'
+ })
+ ],
+ r: [
+ Em.Object.create({
+ state: 'CRITICAL'
+ }),
+ Em.Object.create({
+ state: 'WARNING'
+ }),
+ Em.Object.create({
+ state: 'OTHER'
+ }),
+ Em.Object.create({
+ state: 'OK'
+ })
+ ]
+ }
+ ];
+
+ cases.forEach(function(test){
+ it('should ' + test.m, function () {
+ view.set('controller.content', test.c);
+ expect(view.get('content')).eql(test.r);
+ });
+ });
+
+ });
+
+});