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/01 15:35:18 UTC

git commit: AMBARI-8091. Alerts UI: Summary Page. Create Actions menu. (onechiporenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk ab7fc1ffe -> 76a6dd6a0


AMBARI-8091. Alerts UI: Summary Page. Create Actions menu. (onechiporenko)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/76a6dd6a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/76a6dd6a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/76a6dd6a

Branch: refs/heads/trunk
Commit: 76a6dd6a064c0fa9d6ac3f39aa01b50724aae495
Parents: ab7fc1f
Author: Oleg Nechiporenko <on...@apache.org>
Authored: Sat Nov 1 14:50:13 2014 +0200
Committer: Oleg Nechiporenko <on...@apache.org>
Committed: Sat Nov 1 16:33:06 2014 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers.js                   |  1 +
 .../alert_definitions_actions_controller.js     | 71 ++++++++++++++++++++
 ambari-web/app/messages.js                      |  4 ++
 ambari-web/app/templates/main/alerts.hbs        |  4 ++
 .../main/alerts/alert_definitions_actions.hbs   | 34 ++++++++++
 ambari-web/app/views.js                         |  1 +
 .../alerts/alert_definitions_actions_view.js    | 23 +++++++
 ...alert_definitions_actions_controller_test.js | 56 +++++++++++++++
 8 files changed, 194 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/76a6dd6a/ambari-web/app/controllers.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers.js b/ambari-web/app/controllers.js
index 1690f94..6924ccf 100644
--- a/ambari-web/app/controllers.js
+++ b/ambari-web/app/controllers.js
@@ -67,6 +67,7 @@ require('controllers/main/admin/security/add/step4');
 require('controllers/main/admin/authentication');
 require('controllers/main/alerts_controller');
 require('controllers/main/alert_definitions_controller');
+require('controllers/main/alerts/alert_definitions_actions_controller');
 require('controllers/main/service');
 require('controllers/main/service/item');
 require('controllers/main/service/info/summary');

http://git-wip-us.apache.org/repos/asf/ambari/blob/76a6dd6a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js
new file mode 100644
index 0000000..e5c9568
--- /dev/null
+++ b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js
@@ -0,0 +1,71 @@
+/**
+ * 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.
+ */
+
+App.MainAlertDefinitionActionsController = Em.ArrayController.extend({
+
+  name: 'mainAlertDefinitionActions',
+
+  /**
+   * List of available actions for alert definitions
+   * @type {{title: string, icon: string, action: string, showDivider: boolean}[]}
+   */
+  content: [
+    {
+      title: Em.I18n.t('alerts.actions.create'),
+      icon: 'icon-plus',
+      action: 'createNewAlertDefinition',
+      showDivider: true
+    },
+    {
+      title: Em.I18n.t('alerts.actions.manageGroups'),
+      icon: 'icon-th-large',
+      action: 'manageAlertGroups',
+      showDivider: false
+    },
+    {
+      title: Em.I18n.t('alerts.actions.manageNotifications'),
+      icon: 'icon-envelope-alt',
+      action: 'manageNotifications',
+      showDivider: false
+    }
+  ],
+
+  /**
+   * Common handler for menu item click
+   * Call proper controller's method described in <code>action</code>-field (see <code>content</code>)
+   * @param {object} event
+   * @method actionHandler
+   */
+  actionHandler: function(event) {
+    var menuElement = event.context,
+      action = menuElement.action;
+    if ('function' === Em.typeOf(Em.get(this, action))) {
+      this[action]();
+    }
+    else {
+      console.error('Invalid action provided - ', action);
+    }
+  },
+
+  createNewAlertDefinition: Em.K,
+
+  manageAlertGroups: Em.K,
+
+  manageNotifications: Em.K
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/76a6dd6a/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 9e854be..6625a38 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -819,6 +819,10 @@ Em.I18n.translations = {
   'form.validator.configGroupName':'Invalid Group Name. Only alphanumerics, hyphens, spaces and underscores are allowed.',
   'form.validator.configKey.specific':'"{0}" is invalid Key. Only alphanumerics, hyphens, underscores, asterisks and periods are allowed.',
 
+  'alerts.actions.create': 'Create Alert',
+  'alerts.actions.manageGroups': 'Manage Alert Groups',
+  'alerts.actions.manageNotifications': 'Manage Notifications',
+
   'alerts.table.noAlerts': 'No Alerts to display',
   'alerts.table.header.lastTriggered': 'Last Triggered',
   'alerts.filters.filteredAlertsInfo': '{0} of {1} alerts showing',

http://git-wip-us.apache.org/repos/asf/ambari/blob/76a6dd6a/ambari-web/app/templates/main/alerts.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts.hbs b/ambari-web/app/templates/main/alerts.hbs
index 5e71eb6..07cb3d4 100644
--- a/ambari-web/app/templates/main/alerts.hbs
+++ b/ambari-web/app/templates/main/alerts.hbs
@@ -16,6 +16,10 @@
 * limitations under the License.
 }}
 
+<div class="pull-right">
+  {{view App.MainAlertDefinitionActionsView controllerBinding="App.router.mainAlertDefinitionActionsController"}}
+</div>
+
 <div id="alerts">
   <div class="box-header row">
   </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/76a6dd6a/ambari-web/app/templates/main/alerts/alert_definitions_actions.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/alerts/alert_definitions_actions.hbs b/ambari-web/app/templates/main/alerts/alert_definitions_actions.hbs
new file mode 100644
index 0000000..06455fe
--- /dev/null
+++ b/ambari-web/app/templates/main/alerts/alert_definitions_actions.hbs
@@ -0,0 +1,34 @@
+{{!
+* 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.
+}}
+
+<div class="dropdown">
+  <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">{{t common.actions}} <span class="caret"></span></a>
+  <ul class="dropdown-menu pull-right">
+    {{#each action in controller}}
+      <li>
+        <a href="#" {{action actionHandler action target="controller"}}>
+          <span {{bindAttr class="action.icon"}}></span>
+          {{action.title}}
+        </a>
+      </li>
+      {{#if action.showDivider}}
+        <li class="divider"></li>
+      {{/if}}
+    {{/each}}
+  </ul>
+</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/76a6dd6a/ambari-web/app/views.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js
index 7990f5e..842181a 100644
--- a/ambari-web/app/views.js
+++ b/ambari-web/app/views.js
@@ -42,6 +42,7 @@ require('views/login');
 require('views/main');
 require('views/main/menu');
 require('views/main/alert_definitions_view');
+require('views/main/alerts/alert_definitions_actions_view');
 require('views/main/charts');
 require('views/main/views/details');
 require('views/main/host');

http://git-wip-us.apache.org/repos/asf/ambari/blob/76a6dd6a/ambari-web/app/views/main/alerts/alert_definitions_actions_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/alerts/alert_definitions_actions_view.js b/ambari-web/app/views/main/alerts/alert_definitions_actions_view.js
new file mode 100644
index 0000000..d1699f0
--- /dev/null
+++ b/ambari-web/app/views/main/alerts/alert_definitions_actions_view.js
@@ -0,0 +1,23 @@
+/**
+ * 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.
+ */
+
+App.MainAlertDefinitionActionsView = Em.View.extend({
+
+  templateName: require('templates/main/alerts/alert_definitions_actions')
+
+});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/76a6dd6a/ambari-web/test/controllers/main/alerts/alert_definitions_actions_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alerts/alert_definitions_actions_controller_test.js b/ambari-web/test/controllers/main/alerts/alert_definitions_actions_controller_test.js
new file mode 100644
index 0000000..304e62b
--- /dev/null
+++ b/ambari-web/test/controllers/main/alerts/alert_definitions_actions_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');
+
+var controller;
+
+describe('App.MainAlertDefinitionActionsController', function () {
+
+  beforeEach(function () {
+    controller = App.MainAlertDefinitionActionsController.create({});
+  });
+
+  describe('#actionHandler', function () {
+
+    beforeEach(function () {
+      sinon.stub(controller, 'createNewAlertDefinition', Em.K);
+      sinon.stub(controller, 'manageAlertGroups', Em.K);
+      sinon.stub(controller, 'manageNotifications', Em.K);
+    });
+
+    afterEach(function () {
+      controller.createNewAlertDefinition.restore();
+      controller.manageAlertGroups.restore();
+      controller.manageNotifications.restore();
+    });
+
+    it('should call proper methods', function () {
+
+      controller.actionHandler({action: 'createNewAlertDefinition'});
+      controller.actionHandler({action: 'manageAlertGroups'});
+      controller.actionHandler({action: 'manageNotifications'});
+      expect(controller.createNewAlertDefinition.calledOnce).to.be.ok;
+      expect(controller.manageAlertGroups.calledOnce).to.be.ok;
+      expect(controller.manageNotifications.calledOnce).to.be.ok;
+
+    });
+
+  });
+
+});
\ No newline at end of file