ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-10723 Create widget wizard: Creation of a new widget should also add it to the active current layout. (atkach)
Date Fri, 24 Apr 2015 12:12:02 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 27266f57d -> 08e957c2e


AMBARI-10723 Create widget wizard: Creation of a new widget should also add it to the active
current layout. (atkach)


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

Branch: refs/heads/trunk
Commit: 08e957c2e1baac3a715d7c66eb7e0b69a70a59ed
Parents: 27266f5
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Fri Apr 24 13:35:23 2015 +0300
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Fri Apr 24 15:11:36 2015 +0300

----------------------------------------------------------------------
 .../app/controllers/main/service/info/summary.js |  2 +-
 .../service/widgets/create/step3_controller.js   |  6 +++++-
 .../service/widgets/create/wizard_controller.js  | 19 +++++++++++++++++--
 ambari-web/app/routes/add_widget.js              |  6 +++---
 ambari-web/app/routes/main.js                    |  1 +
 .../app/views/main/service/info/summary.js       |  8 --------
 6 files changed, 27 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/08e957c2/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 421206a..e65b9dc 100644
--- a/ambari-web/app/controllers/main/service/info/summary.js
+++ b/ambari-web/app/controllers/main/service/info/summary.js
@@ -571,7 +571,7 @@ App.MainServiceInfoSummaryController = Em.Controller.extend(App.WidgetSectionMix
    * create widget
    */
   createWidget: function () {
-    App.router.send('addServiceWidget', this.get('content'));
+    App.router.send('addServiceWidget', this.get('activeWidgetLayout.widgets').objectAt(0));
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/08e957c2/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 852ab57..e460ccf 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
@@ -27,7 +27,7 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
   scopes: [
     Em.Object.create({
       name: 'User',
-      checked: true
+      checked: false
     }),
     Em.Object.create({
       name: 'Cluster',
@@ -92,6 +92,10 @@ App.WidgetWizardStep3Controller = Em.Controller.extend({
     this.get('scopes').forEach(function (scope) {
       scope.set('checked', scope.get('name').toUpperCase() == this.get('content.widgetScope'));
     }, this);
+    //if no scope selected, choose User by default
+    if (!this.get('scopes').someProperty('checked')) {
+      this.get('scopes').findProperty('name', 'User').set('checked', true);
+    }
   },
 
   //TODO: Following computed property needs to be implemented. Next button should be enabled
when there is no validation error and all required fields are filled

http://git-wip-us.apache.org/repos/asf/ambari/blob/08e957c2/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 94fc565..ad66f4e 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
@@ -37,6 +37,12 @@ App.WidgetWizardController = App.WizardController.extend({
     widgetType: '',
 
     /**
+     * @type {number}
+     * @default null
+     */
+    layoutId: null,
+
+    /**
      * Example:
      * {
      *  "display_unit": "%",
@@ -258,8 +264,17 @@ App.WidgetWizardController = App.WizardController.extend({
     });
   },
 
-  postWidgetDefinitionSuccessCallback: function() {
-
+  /**
+   * assign created widget to active layout if it present
+   * @param data
+   */
+  postWidgetDefinitionSuccessCallback: function (data) {
+    if (Em.isNone(this.get('content.layoutId'))) return;
+    var widgets = App.WidgetLayout.find(this.get('content.layoutId')).get('widgets').toArray();
+    widgets.pushObject(Em.Object.create({
+      id: data.resources[0].WidgetInfo.id
+    }));
+    App.router.get('mainServiceInfoSummaryController').saveWidgetLayout(widgets);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/08e957c2/ambari-web/app/routes/add_widget.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_widget.js b/ambari-web/app/routes/add_widget.js
index 913e154..7973022 100644
--- a/ambari-web/app/routes/add_widget.js
+++ b/ambari-web/app/routes/add_widget.js
@@ -134,9 +134,9 @@ module.exports = App.WizardRoute.extend({
       widgetWizardController.save('expressions', widgetStep2controller.get('expressions'));
       widgetWizardController.save('dataSets', widgetStep2controller.get('dataSets'));
       widgetWizardController.save('templateValue', widgetStep2controller.get('templateValue'));
-      widgetWizardController.setDBProperty('widgetName', null);
-      widgetWizardController.setDBProperty('widgetDescription', null);
-      widgetWizardController.setDBProperty('widgetScope', null);
+      widgetWizardController.save('widgetName', null);
+      widgetWizardController.save('widgetDescription', null);
+      widgetWizardController.save('widgetScope', null);
       router.transitionTo('step3');
     }
   }),

http://git-wip-us.apache.org/repos/asf/ambari/blob/08e957c2/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index a311d49..42fb206 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -567,6 +567,7 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
     if (context) {
       var widgetController = router.get('widgetWizardController');
       widgetController.save('widgetService', context.get('serviceName'));
+      widgetController.save('layoutId', context.get('layout.id'));
     }
     router.transitionTo('addWidget');
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/08e957c2/ambari-web/app/views/main/service/info/summary.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/summary.js b/ambari-web/app/views/main/service/info/summary.js
index 22af416..eed0629 100644
--- a/ambari-web/app/views/main/service/info/summary.js
+++ b/ambari-web/app/views/main/service/info/summary.js
@@ -369,14 +369,6 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, {
   },
 
   /**
-   * launch Add Widget wizard
-   * @param event
-   */
-  goToAddWidgetWizard: function (event) {
-    App.router.send('addServiceWidget', event.context);
-  },
-
-  /**
    * list of static actions of widget
    * @type {Array}
    */


Mime
View raw message