You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/07/09 10:35:52 UTC
incubator-ignite git commit: # IGNITE-843 Implement updating profile.
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-843 e9758acb5 -> 92d6209f8
# IGNITE-843 Implement updating profile.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/92d6209f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/92d6209f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/92d6209f
Branch: refs/heads/ignite-843
Commit: 92d6209f83773dca44d47da18cb2295e26726edb
Parents: e9758ac
Author: sevdokimov <se...@jetbrains.com>
Authored: Thu Jul 9 11:35:33 2015 +0300
Committer: sevdokimov <se...@jetbrains.com>
Committed: Thu Jul 9 11:35:47 2015 +0300
----------------------------------------------------------------------
.../nodejs/controllers/profile-controller.js | 48 ++++++++++++++++++++
.../web-control-center/nodejs/routes/profile.js | 18 ++++++++
.../nodejs/views/profile.jade | 20 ++++++--
3 files changed, 82 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/92d6209f/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
new file mode 100644
index 0000000..eca0147
--- /dev/null
+++ b/modules/web-control-center/nodejs/controllers/profile-controller.js
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+controlCenterModule.controller('profileController', ['$scope', '$alert', '$http', function ($scope, $alert, $http) {
+
+ $scope.editableUser = angular.copy($scope.savedUser);
+
+ $scope.editField = null;
+
+ $scope.showInfo = function (msg) {
+ if ($scope.alert)
+ $scope.alert.hide();
+
+ $scope.alert = $alert({
+ type: 'success',
+ title: msg,
+ duration: 2
+ });
+ };
+
+ $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(data) {
+ $scope.showInfo('Failed to update profile: ' + data);
+ });
+ }
+ });
+
+}]);
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/92d6209f/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 d19394b..008addf 100644
--- a/modules/web-control-center/nodejs/routes/profile.js
+++ b/modules/web-control-center/nodejs/routes/profile.js
@@ -33,4 +33,22 @@ router.get('/profile', function(req, res) {
});
});
+router.post('/profile/saveUser', function(req, res) {
+ var userId = req.body._id;
+
+ if (userId != req.currentUserId() && userId != req.user._id)
+ return res.sendStatus(403);
+
+ var u = {
+ username: req.body.username
+ };
+
+ db.Account.findByIdAndUpdate(userId, u, {new: true}, function(err, val) {
+ if (err)
+ return res.status(500).send(err);
+
+ res.json(uiUtils.filterUser(val));
+ })
+});
+
module.exports = router;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/92d6209f/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 0e5268d..6d5276d 100644
--- a/modules/web-control-center/nodejs/views/profile.jade
+++ b/modules/web-control-center/nodejs/views/profile.jade
@@ -16,13 +16,25 @@
extends templates/layout-sidebar
+append scripts
+ script(src='/profile-controller.js')
+
block content
- .docs-header(ng-init='editableUser = #{JSON.stringify(filterUser(editableUser))}')
+ .docs-header(ng-init='savedUser = #{JSON.stringify(filterUser(editableUser))}')
h1 User profile
p Profile of
- strong {{editableUser.username}}.
+ strong {{savedUser.username}}.
hr
.docs-body()
- | User name:
- a(href='#' editable-text="editableUser.username") {{editableUser.username}}
+ div(ng-controller='profileController')
+ | User name:
+
+ div(ng-show='editField != "username"')
+ a(href ng-click='editField = "username"') {{editableUser.username}}
+ div(ng-show='editField == "username"')
+ i.stackTipField.fa.fa-floppy-o(ng-click='editField = null')
+ .input-tip
+ input.form-control(type='text' ng-model='editableUser.username')
+
+
\ No newline at end of file