Repository: ambari Updated Branches: refs/heads/trunk 91700e782 -> 8b0e4f878
AMBARI-8816. Need positive confirmation upon creating Alert Group (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/8b0e4f87 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8b0e4f87 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8b0e4f87 Branch: refs/heads/trunk Commit: 8b0e4f8782486d9f44dafa7e0d34a48d3d2aa9f5 Parents: 91700e7 Author: Oleg Nechiporenko <[email protected]> Authored: Fri Dec 19 13:57:52 2014 +0200 Committer: Oleg Nechiporenko <[email protected]> Committed: Fri Dec 19 13:57:52 2014 +0200 ---------------------------------------------------------------------- .../main/alert_definitions_controller.js | 2 +- .../alert_definitions_actions_controller.js | 16 ++ ambari-web/app/messages.js | 5 + .../app/templates/common/alerts_popup.hbs | 59 ------- .../templates/common/confirmation_feedback.hbs | 30 ---- .../common/modal_popups/alerts_popup.hbs | 59 +++++++ .../modal_popups/confirmation_feedback.hbs | 30 ++++ .../common/modal_popups/prompt_popup.hbs | 30 ++++ .../app/templates/common/prompt_popup.hbs | 30 ---- .../alerts/alert_groups/success_popup_body.hbs | 21 +++ ambari-web/app/views.js | 5 + ambari-web/app/views/common/modal_popup.js | 175 +------------------ .../views/common/modal_popups/alert_popup.js | 42 +++++ .../modal_popups/confirmation_feedback_popup.js | 85 +++++++++ .../common/modal_popups/confirmation_popup.js | 57 ++++++ .../views/common/modal_popups/prompt_popup.js | 54 ++++++ .../views/common/modal_popups/reload_popup.js | 30 ++++ ...alert_definitions_actions_controller_test.js | 19 ++ 18 files changed, 455 insertions(+), 294 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/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 a792840..2a07dcc 100644 --- a/ambari-web/app/controllers/main/alert_definitions_controller.js +++ b/ambari-web/app/controllers/main/alert_definitions_controller.js @@ -151,7 +151,7 @@ App.MainAlertDefinitionsController = Em.ArrayController.extend({ bodyClass: Em.View.extend({ - templateName: require('templates/common/alerts_popup'), + templateName: require('templates/common/modal_popups/alerts_popup'), controller: self, http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/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 index 83445cc..b8a8af6 100644 --- a/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js +++ b/ambari-web/app/controllers/main/alerts/alert_definitions_actions_controller.js @@ -90,6 +90,12 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({ onPrimary: function () { 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 console.log("manageAlertGroups(): Saving modified Alert groups: ", modifiedAlertGroups); var self = this; @@ -137,6 +143,16 @@ App.MainAlertDefinitionActionsController = Em.ArrayController.extend({ } else { 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').updateAlertDefinitions(function() { App.router.get('updateController').updateAlertNotifications(Em.K); http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index b5da1cb..edf3b47 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -876,6 +876,11 @@ Em.I18n.translations = { 'alerts.actions.manageNotifications': 'Manage Notifications', '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.header.lastTriggered': 'Last Status Changed', 'alerts.table.header.lastChecked': 'Last Checked', http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/templates/common/alerts_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/alerts_popup.hbs b/ambari-web/app/templates/common/alerts_popup.hbs deleted file mode 100644 index 3a742e6..0000000 --- a/ambari-web/app/templates/common/alerts_popup.hbs +++ /dev/null @@ -1,59 +0,0 @@ -{{! -* 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="alerts-popup-wrap"> - {{#if view.isLoaded}} - <div class="alert-list-main-warp"> - <div class="top-wrap"> - <div class="service-top">{{t alerts.definition.details.serviceHost}}</div> - <div class="name-top">{{t alerts.fastAccess.popup.body.name}}</div> - <div class="last-triggered-top">{{t common.status}}</div> - </div> - <div id="alert-info"> - {{#if view.isAlertEmptyList}} - <div class="alert-list-wrap">{{t alerts.fastAccess.popup.body.noalerts}}</div> - {{else}} - {{#each alertInstance in view.contents}} - <div class="alert-list-wrap"> - <div class="alert-list-line-cursor"> - <div class="service-text"><a href="#" {{action "gotoService" alertInstance.service target="view"}}>{{alertInstance.service.displayName}}</a> - {{#if alertInstance.host.hostName}} - {{#if alertInstance.service.displayName}} - / - {{/if}} - <a {{action "goToHostAlerts" alertInstance.host target="view"}} href="#">{{alertInstance.host.hostName}}</a> - {{/if}} - </div> - <div class="name-text"><a href="#" {{action "gotoAlertDetails" alertInstance target="view"}}>{{alertInstance.label}}</a></div> - <div class="status-col" rel="alert-status-tooltip" {{bindAttr title="alertInstance.lastTriggered"}}> - <span> - <span class="status-icon">{{{alertInstance.status}}}</span> - <time class="timeago" {{bindAttr data-original-title="alertInstance.lastTriggeredVerboseDisplay"}}>{{alertInstance.lastTriggeredForFormatted}}</time> - </span> - </div> - </div> - </div> - {{/each}} - {{/if}} - </div> - </div> - {{else}} - <div class="spinner"></div> - {{/if}} -</div> - http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/templates/common/confirmation_feedback.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/confirmation_feedback.hbs b/ambari-web/app/templates/common/confirmation_feedback.hbs deleted file mode 100644 index bda28b8..0000000 --- a/ambari-web/app/templates/common/confirmation_feedback.hbs +++ /dev/null @@ -1,30 +0,0 @@ -{{! -* 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> - {{view.parentView.statusMessage}} -</div> -{{#if view.parentView.additionalWarningMsg}} - <br /> - <div class='alert'> - {{view.parentView.additionalWarningMsg}} - </div> -{{/if}} -{{#if view.parentView.putInMaintenance}} - <label class="checkbox">{{view Ember.Checkbox checkedBinding="view.parentView.runMmOperation"}} {{view.parentView.turnOnMmMsg}}</label> -{{/if}} - http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/templates/common/modal_popups/alerts_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popups/alerts_popup.hbs b/ambari-web/app/templates/common/modal_popups/alerts_popup.hbs new file mode 100644 index 0000000..3a742e6 --- /dev/null +++ b/ambari-web/app/templates/common/modal_popups/alerts_popup.hbs @@ -0,0 +1,59 @@ +{{! +* 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="alerts-popup-wrap"> + {{#if view.isLoaded}} + <div class="alert-list-main-warp"> + <div class="top-wrap"> + <div class="service-top">{{t alerts.definition.details.serviceHost}}</div> + <div class="name-top">{{t alerts.fastAccess.popup.body.name}}</div> + <div class="last-triggered-top">{{t common.status}}</div> + </div> + <div id="alert-info"> + {{#if view.isAlertEmptyList}} + <div class="alert-list-wrap">{{t alerts.fastAccess.popup.body.noalerts}}</div> + {{else}} + {{#each alertInstance in view.contents}} + <div class="alert-list-wrap"> + <div class="alert-list-line-cursor"> + <div class="service-text"><a href="#" {{action "gotoService" alertInstance.service target="view"}}>{{alertInstance.service.displayName}}</a> + {{#if alertInstance.host.hostName}} + {{#if alertInstance.service.displayName}} + / + {{/if}} + <a {{action "goToHostAlerts" alertInstance.host target="view"}} href="#">{{alertInstance.host.hostName}}</a> + {{/if}} + </div> + <div class="name-text"><a href="#" {{action "gotoAlertDetails" alertInstance target="view"}}>{{alertInstance.label}}</a></div> + <div class="status-col" rel="alert-status-tooltip" {{bindAttr title="alertInstance.lastTriggered"}}> + <span> + <span class="status-icon">{{{alertInstance.status}}}</span> + <time class="timeago" {{bindAttr data-original-title="alertInstance.lastTriggeredVerboseDisplay"}}>{{alertInstance.lastTriggeredForFormatted}}</time> + </span> + </div> + </div> + </div> + {{/each}} + {{/if}} + </div> + </div> + {{else}} + <div class="spinner"></div> + {{/if}} +</div> + http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/templates/common/modal_popups/confirmation_feedback.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popups/confirmation_feedback.hbs b/ambari-web/app/templates/common/modal_popups/confirmation_feedback.hbs new file mode 100644 index 0000000..bda28b8 --- /dev/null +++ b/ambari-web/app/templates/common/modal_popups/confirmation_feedback.hbs @@ -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. +}} +<div> + {{view.parentView.statusMessage}} +</div> +{{#if view.parentView.additionalWarningMsg}} + <br /> + <div class='alert'> + {{view.parentView.additionalWarningMsg}} + </div> +{{/if}} +{{#if view.parentView.putInMaintenance}} + <label class="checkbox">{{view Ember.Checkbox checkedBinding="view.parentView.runMmOperation"}} {{view.parentView.turnOnMmMsg}}</label> +{{/if}} + http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs b/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs new file mode 100644 index 0000000..078cc65 --- /dev/null +++ b/ambari-web/app/templates/common/modal_popups/prompt_popup.hbs @@ -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. +}} +<div class="prompt-popup"> + <form> + <div {{bindAttr class=":control-group view.parentView.isInvalid:error"}}> + <label class="control-label">{{view.text}}</label> + <div class="controls"> + {{view Em.TextField class="prompt-input" valueBinding="view.parentView.inputValue"}} + </div> + {{#if view.parentView.isInvalid}} + <span class="help-inline">{{view.parentView.errorMessage}}</span> + {{/if}} + </div> + </form> +</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/templates/common/prompt_popup.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/prompt_popup.hbs b/ambari-web/app/templates/common/prompt_popup.hbs deleted file mode 100644 index 078cc65..0000000 --- a/ambari-web/app/templates/common/prompt_popup.hbs +++ /dev/null @@ -1,30 +0,0 @@ -{{! -* 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="prompt-popup"> - <form> - <div {{bindAttr class=":control-group view.parentView.isInvalid:error"}}> - <label class="control-label">{{view.text}}</label> - <div class="controls"> - {{view Em.TextField class="prompt-input" valueBinding="view.parentView.inputValue"}} - </div> - {{#if view.parentView.isInvalid}} - <span class="help-inline">{{view.parentView.errorMessage}}</span> - {{/if}} - </div> - </form> -</div> http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/templates/main/alerts/alert_groups/success_popup_body.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/alerts/alert_groups/success_popup_body.hbs b/ambari-web/app/templates/main/alerts/alert_groups/success_popup_body.hbs new file mode 100644 index 0000000..71b9c32 --- /dev/null +++ b/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> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/views.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views.js b/ambari-web/app/views.js index 107c2cf..c51cc10 100644 --- a/ambari-web/app/views.js +++ b/ambari-web/app/views.js @@ -25,6 +25,11 @@ require('views/common/chart/pie'); require('views/common/chart/linear'); require('views/common/chart/linear_time'); 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/rolling_restart_view'); require('views/common/select_custom_date_view'); http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/views/common/modal_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popup.js b/ambari-web/app/views/common/modal_popup.js index 155da55..08e63dd 100644 --- a/ambari-web/app/views/common/modal_popup.js +++ b/ambari-web/app/views/common/modal_popup.js @@ -113,177 +113,4 @@ App.ModalPopup.reopenClass({ 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(); - } - } - }); -}; +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/views/common/modal_popups/alert_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/alert_popup.js b/ambari-web/app/views/common/modal_popups/alert_popup.js new file mode 100644 index 0000000..413d33c --- /dev/null +++ b/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(); + } + } + }); +}; http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js b/ambari-web/app/views/common/modal_popups/confirmation_feedback_popup.js new file mode 100644 index 0000000..f445222 --- /dev/null +++ b/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(); + } + } + }); +}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/views/common/modal_popups/confirmation_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/confirmation_popup.js b/ambari-web/app/views/common/modal_popups/confirmation_popup.js new file mode 100644 index 0000000..22830fb --- /dev/null +++ b/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(); + } + } + }); +}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/views/common/modal_popups/prompt_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/prompt_popup.js b/ambari-web/app/views/common/modal_popups/prompt_popup.js new file mode 100644 index 0000000..df45489 --- /dev/null +++ b/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(); + } + } + }); +}; http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/ambari-web/app/views/common/modal_popups/reload_popup.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/modal_popups/reload_popup.js b/ambari-web/app/views/common/modal_popups/reload_popup.js new file mode 100644 index 0000000..0c5eaf0 --- /dev/null +++ b/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 + }); +}; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/8b0e4f87/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 index f01b055..dc8bd0d 100644 --- 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 @@ -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; + + }); + + }); + }); \ No newline at end of file
