2014-06-21 21:22:38 +00:00
|
|
|
'use strict';
|
|
|
|
|
2014-07-13 23:46:49 +00:00
|
|
|
angular.module('app').controller("UserController", function($scope, $http, user) {
|
2014-06-21 21:22:38 +00:00
|
|
|
|
2014-07-10 05:24:06 +00:00
|
|
|
$scope.account = user;
|
2014-06-21 21:22:38 +00:00
|
|
|
|
|
|
|
// get the user details
|
2014-09-30 07:43:50 +00:00
|
|
|
$http({method: 'GET', url: '/api/user'}).
|
2014-06-21 21:22:38 +00:00
|
|
|
success(function(data, status, headers, config) {
|
|
|
|
$scope.user = data;
|
|
|
|
$scope.userTemp = {
|
|
|
|
email : $scope.user.email,
|
|
|
|
name : $scope.user.name
|
|
|
|
};
|
|
|
|
}).
|
|
|
|
error(function(data, status, headers, config) {
|
|
|
|
console.log(data);
|
|
|
|
});
|
|
|
|
|
|
|
|
$scope.save = function() {
|
|
|
|
// request to create a new repository
|
2014-09-30 07:43:50 +00:00
|
|
|
$http({method: 'PUT', url: '/api/user', data: $scope.userTemp }).
|
2014-06-21 21:22:38 +00:00
|
|
|
success(function(data, status, headers, config) {
|
|
|
|
delete $scope.failure;
|
|
|
|
$scope.user = data;
|
|
|
|
}).
|
|
|
|
error(function(data, status, headers, config) {
|
|
|
|
$scope.failure = data;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
$scope.cancel = function() {
|
|
|
|
delete $scope.failure;
|
|
|
|
$scope.userTemp = {
|
|
|
|
email : $scope.user.email,
|
|
|
|
name : $scope.user.name
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|