From 7ba7dcfd2155773fb3c8bffe516547793a370d6f Mon Sep 17 00:00:00 2001 From: Amos Haviv Date: Wed, 26 Mar 2014 01:30:58 +0200 Subject: [PATCH] Adding New files --- public/modules/users/controllers/settings.js | 34 +++++++++++++++++++ public/modules/users/css/users.css | 5 +++ public/modules/users/services/users.js | 12 +++++++ .../users/views/settings/password.html | 30 ++++++++++++++++ .../modules/users/views/settings/profile.html | 34 +++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 public/modules/users/controllers/settings.js create mode 100644 public/modules/users/css/users.css create mode 100644 public/modules/users/services/users.js create mode 100644 public/modules/users/views/settings/password.html create mode 100644 public/modules/users/views/settings/profile.html diff --git a/public/modules/users/controllers/settings.js b/public/modules/users/controllers/settings.js new file mode 100644 index 00000000..43b3156c --- /dev/null +++ b/public/modules/users/controllers/settings.js @@ -0,0 +1,34 @@ +'use strict'; + +angular.module('mean.users').controller('SettingsController', ['$scope', '$http', '$location', 'Users', 'Authentication', + function($scope, $http, $location, Users, Authentication) { + $scope.user = Authentication.user; + + //If user is not signed in then redirect back home + if (!$scope.user) $location.path('/'); + + $scope.updateUserProfile = function() { + $scope.success = $scope.error = null; + var user = new Users($scope.user); + + user.$update(function(response) { + $scope.success = true; + Authentication.user = response; + }, function(response) { + $scope.error = response.data.message; + }); + }; + + $scope.changeUserPassword = function() { + $scope.success = $scope.error = null; + + $http.post('/users/password', $scope.passwordDetails).success(function(response) { + // If successful show success message and clear form + $scope.success = true; + $scope.passwordDetails = null; + }).error(function(response) { + $scope.error = response.message; + }); + }; + } +]); \ No newline at end of file diff --git a/public/modules/users/css/users.css b/public/modules/users/css/users.css new file mode 100644 index 00000000..487df40a --- /dev/null +++ b/public/modules/users/css/users.css @@ -0,0 +1,5 @@ +@media (min-width: 992px) { + .nav-users { + position: fixed; + } +} \ No newline at end of file diff --git a/public/modules/users/services/users.js b/public/modules/users/services/users.js new file mode 100644 index 00000000..3ab57c13 --- /dev/null +++ b/public/modules/users/services/users.js @@ -0,0 +1,12 @@ +'use strict'; + +//Users service used for users REST endpoint +angular.module('mean.users').factory('Users', ['$resource', + function($resource) { + return $resource('users', {}, { + update: { + method: 'PUT' + } + }); + } +]); \ No newline at end of file diff --git a/public/modules/users/views/settings/password.html b/public/modules/users/views/settings/password.html new file mode 100644 index 00000000..485cb7bd --- /dev/null +++ b/public/modules/users/views/settings/password.html @@ -0,0 +1,30 @@ +
+

Change your password

+
+ +
+
\ No newline at end of file diff --git a/public/modules/users/views/settings/profile.html b/public/modules/users/views/settings/profile.html new file mode 100644 index 00000000..5006dc9f --- /dev/null +++ b/public/modules/users/views/settings/profile.html @@ -0,0 +1,34 @@ +
+

Edit your profile

+
+ +
+
\ No newline at end of file