Loading src/app/dao/TabuMiddlewareService.ts +5 −1 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,11 @@ export class TabuMiddlewareService { } } addSession(req: any): Promise<any> { addSession(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}addSession`, req); return this.request('POST', `${environment.tabuMiddlewareURL}addSession`, req); } } getGamestatus(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}getGamestatus`, req); } } } src/app/interface/gameStatus.ts 0 → 100644 +8 −0 Original line number Original line Diff line number Diff line export interface GameStatus { sessionID: number; red: number; blue: number; redTurn: boolean; activeExplainer: boolean; activeWatchdog: boolean; } src/app/overview/overview.component.ts +33 −2 Original line number Original line Diff line number Diff line import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core'; import {Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {GameStatus} from '../interface/gameStatus'; @Component({ @Component({ selector: 'app-overview', selector: 'app-overview', Loading @@ -8,10 +10,39 @@ import {Router} from '@angular/router'; }) }) export class OverviewComponent implements OnInit { export class OverviewComponent implements OnInit { constructor(private router: Router) { } sessionName = ''; gameStatus: GameStatus = { sessionID: -1, red: 0, blue: 0, redTurn: true, activeExplainer: false, activeWatchdog: false }; constructor(private router: Router, private activatedRoute: ActivatedRoute, private service: TabuMiddlewareService) { } ngOnInit(): void { ngOnInit(): void { this.activatedRoute.paramMap.subscribe(params => { this.sessionName = String(params.get('sessionName')); console.log('SessionName: ', this.sessionName); this.service.getGamestatus({"spielname": this.sessionName}).then(value => { const status = JSON.parse(value.status); if (status) { this.gameStatus.sessionID = JSON.parse(value.sessionID); this.gameStatus.red = JSON.parse(value.red); this.gameStatus.blue = JSON.parse(value.blue); this.gameStatus.redTurn = JSON.parse(value.redTurn); this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer); this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog); } console.log(this.gameStatus); }).catch(reason => console.log(reason)); }); } } startGame(): void { startGame(): void { this.router.navigate([this.router.url+'/red/watchdog']); this.router.navigate([this.router.url+'/red/watchdog']); } } Loading src/app/select-game/select-game.component.html +3 −3 Original line number Original line Diff line number Diff line Loading @@ -13,13 +13,13 @@ <form> <form> <mat-form-field> <mat-form-field> <mat-label>Spielname</mat-label> <mat-label>Spielname</mat-label> <input #spielname type="text" matInput (keyup)="checkSpielname(spielname.value)" (keypress)="keyPressAlphaNumeric($event)"> <input #sessionName type="text" matInput (keyup)="checkSpielname(sessionName.value)" (keypress)="keyPressAlphaNumeric($event)"> </mat-form-field> </mat-form-field> </form> </form> </mat-card-content> </mat-card-content> <mat-card-actions> <mat-card-actions> <button [disabled]="buttonCreateGameDisabled" mat-raised-button color="primary" (click)="createGame(spielname.value)">Spiel erstellen</button> <button [disabled]="buttonCreateGameDisabled" mat-raised-button color="primary" (click)="createGame(sessionName.value)">Spiel erstellen</button> <button [disabled]="buttonJoinGameDisabled" mat-raised-button color="primary" (click)="joinGame(spielname.value)">Spiel beitreten</button> <button [disabled]="buttonJoinGameDisabled" mat-raised-button color="primary" (click)="joinGame(sessionName.value)">Spiel beitreten</button> </mat-card-actions> </mat-card-actions> </mat-card> </mat-card> </div> </div> src/app/select-game/select-game.component.ts +8 −8 Original line number Original line Diff line number Diff line Loading @@ -23,12 +23,12 @@ export class SelectGameComponent implements OnInit { console.log('Response:', response); console.log('Response:', response); } } createGame(spielname: string): void { createGame(sessionName: string): void { this.server.addSession({"spielname": '' + spielname + ''}).then(value => { this.server.addSession({"spielname": sessionName}).then(value => { console.log(value); console.log(value); const status = JSON.parse(value.status); const status = JSON.parse(value.status); if (status) { if (status) { this.router.navigate([spielname]); this.router.navigate([sessionName]); } } }).catch(reason => { }).catch(reason => { console.log(reason); console.log(reason); Loading @@ -36,8 +36,8 @@ export class SelectGameComponent implements OnInit { }); }); } } joinGame(spielname: string): void { joinGame(sessionName: string): void { this.router.navigate([spielname]); this.router.navigate([sessionName]); } } keyPressAlphaNumeric(event: KeyboardEvent): boolean { keyPressAlphaNumeric(event: KeyboardEvent): boolean { Loading @@ -49,13 +49,13 @@ export class SelectGameComponent implements OnInit { } } } } checkSpielname(spielname: string): void { checkSpielname(sessionName: string): void { if (spielname.length === 0) { if (sessionName.length === 0) { this.buttonCreateGameDisabled = true; this.buttonCreateGameDisabled = true; this.buttonJoinGameDisabled = true; this.buttonJoinGameDisabled = true; return; return; } else { } else { this.server.isSession({'spielname': spielname}).then(value => { this.server.isSession({'spielname': sessionName}).then(value => { console.log('Response: ', value.status); console.log('Response: ', value.status); const status = JSON.parse(value.status); const status = JSON.parse(value.status); if (status) { if (status) { Loading Loading
src/app/dao/TabuMiddlewareService.ts +5 −1 Original line number Original line Diff line number Diff line Loading @@ -31,7 +31,11 @@ export class TabuMiddlewareService { } } addSession(req: any): Promise<any> { addSession(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}addSession`, req); return this.request('POST', `${environment.tabuMiddlewareURL}addSession`, req); } } getGamestatus(req: any): Promise<any> { console.log(req); return this.request('POST', `${environment.tabuMiddlewareURL}getGamestatus`, req); } } }
src/app/interface/gameStatus.ts 0 → 100644 +8 −0 Original line number Original line Diff line number Diff line export interface GameStatus { sessionID: number; red: number; blue: number; redTurn: boolean; activeExplainer: boolean; activeWatchdog: boolean; }
src/app/overview/overview.component.ts +33 −2 Original line number Original line Diff line number Diff line import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core'; import {Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router'; import {TabuMiddlewareService} from '../dao/TabuMiddlewareService'; import {GameStatus} from '../interface/gameStatus'; @Component({ @Component({ selector: 'app-overview', selector: 'app-overview', Loading @@ -8,10 +10,39 @@ import {Router} from '@angular/router'; }) }) export class OverviewComponent implements OnInit { export class OverviewComponent implements OnInit { constructor(private router: Router) { } sessionName = ''; gameStatus: GameStatus = { sessionID: -1, red: 0, blue: 0, redTurn: true, activeExplainer: false, activeWatchdog: false }; constructor(private router: Router, private activatedRoute: ActivatedRoute, private service: TabuMiddlewareService) { } ngOnInit(): void { ngOnInit(): void { this.activatedRoute.paramMap.subscribe(params => { this.sessionName = String(params.get('sessionName')); console.log('SessionName: ', this.sessionName); this.service.getGamestatus({"spielname": this.sessionName}).then(value => { const status = JSON.parse(value.status); if (status) { this.gameStatus.sessionID = JSON.parse(value.sessionID); this.gameStatus.red = JSON.parse(value.red); this.gameStatus.blue = JSON.parse(value.blue); this.gameStatus.redTurn = JSON.parse(value.redTurn); this.gameStatus.activeExplainer = JSON.parse(value.activeExplainer); this.gameStatus.activeWatchdog = JSON.parse(value.activeWatchdog); } console.log(this.gameStatus); }).catch(reason => console.log(reason)); }); } } startGame(): void { startGame(): void { this.router.navigate([this.router.url+'/red/watchdog']); this.router.navigate([this.router.url+'/red/watchdog']); } } Loading
src/app/select-game/select-game.component.html +3 −3 Original line number Original line Diff line number Diff line Loading @@ -13,13 +13,13 @@ <form> <form> <mat-form-field> <mat-form-field> <mat-label>Spielname</mat-label> <mat-label>Spielname</mat-label> <input #spielname type="text" matInput (keyup)="checkSpielname(spielname.value)" (keypress)="keyPressAlphaNumeric($event)"> <input #sessionName type="text" matInput (keyup)="checkSpielname(sessionName.value)" (keypress)="keyPressAlphaNumeric($event)"> </mat-form-field> </mat-form-field> </form> </form> </mat-card-content> </mat-card-content> <mat-card-actions> <mat-card-actions> <button [disabled]="buttonCreateGameDisabled" mat-raised-button color="primary" (click)="createGame(spielname.value)">Spiel erstellen</button> <button [disabled]="buttonCreateGameDisabled" mat-raised-button color="primary" (click)="createGame(sessionName.value)">Spiel erstellen</button> <button [disabled]="buttonJoinGameDisabled" mat-raised-button color="primary" (click)="joinGame(spielname.value)">Spiel beitreten</button> <button [disabled]="buttonJoinGameDisabled" mat-raised-button color="primary" (click)="joinGame(sessionName.value)">Spiel beitreten</button> </mat-card-actions> </mat-card-actions> </mat-card> </mat-card> </div> </div>
src/app/select-game/select-game.component.ts +8 −8 Original line number Original line Diff line number Diff line Loading @@ -23,12 +23,12 @@ export class SelectGameComponent implements OnInit { console.log('Response:', response); console.log('Response:', response); } } createGame(spielname: string): void { createGame(sessionName: string): void { this.server.addSession({"spielname": '' + spielname + ''}).then(value => { this.server.addSession({"spielname": sessionName}).then(value => { console.log(value); console.log(value); const status = JSON.parse(value.status); const status = JSON.parse(value.status); if (status) { if (status) { this.router.navigate([spielname]); this.router.navigate([sessionName]); } } }).catch(reason => { }).catch(reason => { console.log(reason); console.log(reason); Loading @@ -36,8 +36,8 @@ export class SelectGameComponent implements OnInit { }); }); } } joinGame(spielname: string): void { joinGame(sessionName: string): void { this.router.navigate([spielname]); this.router.navigate([sessionName]); } } keyPressAlphaNumeric(event: KeyboardEvent): boolean { keyPressAlphaNumeric(event: KeyboardEvent): boolean { Loading @@ -49,13 +49,13 @@ export class SelectGameComponent implements OnInit { } } } } checkSpielname(spielname: string): void { checkSpielname(sessionName: string): void { if (spielname.length === 0) { if (sessionName.length === 0) { this.buttonCreateGameDisabled = true; this.buttonCreateGameDisabled = true; this.buttonJoinGameDisabled = true; this.buttonJoinGameDisabled = true; return; return; } else { } else { this.server.isSession({'spielname': spielname}).then(value => { this.server.isSession({'spielname': sessionName}).then(value => { console.log('Response: ', value.status); console.log('Response: ', value.status); const status = JSON.parse(value.status); const status = JSON.parse(value.status); if (status) { if (status) { Loading