Skip to content

Commit

Permalink
Added components related to games list and board and improved base st…
Browse files Browse the repository at this point in the history
…ructure #12
  • Loading branch information
acautin committed Nov 13, 2017
1 parent 5a8cf07 commit 313e6d8
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 15 deletions.
4 changes: 3 additions & 1 deletion priv/dev/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import { Routes, RouterModule } from "@angular/router";
import { LoginComponent } from "app/auth/login/login.component";
import { RegisterComponent } from "app/auth/register/register.component";
import { WelcomeComponent } from "app/welcome/welcome.component";
import { TypeListComponent } from "app/games/type-list/type-list.component";

const appRoutes: Routes = [
{path: '', redirectTo: 'welcome', pathMatch: 'full'},
{path: 'welcome', component: WelcomeComponent},
{path: 'register', component: RegisterComponent},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent}
{path: 'type-list', component: TypeListComponent}
];

@NgModule({
Expand Down
8 changes: 6 additions & 2 deletions priv/dev/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { BoardComponent } from './board/board.component';
import { BoardComponent } from './games/board/board.component';
import { MovesComponent } from './moves/moves.component';
import { WelcomeComponent } from './welcome/welcome.component';
import { HeaderComponent } from './header/header.component';
import { LoginComponent } from './auth/login/login.component';
import { RegisterComponent } from './auth/register/register.component';
import { AuthService } from 'app/auth/auth.service';
import { AppRoutingModule } from 'app/app-routing.module';
import { TypeListComponent } from './games/type-list/type-list.component';
import { GameListComponent } from './games/game-list/game-list.component';

@NgModule({
declarations: [
Expand All @@ -21,7 +23,9 @@ import { AppRoutingModule } from 'app/app-routing.module';
WelcomeComponent,
HeaderComponent,
LoginComponent,
RegisterComponent
RegisterComponent,
TypeListComponent,
GameListComponent
],
imports: [
BrowserModule,
Expand Down
12 changes: 11 additions & 1 deletion priv/dev/src/app/auth/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { Injectable } from "@angular/core";
import { Router } from "@angular/router";

@Injectable()
export class AuthService {
// TODO: For now a dummy service
private authenticated = false;

login() {
constructor(private router: Router) {}

login(email: string, password: string) {
console.log("Loging in user:", email);
console.log(password);
this.authenticated = true;
this.router.navigate(['/type-list']);
}

logout() {
this.authenticated = false;
this.router.navigate(['/']);
}

isAuthenticated() {
Expand Down
2 changes: 1 addition & 1 deletion priv/dev/src/app/auth/login/login.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form>
<form (ngSubmit)="login(f)" #f="ngForm">
<div class="form-group">
<label for="email">Email</label>
<input type="email" class="form-control" id="email" name="email" ngModel>
Expand Down
18 changes: 12 additions & 6 deletions priv/dev/src/app/auth/login/login.component.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { Component, OnInit } from '@angular/core';
import { NgForm } from '@angular/forms';
import { AuthService } from 'app/auth/auth.service';

@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {

constructor() { }
constructor(private authService: AuthService) { }

ngOnInit() {
}
ngOnInit() { }

login(form: NgForm) {
const email = form.value.email;
const password = form.value.password;
this.authService.login(email, password);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
3 changes: 3 additions & 0 deletions priv/dev/src/app/games/game-list/game-list.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
game-list works!
</p>
25 changes: 25 additions & 0 deletions priv/dev/src/app/games/game-list/game-list.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { GameListComponent } from './game-list.component';

describe('GameListComponent', () => {
let component: GameListComponent;
let fixture: ComponentFixture<GameListComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ GameListComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(GameListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions priv/dev/src/app/games/game-list/game-list.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-game-list',
templateUrl: './game-list.component.html',
styleUrls: ['./game-list.component.css']
})
export class GameListComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
Empty file.
3 changes: 3 additions & 0 deletions priv/dev/src/app/games/type-list/type-list.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>
List of supported game types from server will be presented here.
</p>
25 changes: 25 additions & 0 deletions priv/dev/src/app/games/type-list/type-list.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { TypeListComponent } from './type-list.component';

describe('TypeListComponent', () => {
let component: TypeListComponent;
let fixture: ComponentFixture<TypeListComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ TypeListComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(TypeListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions priv/dev/src/app/games/type-list/type-list.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-type-list',
templateUrl: './type-list.component.html',
styleUrls: ['./type-list.component.css']
})
export class TypeListComponent implements OnInit {

constructor() { }

ngOnInit() {
}

}
6 changes: 3 additions & 3 deletions priv/dev/src/app/header/header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<li><a routerLink="/login">Login</a></li>
<li><a routerLink="/register">Register</a></li>
</ng-template>
<li *ngIf="authService.isAuthenticated()"><a (click)="onLogout()">Logout</a></li>
<li class="dropdown" appDropdown *ngIf="authService.isAuthenticated()">
<li *ngIf="authService.isAuthenticated()"><a (click)="logout()">Logout</a></li>
<!--li class="dropdown" appDropdown *ngIf="authService.isAuthenticated()">
<a class="dropdown-toggle" role="button">Manage <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a (click)="saveData()">Save Data</a></li>
<li><a (click)="fetchData()">Fetch Data</a></li>
</ul>
</li>
</li-->
</ul>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions priv/dev/src/app/header/header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ export class HeaderComponent implements OnInit {
ngOnInit() {
}

logout() {
this.authService.logout();
}

}
2 changes: 1 addition & 1 deletion priv/dev/src/app/welcome/welcome.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<p>
welcome to egambo!
</p>
<button routerLink="/game-types-list" class="btn btn-success">Try now</button>
<button routerLink="/type-list" class="btn btn-success">Try now</button>

0 comments on commit 313e6d8

Please sign in to comment.