mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-05-08 23:17:19 +02:00
Adding New files
This commit is contained in:
34
public/modules/users/controllers/settings.js
Normal file
34
public/modules/users/controllers/settings.js
Normal file
@@ -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;
|
||||
});
|
||||
};
|
||||
}
|
||||
]);
|
||||
5
public/modules/users/css/users.css
Normal file
5
public/modules/users/css/users.css
Normal file
@@ -0,0 +1,5 @@
|
||||
@media (min-width: 992px) {
|
||||
.nav-users {
|
||||
position: fixed;
|
||||
}
|
||||
}
|
||||
12
public/modules/users/services/users.js
Normal file
12
public/modules/users/services/users.js
Normal file
@@ -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'
|
||||
}
|
||||
});
|
||||
}
|
||||
]);
|
||||
30
public/modules/users/views/settings/password.html
Normal file
30
public/modules/users/views/settings/password.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<section class="row" data-ng-controller="SettingsController">
|
||||
<h3 class="col-md-12 text-center">Change your password</h3>
|
||||
<div class="col-xs-offset-2 col-xs-8 col-md-offset-5 col-md-2">
|
||||
<form data-ng-submit="changeUserPassword()" class="signin form-horizontal" autocomplete="off">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="currentPassword">Current Password</label>
|
||||
<input type="password" id="currentPassword" name="currentPassword" class="form-control" data-ng-model="passwordDetails.currentPassword" placeholder="Current Password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="newPassword">New Password</label>
|
||||
<input type="password" id="newPassword" name="newPassword" class="form-control" data-ng-model="passwordDetails.newPassword" placeholder="New Password">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="verifyPassword">Verify Password</label>
|
||||
<input type="password" id="verifyPassword" name="verifyPassword" class="form-control" data-ng-model="passwordDetails.verifyPassword" placeholder="Verify Password">
|
||||
</div>
|
||||
<div class="text-center form-group">
|
||||
<button type="submit" class="btn btn-large btn-primary">Save Password</button>
|
||||
</div>
|
||||
<div data-ng-show="success" class="text-center text-success">
|
||||
<strong>Password Changed Successfully</strong>
|
||||
</div>
|
||||
<div data-ng-show="error" class="text-center text-danger">
|
||||
<strong>{{error}}</strong>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
34
public/modules/users/views/settings/profile.html
Normal file
34
public/modules/users/views/settings/profile.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<section class="row" data-ng-controller="SettingsController">
|
||||
<h3 class="col-md-12 text-center">Edit your profile</h3>
|
||||
<div class="col-xs-offset-2 col-xs-8 col-md-offset-5 col-md-2">
|
||||
<form data-ng-submit="updateUserProfile()" class="signin form-horizontal" autocomplete="off">
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="firstName">First Name</label>
|
||||
<input type="text" id="firstName" name="firstName" class="form-control" data-ng-model="user.firstName" placeholder="First Name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="lastName">Last Name</label>
|
||||
<input type="text" id="lastName" name="lastName" class="form-control" data-ng-model="user.lastName" placeholder="Last Name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="email">Email</label>
|
||||
<input type="text" id="email" name="email" class="form-control" data-ng-model="user.email" placeholder="Email">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="username">Username</label>
|
||||
<input type="text" id="username" name="username" class="form-control" data-ng-model="user.username" placeholder="Username">
|
||||
</div>
|
||||
<div class="text-center form-group">
|
||||
<button type="submit" class="btn btn-large btn-primary">Save Profile</button>
|
||||
</div>
|
||||
<div data-ng-show="success" class="text-center text-success">
|
||||
<strong>Profile Saved Successfully</strong>
|
||||
</div>
|
||||
<div data-ng-show="error" class="text-center text-danger">
|
||||
<strong>{{error}}</strong>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
Reference in New Issue
Block a user