Selaa lähdekoodia

AMBARI-8816. Need positive confirmation upon creating Alert Group (onechiporenko)

Oleg Nechiporenko 10 vuotta sitten
vanhempi
commit
8b0e4f8782

+ 1 - 1
ambari-web/app/controllers/main/alert_definitions_controller.js

@@ -151,7 +151,7 @@ App.MainAlertDefinitionsController = Em.ArrayController.extend({
 
 
       bodyClass: Em.View.extend({
       bodyClass: Em.View.extend({
 
 
-        templateName: require('templates/common/alerts_popup'),
+        templateName: require('templates/common/modal_popups/alerts_popup'),
 
 
         controller: self,
         controller: self,
 
 

+ 16 - 0
ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js

@@ -90,6 +90,12 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({
 
 
       onPrimary: function () {
       onPrimary: function () {
         var modifiedAlertGroups = this.get('subViewController.defsModifiedAlertGroups');
         var modifiedAlertGroups = this.get('subViewController.defsModifiedAlertGroups');
+        var dataForSuccessPopup = {
+          created: modifiedAlertGroups.toCreate.length,
+          deleted: modifiedAlertGroups.toDelete.length,
+          updated: modifiedAlertGroups.toSet.length
+        };
+        var showSuccessPopup = dataForSuccessPopup.created + dataForSuccessPopup.deleted + dataForSuccessPopup.updated > 0;
         // Save modified Alert-groups
         // Save modified Alert-groups
         console.log("manageAlertGroups(): Saving modified Alert groups: ", modifiedAlertGroups);
         console.log("manageAlertGroups(): Saving modified Alert groups: ", modifiedAlertGroups);
         var self = this;
         var self = this;
@@ -137,6 +143,16 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({
             }
             }
             else {
             else {
               self.hide();
               self.hide();
+              if (showSuccessPopup) {
+                App.ModalPopup.show({
+                  secondary: null,
+                  header: Em.I18n.t('alerts.groups.successPopup.header'),
+                  bodyClass: Em.View.extend({
+                    dataForSuccessPopup: dataForSuccessPopup,
+                    templateName: require('templates/main/alerts/alert_groups/success_popup_body')
+                  })
+                });
+              }
               App.router.get('updateController').updateAlertGroups(function () {
               App.router.get('updateController').updateAlertGroups(function () {
                 App.router.get('updateController').updateAlertDefinitions(function() {
                 App.router.get('updateController').updateAlertDefinitions(function() {
                   App.router.get('updateController').updateAlertNotifications(Em.K);
                   App.router.get('updateController').updateAlertNotifications(Em.K);

+ 5 - 0
ambari-web/app/messages.js

@@ -876,6 +876,11 @@ Em.I18n.translations = {
   'alerts.actions.manageNotifications': 'Manage Notifications',
   'alerts.actions.manageNotifications': 'Manage Notifications',
   'alerts.actions.manageNotifications.info': 'You can manage notification methods and recipients.',
   'alerts.actions.manageNotifications.info': 'You can manage notification methods and recipients.',
 
 
+  'alerts.groups.successPopup.header': 'Alert Groups processing results',
+  'alerts.groups.successPopup.body.created': 'New Alert Groups',
+  'alerts.groups.successPopup.body.updated': 'Updated Alert Groups',
+  'alerts.groups.successPopup.body.deleted': 'Removed Alert Groups',
+
   'alerts.table.noAlerts': 'No Alerts to display',
   'alerts.table.noAlerts': 'No Alerts to display',
   'alerts.table.header.lastTriggered': 'Last Status Changed',
   'alerts.table.header.lastTriggered': 'Last Status Changed',
   'alerts.table.header.lastChecked': 'Last Checked',
   'alerts.table.header.lastChecked': 'Last Checked',

+ 0 - 0
ambari-web/app/templates/common/alerts_popup.hbs → ambari-web/app/templates/common/modal_popups/alerts_popup.hbs


+ 0 - 0
ambari-web/app/templates/common/confirmation_feedback.hbs → ambari-web/app/templates/common/modal_popups/confirmation_feedback.hbs


+ 0 - 0
ambari-web/app/templates/common/prompt_popup.hbs → ambari-web/app/templates/common/modal_popups/prompt_popup.hbs


+ 21 - 0
ambari-web/app/templates/main/alerts/alert_groups/success_popup_body.hbs

@@ -0,0 +1,21 @@
+{{!
+* 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.
+}}
+
+<p>{{t alerts.groups.successPopup.body.created}} - <strong>{{view.dataForSuccessPopup.created}}</strong></p>
+<p>{{t alerts.groups.successPopup.body.updated}} - <strong>{{view.dataForSuccessPopup.updated}}</strong></p>
+<p>{{t alerts.groups.successPopup.body.deleted}} - <strong>{{view.dataForSuccessPopup.deleted}}</strong></p>

+ 5 - 0
ambari-web/app/views.js

@@ -25,6 +25,11 @@ require('views/common/chart/pie');
 require('views/common/chart/linear');
 require('views/common/chart/linear');
 require('views/common/chart/linear_time');
 require('views/common/chart/linear_time');
 require('views/common/modal_popup');
 require('views/common/modal_popup');
+require('views/common/modal_popups/alert_popup');
+require('views/common/modal_popups/confirmation_feedback_popup');
+require('views/common/modal_popups/confirmation_popup');
+require('views/common/modal_popups/prompt_popup');
+require('views/common/modal_popups/reload_popup');
 require('views/common/editable_list');
 require('views/common/editable_list');
 require('views/common/rolling_restart_view');
 require('views/common/rolling_restart_view');
 require('views/common/select_custom_date_view');
 require('views/common/select_custom_date_view');

+ 1 - 174
ambari-web/app/views/common/modal_popup.js

@@ -113,177 +113,4 @@ App.ModalPopup.reopenClass({
     return popup;
     return popup;
   }
   }
 
 
-});
-
-App.showReloadPopup = function () {
-  return App.ModalPopup.show({
-    primary: null,
-    secondary: null,
-    showFooter: false,
-    header: this.t('app.reloadPopup.header'),
-    body: "<div id='reload_popup' class='alert alert-info'><div class='spinner'><span>" + this.t('app.reloadPopup.text') + "</span></div></div><div><a href='#' onclick='location.reload();'>" + this.t('app.reloadPopup.link') + "</a></div>",
-    encodeBody: false
-  });
-};
-
-/**
- * Show confirmation popup
- *
- * @param {Function} primary - "OK" button click handler
- * @param {String} body - additional text constant. Will be placed in the popup-body
- * @param {Function} secondary
- * @param {String} header
- * @param {String} primaryText
- * @return {*}
- */
-App.showConfirmationPopup = function (primary, body, secondary, header, primaryText) {
-  if (!primary) {
-    return false;
-  }
-  return App.ModalPopup.show({
-    encodeBody: false,
-    primary: primaryText || Em.I18n.t('ok'),
-    header: header || Em.I18n.t('popup.confirmation.commonHeader'),
-    body: body || Em.I18n.t('question.sure'),
-    onPrimary: function () {
-      this.hide();
-      primary();
-    },
-    onSecondary: function () {
-      this.hide();
-      if (secondary) {
-        secondary();
-      }
-    },
-    onClose:  function () {
-      this.hide();
-      if (secondary) {
-        secondary();
-      }
-    }
-  });
-};
-
-/**
- * Show confirmation popup
- * After sending command watch status of query,
- * and in case of failure provide ability to retry to launch an operation.
- *
- * @param {Function} primary - "OK" button click handler
- * @param {Object} bodyMessage - confirmMsg:{String},
-                                 confirmButton:{String},
-                                 additionalWarningMsg:{String},
- * @param {Function} secondary - "Cancel" button click handler
- * @return {*}
- */
-App.showConfirmationFeedBackPopup = function (primary, bodyMessage, secondary) {
-  if (!primary) {
-    return false;
-  }
-  return App.ModalPopup.show({
-    header: Em.I18n.t('popup.confirmation.commonHeader'),
-    bodyClass: Em.View.extend({
-      templateName: require('templates/common/confirmation_feedback')
-    }),
-    query: Em.Object.create({status: "INIT"}),
-    primary: function () {
-      return bodyMessage? bodyMessage.confirmButton : Em.I18n.t('ok');
-    }.property('bodyMessage'),
-    onPrimary: function () {
-      this.set('query.status', "INIT");
-      this.set('disablePrimary', true);
-      this.set('disableSecondary', true);
-      this.set('statusMessage', Em.I18n.t('popup.confirmationFeedBack.sending'));
-      this.hide();
-      primary(this.get('query'), this.get('runMmOperation'));
-    },
-    statusMessage: function () {
-      return bodyMessage? bodyMessage.confirmMsg : Em.I18n.t('question.sure');
-    }.property('bodyMessage'),
-    additionalWarningMsg: function () {
-      return bodyMessage? bodyMessage.additionalWarningMsg : null;
-    }.property('bodyMessage'),
-    putInMaintenance: function () {
-      return bodyMessage ? bodyMessage.putInMaintenance : null;
-    }.property('bodyMessage'),
-    runMmOperation: false,
-    turnOnMmMsg: function () {
-      return bodyMessage ? bodyMessage.turnOnMmMsg : null;
-    }.property('bodyMessage'),
-    watchStatus: function() {
-      if (this.get('query.status') === "SUCCESS") {
-        this.hide();
-      } else if(this.get('query.status') === "FAIL") {
-        this.set('primaryClass', 'btn-primary');
-        this.set('primary', Em.I18n.t('common.retry'));
-        this.set('disablePrimary', false);
-        this.set('disableSecondary', false);
-        this.set('statusMessage', Em.I18n.t('popup.confirmationFeedBack.query.fail'));
-      }
-    }.observes('query.status'),
-    onSecondary: function () {
-      this.hide();
-      if (secondary) {
-        secondary();
-      }
-    }
-  });
-};
-
-/**
- * Show alert popup
- *
- * @param {String} header - header of the popup
- * @param {String} body - body of the popup
- * @param {Function} primary - function to call upon clicking the OK button
- * @return {*}
- */
-App.showAlertPopup = function (header, body, primary) {
-  return App.ModalPopup.show({
-    primary: Em.I18n.t('ok'),
-    secondary: null,
-    header: header,
-    body: body,
-    onPrimary: function () {
-      this.hide();
-      if (primary) {
-        primary();
-      }
-    }
-  });
-};
-
-/**
- * Show prompt popup
- *
- * @param {String} text - additional text constant. Will be placed on the top of the input field
- * @param {Function} primary - "OK" button click handler
- * @param {String} defaultValue - additional text constant. Will be default value for input field
- * @param {Function} secondary
- * @return {*}
- */
-App.showPromptPopup = function (text, primary, defaultValue, secondary) {
-  if (!primary) {
-    return false;
-  }
-  return App.ModalPopup.show({
-    header: Em.I18n.t('popup.prompt.commonHeader'),
-    bodyClass: Em.View.extend({
-      templateName: require('templates/common/prompt_popup'),
-      text: text
-    }),
-    inputValue: defaultValue || '',
-    isInvalid: false,
-    errorMessage: '',
-    onPrimary: function () {
-      this.hide();
-      primary(this.get('inputValue'));
-    },
-    onSecondary: function () {
-      this.hide();
-      if (secondary) {
-        secondary();
-      }
-    }
-  });
-};
+});

+ 42 - 0
ambari-web/app/views/common/modal_popups/alert_popup.js

@@ -0,0 +1,42 @@
+/**
+ * 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');
+
+/**
+ * Show alert popup
+ *
+ * @param {String} header - header of the popup
+ * @param {String} body - body of the popup
+ * @param {Function} primary - function to call upon clicking the OK button
+ * @return {*}
+ */
+App.showAlertPopup = function (header, body, primary) {
+  return App.ModalPopup.show({
+    primary: Em.I18n.t('ok'),
+    secondary: null,
+    header: header,
+    body: body,
+    onPrimary: function () {
+      this.hide();
+      if (primary) {
+        primary();
+      }
+    }
+  });
+};

+ 85 - 0
ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js

@@ -0,0 +1,85 @@
+/**
+ * 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');
+
+/**
+ * Show confirmation popup
+ * After sending command watch status of query,
+ * and in case of failure provide ability to retry to launch an operation.
+ *
+ * @param {Function} primary - "OK" button click handler
+ * @param {Object} bodyMessage - confirmMsg:{String},
+ confirmButton:{String},
+ additionalWarningMsg:{String},
+ * @param {Function} secondary - "Cancel" button click handler
+ * @return {*}
+ */
+App.showConfirmationFeedBackPopup = function (primary, bodyMessage, secondary) {
+  if (!primary) {
+    return false;
+  }
+  return App.ModalPopup.show({
+    header: Em.I18n.t('popup.confirmation.commonHeader'),
+    bodyClass: Em.View.extend({
+      templateName: require('templates/common/modal_popups/confirmation_feedback')
+    }),
+    query: Em.Object.create({status: "INIT"}),
+    primary: function () {
+      return bodyMessage? bodyMessage.confirmButton : Em.I18n.t('ok');
+    }.property('bodyMessage'),
+    onPrimary: function () {
+      this.set('query.status', "INIT");
+      this.set('disablePrimary', true);
+      this.set('disableSecondary', true);
+      this.set('statusMessage', Em.I18n.t('popup.confirmationFeedBack.sending'));
+      this.hide();
+      primary(this.get('query'), this.get('runMmOperation'));
+    },
+    statusMessage: function () {
+      return bodyMessage? bodyMessage.confirmMsg : Em.I18n.t('question.sure');
+    }.property('bodyMessage'),
+    additionalWarningMsg: function () {
+      return bodyMessage? bodyMessage.additionalWarningMsg : null;
+    }.property('bodyMessage'),
+    putInMaintenance: function () {
+      return bodyMessage ? bodyMessage.putInMaintenance : null;
+    }.property('bodyMessage'),
+    runMmOperation: false,
+    turnOnMmMsg: function () {
+      return bodyMessage ? bodyMessage.turnOnMmMsg : null;
+    }.property('bodyMessage'),
+    watchStatus: function() {
+      if (this.get('query.status') === "SUCCESS") {
+        this.hide();
+      } else if(this.get('query.status') === "FAIL") {
+        this.set('primaryClass', 'btn-primary');
+        this.set('primary', Em.I18n.t('common.retry'));
+        this.set('disablePrimary', false);
+        this.set('disableSecondary', false);
+        this.set('statusMessage', Em.I18n.t('popup.confirmationFeedBack.query.fail'));
+      }
+    }.observes('query.status'),
+    onSecondary: function () {
+      this.hide();
+      if (secondary) {
+        secondary();
+      }
+    }
+  });
+};

+ 57 - 0
ambari-web/app/views/common/modal_popups/confirmation_popup.js

@@ -0,0 +1,57 @@
+/**
+ * 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');
+
+/**
+ * Show confirmation popup
+ *
+ * @param {Function} primary - "OK" button click handler
+ * @param {String} body - additional text constant. Will be placed in the popup-body
+ * @param {Function} secondary
+ * @param {String} header
+ * @param {String} primaryText
+ * @return {*}
+ */
+App.showConfirmationPopup = function (primary, body, secondary, header, primaryText) {
+  if (!primary) {
+    return false;
+  }
+  return App.ModalPopup.show({
+    encodeBody: false,
+    primary: primaryText || Em.I18n.t('ok'),
+    header: header || Em.I18n.t('popup.confirmation.commonHeader'),
+    body: body || Em.I18n.t('question.sure'),
+    onPrimary: function () {
+      this.hide();
+      primary();
+    },
+    onSecondary: function () {
+      this.hide();
+      if (secondary) {
+        secondary();
+      }
+    },
+    onClose:  function () {
+      this.hide();
+      if (secondary) {
+        secondary();
+      }
+    }
+  });
+};

+ 54 - 0
ambari-web/app/views/common/modal_popups/prompt_popup.js

@@ -0,0 +1,54 @@
+/**
+ * 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');
+
+/**
+ * Show prompt popup
+ *
+ * @param {String} text - additional text constant. Will be placed on the top of the input field
+ * @param {Function} primary - "OK" button click handler
+ * @param {String} defaultValue - additional text constant. Will be default value for input field
+ * @param {Function} secondary
+ * @return {*}
+ */
+App.showPromptPopup = function (text, primary, defaultValue, secondary) {
+  if (!primary) {
+    return false;
+  }
+  return App.ModalPopup.show({
+    header: Em.I18n.t('popup.prompt.commonHeader'),
+    bodyClass: Em.View.extend({
+      templateName: require('templates/common/modal_popups/prompt_popup'),
+      text: text
+    }),
+    inputValue: defaultValue || '',
+    isInvalid: false,
+    errorMessage: '',
+    onPrimary: function () {
+      this.hide();
+      primary(this.get('inputValue'));
+    },
+    onSecondary: function () {
+      this.hide();
+      if (secondary) {
+        secondary();
+      }
+    }
+  });
+};

+ 30 - 0
ambari-web/app/views/common/modal_popups/reload_popup.js

@@ -0,0 +1,30 @@
+/**
+ * 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');
+
+App.showReloadPopup = function () {
+  return App.ModalPopup.show({
+    primary: null,
+    secondary: null,
+    showFooter: false,
+    header: this.t('app.reloadPopup.header'),
+    body: "<div id='reload_popup' class='alert alert-info'><div class='spinner'><span>" + this.t('app.reloadPopup.text') + "</span></div></div><div><a href='#' onclick='location.reload();'>" + this.t('app.reloadPopup.link') + "</a></div>",
+    encodeBody: false
+  });
+};

+ 19 - 0
ambari-web/test/controllers/main/alerts/alert_definitions_actions_controller_test.js

@@ -70,4 +70,23 @@ describe('App.MainAlertDefinitionActionsController', function () {
 
 
   });
   });
 
 
+  describe('#createNewAlertDefinition', function () {
+
+    beforeEach(function () {
+      sinon.stub(App.router, 'transitionTo', Em.K);
+    });
+
+    afterEach(function () {
+      App.router.transitionTo.restore();
+    });
+
+    it('should navigate to wizard', function () {
+
+      controller.createNewAlertDefinition();
+      expect(App.router.transitionTo.calledWith('alertAdd')).to.be.true;
+
+    });
+
+  });
+
 });
 });