|
|
|
@ -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;
|
|
|
|
|
}
|
|
|
|
|