Skip to content

Commit 2f0ee36

Browse files
committed
Profile info and profile settings now works + removed unnecessary code
1 parent 694b564 commit 2f0ee36

File tree

9 files changed

+190
-201
lines changed

9 files changed

+190
-201
lines changed

docs/FEATURES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* Auth Guard
1313
* Profile
1414
* Profile image animation
15+
* Profile settings
1516
* Password reset
1617
* Alerts
1718
* 360 view

docs/TODO.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
All improvements to this repo will first be done in the development branch.
22

33
## To Do List
4-
* Make every component responsive
4+
* Make every component responsive (flex-layout)
55

66
## To Finish List (known issues)
77
### Auth
@@ -11,7 +11,6 @@ All improvements to this repo will first be done in the development branch.
1111

1212
### Profile
1313
* Profile image uploading
14-
* Profile settings (change settings)
1514
* Messaging layout and functionality
1615

1716
### Tests

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngxmatfire",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"author": "Jeroen Ouwehand",
55
"description": "Full stack starter app with Angular 4, Material Design and Firebase.",
66
"keywords": [

src/app/components/profile/profile-settings.component.html

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22
<md-card>
33
<h3>My profile settings</h3>
44

5-
<form class="form" (ngSubmit)="onUpdateUserInfo(sv)" #sv="ngForm">
6-
7-
<md-input-container class="form-group">
8-
<input mdInput placeholder="Username" id="displayName" name="displayName" ngModel required>
9-
</md-input-container>
10-
11-
<md-input-container class="form-group">
12-
<textarea mdInput placeholder="Short Bio" rows="8" id="bio" name="bio" ngModel required></textarea>
13-
</md-input-container>
14-
15-
<hr>
16-
17-
<md-card-actions class="button">
18-
<button md-raised-button class="primary" type="submit">Save Settings</button>
19-
</md-card-actions>
20-
21-
<md-card-actions class="button">
22-
<button md-raised-button class="primary" (click)="onLogout()">Logout</button>
23-
</md-card-actions>
24-
25-
</form>
26-
27-
<md-card-actions class="button">
28-
<button md-raised-button class="primary" (click)="onPasswordReset()">Reset Password</button>
29-
</md-card-actions>
5+
<form class="form" (ngSubmit)="onUpdateUserInfo(sv)" #sv="ngForm">
6+
7+
<md-input-container class="form-group">
8+
<input mdInput placeholder="Username" id="displayName" name="displayName" [(ngModel)]="displayName" required>
9+
</md-input-container>
10+
11+
<md-input-container class="form-group">
12+
<textarea mdInput placeholder="Short Bio" rows="6" id="bio" name="bio" [(ngModel)]="bio" required></textarea>
13+
</md-input-container>
14+
15+
<hr>
16+
17+
<md-card-actions class="button">
18+
<button md-raised-button class="primary" type="submit">Save Settings</button>
19+
</md-card-actions>
20+
21+
<md-card-actions class="button">
22+
<button md-raised-button class="primary" (click)="onLogout()">Logout</button>
23+
</md-card-actions>
24+
25+
<md-card-actions class="button">
26+
<button md-raised-button class="primary" (click)="onPasswordReset()">Reset Password</button>
27+
</md-card-actions>
28+
29+
</form>
3030

3131
</md-card>
3232
</div>

src/app/components/profile/profile-settings.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ import { Profile, AuthService, AlertService, UserService } from '../shared';
1212
styleUrls: ['./profile-settings.component.scss']
1313
})
1414
export class ProfileSettingsComponent implements OnInit {
15-
uid: any;
15+
uid = firebase.auth().currentUser.uid;
16+
displayName: string = "Your username";
17+
bio: any = "Your bio";
1618

1719
constructor(
1820
private authService: AuthService,
@@ -21,7 +23,11 @@ export class ProfileSettingsComponent implements OnInit {
2123
}
2224

2325
ngOnInit() {
24-
}
26+
firebase.database().ref().child(`users/${this.uid}`).once('value').then((snap) => {
27+
this.displayName = snap.val().displayName;
28+
this.bio = snap.val().bio;
29+
});
30+
}
2531

2632
onPasswordReset() {
2733
this.userService.sendUserPasswordResetEmail();

src/app/components/profile/profile.component.html

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
<div class="profile">
22
<md-card>
3-
43
<div [@imageAnimation]='state' (click)="animateImage()" class="avatar"><img [src]="fullImagePath"></div>
5-
6-
<md-card-header>
7-
<md-card-title><h3>{{profileTitle}}</h3></md-card-title>
8-
<md-card-title><h4>{{userEmail()}}</h4>
9-
<md-card-subtitle id="displayName" name="displayName" ngModel>({{userName()}})</md-card-subtitle>
10-
<md-card-subtitle>{{user.uid}}</md-card-subtitle>
11-
</md-card-title>
12-
</md-card-header>
134

14-
<hr />
5+
<md-card-header>
6+
<md-card-title><h3>{{profileTitle}}</h3></md-card-title>
7+
<md-card-title><h4>{{userEmail()}}</h4>
8+
<md-card-subtitle>{{displayName}}</md-card-subtitle>
9+
</md-card-title>
10+
</md-card-header>
1511

16-
<!-- <md-card-subtitle>{{profileBio}}</md-card-subtitle> -->
12+
<hr>
13+
14+
<md-card-subtitle>{{bio}}</md-card-subtitle>
1715

1816
<md-card-actions class="button">
1917
<button md-raised-button class="primary" (click)="onPasswordReset()">Reset my password</button>

src/app/components/profile/profile.component.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
md-card {
66
width: 400px;
7-
height: 390px;
7+
height: 460px;
88
margin: 100px auto;
99
}
1010

@@ -38,5 +38,7 @@ a:hover {
3838
}
3939

4040
.button {
41+
position: absolute;
42+
bottom: 35px;
4143
margin: 0 auto;
4244
}

src/app/components/profile/profile.component.ts

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, OnInit } from '@angular/core';
22
import { ActivatedRoute, Params } from '@angular/router';
3-
import { FormGroup, ReactiveFormsModule } from '@angular/forms';
43
import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';
4+
55
import * as firebase from 'firebase';
66

77
import { User, Profile, UserService, AlertService } from '../shared';
@@ -28,35 +28,23 @@ import { User, Profile, UserService, AlertService } from '../shared';
2828
]
2929
})
3030
export class ProfileComponent implements OnInit {
31-
profile: Profile;
32-
currentUser: User;
33-
user: {uid: any};
3431
uid = firebase.auth().currentUser.uid;
3532

3633
fullImagePath: string;
3734
profileTitle: string = 'My profile';
38-
displayName: any;
39-
bio: any;
35+
displayName: string = "Your username";
36+
bio: any = "Your bio";
4037

4138
state = 'small';
4239

43-
constructor(private route: ActivatedRoute,
44-
private userService: UserService,
45-
private alertService: AlertService) {
46-
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';
4745
}
4846

4947
ngOnInit() {
50-
this.user = {
51-
uid: this.route.snapshot.params['uid']
52-
};
53-
this.route.params
54-
.subscribe(
55-
(params: Params) => {
56-
this.user.uid = params['uid'];
57-
}
58-
);
59-
6048
firebase.database().ref().child('users/' + this.uid).once('value').then((snap) => {
6149
this.displayName = snap.val().displayName,
6250
this.bio = snap.val().bio
@@ -72,11 +60,6 @@ export class ProfileComponent implements OnInit {
7260
return firebase.auth().currentUser.email;
7361
}
7462

75-
userName() {
76-
this.userService.getUserProfileInformation();
77-
return firebase.auth().currentUser.displayName;
78-
}
79-
8063
onPasswordReset() {
8164
this.userService.sendUserPasswordResetEmail();
8265
this.alertService.showToaster('Reset password is sent to your email');

0 commit comments

Comments
 (0)