2015-06-16 20:32:10 +00:00
|
|
|
angular.module('SeHub')
|
2015-06-24 21:10:08 +00:00
|
|
|
.controller('profileController', ['$scope', '$rootScope', 'dataService', 'apiService',
|
2015-06-26 12:13:26 +00:00
|
|
|
'$cookies', '$location', '$routeParams',
|
2015-06-24 21:10:08 +00:00
|
|
|
function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) {
|
2015-06-16 20:32:10 +00:00
|
|
|
|
2015-06-17 19:46:26 +00:00
|
|
|
var token = $cookies['com.sehub.www'];
|
2015-06-26 12:13:26 +00:00
|
|
|
var id = $routeParams.id;
|
2015-06-17 19:46:26 +00:00
|
|
|
$scope.loadingData = true;
|
|
|
|
$scope.isInRegisterMode = false;
|
2015-06-16 20:32:10 +00:00
|
|
|
|
2015-06-26 12:13:26 +00:00
|
|
|
$scope.title = "Profile";
|
2015-06-16 20:32:10 +00:00
|
|
|
|
2015-06-26 12:13:26 +00:00
|
|
|
apiService.getUserById(token, id).success(function(data) {
|
2015-06-17 19:46:26 +00:00
|
|
|
if (data.message == 'No User Found') {
|
|
|
|
console.error("No User Found!");
|
|
|
|
}
|
|
|
|
$scope.user = data;
|
2015-06-26 12:13:26 +00:00
|
|
|
apiService.getCampusesByUserId(token, id).success(function(data) {
|
|
|
|
$scope.campuses = data;
|
|
|
|
console.log(data);
|
|
|
|
|
2015-06-17 19:46:26 +00:00
|
|
|
$scope.loadingData = false;
|
2015-06-26 12:13:26 +00:00
|
|
|
}).error(function(err) {
|
|
|
|
console.error(err);
|
|
|
|
});
|
|
|
|
|
2015-06-17 19:46:26 +00:00
|
|
|
});
|
|
|
|
|
2015-06-26 12:13:26 +00:00
|
|
|
|
|
|
|
|
2015-06-17 19:46:26 +00:00
|
|
|
$scope.isEditMode = false;
|
|
|
|
$scope.profileMode = "Edit Profile";
|
|
|
|
$scope.profileModeIcon = "fa fa-pencil";
|
2015-06-16 20:32:10 +00:00
|
|
|
|
2015-06-17 19:46:26 +00:00
|
|
|
$scope.changeProfileMode = function() {
|
|
|
|
$scope.isEditMode = !$scope.isEditMode;
|
|
|
|
if ($scope.isEditMode) {
|
|
|
|
$scope.profileMode = "Save Profile";
|
|
|
|
$scope.profileModeIcon = "fa fa-floppy-o";
|
|
|
|
} else {
|
2015-06-18 21:02:06 +00:00
|
|
|
apiService.updateUser(token, $scope.user).success(function(data) {
|
2015-06-18 20:26:51 +00:00
|
|
|
console.info('User Saved');
|
|
|
|
dataService.userBrodcast($scope.user);
|
|
|
|
|
2015-06-18 21:02:06 +00:00
|
|
|
}).error(function(e) {
|
2015-06-18 20:26:51 +00:00
|
|
|
console.error('Fail To Save User');
|
|
|
|
});
|
2015-06-17 19:46:26 +00:00
|
|
|
$scope.profileMode = "Edit Profile";
|
|
|
|
$scope.profileModeIcon = "fa fa-pencil";
|
|
|
|
}
|
2015-06-16 21:07:21 +00:00
|
|
|
}
|
|
|
|
|
2015-06-17 19:46:26 +00:00
|
|
|
/**
|
|
|
|
* DEBUG DATA
|
|
|
|
*/
|
|
|
|
$scope.courses = [{
|
|
|
|
"courseName": "Advance Math",
|
|
|
|
"campusName": "JCE",
|
|
|
|
"startDate": {
|
|
|
|
"year": 2015,
|
|
|
|
"month": 4,
|
|
|
|
"day": 3
|
|
|
|
},
|
|
|
|
"endDate": {
|
|
|
|
"year": 2016,
|
|
|
|
"month": 5,
|
|
|
|
"day": 14
|
|
|
|
},
|
|
|
|
"taskFlag": false,
|
|
|
|
"campus_avatar": "https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg"
|
|
|
|
}];
|
|
|
|
|
2015-06-26 12:13:26 +00:00
|
|
|
// $scope.campuses = [{
|
|
|
|
// 'title': 'JCE',
|
|
|
|
// 'email_ending': '@post.jce.ac.il',
|
|
|
|
// 'master_user_id': 123453433341,
|
|
|
|
// 'avatar_url': 'https://yt3.ggpht.com/--ZkWxybWGOM/AAAAAAAAAAI/AAAAAAAAAAA/_nAICC_kzzI/s88-c-k-no/photo.jpg'
|
|
|
|
// }, {
|
|
|
|
// 'title': 'Stanford',
|
|
|
|
// 'email_ending': '@post.jce.ac.il',
|
|
|
|
// 'master_user_id': 123453433341,
|
|
|
|
// 'avatar_url': 'https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcR9M4uQgaJP1zyiCGw-dK31hU8buWqeuOi9vTXBd4Y8hQcFTZqA'
|
|
|
|
// }];
|
2015-06-16 20:32:10 +00:00
|
|
|
|
|
|
|
|
2015-06-18 21:02:06 +00:00
|
|
|
$scope.labels = ['Commits', 'Issues Assigned', 'Messages', 'Open Tasks'];
|
|
|
|
$scope.series = ['Project A', 'Project B'];
|
|
|
|
|
|
|
|
$scope.data = [
|
|
|
|
[54, 3, 15, 3],
|
|
|
|
[28, 48, 40, 3]
|
|
|
|
];
|
|
|
|
|
2015-06-26 12:34:07 +00:00
|
|
|
$scope.isUser = $scope.$parent.user.id.toString() /*The Actual User*/ === $routeParams.id /*The Profile User*/;
|
2015-06-18 21:02:06 +00:00
|
|
|
|
2015-06-17 19:46:26 +00:00
|
|
|
}
|
|
|
|
]);
|