You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by xi...@apache.org on 2015/05/05 01:18:30 UTC
ambari git commit: AMBARI-10915. Widgets: UI changes v3c.(xiwang)
Repository: ambari
Updated Branches:
refs/heads/trunk 46e2bb361 -> 1f1a9c792
AMBARI-10915. Widgets: UI changes v3c.(xiwang)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1f1a9c79
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1f1a9c79
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1f1a9c79
Branch: refs/heads/trunk
Commit: 1f1a9c792e9cdabf306e92cb1e8eb2898868d59d
Parents: 46e2bb3
Author: Xi Wang <xi...@apache.org>
Authored: Mon May 4 15:48:00 2015 -0700
Committer: Xi Wang <xi...@apache.org>
Committed: Mon May 4 16:18:20 2015 -0700
----------------------------------------------------------------------
.../controllers/main/service/info/summary.js | 34 ++++++-----
.../service/widgets/create/step3_controller.js | 39 +++++++++++++
.../main/service/widgets/edit_controller.js | 37 ++++++++++++
ambari-web/app/messages.js | 4 ++
.../app/mixins/common/widgets/widget_mixin.js | 59 +++++++++++++++++++-
ambari-web/app/routes/edit_widget.js | 8 +--
.../app/styles/enhanced_service_dashboard.less | 3 +
.../main/service/widgets/create/step3.hbs | 9 ++-
8 files changed, 169 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f1a9c79/ambari-web/app/controllers/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/summary.js b/ambari-web/app/controllers/main/service/info/summary.js
index 528abb8..58c0605 100644
--- a/ambari-web/app/controllers/main/service/info/summary.js
+++ b/ambari-web/app/controllers/main/service/info/summary.js
@@ -543,23 +543,31 @@ App.MainServiceInfoSummaryController = Em.Controller.extend(App.WidgetSectionMix
},
/**
- * unshare widgets, on click handler for "Unshare"
- */
- unshareWidget: function (event) {
- var widget = event.context;
- var widgetName = widget.widgetName;
- //todo unshare current widget
-
- },
-
- /**
* Share widgets, on click handler for "Share"
*/
shareWidget: function (event) {
var widget = event.context;
- var widgetName = widget.widgetName;
- // todo share current widget
-
+ var self = this;
+ var bodyMessage = Em.Object.create({
+ confirmMsg: Em.I18n.t('dashboard.widgets.browser.action.share.confirmation'),
+ confirmButton: Em.I18n.t('dashboard.widgets.browser.action.share')
+ });
+ return App.showConfirmationFeedBackPopup(function (query) {
+ return App.ajax.send({
+ name: 'widgets.wizard.edit',
+ sender: self,
+ data: {
+ data: {
+ "WidgetInfo": {
+ "widget_name": widget.get("widgetName"),
+ "scope": "CLUSTER"
+ }
+ },
+ widgetId: widget.get("id")
+ },
+ success: 'updateWidgetBrowser'
+ });
+ }, bodyMessage);
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f1a9c79/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js b/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js
index 283d5f1..4aff9cf 100644
--- a/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js
+++ b/ambari-web/app/controllers/main/service/widgets/create/step3_controller.js
@@ -21,6 +21,10 @@ var App = require('app');
App.WidgetWizardStep3Controller = Em.Controller.extend({
name: "widgetWizardStep3Controller",
+ isEditController: function () {
+ return this.get('content.controllerName') == 'widgetEditController';
+ }.property('content.controllerName'),
+
/**
* @type {string}
*/
@@ -37,12 +41,32 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
isSharedChecked: false,
/**
+ * @type {boolean}
+ */
+ isSharedCheckboxDisabled: false,
+
+ /**
* @type {string}
*/
widgetScope: function () {
return this.get('isSharedChecked')? 'Cluster': 'User';
}.property('isSharedChecked'),
+ showConfirmationOnSharing: function () {
+ var self = this;
+ if(this.get('isSharedChecked')) {
+ var bodyMessage = Em.Object.create({
+ confirmMsg: Em.I18n.t('dashboard.widgets.browser.action.share.confirmation'),
+ confirmButton: Em.I18n.t('dashboard.widgets.browser.action.share')
+ });
+ return App.showConfirmationFeedBackPopup(function (query) {
+ self.set('isSharedChecked', true);
+ }, bodyMessage, function (query) {
+ self.set('isSharedChecked', false);
+ });
+ }
+ },
+
/**
* @type {string}
*/
@@ -75,6 +99,10 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
this.set('widgetName', this.get('content.widgetName'));
this.set('widgetDescription', this.get('content.widgetDescription'));
this.set('isSharedChecked', this.get('content.widgetScope') == 'CLUSTER');
+ // on editing, dont allow changing from shared scope to unshare
+ this.set('isSharedCheckboxDisabled', this.get('content.widgetScope') == 'CLUSTER' &&
+ this.get('isEditController'));
+ this.addObserver('isSharedChecked', this, this.showConfirmationOnSharing);
},
isSubmitDisabled: function () {
@@ -107,7 +135,18 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
};
},
+ cancel: function () {
+ var controller = App.router.get('widgetEditController');
+ controller.cancel();
+ },
+
complete: function () {
App.router.send('complete', this.collectWidgetData());
+ var editController = App.router.get('widgetEditController');
+ editController.finish();
+ editController.get('popup').hide();
+ var serviceName = editController.get('content.widgetService');
+ var service = App.Service.find().findProperty('serviceName', serviceName);
+ App.router.transitionTo('main.services.service', service);
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f1a9c79/ambari-web/app/controllers/main/service/widgets/edit_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/widgets/edit_controller.js b/ambari-web/app/controllers/main/service/widgets/edit_controller.js
index bbd2594..8f66c21 100644
--- a/ambari-web/app/controllers/main/service/widgets/edit_controller.js
+++ b/ambari-web/app/controllers/main/service/widgets/edit_controller.js
@@ -149,6 +149,43 @@ App.WidgetEditController = App.WidgetWizardController.extend({
},
+ cancel: function () {
+ var self = this;
+ var step3Controller = App.router.get('widgetWizardStep3Controller');
+ return App.ModalPopup.show({
+ header: Em.I18n.t('common.warning'),
+ bodyClass: Em.View.extend({
+ template: Ember.Handlebars.compile('{{t alerts.saveChanges}}')
+ }),
+ primary: Em.I18n.t('common.save'),
+ secondary: Em.I18n.t('common.discard'),
+ third: Em.I18n.t('common.cancel'),
+ disablePrimary: function () {
+ if (self.get('currentStep') == 2 && !step3Controller.get('isSubmitDisabled')) {
+ return false;
+ } else {
+ return true;
+ }
+ }.property(''),
+ onPrimary: function () {
+ if (self.get('currentStep') == 2) {
+ App.router.send('complete', step3Controller.collectWidgetData());
+ }
+ this.onSecondary();
+ },
+ onSecondary: function () {
+ this.hide();
+ self.finish();
+ self.get('popup').hide();
+ var serviceName = self.get('content.widgetService');
+ var service = App.Service.find().findProperty('serviceName', serviceName);
+ App.router.transitionTo('main.services.service', service);
+ },
+ onThird: function () {
+ this.hide();
+ }
+ });
+ },
/**
* Clear all temporary data
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f1a9c79/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index f9d03a9..652c415 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2279,6 +2279,7 @@ Em.I18n.translations = {
'dashboard.widgets.browser.action.delete': 'Delete',
'dashboard.widgets.browser.action.unshare': 'Unshare',
'dashboard.widgets.browser.action.share': 'Share',
+ 'dashboard.widgets.browser.action.share.confirmation': 'You are about to make this a shared widget. All cluster operators will be able to modify or delete this widget. Are you sure you want to share this widget?',
'dashboard.widgets.browser.shareIcon.tooltip': 'Shared',
'dashboard.widgets.browser.action.delete.bodyMsg': 'You are about to permanently delete widget: {0}. You can add it back through creating new widget.',
'dashboard.widgets.browser.action.delete.btnMsg': 'Confirm Delete',
@@ -2530,6 +2531,9 @@ Em.I18n.translations = {
'widget.edit.wizard.header': 'Edit Widget',
'widget.clone.body': 'Are you sure you want to clone current widget <b>{0}</b>?',
+ 'widget.edit.body': 'This is a shared widget and the edits are going to change this widget for all users. Would you prefer to Clone the widget instead?',
+ 'widget.edit.button.primary': 'Edit Shared',
+ 'widget.edit.button.secondary': 'Clone and Edit',
'dashboard.widgets.wizard.step2.addMetrics': 'Add Metrics and operators here...',
'dashboard.widgets.wizard.step2.newMetric': '+ Add Metric',
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f1a9c79/ambari-web/app/mixins/common/widgets/widget_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/widgets/widget_mixin.js b/ambari-web/app/mixins/common/widgets/widget_mixin.js
index ada72c9..676be85 100644
--- a/ambari-web/app/mixins/common/widgets/widget_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js
@@ -481,15 +481,26 @@ App.WidgetMixin = Ember.Mixin.create({
/**
* post widget definition to server
* @param {boolean} isClone
+ * * @param {boolean} isEditClonedWidget
* @returns {$.ajax}
*/
- postWidgetDefinition: function (isClone) {
+ postWidgetDefinition: function (isClone, isEditClonedWidget) {
var data = this.collectWidgetData();
if (isClone) {
data.WidgetInfo.widget_name += this.get('CLONE_SUFFIX');
//TODO remove setting diplay_name once API supports it
data.WidgetInfo.display_name = data.WidgetInfo.widget_name;
}
+ if (isEditClonedWidget) {
+ return App.ajax.send({
+ name: 'widgets.wizard.add',
+ sender: this,
+ data: {
+ data: data
+ },
+ success: 'editNewClonedWidget'
+ });
+ }
return App.ajax.send({
name: 'widgets.wizard.add',
sender: this,
@@ -512,10 +523,54 @@ App.WidgetMixin = Ember.Mixin.create({
},
/*
+ * enter edit wizard of the newly cloned widget
+ */
+ editNewClonedWidget: function (data) {
+ var controller = this.get('controller');
+ var widgets = this.get('content.layout.widgets').toArray();
+ var id = data.resources[0].WidgetInfo.id;
+ widgets.pushObject(Em.Object.create({
+ id: id
+ }));
+ var mainServiceInfoSummaryController = App.router.get('mainServiceInfoSummaryController');
+ mainServiceInfoSummaryController.saveWidgetLayout(widgets).done(function() {
+ mainServiceInfoSummaryController.getActiveWidgetLayout().done(function() {
+ var newWidget = App.Widget.find().findProperty('id', id);
+ controller.editWidget(newWidget);
+ });
+ });
+ },
+
+ /*
* make call when clicking on "edit icon" on widget
*/
editWidget: function (event) {
- this.get('controller').editWidget(this.get('content'));
+ var self = this;
+ var isShared = this.get('content.scope') == 'CLUSTER';
+ if (!isShared) {
+ self.get('controller').editWidget(self.get('content'));
+ } else {
+ return App.ModalPopup.show({
+ header: Em.I18n.t('common.warning'),
+ bodyClass: Em.View.extend({
+ template: Ember.Handlebars.compile('{{t widget.edit.body}}')
+ }),
+ primary: Em.I18n.t('widget.edit.button.primary'),
+ secondary: Em.I18n.t('widget.edit.button.secondary'),
+ third: Em.I18n.t('common.cancel'),
+ onPrimary: function () {
+ this.hide();
+ self.get('controller').editWidget(self.get('content'));
+ },
+ onSecondary: function () {
+ this.hide();
+ self.postWidgetDefinition(true, true);
+ },
+ onThird: function () {
+ this.hide();
+ }
+ });
+ }
}
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f1a9c79/ambari-web/app/routes/edit_widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/edit_widget.js b/ambari-web/app/routes/edit_widget.js
index 6ab50e3..38f0e53 100644
--- a/ambari-web/app/routes/edit_widget.js
+++ b/ambari-web/app/routes/edit_widget.js
@@ -33,12 +33,7 @@ module.exports = App.WizardRoute.extend({
secondary: null,
onClose: function () {
- var self = this;
- widgetEditController.finish();
- self.hide();
- var serviceName = widgetEditController.get('content.widgetService');
- var service = App.Service.find().findProperty('serviceName', serviceName);
- router.transitionTo('main.services.service', service);
+ widgetEditController.cancel();
},
didInsertElement: function () {
@@ -107,7 +102,6 @@ module.exports = App.WizardRoute.extend({
back: Em.Router.transitionTo('step1'),
complete: function (router, context) {
router.get('widgetEditController').putWidgetDefinition(context);
- router.get('widgetEditController.popup').onClose();
}
})
});
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f1a9c79/ambari-web/app/styles/enhanced_service_dashboard.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/enhanced_service_dashboard.less b/ambari-web/app/styles/enhanced_service_dashboard.less
index 939cf5b..5a1700b 100644
--- a/ambari-web/app/styles/enhanced_service_dashboard.less
+++ b/ambari-web/app/styles/enhanced_service_dashboard.less
@@ -409,6 +409,9 @@
}
}
}
+ #add-widget-step3-save {
+ margin-left: 5px;;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/1f1a9c79/ambari-web/app/templates/main/service/widgets/create/step3.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/service/widgets/create/step3.hbs b/ambari-web/app/templates/main/service/widgets/create/step3.hbs
index 7234692..22f8526 100644
--- a/ambari-web/app/templates/main/service/widgets/create/step3.hbs
+++ b/ambari-web/app/templates/main/service/widgets/create/step3.hbs
@@ -34,7 +34,7 @@
<div class="span2 title">{{t widget.create.wizard.step3.sharing}}</div>
<div class="span10">
<label class="checkbox">
- {{view Ember.Checkbox checkedBinding="controller.isSharedChecked"}}
+ {{view Ember.Checkbox disabledBinding="controller.isSharedCheckboxDisabled" checkedBinding="controller.isSharedChecked"}}
{{t widget.create.wizard.step3.sharing.msg}}
</label>
</div>
@@ -48,6 +48,11 @@
<div class="btn-area">
<button id="add-widget-step3-back" class="btn" {{action back}}>← {{t common.back}}</button>
- <button id="add-widget-step3-complete" class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action "complete" target="controller"}}>{{t common.complete}}</button>
+ {{#if controller.isEditController}}
+ <button id="add-widget-step3-save" class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action "complete" target="controller"}}>{{t common.save}}</button>
+ <button id="add-widget-step3-cancel" class="btn pull-right" {{action "cancel" target="controller"}}>{{t common.cancel}}</button>
+ {{else}}
+ <button id="add-widget-step3-complete" class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action "complete" target="controller"}}>{{t common.complete}}</button>
+ {{/if}}
</div>
</div>
\ No newline at end of file