From 92c7744599a562d1ca59d7d7891b7eb0ffa2e2a9 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 15 Jan 2020 18:05:28 +0100 Subject: [PATCH] Add profile picture on profile page --- .../components/profile/profile.component.html | 11 +-- .../components/profile/profile.component.ts | 4 +- src/app/services/profile/profile.service.ts | 5 ++ src/assets/images/account_circle-24px.svg | 81 +++++++++++++++++++ 4 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 src/assets/images/account_circle-24px.svg diff --git a/src/app/components/profile/profile.component.html b/src/app/components/profile/profile.component.html index 507a73d..b40f0f6 100644 --- a/src/app/components/profile/profile.component.html +++ b/src/app/components/profile/profile.component.html @@ -4,12 +4,12 @@
- + camera_alt
- +
{{userProfile.username}} @@ -45,12 +45,13 @@ -
- +
+ camera_alt +
- +
{{userProfile.username}} @{{userProfile.handle}} diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index 2811552..412b106 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -73,7 +73,9 @@ export class ProfileComponent implements OnInit { formData.append('profilePicture', event.target.files[0]); this.http.post('https://greenvironment.net/upload', formData).subscribe( - (response) => console.log(response), + async (response: Response) => { + this.userProfile.profilePicture = 'https://greenvironment.net/' + (await response.json()).filename; + }, (error) => console.log(error) ); } diff --git a/src/app/services/profile/profile.service.ts b/src/app/services/profile/profile.service.ts index e8735b1..3de1124 100644 --- a/src/app/services/profile/profile.service.ts +++ b/src/app/services/profile/profile.service.ts @@ -81,6 +81,11 @@ export class ProfileService { profile.level = response.data.getUser.level; profile.friendCount = response.data.getUser.friendCount; profile.groupCount = response.data.getUser.groupCount; + if (response.data.getUser.profilePicture) { + profile.profilePicture = 'https://greenvironment.net/' + response.data.getUser.profilePicture; + } else { + profile.profilePicture = 'assets/images/account_circle-24px.svg'; + } const temp = new Date(Number(response.data.getUser.joinedAt)); const date = temp.toLocaleString('en-GB'); profile.joinedAt = date; diff --git a/src/assets/images/account_circle-24px.svg b/src/assets/images/account_circle-24px.svg new file mode 100644 index 0000000..6b911ac --- /dev/null +++ b/src/assets/images/account_circle-24px.svg @@ -0,0 +1,81 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + +