1
1
import { Component , OnInit } from '@angular/core' ;
2
2
import { ActivatedRoute , Params } from '@angular/router' ;
3
3
import { trigger , state , style , transition , animate , keyframes } from '@angular/animations' ;
4
+
4
5
import * as firebase from 'firebase' ;
5
6
6
7
import { User , Profile , UserService , AlertService } from '../shared' ;
@@ -27,32 +28,27 @@ import { User, Profile, UserService, AlertService } from '../shared';
27
28
]
28
29
} )
29
30
export class ProfileComponent implements OnInit {
30
- profile : Profile ;
31
- currentUser : User ;
32
- user : { uid : any } ;
31
+ uid = firebase . auth ( ) . currentUser . uid ;
33
32
34
- profileTitle = 'My profile' ;
35
- // profileBio: string = 'Here you can place your own personal bio text.';
36
33
fullImagePath : string ;
34
+ profileTitle : string = 'My profile' ;
35
+ displayName : string = "Your username" ;
36
+ bio : any = "Your bio" ;
37
37
38
38
state = 'small' ;
39
39
40
- constructor ( private route : ActivatedRoute ,
41
- private userService : UserService ,
42
- private alertService : AlertService ) {
43
- this . fullImagePath = '/assets/img/mb-bg-04.png' ;
40
+ constructor (
41
+ private route : ActivatedRoute ,
42
+ private userService : UserService ,
43
+ private alertService : AlertService ) {
44
+ this . fullImagePath = '/assets/img/mb-bg-04.png' ;
44
45
}
45
46
46
47
ngOnInit ( ) {
47
- this . user = {
48
- uid : this . route . snapshot . params [ 'uid' ]
49
- } ;
50
- this . route . params
51
- . subscribe (
52
- ( params : Params ) => {
53
- this . user . uid = params [ 'uid' ] ;
54
- }
55
- ) ;
48
+ firebase . database ( ) . ref ( ) . child ( 'users/' + this . uid ) . once ( 'value' ) . then ( ( snap ) => {
49
+ this . displayName = snap . val ( ) . displayName ,
50
+ this . bio = snap . val ( ) . bio
51
+ } ) ;
56
52
}
57
53
58
54
animateImage ( ) {
@@ -64,11 +60,6 @@ export class ProfileComponent implements OnInit {
64
60
return firebase . auth ( ) . currentUser . email ;
65
61
}
66
62
67
- userName ( ) {
68
- this . userService . getUserProfileInformation ( ) ;
69
- return firebase . auth ( ) . currentUser . displayName ;
70
- }
71
-
72
63
onPasswordReset ( ) {
73
64
this . userService . sendUserPasswordResetEmail ( ) ;
74
65
this . alertService . showToaster ( 'Reset password is sent to your email' ) ;
0 commit comments