From 73f37bad442af712e49a197ba59eb607c84627fe Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 1 Jan 2020 22:58:55 +0100 Subject: [PATCH 1/9] disabled zoom on mobile devices --- .../components/main-navigation/main-navigation.component.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/components/main-navigation/main-navigation.component.html b/src/app/components/main-navigation/main-navigation.component.html index 941c0bb..3b4669e 100644 --- a/src/app/components/main-navigation/main-navigation.component.html +++ b/src/app/components/main-navigation/main-navigation.component.html @@ -1,4 +1,5 @@ - + + From 91ebff182a36d33cc488ef97d2d22a23c0a9f0a8 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 3 Jan 2020 00:43:21 +0100 Subject: [PATCH 2/9] added friend request button on profile page --- .../components/profile/profile.component.html | 8 +++++ .../components/profile/profile.component.sass | 6 ++++ .../components/profile/profile.component.ts | 26 +++++++++++++--- src/app/components/search/search.component.ts | 25 ++------------- src/app/services/request/request.service.ts | 31 +++++++++++++++++++ 5 files changed, 68 insertions(+), 28 deletions(-) diff --git a/src/app/components/profile/profile.component.html b/src/app/components/profile/profile.component.html index a6fca4f..a93020d 100644 --- a/src/app/components/profile/profile.component.html +++ b/src/app/components/profile/profile.component.html @@ -8,6 +8,14 @@
{{user.username}} {{user.handle}} +
+ +
diff --git a/src/app/components/profile/profile.component.sass b/src/app/components/profile/profile.component.sass index 4d0369e..94f9cde 100644 --- a/src/app/components/profile/profile.component.sass +++ b/src/app/components/profile/profile.component.sass @@ -16,6 +16,12 @@ margin: 0 auto width: 100% max-width: 690px + .icon-box + text-align: right + width: 100% + .request-button + margin-top: 0.5em + margin-bottom: 0.5em .mat-table width: 100% diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index 1da58c8..59aa850 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -7,6 +7,8 @@ import { Levellist } from 'src/app/models/levellist'; import { environment } from 'src/environments/environment'; import {MatSort} from '@angular/material/sort'; import {MatTableDataSource} from '@angular/material/table'; +import { RequestService } from 'src/app/services/request/request.service'; +import { DatasharingService } from '../../services/datasharing.service'; @Component({ selector: 'app-profile', @@ -18,7 +20,8 @@ export class ProfileComponent implements OnInit { actionlist: Actionlist = new Actionlist(); levellist: Levellist = new Levellist(); - user: User = new User(); + private user: User = new User(); + self: User; id: string; rankname: string; profileNotFound = false; @@ -26,7 +29,12 @@ export class ProfileComponent implements OnInit { dataSource = new MatTableDataSource(this.actionlist.Actions); displayedLevelColumns = ['level', 'name']; levelSource = this.levellist.levels; - constructor(private router: Router, private http: Http) { } + + constructor( + private router: Router, + private http: Http, + private requestService: RequestService, + private data: DatasharingService) { } @ViewChild(MatSort, {static: true}) sort: MatSort; ngOnInit() { @@ -37,12 +45,14 @@ export class ProfileComponent implements OnInit { const headers = new Headers(); headers.set('Content-Type', 'application/json'); - return this.http.post(url, this.buildJson(this.id)) + this.http.post(url, this.buildJson(this.id)) .subscribe(response => { console.log(response.text()); this.updateUserInfo(response.json()); - } - ); + }); + this.data.currentUserInfo.subscribe(user => { + this.self = user; + }); } public updateUserInfo(response: any) { @@ -55,11 +65,17 @@ export class ProfileComponent implements OnInit { this.user.points = response.data.getUser.points; this.user.level = response.data.getUser.level; this.rankname = this.levellist.getLevelName(this.user.level); + this.user.allowedToSendRequest = this.requestService.isAllowedToSendRequest(response.data.getUser.id, this.self); } else { this.profileNotFound = true; } } + public sendFriendRequest(user: User) { + user.allowedToSendRequest = false; + this.requestService.sendFriendRequest(user); + } + public buildJson(id: string): any { const body = {query: `query($userId: ID) { getUser(userId:$userId){ diff --git a/src/app/components/search/search.component.ts b/src/app/components/search/search.component.ts index 4cd8ea4..b927242 100644 --- a/src/app/components/search/search.component.ts +++ b/src/app/components/search/search.component.ts @@ -57,24 +57,7 @@ export class SearchComponent implements OnInit { .subscribe(response => { this.foundUsers = this.searchService.renderUsers(response.json()); for (const foundUser of this.foundUsers) { - if (!this.user.loggedIn) {foundUser.allowedToSendRequest = false; } else { - for (const receiverID of this.user.sentRequestUserIDs) { - if (foundUser.userID === receiverID || - foundUser.userID === this.user.userID) { - foundUser.allowedToSendRequest = false; - } - } - for (const friend of this.user.friends) { - if (foundUser.userID === friend.id) { - foundUser.allowedToSendRequest = false; - } - } - for (const sender of this.user.receivedRequests) { - if (foundUser.userID === sender.senderUserID) { - foundUser.allowedToSendRequest = false; - } - } - } + foundUser.allowedToSendRequest = this.requestService.isAllowedToSendRequest(foundUser.userID, this.user); } this.loading = false; }); @@ -86,11 +69,7 @@ export class SearchComponent implements OnInit { public sendFriendRequest(user: User) { user.allowedToSendRequest = false; - const headers = new Headers(); - headers.set('Content-Type', 'application/json'); - this.http.post(environment.graphQLUrl, this.requestService.buildJsonRequest(user.userID, 'FRIENDREQUEST')) - .subscribe(response => { - }); + this.requestService.sendFriendRequest(user); } } diff --git a/src/app/services/request/request.service.ts b/src/app/services/request/request.service.ts index 36271ca..8cf340e 100644 --- a/src/app/services/request/request.service.ts +++ b/src/app/services/request/request.service.ts @@ -3,6 +3,7 @@ import {Headers, Http} from '@angular/http'; import {DatasharingService} from '../datasharing.service'; import {Router} from '@angular/router'; import {environment} from 'src/environments/environment'; +import { User } from 'src/app/models/user'; @Injectable({ @@ -13,6 +14,36 @@ export class RequestService { constructor(private http: Http, private data: DatasharingService, private router: Router) { } + public isAllowedToSendRequest(userID: number, self: User): boolean { + if (!self.loggedIn) { return false; } else { + for (const receiverID of self.sentRequestUserIDs) { + if (userID === receiverID || + userID === self.userID) { + return false; + } + } + for (const friend of self.friends) { + if (userID === friend.id) { + return false; + } + } + for (const sender of self.receivedRequests) { + if (userID === sender.senderUserID) { + return false; + } + } + } + return true; + } + + public sendFriendRequest(user: User) { + const headers = new Headers(); + headers.set('Content-Type', 'application/json'); + this.http.post(environment.graphQLUrl, this.buildJsonRequest(user.userID, 'FRIENDREQUEST')) + .subscribe(response => { + }); + } + public buildJsonRequest(id_: number, type_: String): any { const body = { query: `mutation($id: ID!, $type: RequestType) { From 7ded9d49b8b0c53751bb6c8da49e9005e573e477 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 3 Jan 2020 00:49:22 +0100 Subject: [PATCH 3/9] added login button to the settings menu --- .../main-navigation/main-navigation.component.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app/components/main-navigation/main-navigation.component.html b/src/app/components/main-navigation/main-navigation.component.html index 3b4669e..814da14 100644 --- a/src/app/components/main-navigation/main-navigation.component.html +++ b/src/app/components/main-navigation/main-navigation.component.html @@ -106,6 +106,12 @@ log out +
+ +
From b1f3b7201c606173da686c88d4db8f5b5d6b8eb6 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 3 Jan 2020 12:34:35 +0100 Subject: [PATCH 4/9] fixed profile link bug --- .../components/profile/profile.component.html | 18 +++++----- .../components/profile/profile.component.ts | 33 ++++++++++++------- 2 files changed, 31 insertions(+), 20 deletions(-) diff --git a/src/app/components/profile/profile.component.html b/src/app/components/profile/profile.component.html index a93020d..9d15582 100644 --- a/src/app/components/profile/profile.component.html +++ b/src/app/components/profile/profile.component.html @@ -6,13 +6,13 @@
- {{user.username}} - {{user.handle}} + {{userProfile.username}} + {{userProfile.handle}}
@@ -21,27 +21,27 @@
name:
- +
handle:
- +
profileID:
- +
points:
- +
level:
- + diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index 59aa850..4f8f4f2 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, ViewChild} from '@angular/core'; -import {Router} from '@angular/router'; +import {Router, NavigationEnd} from '@angular/router'; import {Http, URLSearchParams, Headers} from '@angular/http'; import { User } from 'src/app/models/user'; import { Actionlist } from 'src/app/models/actionlist'; @@ -20,7 +20,7 @@ export class ProfileComponent implements OnInit { actionlist: Actionlist = new Actionlist(); levellist: Levellist = new Levellist(); - private user: User = new User(); + userProfile: User = new User(); self: User; id: string; rankname: string; @@ -34,7 +34,17 @@ export class ProfileComponent implements OnInit { private router: Router, private http: Http, private requestService: RequestService, - private data: DatasharingService) { } + private data: DatasharingService) { + router.events.forEach((event) => { + // check if the user is on the profile page (of userY) and routes to the page of userY (e.g. his own page) + if (event instanceof NavigationEnd) { + if (this.id !== this.router.url.substr(this.router.url.lastIndexOf('/') + 1) && this.id) { + // reload the user + this.ngOnInit(); + } + } + }); + } @ViewChild(MatSort, {static: true}) sort: MatSort; ngOnInit() { @@ -58,14 +68,15 @@ export class ProfileComponent implements OnInit { public updateUserInfo(response: any) { if (response.data.getUser != null) { this.profileNotFound = false; - this.user.loggedIn = true; - this.user.userID = response.data.getUser.id; - this.user.username = response.data.getUser.name; - this.user.handle = response.data.getUser.handle; - this.user.points = response.data.getUser.points; - this.user.level = response.data.getUser.level; - this.rankname = this.levellist.getLevelName(this.user.level); - this.user.allowedToSendRequest = this.requestService.isAllowedToSendRequest(response.data.getUser.id, this.self); + this.userProfile.loggedIn = true; + this.userProfile.userID = response.data.getUser.id; + this.userProfile.username = response.data.getUser.name; + this.userProfile.handle = response.data.getUser.handle; + this.userProfile.points = response.data.getUser.points; + this.userProfile.level = response.data.getUser.level; + this.rankname = this.levellist.getLevelName(this.userProfile.level); + // tslint:disable-next-line:max-line-length + this.userProfile.allowedToSendRequest = this.requestService.isAllowedToSendRequest(response.data.getUser.id, this.self); } else { this.profileNotFound = true; } From 1a9023750a1519b3e4ef2d483121fccf8bf9795d Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 3 Jan 2020 13:15:02 +0100 Subject: [PATCH 5/9] darken the background colour --- src/styles/greenvironment-material-theme.scss | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/styles/greenvironment-material-theme.scss b/src/styles/greenvironment-material-theme.scss index 5c30826..d83e945 100644 --- a/src/styles/greenvironment-material-theme.scss +++ b/src/styles/greenvironment-material-theme.scss @@ -11,7 +11,6 @@ // hue. Available color palettes: https://material.io/design/color/ $primary: mat-palette($mat-light-green); $accent: mat-palette($mat-brown, A200, A100, A400); -$background-color: map_get($mat-grey, 50); // The warn palette is optional (defaults to red). $warn: mat-palette($mat-red); @@ -19,7 +18,7 @@ $warn: mat-palette($mat-red); $light-theme: mat-light-theme($primary, $accent, $warn); // Set custom background color -$background-color: map_get($mat-blue-grey, 50); +$background-color: #e6e6e6; $background: map-get($light-theme, background); $background: map_merge($background, (background: $background-color)); @@ -29,13 +28,16 @@ $light-theme: map_merge($light-theme, (background: $background)); $dark-primary: mat-palette($mat-light-green); $dark-accent: mat-palette($mat-brown, A200, A100, A400); - -// The warn palette is optional (defaults to red). $dark-warn: mat-palette($mat-red); // Create the theme object (a Sass map containing all of the palettes). $dark-theme: mat-dark-theme($dark-primary, $dark-accent, $dark-warn); +$dark-background-color: #121212; + +$dark-background: map-get($dark-theme, background); +$dark-background: map_merge($dark-background, (background: $dark-background-color)); +$dark-theme: map_merge($dark-theme, (background: $dark-background)); .dark-theme { @include angular-material-theme($dark-theme); From 309f8c7c9339d6ea3802dfd22ce09918b1daadba Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 3 Jan 2020 13:32:51 +0100 Subject: [PATCH 6/9] too long handles are cut now --- src/app/components/search/search.component.sass | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/components/search/search.component.sass b/src/app/components/search/search.component.sass index a256f6a..85c4400 100644 --- a/src/app/components/search/search.component.sass +++ b/src/app/components/search/search.component.sass @@ -20,9 +20,11 @@ box-sizing: border-box width: 100% margin-top: 0.5em - + /deep/ .mat-card-header-text + width: 1000% .mat-card-subtitle margin: 0 + word-break: break-all .request-button margin-top: 0.5em margin-bottom: 0.5em From 17053fff49e52dd810ebc14709211fc40dd6b690 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 3 Jan 2020 13:50:28 +0100 Subject: [PATCH 7/9] added 'not logged in info' in feed --- src/app/components/feed/feed.component.html | 65 +++++++++++++-------- src/app/components/feed/feed.component.sass | 3 + 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/app/components/feed/feed.component.html b/src/app/components/feed/feed.component.html index 8ce9d5b..4acdf59 100644 --- a/src/app/components/feed/feed.component.html +++ b/src/app/components/feed/feed.component.html @@ -1,29 +1,44 @@
- - - - - - -

- I protected the environment. -

- - What did you do? - - nothing ;) - - {{action.name}} - - - - -
-
+
+ + + + + + +

+ I protected the environment. +

+ + What did you do? + + nothing ;) + + {{action.name}} + + + + +
+
+
+
+ + + + You are not logged in. Do you want to post something? + + + + Login + + +
+
New diff --git a/src/app/components/feed/feed.component.sass b/src/app/components/feed/feed.component.sass index cbedf1a..2aaf164 100644 --- a/src/app/components/feed/feed.component.sass +++ b/src/app/components/feed/feed.component.sass @@ -10,6 +10,9 @@ display: flex width: 100% padding: 0.5em +#info + ::ng-deep .mat-card-header-text + margin: 0px #feedlist width: 100% From 95b4e32c1363c2f56c592c4fa47dabf7d20f6565 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 3 Jan 2020 13:55:39 +0100 Subject: [PATCH 8/9] disabled chat and social tab if not logged in --- src/app/components/home/home.component.html | 4 ++-- .../components/main-navigation/main-navigation.component.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/components/home/home.component.html b/src/app/components/home/home.component.html index 0949129..80fc08e 100644 --- a/src/app/components/home/home.component.html +++ b/src/app/components/home/home.component.html @@ -12,7 +12,7 @@ -->
- + chat @@ -24,7 +24,7 @@ - + people diff --git a/src/app/components/main-navigation/main-navigation.component.ts b/src/app/components/main-navigation/main-navigation.component.ts index fee1f60..d3c11a7 100644 --- a/src/app/components/main-navigation/main-navigation.component.ts +++ b/src/app/components/main-navigation/main-navigation.component.ts @@ -54,10 +54,10 @@ export class MainNavigationComponent implements OnInit { { path: '/imprint', label: 'Imprint' }, ]; navLinks = [ + { path: '/login', label: 'Login' }, { path: '', label: 'Home' }, { path: '/about', label: 'About' }, { path: '/imprint', label: 'Imprint' }, - { path: '/login', label: 'Login' }, ]; @HostBinding('class') componentCssClass; From b910f4086ee24c96bed038159a416a211bdfc815 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 3 Jan 2020 14:34:47 +0100 Subject: [PATCH 9/9] tabs in social container adapt to width now, too long usernames are cut --- src/app/components/home/home.component.html | 7 ++++--- src/app/components/home/home.component.sass | 2 +- src/app/components/search/search.component.sass | 5 +++++ src/app/components/social/social.component.html | 2 +- src/app/components/social/social.component.sass | 4 ++++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app/components/home/home.component.html b/src/app/components/home/home.component.html index 80fc08e..e274fc6 100644 --- a/src/app/components/home/home.component.html +++ b/src/app/components/home/home.component.html @@ -1,7 +1,8 @@
-
-
-
+
+
+ +
{{user.username}}{{userProfile.username}}
{{user.handle}}{{userProfile.handle}}
{{user.userID}}{{userProfile.userID}}
{{user.points}}{{userProfile.points}}
{{user.level}}{{userProfile.level}}