incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1438851 - in /incubator/ambari/trunk: CHANGES.txt ambari-web/app/models/form.js ambari-web/app/models/user.js ambari-web/app/routes/main.js ambari-web/app/views/main/admin/user/create.js ambari-web/app/views/main/admin/user/edit.js
Date Sat, 26 Jan 2013 05:25:08 GMT
Author: yusaku
Date: Sat Jan 26 05:25:08 2013
New Revision: 1438851

URL: http://svn.apache.org/viewvc?rev=1438851&view=rev
Log:
AMBARI-1263. Refactoring of User Management code. (yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/models/form.js
    incubator/ambari/trunk/ambari-web/app/models/user.js
    incubator/ambari/trunk/ambari-web/app/routes/main.js
    incubator/ambari/trunk/ambari-web/app/views/main/admin/user/create.js
    incubator/ambari/trunk/ambari-web/app/views/main/admin/user/edit.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1438851&r1=1438850&r2=1438851&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Sat Jan 26 05:25:08 2013
@@ -34,6 +34,8 @@ Trunk (unreleased changes):
 
  IMPROVEMENTS
 
+ AMBARI-1263. Refactoring of User Management code. (yusaku)
+
  AMBARI-1254. Modify App Browser to use server-side paging/sorting/filtering.
  (yusaku)
 

Modified: incubator/ambari/trunk/ambari-web/app/models/form.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/form.js?rev=1438851&r1=1438850&r2=1438851&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/form.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/form.js Sat Jan 26 05:25:08 2013
@@ -91,20 +91,6 @@ App.Form = Em.View.extend({
 
   }.observes("object"),
 
-  /**
-   *
-   */
-
-  getValues:function () {
-    var values = {};
-    $.each(this.get('fields'), function () {
-      if (!(this.get('displayType') == 'password' && validator.empty(this.get('value'))))
{ // if this is not empty password field
-        values[this.get('name')] = this.get('value');
-      }
-    });
-    return values;
-  },
-
   clearValues:function () {
     $.each(this.fields, function () {
       this.set('value', '');
@@ -116,19 +102,21 @@ App.Form = Em.View.extend({
    * @return {Boolean}
    */
   save:function () {
-    var thisForm = this;
     var object = this.get('object');
+    var formValues = {};
+    $.each(this.get('fields'), function () {
+      formValues[this.get('name')] = this.get('value');
+    });
     if (!this.get('isObjectNew')) {
-      $.each(this.getValues(), function (i, v) {
-        object.set(i, v);
+      $.each(formValues, function (k, v) {
+        object.set(k, v);
       });
-    } else {
-      if (this.get('className'))
-      {
-        var rec = App.store.createRecord(this.get('className'), this.getValues());
-        //rec.get('stateManager').send('becameClean');
+    }
+    else {
+      if (this.get('className')) {
+        App.store.createRecord(this.get('className'), formValues);
       }
-      else{
+      else {
         console.log("Please define class name for your form " + this.constructor);
       }
     }

Modified: incubator/ambari/trunk/ambari-web/app/models/user.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/user.js?rev=1438851&r1=1438850&r2=1438851&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/user.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/user.js Sat Jan 26 05:25:08 2013
@@ -26,6 +26,9 @@ App.UserModel = Em.Object.extend({
 
 App.User = DS.Model.extend({
   userName:DS.attr('string'),
+  id:function(){
+    return this.get('userName');
+  }.property('userName'),
   roles:DS.attr('string'),
   isLdap:DS.attr('boolean'),
   type: function(){
@@ -67,12 +70,6 @@ App.EditUserForm = App.Form.extend({
     }
   }.observes('isObjectNew'),
 
-  getValues:function () {
-    var values = this._super();
-    values.type = ['local'];
-    return values;
-  },
-
   isValid:function () {
 
     var isValid = this._super();
@@ -132,17 +129,8 @@ App.CreateUserForm = App.Form.extend({
     }
   }.observes('isObjectNew'),
 
-  getValues:function () {
-    var values = this._super();
-    values.type = ['local'];
-    values.id = values.userName;
-    return values;
-  },
-
-
   isValid:function () {
     var isValid = this._super();
-    thisForm = this;
 
     var passField = this.get('field.password');
     var passRetype = this.get('field.passwordRetype');

Modified: incubator/ambari/trunk/ambari-web/app/routes/main.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/routes/main.js?rev=1438851&r1=1438850&r2=1438851&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/routes/main.js (original)
+++ incubator/ambari/trunk/ambari-web/app/routes/main.js Sat Jan 26 05:25:08 2013
@@ -215,7 +215,7 @@ module.exports = Em.Route.extend({
       }),
 
       editUser:Em.Route.extend({
-        route:'/edit/:userName',
+        route:'/edit/:user_id',
         connectOutlets:function (router, user) {
           router.get('mainAdminController').connectOutlet('mainAdminUserEdit', user);
         }

Modified: incubator/ambari/trunk/ambari-web/app/views/main/admin/user/create.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/admin/user/create.js?rev=1438851&r1=1438850&r2=1438851&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/admin/user/create.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views/main/admin/user/create.js Sat Jan 26 05:25:08
2013
@@ -25,17 +25,17 @@ App.MainAdminUserCreateView = Em.View.ex
     var parent_controller=this.get("controller").controllers.mainAdminUserController;
     var form = this.get("userForm");
     if(form.isValid()) {
-      form.getField("userName").set('value', form.getValues().userName.toLowerCase());
-      if(form.getValues().admin === "" || form.getValues().admin == true) {
+      form.getField("userName").set('value', form.getField("userName").get('value').toLowerCase());
+      if(form.getField("admin").get('value') === "" || form.getField("admin").get('value')
== true) {
         form.getField("roles").set("value","admin,user");
         form.getField("admin").set("value","true");
       } else{
         form.getField("roles").set("value","user");
       }
-      parent_controller.sendCommandToServer('/users/' + form.getValues().userName, "POST"
, {
+      parent_controller.sendCommandToServer('/users/' + form.getField("userName").get('value'),
"POST" , {
         Users: {
           password: form.getField("password").get('value'),
-          roles: form.getValues().roles
+          roles: form.getField("roles").get('value')
         }
       }, function (success) {
 

Modified: incubator/ambari/trunk/ambari-web/app/views/main/admin/user/edit.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/main/admin/user/edit.js?rev=1438851&r1=1438850&r2=1438851&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/main/admin/user/edit.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views/main/admin/user/edit.js Sat Jan 26 05:25:08
2013
@@ -26,24 +26,24 @@ App.MainAdminUserEditView = Em.View.exte
     var form = this.get("userForm");
     if(form.isValid()) {
       var Users={};
-      if(form.getValues().admin === "" || form.getValues().admin == true) {
+      if(form.getField("admin").get('value') === "" || form.getField("admin").get('value')
== true) {
         form.getField("roles").set("value","admin,user");
         form.getField("admin").set("value","true");
       } else{
         form.getField("roles").set("value","user");
       }
 
-      Users.roles = form.getValues().roles;
+      Users.roles = form.getField("roles").get('value');
 
-      if(form.getValues().new_password != "" && form.getValues().old_password !=
""){
-        Users.password=form.getValues().new_password;
-        Users.old_password=form.getValues().old_password;
+      if(form.getField("new_password").get('value') != "" && form.getField("old_password").get('value')
!= "") {
+        Users.password = form.getField("new_password").get('value');
+        Users.old_password = form.getField("old_password").get('value');
       }
 
-      parent_controller.sendCommandToServer('/users/' + form.getValues().userName, "PUT"
, {
+      parent_controller.sendCommandToServer('/users/' + form.getField("userName").get('value'),
"PUT" , {
        Users:Users
       }, function (success) {
-
+        console.log('success', success);
         if (!success) {
           return;
         }
@@ -57,14 +57,13 @@ App.MainAdminUserEditView = Em.View.exte
 
   userForm: App.EditUserForm.create({}),
 
-  didInsertElement: function(){
+  didInsertElement: function() {
     var form = this.get('userForm');
-    if( form.getField("isLdap").get("value") )
-    {
+    if(form.getField("isLdap").get("value")) {
       form.getField("old_password").set("disabled",true);
       form.getField("new_password").set("disabled",true);
-    }else{
-      //debugger;
+    }
+    else {
       form.getField("old_password").set("disabled",false);
       form.getField("new_password").set("disabled",false);
     }



Mime
View raw message