ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [2/2] incubator-ignite git commit: IGNITE-843 Fixed profile UI.
Date Fri, 10 Jul 2015 04:24:16 GMT
IGNITE-843 Fixed profile UI.


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/0b1db97e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/0b1db97e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/0b1db97e

Branch: refs/heads/ignite-843
Commit: 0b1db97ede5d4a16f3b8b7eacd554312dea89291
Parents: 399310b
Author: AKuznetsov <akuznetsov@gridgain.com>
Authored: Fri Jul 10 11:24:10 2015 +0700
Committer: AKuznetsov <akuznetsov@gridgain.com>
Committed: Fri Jul 10 11:24:10 2015 +0700

----------------------------------------------------------------------
 modules/web-control-center/nodejs/app.js        |  2 +-
 .../nodejs/controllers/profile-controller.js    | 59 +++++++++++---------
 .../web-control-center/nodejs/routes/profile.js |  6 +-
 .../nodejs/views/admin/userList.jade            |  3 +-
 .../web-control-center/nodejs/views/login.jade  | 11 ++--
 .../nodejs/views/profile.jade                   | 43 +++++++++-----
 6 files changed, 73 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b1db97e/modules/web-control-center/nodejs/app.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/app.js b/modules/web-control-center/nodejs/app.js
index a3efe2f..175ff00 100644
--- a/modules/web-control-center/nodejs/app.js
+++ b/modules/web-control-center/nodejs/app.js
@@ -127,7 +127,7 @@ app.all('*', function(req, res, next) {
 
 app.use('/', publicRoutes);
 app.use('/admin', mustAuthenticated, adminOnly, adminRouter);
-app.use('/', mustAuthenticated, profileRouter);
+app.use('/profile', mustAuthenticated, profileRouter);
 
 app.use('/configuration/clusters', clustersRouter);
 app.use('/configuration/caches', cachesRouter);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b1db97e/modules/web-control-center/nodejs/controllers/profile-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/profile-controller.js b/modules/web-control-center/nodejs/controllers/profile-controller.js
index 5610a18..11c965e 100644
--- a/modules/web-control-center/nodejs/controllers/profile-controller.js
+++ b/modules/web-control-center/nodejs/controllers/profile-controller.js
@@ -18,7 +18,7 @@
 controlCenterModule.controller('profileController', ['$scope', '$alert', '$http', 'commonFunctions',
     function ($scope, $alert, $http, commonFunctions) {
     
-    $scope.editableUser = angular.copy($scope.savedUser);
+    $scope.profileUser = angular.copy($scope.loggedInUser);
 
     $scope.editField = null;
 
@@ -41,32 +41,39 @@ controlCenterModule.controller('profileController', ['$scope', '$alert',
'$http'
         });
     };
 
-    $scope.changePass = function() {
-        if (!$scope.pass1 || $scope.pass1.length == 0 || $scope.pass1 != $scope.pass2)
-            return;
+    $scope.saveUser = function() {
+        if ($scope.profileUser) {
+            var userName = $scope.profileUser.username;
+            var oldPass = $scope.profileUser.oldPassword;
+            var newPass = $scope.profileUser.newPassword;
+            var confirm = $scope.profileUser.confirm;
 
-        $http.post('/profile/changePassword', {_id: $scope.editableUser._id, pass: $scope.pass1}).success(function()
{
-            $scope.showInfo('Password has been changed');
-
-            $scope.pass1 = '';
-            $scope.pass2 = '';
-            $scope.showChangePasswordForm = false;
-        }).error(function(err) {
-            $scope.showError('Failed to change password: ' + commonFunctions.errorMessage(err));
-        });
+            if (userName && oldPass && newPass && confirm &&
+                userName.length > 0 && oldPass.length > 0 && newPass.length
> 0 && confirm.length > 0 &&
+                newPass == confirm
+            ) {
+                $http.post('/profile/changePassword', {
+                    _id: $scope.editableUser._id,
+                    pass: $scope.pass1
+                }).success(function () {
+                    $scope.showInfo('Profile saved.');
+                }).error(function (err) {
+                    $scope.showError('Failed to save profile: ' + commonFunctions.errorMessage(err));
+                });
+            }
+        }
     };
-    
-    $scope.$watch('editField', function(val) {
-        if (!angular.equals($scope.editableUser, $scope.savedUser)) {
-            $http.post('/profile/saveUser', $scope.editableUser).success(function(updatedUser)
{
-                angular.copy(updatedUser, $scope.savedUser);
-                angular.copy(updatedUser, $scope.editableUser);
 
-                $scope.showInfo('Profile has been updated');
-            }).error(function(err) {
-                $scope.showError('Failed to update profile: ' + commonFunctions.errorMessage(err));
-            });
-        }
-    });
-    
+    //$scope.$watch('editField', function(val) {
+    //    if (!angular.equals($scope.editableUser, $scope.savedUser)) {
+    //        $http.post('/profile/saveUser', $scope.editableUser).success(function(updatedUser)
{
+    //            angular.copy(updatedUser, $scope.savedUser);
+    //            angular.copy(updatedUser, $scope.editableUser);
+    //
+    //            $scope.showInfo('Profile has been updated');
+    //        }).error(function(err) {
+    //            $scope.showError('Failed to update profile: ' + commonFunctions.errorMessage(err));
+    //        });
+    //    }
+    //});
 }]);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b1db97e/modules/web-control-center/nodejs/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/profile.js b/modules/web-control-center/nodejs/routes/profile.js
index 1561704..71b03af 100644
--- a/modules/web-control-center/nodejs/routes/profile.js
+++ b/modules/web-control-center/nodejs/routes/profile.js
@@ -31,7 +31,7 @@ router.all('/profile/*', function(req, res, next) {
 /**
  * Get list of user accounts.
  */
-router.get('/profile', function(req, res) {
+router.get('/', function(req, res) {
     var user_id = req.currentUserId();
 
     db.Account.findById(user_id, function (err, user) {
@@ -42,7 +42,7 @@ router.get('/profile', function(req, res) {
     });
 });
 
-router.post('/profile/saveUser', function(req, res) {
+router.post('/saveUser', function(req, res) {
     var u = {
         username: req.body.username
     }; 
@@ -55,7 +55,7 @@ router.post('/profile/saveUser', function(req, res) {
     })
 });
 
-router.post('/profile/changePassword', function(req, res) {
+router.post('/changePassword', function(req, res) {
     var pass = req.body.pass;
     
     if (!pass || pass.length == 0)

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b1db97e/modules/web-control-center/nodejs/views/admin/userList.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/admin/userList.jade b/modules/web-control-center/nodejs/views/admin/userList.jade
index a592c2a..1986ca2 100644
--- a/modules/web-control-center/nodejs/views/admin/userList.jade
+++ b/modules/web-control-center/nodejs/views/admin/userList.jade
@@ -20,8 +20,7 @@ block container
     .greedy.row(ng-controller='adminController')
         .docs-content
             .docs-header
-                h1 Users
-                p List of registered users
+                h1 List of registered users
                 hr
             .docs-body
                 table.table.table-striped(st-table='userListDisplay' st-safe-src='userList')

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b1db97e/modules/web-control-center/nodejs/views/login.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/login.jade b/modules/web-control-center/nodejs/views/login.jade
index a15bd73..204e763 100644
--- a/modules/web-control-center/nodejs/views/login.jade
+++ b/modules/web-control-center/nodejs/views/login.jade
@@ -14,6 +14,9 @@
     See the License for the specific language governing permissions and
     limitations under the License.
 
+mixin lbl(txt)
+    label.col-sm-3.required #{txt}
+
 .modal.center(role='dialog')
     .modal-dialog
         .modal-content
@@ -28,19 +31,19 @@
                 .modal-body.row
                     .col-sm-9.login.col-sm-offset-1
                         .details-row(ng-show='action == "register"')
-                            label.col-sm-3.required Full Name:
+                            +lbl('Full Name:')
                             .col-sm-9
                                 input.form-control(type='text', ng-model='user_info.username',
placeholder='John Smith', focus-me='action=="register"', ng-required='action=="register"')
                         .details-row
-                            label.col-sm-3.required Email:
+                            +lbl('Email:')
                             .col-sm-9
                                 input.form-control(type='email', ng-model='user_info.email',
placeholder='you@domain.com', focus-me='action=="login"', required)
                         .details-row
-                            label.col-sm-3.required Password:
+                            +lbl('Password:')
                             .col-sm-9
                                 input.form-control(type='password', ng-model='user_info.password',
placeholder='Password', required, ng-keyup='action == "login" && $event.keyCode ==
13 ? auth(action, user_info) : null')
                         .details-row(ng-show='action == "register"')
-                            label.col-sm-3.required Confirm:
+                            +lbl('Confirm:')
                             .col-sm-9.input-tip.has-feedback
                                 input.form-control(type='password', ng-model='user_info.confirm',
placeholder='Confirm password', required, ng-keyup='$event.keyCode == 13 ? auth(action, user_info)
: null')
                                 i.fa.fa-exclamation-triangle.form-control-feedback(ng-show='user_info.password
!= user_info.confirm' bs-tooltip data-title='Password does not match confirmation' type='button')

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/0b1db97e/modules/web-control-center/nodejs/views/profile.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/profile.jade b/modules/web-control-center/nodejs/views/profile.jade
index 84150a1..f726bc4 100644
--- a/modules/web-control-center/nodejs/views/profile.jade
+++ b/modules/web-control-center/nodejs/views/profile.jade
@@ -17,32 +17,45 @@
 extends templates/layout
 
 mixin lbl(txt)
-    label.col-sm-2.labelFormField #{txt}
+    label.col-sm-2.required.labelFormField #{txt}
 
 append scripts
     script(src='/profile-controller.js')
 
 block container
-    .row.greedy(ng-controller='profileController' ng-init='savedUser = #{JSON.stringify(filterUser(editableUser))}')
+    .row.greedy(ng-controller='profileController')
         .docs-content
             .docs-header
                 h1 User profile
                 hr
             .docs-body
                 form.form-horizontal(name='profileForm' novalidate)
-                    .col-sm-12
-                        .col-sm-8.settings-row(style='padding: 0')
+                    .col-sm-10(style='padding: 0')
+                        .details-row
                             +lbl('User name:')
-                            .col-sm-8
-                                input.form-control(type='text' ng-model='editableUser.username'
placeholder='Input name' required)
-                        .col-sm-8.settings-row(style='padding: 0')
-                            +lbl('New password:')
-                            .col-sm-8
-                                input.form-control(type='password', ng-model='editableUser.password'
placeholder='Password' required)
-                        .col-sm-8.settings-row(style='padding: 0')
-                            +lbl('Confirm:')
-                            .col-sm-8
-                                input.form-control(type='password', ng-model='editableUser.confirm'
placeholder='Confirm' required)
-                    .col-sm-12.settings-row
+                            .col-sm-4
+                                input.form-control(type='text' ng-model='profileUser.username'
placeholder='Input name' required)
+                        .details-row
+                            +lbl('Email:')
+                            .col-sm-4
+                                input.form-control(type='email' ng-model='profileUser.email'
placeholder='you@domain.com' required)
+                        .details-row
+                            label
+                                input(type="checkbox" ng-model='change_password')
+                                | Change password
+                        div(ng-show='change_password')
+                            .details-row
+                                +lbl('Old password:')
+                                .col-sm-4
+                                    input.form-control(ng-show='change_password' type='password',
ng-model='profileUser.oldPassword' placeholder='Old password' ng-required='change_password')
+                            .details-row
+                                +lbl('New password:')
+                                .col-sm-4
+                                    input.form-control(ng-show='change_password' type='password',
ng-model='profileUser.newPassword' placeholder='New password' ng-required='change_password')
+                            .details-row
+                                +lbl('Confirm:')
+                                .col-sm-4
+                                    input.form-control(type='password', ng-model='profileUser.confirm'
placeholder='Confirm' ng-required='change_password')
+                    .col-sm-12.details-row
                         button#save-btn.btn.btn-primary(ng-disabled='profileForm.$invalid'
ng-click='saveUser()') Save
 


Mime
View raw message