mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-01-15 03:42:23 +01:00
Added visual notification for user/article updates angular-ui-notification config added to core client config Notification idea from #369
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
angular
|
|
.module('users')
|
|
.controller('EditProfileController', EditProfileController);
|
|
|
|
EditProfileController.$inject = ['$scope', '$http', '$location', 'UsersService', 'Authentication', 'Notification'];
|
|
|
|
function EditProfileController($scope, $http, $location, UsersService, Authentication, Notification) {
|
|
var vm = this;
|
|
|
|
vm.user = Authentication.user;
|
|
vm.updateUserProfile = updateUserProfile;
|
|
|
|
// Update a user profile
|
|
function updateUserProfile(isValid) {
|
|
|
|
if (!isValid) {
|
|
$scope.$broadcast('show-errors-check-validity', 'vm.userForm');
|
|
|
|
return false;
|
|
}
|
|
|
|
var user = new UsersService(vm.user);
|
|
|
|
user.$update(function (response) {
|
|
$scope.$broadcast('show-errors-reset', 'vm.userForm');
|
|
|
|
Notification.success({ message: '<i class="glyphicon glyphicon-ok"></i> Edit profile successful!' });
|
|
Authentication.user = response;
|
|
}, function (response) {
|
|
Notification.error({ message: response.data.message, title: '<i class="glyphicon glyphicon-remove"></i> Edit profile failed!' });
|
|
});
|
|
}
|
|
}
|
|
}());
|