Adding profile component (de)activation logic
This commit is contained in:
parent
18a02f0940
commit
47c494653c
|
@ -1,8 +1,8 @@
|
||||||
import {NgModule} from '@angular/core';
|
import {NgModule} from '@angular/core';
|
||||||
import {RouterModule, Routes} from '@angular/router';
|
import {RouterModule, Routes} from '@angular/router';
|
||||||
import { GamenightComponent } from './pages/gamenight/gamenight.component';
|
import {GamenightComponent} from './pages/gamenight/gamenight.component';
|
||||||
import {HomeComponent} from './pages/home/home.component';
|
import {HomeComponent} from './pages/home/home.component';
|
||||||
import { StatsComponent } from './pages/stats/stats.component';
|
import {StatsComponent} from './pages/stats/stats.component';
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{path: '', component: HomeComponent, pathMatch: 'full'},
|
{path: '', component: HomeComponent, pathMatch: 'full'},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
import {Component} from '@angular/core';
|
||||||
import {Player} from './models/player';
|
import {Player} from './models/player';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
@ -3,11 +3,11 @@ import {BrowserModule} from '@angular/platform-browser';
|
||||||
|
|
||||||
import {AppRoutingModule} from './app-routing.module';
|
import {AppRoutingModule} from './app-routing.module';
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
import { HomeComponent } from './pages/home/home.component';
|
import {HomeComponent} from './pages/home/home.component';
|
||||||
import { StatsComponent } from './pages/stats/stats.component';
|
import {StatsComponent} from './pages/stats/stats.component';
|
||||||
import { GamenightComponent } from './pages/gamenight/gamenight.component';
|
import {GamenightComponent} from './pages/gamenight/gamenight.component';
|
||||||
import { HeaderComponent } from './components/header/header.component';
|
import {HeaderComponent} from './components/header/header.component';
|
||||||
import { ProfileComponent } from './components/profile/profile.component';
|
import {ProfileComponent} from './components/profile/profile.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
<p>Paddy</p>
|
<p>Paddy</p>
|
||||||
<img src="assets/images/user.png" alt="User Icon" (click)="openProfile()">
|
<img src="assets/images/user.png" alt="User Icon" (click)="openProfile()">
|
||||||
</span>
|
</span>
|
||||||
<app-profile *ngIf="showProfilePopover"></app-profile>
|
<app-profile (showProfilePopoverChange)="closeProfile()" *ngIf="showProfilePopover"></app-profile>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { HeaderComponent } from './header.component';
|
import {HeaderComponent} from './header.component';
|
||||||
|
|
||||||
describe('HeaderComponent', () => {
|
describe('HeaderComponent', () => {
|
||||||
let component: HeaderComponent;
|
let component: HeaderComponent;
|
||||||
|
@ -8,7 +8,7 @@ describe('HeaderComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ HeaderComponent ]
|
declarations: [HeaderComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,10 @@ export class HeaderComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
openProfile(): void {
|
openProfile(): void {
|
||||||
console.log('Called');
|
this.showProfilePopover = true;
|
||||||
this.showProfilePopover = !this.showProfilePopover;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
closeProfile(): void {
|
||||||
|
this.showProfilePopover = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
<div id="profile-popover">
|
<div id="profile-popover">
|
||||||
<p>Test</p>
|
<div *ngIf="isLoggedIn">
|
||||||
|
<h2 class="heading">Hello, Paddy!</h2>
|
||||||
|
<p>You're successfully logged in.</p>
|
||||||
|
<p>Your id is: 1</p>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="!isLoggedIn">
|
||||||
|
<h2 class="heading">Not logged in</h2>
|
||||||
|
<p>Please log in to continue</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -8,6 +8,11 @@
|
||||||
color: $text;
|
color: $text;
|
||||||
background-color: $secondary;
|
background-color: $secondary;
|
||||||
width: 15em;
|
width: 15em;
|
||||||
height: 20em;
|
|
||||||
border-radius: 1em;
|
border-radius: 1em;
|
||||||
|
padding: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2.heading {
|
||||||
|
text-align: center;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { ProfileComponent } from './profile.component';
|
import {ProfileComponent} from './profile.component';
|
||||||
|
|
||||||
describe('ProfileComponent', () => {
|
describe('ProfileComponent', () => {
|
||||||
let component: ProfileComponent;
|
let component: ProfileComponent;
|
||||||
|
@ -8,7 +8,7 @@ describe('ProfileComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ ProfileComponent ]
|
declarations: [ProfileComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, ElementRef, EventEmitter, HostListener, OnInit, Output} from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-profile',
|
selector: 'app-profile',
|
||||||
|
@ -7,9 +7,32 @@ import { Component, OnInit } from '@angular/core';
|
||||||
})
|
})
|
||||||
export class ProfileComponent implements OnInit {
|
export class ProfileComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
initialClick = true;
|
||||||
|
@Output() showProfilePopoverChange = new EventEmitter<boolean>();
|
||||||
|
|
||||||
|
isLoggedIn = true;
|
||||||
|
|
||||||
|
constructor(private eRef: ElementRef) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to close Profile component when user clicks outside the component
|
||||||
|
* @param event
|
||||||
|
*/
|
||||||
|
@HostListener('document:click', ['$event'])
|
||||||
|
@HostListener('document:touchstart', ['$event'])
|
||||||
|
handleOutsideClick(event: any) {
|
||||||
|
if (this.initialClick) {
|
||||||
|
this.initialClick = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.eRef.nativeElement.contains(event.target)) {
|
||||||
|
this.showProfilePopoverChange.emit(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import {Player} from './player';
|
import {Player} from './player';
|
||||||
import {Announcement} from './enums/announcement';
|
import {Announcement} from './enums/announcement';
|
||||||
import { Solo } from './enums/solo';
|
import {Solo} from './enums/solo';
|
||||||
|
|
||||||
export interface Game {
|
export interface Game {
|
||||||
gameId: number;
|
gameId: number;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { GamenightComponent } from './gamenight.component';
|
import {GamenightComponent} from './gamenight.component';
|
||||||
|
|
||||||
describe('GamenightComponent', () => {
|
describe('GamenightComponent', () => {
|
||||||
let component: GamenightComponent;
|
let component: GamenightComponent;
|
||||||
|
@ -8,7 +8,7 @@ describe('GamenightComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ GamenightComponent ]
|
declarations: [GamenightComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-gamenight',
|
selector: 'app-gamenight',
|
||||||
|
@ -7,7 +7,8 @@ import { Component, OnInit } from '@angular/core';
|
||||||
})
|
})
|
||||||
export class GamenightComponent implements OnInit {
|
export class GamenightComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { HomeComponent } from './home.component';
|
import {HomeComponent} from './home.component';
|
||||||
|
|
||||||
describe('HomeComponent', () => {
|
describe('HomeComponent', () => {
|
||||||
let component: HomeComponent;
|
let component: HomeComponent;
|
||||||
|
@ -8,7 +8,7 @@ describe('HomeComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ HomeComponent ]
|
declarations: [HomeComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {ActivatedRoute} from '@angular/router';
|
import {ActivatedRoute} from '@angular/router';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -10,12 +10,13 @@ export class HomeComponent implements OnInit {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute
|
||||||
) { }
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.route.queryParams.subscribe(params => {
|
this.route.queryParams.subscribe(params => {
|
||||||
console.table(params);
|
// Read params
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
||||||
|
|
||||||
import { StatsComponent } from './stats.component';
|
import {StatsComponent} from './stats.component';
|
||||||
|
|
||||||
describe('StatsComponent', () => {
|
describe('StatsComponent', () => {
|
||||||
let component: StatsComponent;
|
let component: StatsComponent;
|
||||||
|
@ -8,7 +8,7 @@ describe('StatsComponent', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [ StatsComponent ]
|
declarations: [StatsComponent]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-stats',
|
selector: 'app-stats',
|
||||||
|
@ -7,7 +7,8 @@ import { Component, OnInit } from '@angular/core';
|
||||||
})
|
})
|
||||||
export class StatsComponent implements OnInit {
|
export class StatsComponent implements OnInit {
|
||||||
|
|
||||||
constructor() { }
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ export class StorageService {
|
||||||
firstName: firstName,
|
firstName: firstName,
|
||||||
token: token,
|
token: token,
|
||||||
sessionKey: sessionKey
|
sessionKey: sessionKey
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setUserInfo(user: User): void {
|
setUserInfo(user: User): void {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user