Browse Source

Merge pull request #19 from ExtProjNomit/ng-profile

Profile and Signup
pull/146/head
Mohammed Tantawy 7 years ago
committed by GitHub
parent
commit
edac0dd369
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 457 additions and 111 deletions
  1. +1
    -0
      package.json
  2. +3
    -9
      src/assets/scripts/ads-details/ads-details.controller.js
  3. +2
    -7
      src/assets/scripts/ads-details/ads-details.service.js
  4. +2
    -8
      src/assets/scripts/ads/ads.controller.js
  5. +3
    -9
      src/assets/scripts/ads/ads.service.js
  6. +5
    -0
      src/assets/scripts/app/index.js
  7. +3
    -2
      src/assets/scripts/app/shared.service.js
  8. +1
    -0
      src/assets/scripts/index.js
  9. +1
    -3
      src/assets/scripts/logout/controller.js
  10. +10
    -9
      src/assets/scripts/nwLogin/controller.js
  11. +10
    -14
      src/assets/scripts/nwLogin/nwLogin.html
  12. +2
    -1
      src/assets/scripts/profile/index.js
  13. +5
    -9
      src/assets/scripts/profile/profile.controller.js
  14. +2
    -3
      src/assets/scripts/profile/profile.html
  15. +2
    -7
      src/assets/scripts/profile/profile.service.js
  16. +317
    -0
      src/assets/scripts/profile/visa.type.js
  17. +0
    -10
      src/assets/scripts/signup/SignupController.js
  18. +10
    -0
      src/assets/scripts/signup/index.js
  19. +16
    -0
      src/assets/scripts/signup/signup.controller.js
  20. +41
    -0
      src/assets/scripts/signup/signup.html
  21. +0
    -3
      src/assets/scripts/signup/signup.js
  22. +21
    -17
      src/assets/scripts/signup/signup.service.js

+ 1
- 0
package.json View File

