2014-06-21 14:22:38 -07:00
|
|
|
'use strict';
|
|
|
|
|
2014-07-13 16:46:49 -07:00
|
|
|
angular.module('app').controller("UserController", function($scope, $http, user) {
|
2014-06-21 14:22:38 -07:00
|
|
|
|
2014-07-09 22:24:06 -07:00
|
|
|
$scope.account = user;
|
2014-06-21 14:22:38 -07:00
|
|
|
|
|
|
|
// get the user details
|
2014-09-30 00:43:50 -07:00
|
|
|
$http({method: 'GET', url: '/api/user'}).
|
2014-06-21 14:22:38 -07: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 00:43:50 -07:00
|
|
|
$http({method: 'PUT', url: '/api/user', data: $scope.userTemp }).
|
2014-06-21 14:22:38 -07: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
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|