Repository: ambari
Updated Branches:
  refs/heads/trunk 03918cf3a -> bd44220a5


AMBARI-10938. Incorrect behavior for clone and edit widget wizard. (jaimin)


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

Branch: refs/heads/trunk
Commit: bd44220a566b230d005cdb5bea76a9453fa1885e
Parents: 03918cf
Author: Jaimin Jetly <[email protected]>
Authored: Tue May 5 11:26:19 2015 -0700
Committer: Jaimin Jetly <[email protected]>
Committed: Tue May 5 11:26:25 2015 -0700

----------------------------------------------------------------------
 .../main/service/widgets/create/step3_controller.js |  3 ++-
 .../service/widgets/create/wizard_controller.js     |  3 +++
 .../main/service/widgets/edit_controller.js         |  3 +++
 .../app/mixins/common/widgets/widget_mixin.js       | 16 ++++------------
 ambari-web/app/models/widget_property.js            |  2 +-
 ambari-web/app/routes/main.js                       |  1 +
 ambari-web/app/utils/ajax/ajax.js                   |  2 +-
 7 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bd44220a/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 39f3433..24be8e2 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
@@ -95,7 +95,7 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
     this.set('widgetProperties', this.get('content.widgetProperties'));
     this.set('widgetValues', this.get('content.widgetValues'));
     this.set('widgetMetrics', this.get('content.widgetMetrics'));
-    this.set('widgetAuthor', App.router.get('loginName'));
+    this.set('widgetAuthor', this.get('content.widgetAuthor'));
     this.set('widgetName', this.get('content.widgetName'));
     this.set('widgetDescription', this.get('content.widgetDescription'));
     this.set('isSharedChecked', this.get('content.widgetScope') == 'CLUSTER');
@@ -120,6 +120,7 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
         widget_type: this.get('content.widgetType'),
         description: this.get('widgetDescription') || "",
         scope: this.get('widgetScope').toUpperCase(),
+        author: this.get('widgetAuthor'),
         "metrics": this.get('widgetMetrics').map(function (metric) {
           return {
             "name": metric.name,

http://git-wip-us.apache.org/repos/asf/ambari/blob/bd44220a/ambari-web/app/controllers/main/service/widgets/create/wizard_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/controllers/main/service/widgets/create/wizard_controller.js 
b/ambari-web/app/controllers/main/service/widgets/create/wizard_controller.js
index edb1b13..e660a2a 100644
--- 
a/ambari-web/app/controllers/main/service/widgets/create/wizard_controller.js
+++ 
b/ambari-web/app/controllers/main/service/widgets/create/wizard_controller.js
@@ -92,6 +92,9 @@ App.WidgetWizardController = App.WizardController.extend({
     templateValue: null,
     widgetName: null,
     widgetDescription: null,
+    widgetAuthor: function () {
+      return App.router.get('loginName');
+    }.property('App.router.loginName'),
     widgetScope: null
   }),
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/bd44220a/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 8f66c21..50860ea 100644
--- a/ambari-web/app/controllers/main/service/widgets/edit_controller.js
+++ b/ambari-web/app/controllers/main/service/widgets/edit_controller.js
@@ -81,6 +81,7 @@ App.WidgetEditController = App.WidgetWizardController.extend({
     widgetName: null,
     widgetDescription: null,
     widgetScope: null,
+    widgetAuthor: null,
     widgetId: null
   }),
 
@@ -111,6 +112,7 @@ App.WidgetEditController = 
App.WidgetWizardController.extend({
         callback: function () {
           this.load('widgetName');
           this.load('widgetDescription');
+          this.load('widgetAuthor');
         }
       }
     ]
@@ -199,6 +201,7 @@ App.WidgetEditController = 
App.WidgetWizardController.extend({
     this.save('widgetValues', []);
     this.save('widgetName', '');
     this.save('widgetDescription', '');
+    this.save('widgetAuthor', '');
     this.save('widgetScope', '');
     this.save('allMetrics', []);
     this.save('expressions', []);

http://git-wip-us.apache.org/repos/asf/ambari/blob/bd44220a/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 4bace6b..6d1e0dd 100644
--- a/ambari-web/app/mixins/common/widgets/widget_mixin.js
+++ b/ambari-web/app/mixins/common/widgets/widget_mixin.js
@@ -494,26 +494,18 @@ App.WidgetMixin = Ember.Mixin.create({
     var data = this.collectWidgetData();
     if (isClone) {
       data.WidgetInfo.widget_name += this.get('CLONE_SUFFIX');
-      //TODO remove setting diplay_name once API supports it
+      //TODO remove setting display_name once API supports it
       data.WidgetInfo.display_name = data.WidgetInfo.widget_name;
+      data.WidgetInfo.scope = 'USER';
     }
-    if (isEditClonedWidget) {
-      return App.ajax.send({
-        name: 'widgets.wizard.add',
-        sender: this,
-        data: {
-          data: data
-        },
-        success: 'editNewClonedWidget'
-      });
-    }
+    var successCallback =  isEditClonedWidget ? 'editNewClonedWidget' :  
'postWidgetDefinitionSuccessCallback';
     return App.ajax.send({
       name: 'widgets.wizard.add',
       sender: this,
       data: {
         data: data
       },
-      success: 'postWidgetDefinitionSuccessCallback'
+      success: successCallback
     });
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/bd44220a/ambari-web/app/models/widget_property.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/widget_property.js 
b/ambari-web/app/models/widget_property.js
index a2bdda9..55b8976 100644
--- a/ambari-web/app/models/widget_property.js
+++ b/ambari-web/app/models/widget_property.js
@@ -214,10 +214,10 @@ App.WidgetPropertyTypes = [
      * @returns {boolean}
      */
     validate: function (value) {
+      value = Number(('' + value).trim());
       if (!value) {
         return true;
       }
-      value = ('' + value).trim();
       return validator.isValidFloat(value) && value > this.get('MIN_VALUE') && 
value <= this.get('MAX_VALUE');
     },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/bd44220a/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index c0a7082..160afa5 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -585,6 +585,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
       widgetController.save('widgetName', context.get('widgetName'));
       widgetController.save('widgetDescription', context.get('description'));
       widgetController.save('widgetScope', context.get('scope'));
+      widgetController.save('widgetAuthor', context.get('author'));
       widgetController.save('widgetId', context.get('id'));
       widgetController.save('allMetrics', []);
       router.get('widgetWizardStep2Controller').convertData(context, 
widgetController);

http://git-wip-us.apache.org/repos/asf/ambari/blob/bd44220a/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js 
b/ambari-web/app/utils/ajax/ajax.js
index ff3f25f..4637063 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -2411,7 +2411,7 @@ var urls = {
   },
 
   'widgets.all.mine.get': {
-    real: 
'/clusters/{clusterName}/widgets?WidgetInfo/author={loginName}&fields=*',
+    real: 
'/clusters/{clusterName}/widgets?WidgetInfo/scope=USER&WidgetInfo/author={loginName}&fields=*',
     mock: '/data/widget_layouts/all_mine_widgets.json'
   },
 

Reply via email to