Browse Source

Merge pull request #56 from ExtProjNomit/profile-upload

profile upload start
pull/146/head
Mohammed Tantawy 7 years ago
committed by GitHub
parent
commit
1abc237fa2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 9 deletions
  1. +45
    -9
      src/assets/scripts/profile/profile.controller.js
  2. +6
    -0
      src/assets/scripts/profile/profile.service.js

+ 45
- 9
src/assets/scripts/profile/profile.controller.js View File

@ -1,17 +1,53 @@
import visas from './visa.type';
/** @ngInject */
const ProfileController = ($scope, ProfileService, UserService) => {
$scope.$on('loadUserSuccess', function (event, user) {
$scope.user = user;
});
UserService.loadUser();
// Load visas in the scope
$scope.visas = visas;
// Listen for event to do operations
$scope.$on('loadUserSuccess', function (event, user) {
$scope.user = user;
// Fetch user info for the profile
ProfileService.fetchProfileService($scope.user.id)
.then((result) => { $scope.profile = result; })
.catch((error) => { console.log(error); })
.then((result) => {
$scope.profile = result;
})
.catch((error) => {
console.log(error);
});
/**
* Update profile function gets updated user from the form
* and queries the DB to update the user's information
*
* v1.0 non selective update
*/
$scope.updateProfile = (userUpdated) => {
ProfileService.updateUserProfile($scope.user.id)
.then((result)=>{
userUpdated.personal.first_name = "Jack"
userUpdated.personal.middle_name= "Francis"
userUpdated.personal.last_name= "Sparrow"
userUpdated.personal.bio = "Captain Jack Sparrow is a fictional character in the Pirates of the Caribbean film series. The character was created by screenwriters Ted Elliott and Terry Rossio, and is portrayed by Johnny Depp.";
userUpdated.personal.phone = 423123123
userUpdated.personal.skills = ['Sailing', 'Robbing', 'Drinking']
userUpdated.personal.main_classification = ['Captain']
userUpdated.personal.languages = ['Rum', 'English']
userUpdated.personal.nationality = "Unknown"
userUpdated.personal.dob = new Date(1987, 8, 1)
userUpdated.personal.address = "199 Eckford Street"
userUpdated.personal.city = "Spinachland"
userUpdated.personal.state = "VIC"
userUpdated.personal.postcode = 3149
userUpdated.personal.education = "PhD"
userUpdated.personal.visa = "Temporary Skill Shortage visa (subclass 482)"
userUpdated.email = "jack@test"
})
}
});
$scope.visas = visas;
UserService.loadUser();
UserService.loadUser();
}
export default ProfileController;

+ 6
- 0
src/assets/scripts/profile/profile.service.js View File

@ -7,6 +7,12 @@ const ProfileService = ($http) => {
.then( (result) => { return result.data; })
.catch( (error) => { return error; });
}
serv.updateUserProfile = (id) => {
return $http.get(`${process.env.RESTAPI_URL}/api/user/${id}`, { withCredentials: true })
.then( (result) => { return result.data; })
.catch( (error) => { return error; });
}
return serv;
}

Loading…
Cancel
Save