@ -19,6 +19,7 @@
"dependencies": {
"angular": "^1.6.4",
"angular-cookies": "^1.6.4",
"angular-filter": "^0.5.17",
"angular-route": "^1.6.4",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.1",


+ 3
- 9
src/assets/scripts/ads-details/ads-details.controller.js View File

@ -1,21 +1,15 @@
import moment from 'moment';
import UserService from '../app/shared.service';
const AdsDetailsController = ($scope, AdsDetailsService, $routeParams, UserService) => {
$scope.$on('loadUserSuccess', function (event, user) {
$scope.user = user;
AdsDetailsService.fetchAdDetails($routeParams)
.then(function(result){
.then((result) => {
$scope.ad = result;
window.msnry.layout();
console.log(result);
})
.catch(function(error){
console.log(error);
});
$scope.daysAgo = (timestamp) => {
return moment(timestamp).fromNow();
}
.catch((error) => { console.log(error); });
$scope.daysAgo = (timestamp) => { return moment(timestamp).fromNow(); }
});
UserService.loadUser();
}


+ 2
- 7
src/assets/scripts/ads-details/ads-details.service.js View File

@ -3,13 +3,8 @@ const AdsDetailsService = ($http) => {
serv.fetchAdDetails = (route) =>{
return $http.get('https://nomitwisp-restapi.herokuapp.com/api/ads/'+route.id)
.then( (result) => {
console.log(route.id);
return result.data;
}, (error) => {
console.log(error);
return error;
});
.then( (result) => { return result.data; })
.catch( (error) => { return error; })
}
return serv;
}


+ 2
- 8
src/assets/scripts/ads/ads.controller.js View File

@ -3,14 +3,8 @@ const AdsController = ($scope, AdsService, UserService) => {
$scope.$on('loadUserSuccess', function (event, user) {
$scope.user = user;
AdsService.fetchAdsService()
.then(function (result) {
$scope.ads = result;
console.log(result);
})
.catch(function (error) {
console.log(error);
})
.then( (result) => { $scope.ads = result; })
.catch( (error) => { console.log(error); })
});
UserService.loadUser();
}


+ 3
- 9
src/assets/scripts/ads/ads.service.js View File

@ -1,17 +1,11 @@
/** @ngInject */
const AdsService = ($http) => {
let serv = {};
serv.fetchAdsService = () =>{
return $http.get('https://nomitwisp-restapi.herokuapp.com/api/ads', { withCredentials: true })
.then( (result) => {
console.log(result.data);
return result.data;
})
.catch( (error) => {
console.log(error);
return [];
});
.then( (result) => { return result.data; })
.catch( (error) => { return error; });
}
return serv;
}


+ 5
- 0
src/assets/scripts/app/index.js View File

@ -13,6 +13,7 @@ angular.module('NomitWisp',
'nwAds',
'nwAdsDetails',
'nwProfile',
'nwSignup',
ngRoute
])
@ -36,6 +37,10 @@ angular.module('NomitWisp',
controller: 'ProfileController',
templateUrl: 'assets/scripts/profile/profile.html'
})
.when('/signup', {
controller: 'SignupController',
templateUrl: 'assets/scripts/signup/signup.html'
})
// .when('/users', {
// controller: 'UsersController',
// templateUrl: ''


+ 3
- 2
src/assets/scripts/app/shared.service.js View File

@ -6,7 +6,7 @@ function parseJwt(token) {
return JSON.parse(window.atob(base64));
};
const UserService = ($cookies, $rootScope) => {
const UserService = ($cookies, $rootScope, $location) => {
let serv = {};
@ -16,7 +16,8 @@ const UserService = ($cookies, $rootScope) => {
$rootScope.$broadcast('loadUserSuccess', parseJwt( $cookies.get('access_token') ));
$('#modalLoginForm').modal('hide');
} else {
$('#modalLoginForm').modal({backdrop: 'static', keyboard: false});
if($location.path() === '/signup') { $('#modalLoginForm').modal('hide'); }
else { $('#modalLoginForm').modal({backdrop: 'static', keyboard: false}); }
}
}


+ 1
- 0
src/assets/scripts/index.js View File

@ -26,5 +26,6 @@ import './dashboard'
import './ads';
import './ads-details';
import './profile';
import './signup';
import './app';

+ 1
- 3
src/assets/scripts/logout/controller.js View File

@ -2,10 +2,8 @@ const LogoutController = ($scope, LogoutService, $cookies, UserService) => {
$scope.userLogged = false;
$scope.userLogout = async () => {
console.log("Logout");
const result = await LogoutService.logoutUserService($scope.user);
await LogoutService.logoutUserService($scope.user);
$cookies.remove('access_token');
console.log(result);
UserService.loadUser();
}
};


+ 10
- 9
src/assets/scripts/nwLogin/controller.js View File

@ -3,17 +3,18 @@ const LoginController = ($scope, $cookies, LoginService, UserService) => {
// load the user if already logged in, for all controllers
UserService.loadUser();
$scope.userLogin = async () => {
let result = await LoginService.loginUserService($scope.user);
if( typeof result.token !== "undefined"){
$scope.userLogin = async (isValid) => {
if(isValid){
let result = await LoginService.loginUserService($scope.user);
if( typeof result.token !== "undefined"){
// save the cookie and reload the user for all controllers
$cookies.put('access_token', result.token);
UserService.loadUser();
// save the cookie and reload the user for all controllers
$cookies.put('access_token', result.token);
UserService.loadUser();
} else {
alert(result);
} else {
alert(result);
}
}
}


+ 10
- 14
src/assets/scripts/nwLogin/nwLogin.html View File

@ -7,7 +7,7 @@
<div class="modal-left" >
<p class="mo-title">Let's start with getting connected.</p>
<div class="subtitle-modal">Sign up and join the WISP. </div>
<button type="button" class="btn btn-signup ">SIGNUP</button>
<a class="btn btn-signup" href="#!signup" role="button">SIGNUP</a>
</div>
<div class="modal-right ">
<div class="logo-wisp-right">
@ -135,19 +135,15 @@
</div> <!--logo-->
<div>
<h4 class=""><strong>Sign In </strong>
<form ng-submit="userLogin()" name="LoginForm">
<input class="modal-username" ng-model="user.email" type="text" placeholder="Email" required>
<input class="modal-username" type="password" ng-model="user.password" placeholder="Password" required>
<button type="submit" class="btn btn-gradient btn-centered mt-2" ng-disabled="LoginForm.$invalid">SIGN IN</button>
</form>
<div ng-show="userLogged">
<h2>Welcome {{user.fullname}}!</h2>
<p ng-show="{{user.role}} == 'user'">This text is only visible to Users</p>
<p ng-show="{{user.role}} == 'company'">This text is only visible to Companies</p>
<p ng-show="{{user.role}} == 'nomit' || {{user.role}} == 'admin'">This text is visible to both Nomit and Admin</p>
<p ng-show="{{user.role}} == 'nomit'">This text is only visible to Nomit</p>
<p ng-show="{{user.role}} == 'admin'">This text is only visible to Admin</p>
</div>
<form ng-submit="userLogin(LoginForm.$valid)" name="LoginForm" novalidate>
<input name="email" class="modal-username form-control" ng-model="user.email" type="email" placeholder="Email" required />
<p ng-show="LoginForm.email.$error.required">This field is required.</p>
<p ng-show="LoginForm.email.$error.email">Invalid email.</p>
<input name="pwd" class="modal-username" type="password" ng-model="user.password" placeholder="Password" ng-minlength=5 required />
<p ng-show="LoginForm.pwd.$error.minlength">Min 5 characters.</p>
<button type="submit" class="btn btn-gradient btn-centered mt-2">SIGN IN</button>
</form>
</div>
</div>
</div>


+ 2
- 1
src/assets/scripts/profile/index.js View File

@ -1,8 +1,9 @@
import angular from 'angular';
import angularFilter from 'angular-filter';
import ProfileController from './profile.controller';
import ProfileService from './profile.service';
angular.module('nwProfile', [])
angular.module('nwProfile', [angularFilter])
.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.withCredentials = true;
}])


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

@ -1,3 +1,4 @@
import visas from './visa.type';
/** @ngInject */
const ProfileController = ($scope, ProfileService, UserService) => {
$scope.$on('loadUserSuccess', function (event, user) {
@ -5,16 +6,11 @@ const ProfileController = ($scope, ProfileService, UserService) => {
});
UserService.loadUser();
// Call service to fetch user data
ProfileService.fetchProfileService($scope.user.id)
.then(function (result) {
$scope.profile = result;
})
.catch(function (error) {
console.log(error);
})
.then((result) => { $scope.profile = result; })
.catch((error) => { console.log(error); })
$scope.visas = visas;
UserService.loadUser();
}


+ 2
- 3
src/assets/scripts/profile/profile.html View File

@ -78,9 +78,8 @@
</div>
<div class="col-4 profile-form-row">
<h9 class="">Visa Type</h9>
<select id="inputVisa" class="form-control">
<option selected>Student</option>
<option>...</option>
<select id="inputVisa" class="form-control" ng-model="user.role" ng-options="visa.name group by visa.type for visa in visas">
<option value="" selected>Choose visa...</option>
</select>
</div>
<div class="col-4 profile-form-row">


+ 2
- 7
src/assets/scripts/profile/profile.service.js View File

@ -4,13 +4,8 @@ const ProfileService = ($http) => {
serv.fetchProfileService = (id) =>{
return $http.get('https://nomitwisp-restapi.herokuapp.com/api/user/'+id, { withCredentials: true })
.then( (result) => {
return result.data;
})
.catch( (error) => {
console.log(error);
return [];
});
.then( (result) => { return result.data; })
.catch( (error) => { return error; });
}
return serv;
}


+ 317
- 0
src/assets/scripts/profile/visa.type.js View File

@ -0,0 +1,317 @@
const visas = [
{
id: 0,
type: "Visitor visa",
subclass: "601",
name: "Electronic Travel Authority (subclass 601)"
},
{
id: 1,
type: "Visitor visa",
subclass: "651",
name: "eVisitor (subclass 651)"
},
{
id: 2,
type: "Visitor visa",
subclass: "771",
name: "Transit visa (subclass 771)"
},
{
id: 3,
type: "Visitor visa",
subclass: "600",
name: "Visitor (subclass 600)"
},
{
id: 4,
type: "Visitor visa",
subclass: "417-462",
name: "Work and Holiday visa (subclass 417 462)"
},
{
id: 5,
type: "Studying and training visas",
subclass: "500",
name: "Student visa (subclass 500)"
},
{
id: 6,
type: "Studying and training visas",
subclass: "590",
name: "Student Guardian visa (subclass 590)"
},
{
id: 7,
type: "Studying and training visas",
subclass: "407",
name: "Training visa (subclass 407)"
},
{
id: 8,
type: "Family and partner visas",
subclass: "102",
name: "Adoption visa (subclass 102)"
},
{
id: 9,
type: "Family and partner visas",
subclass: "114-838",
name: "Aged Dependent Relative visa (subclass 114 838)"
},
{
id: 10,
type: "Family and partner visas",
subclass: "804",
name: "Aged Parent visa (subclass 804)"
},
{
id: 11,
type: "Family and partner visas",
subclass: "116-836",
name: "Carer visa (subclass 116 836)"
},
{
id: 12,
type: "Family and partner visas",
subclass: "101-802",
name: "Child visa (subclass 101 802)"
},
{
id: 12,
type: "Family and partner visas",
subclass: "864-884",
name: "Contributory Aged Parent visa (subclass 864 884)"
},
{
id: 13,
type: "Family and partner visas",
subclass: "143-173",
name: "Contributory Parent visa (subclass 143 173)"
},
{
id: 14,
type: "Family and partner visas",
subclass: "445",
name: "Dependent Child visa (subclass 445)"
},
{
id: 15,
type: "Family and partner visas",
subclass: "461",
name: "New Zealand Citizen Family Relationship (temporary) visa (subclass 461)"
},
{
id: 16,
type: "Family and partner visas",
subclass: "117-837",
name: "Orphan Relative (subclass 117 837)"
},
{
id: 17,
type: "Family and partner visas",
subclass: "103",
name: "Parent visa (subclass 103)"
},
{
id: 18,
type: "Family and partner visas",
subclass: "100-309",
name: "Partner (Provisional and Migrant) visa (subclass 309 100)"
},
{
id: 19,
type: "Family and partner visas",
subclass: "801-820",
name: "Partner visa (subclass 820 801)"
},
{
id: 20,
type: "Family and partner visas",
subclass: "300",
name: "Prospective Marriage visa (subclass 300)"
},
{
id: 21,
type: "Family and partner visas",
subclass: "115-835",
name: "Remaining Relative visa (subclass 115 835)"
},
{
id: 22,
type: "Working and skilled visas",
subclass: "188-888",
name: "Business Innovation and Investment visa (subclass 188 888)"
},
{
id: 23,
type: "Working and skilled visas",
subclass: "890",
name: "Business Owner (subclass 890)"
},
{
id: 24,
type: "Working and skilled visas",
subclass: "132",
name: "Business Talent visa (subclass 132)"
},
{
id: 25,
type: "Working and skilled visas",
subclass: "124-858",
name: "Distinguished Talent visa (subclass 124 858)"
},
{
id: 26,
type: "Working and skilled visas",
subclass: "186",
name: "Employer Nomination Scheme (subclass 186)"
},
{
id: 27,
type: "Working and skilled visas",
subclass: "891",
name: "Investor visa (subclass 891)"
},
{
id: 28,
type: "Working and skilled visas",
subclass: "187",
name: "Regional Sponsor Migration Scheme (subclass 187)"
},
{
id: 29,
type: "Working and skilled visas",
subclass: "189",
name: "Skilled Independent visa (subclass 189)"
},
{
id: 30,
type: "Working and skilled visas",
subclass: "190",
name: "Skilled Nominated visa (subclass 190)"
},
{
id: 30,
type: "Working and skilled visas",
subclass: "476",
name: "Skilled-Recognised Graduate visa (subclass 476)"
},
{
id: 31,
type: "Working and skilled visas",
subclass: "489-887",
name: "Skilled Regional visa (subclass 489 887)"
},
{
id: 32,
type: "Working and skilled visas",
subclass: "892",
name: "State or Territory Sponsored Business Owner visa (subclass 892)"
},
{
id: 33,
type: "Working and skilled visas",
subclass: "893",
name: "State or Territory Sponsored Investor visa (subclass 893)"
},
{
id: 34,
type: "Working and skilled visas",
subclass: "408",
name: "Temporary Activity visa (subclass 408)"
},
{
id: 35,
type: "Working and skilled visas",
subclass: "485",
name: "Temporary Graduate visa (subclass 485)"
},
{
id: 36,
type: "Working and skilled visas",
subclass: "400-403",
name: "Temporary Work visa (subclass 400 403)"
},
{
id: 37,
type: "Working and skilled visas",
subclass: "482",
name: "Temporary Skill Shortage visa (subclass 482)"
},
]
export default visas;
/**
Refugee and humanitarian visas
Global Special Humanitarian (subclass 202)
Protection visa (subclass 866)
Refugee visas (subclass 200, 201, 203 and 204)
Temporary Protection visa (subclass 785)
Safe Haven Enterprise visa (subclass 790)
Other visas
Bridging visa A BVA - (subclass 010)
Bridging visa B BVB (subclass 020)
Bridging visa C BVC (subclass 030)
Bridging visa E BVE (subclass 050 and 051)
Crew Travel Authority visa (subclass 942)
Former Resident visa (subclass 151)
Maritime Crew visa (subclass 988)
Medical Treatment visa (subclass 602)
Resident Return visa (subclass 155 157)
Special Category visa (subclass 444)
Special Purpose visa
Retirement visa (subclass 410)
Investor Retirement visa (subclass 405)
Confirmatory (Residence) visa (subclass 808)
Repealed visas
Business (Short Stay) visa (subclass 456)
Business Skills (Provisional) visa (subclass 160 and 165)
Domestic Worker (Temporary) Diplomatic and Consular visa (subclass 426)
Domestic Worker (Temporary) Executive visa (subclass 427)
Electronic Travel Authority (Business Entrant) visa (subclass 956 and 977)
Electronic Travel Authority (Visitor) visa (subclass 976)
Employer Nomination Scheme (subclass 121 and 856)
Established Business in Australia visa (subclass 845)
Exchange visa (subclass 411)
Foreign Government Agency (subclass 415)
Government Agreement visa (subclass 406)
Labour Agreement visa (subclass 120)
Labour Agreement visa (subclass 855)
Media and Film Staff visa (subclass 423)
Medical Practitioner visa (subclass 422)
Medical Treatment (Short Stay) visa (subclass 675)
Medical Treatment Long Stay visa (subclass 685)
Regional Sponsor Migration Scheme (subclass 119 and 857)
Religious Worker visa (subclass 428)
Skilled Designated Area Sponsored visa (subclass 496)
Skilled Independent Regional (Provisional) visa (subclass 495)
Skilled Independent visa (subclass 175)
Skilled Independent visa (subclass 885)
Skilled Regional Sponsored visa (subclass 475)
Skilled Regional Sponsored (subclass 487)
Skilled Sponsored visa (subclass 176)
Special Program visa (subclass 416)
Sponsored visa (subclass 886)
Sport visa (subclass 421)
Superyacht Crew visa (subclass 488)
State or Territory Sponsored Regional Established Business in Australia visa (subclass 846)
Temporary Work (Entertainment) visa (subclass 420)
Temporary Work (Skilled) visa (subclass 457)
Tourist visa (subclass 676)
Temporary Work (long Stay Activity) visa (subclass 401)
Training and Research visa (subclass 402)
Visiting Academic visa (subclass 419)
Foreign Affairs or Defence sector visa (subclass 576)
Higher Education Sector visa (subclass 573)
Independent ELICOS Sector visa (subclass 570)
Non Award Sector visa (subclass 575)
Postgraduate Research Sector visa (subclass 574)
School Sector visa (subclass 571)
Student Guardian visa (subclass 580)
Vocational Education and Training Sector visa (Subclass 572)
] */

+ 0
- 10
src/assets/scripts/signup/SignupController.js View File

@ -1,10 +0,0 @@
'use strict';
angular.module('NomitWisp-Signup', [])
.controller('SignupController', SignupController);
/** @ngInject */
function SignupController($scope) {
}

+ 10
- 0
src/assets/scripts/signup/index.js View File

@ -0,0 +1,10 @@
'use strict';
import * as angular from 'angular';
import ngCookies from 'angular-cookies';
import SignupController from './signup.controller';
import SignupService from './signup.service';
angular.module('nwSignup', [ngCookies])
.controller(SignupController.name, SignupController)
.factory(SignupService.name, SignupService);

+ 16
- 0
src/assets/scripts/signup/signup.controller.js View File

@ -0,0 +1,16 @@
'use strict';
/** @ngInject */
const SignupController = ($scope, $cookies, $location, SignupService, UserService) => {
$scope.userSignup = async() => {
await SignupService.signupUserService($scope.user)
.then((result) => {
$cookies.put('access_token', result);
UserService.loadUser();
$location.path('/');
})
.catch((error) => { console.log(error); })
}
}
export default SignupController;

+ 41
- 0
src/assets/scripts/signup/signup.html View File

@ -0,0 +1,41 @@
<div class="peers ai-s fxw-nw h-100vh">
<div class="peer peer-greed h-100 pos-r bgr-n bgpX-c bgpY-c bgsz-cv" style='background-image: url("assets/static/images/bg.jpg")'>
<div class="pos-a centerXY">
<div class="bgc-white bdrs-50p pos-r" style='width: 120px; height: 120px;'>
<img class="pos-a centerXY" src="assets/static/images/logo.png" alt="">
</div>
</div>
</div>
<div ng-controller="SignupController" class="col-12 col-md-4 peer pX-40 pY-80 h-100 bgc-white scrollable pos-r" style='min-width: 320px;'>
<h4 class="fw-300 c-grey-900 mB-40">Register</h4>
<form ng-submit="userSignup()" name="SignupForm">
<div class="form-group">
<label class="text-normal text-dark">Fullname</label>
<input type="text" class="form-control" ng-model="user.fullname" Placeholder='John Doe' required />
</div>
<div class="form-group">
<label class="text-normal text-dark">Role</label>
<select ng-model="user.role">
<option ng-selected="user.role==''" value="">Choose role...</option>
<option value="User">User</option>
<option value="Company">Company</option>
</select>
</div>
<div class="form-group">
<label class="text-normal text-dark">Email Address</label>
<input type="email" class="form-control" ng-model="user.email" Placeholder='name@email.com' required />
</div>
<div class="form-group">
<label class="text-normal text-dark">Password</label>
<input type="password" class="form-control" ng-model="user.password" placeholder="Password" required />
</div>
<div class="form-group">
<label class="text-normal text-dark">Confirm Password</label>
<input type="password" class="form-control" placeholder="Password" required />
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" ng-disabled="SignupForm.$invalid">Register</button>
</div>
</form>
</div>
</div>

+ 0
- 3
src/assets/scripts/signup/signup.js View File

@ -1,3 +0,0 @@
'use strict';
angular.module('NomitWisp-Signup', []);

+ 21
- 17
src/assets/scripts/signup/signup.service.js View File

@ -1,22 +1,26 @@
'use strict';
angular.module('NomitWisp-Signup', [])
.factory(SignupService.name, SignupService);
/** @ngInject */
function SignupService($http) {
return $http({
method: 'POST',
url: 'https://nomitwisp-restapi.herokuapp.com/signup',
data: user,
headers: { 'Content-Type': 'application/json' }
})
.then((result) => {
console.log(result.data.token);
return result.data.token;
}).catch((err) => {
console.log(err.data);
return err.data;
});
const SignupService = ($http)=> {
let serv = {};
serv.signupUserService = (user) => {
return $http({
method: 'POST',
url: 'https://nomitwisp-restapi.herokuapp.com/signup',
data: user,
headers: { 'Content-Type': 'application/json' }
})
.then((result) => {
console.log(result.data.token);
return result.data.token;
}).catch((err) => {
console.log(err.data);
return err.data;
});
}
return serv;
}
export default SignupService;

Loading…
Cancel
Save