Commit ea8eddf9 authored by Dennis Willers's avatar Dennis Willers 🏀

Implement Request isSpielSession and toggle buttons if game exist

parent 3da4c57a
Pipeline #281 passed with stages
in 5 minutes and 12 seconds
......@@ -26,6 +26,11 @@ export class TabuMiddlewareService {
return this.request('GET', `${environment.tabuMiddlewareURL}SpielSession`);
}
isSpielSession(req: any): Promise<any> {
console.log('json: ', req);
return this.request('POST', `${environment.tabuMiddlewareURL}isSpielSession`, req);
}
addSpielSession(event: any): Promise<any> {
return this.request('POST', `${environment.tabuMiddlewareURL}addSpielSession`, event);
}
......
......@@ -18,8 +18,8 @@
</form>
</mat-card-content>
<mat-card-actions>
<button [disabled]="buttonsDisabled" mat-raised-button color="primary" (click)="getSpielSessions()">Spiel erstellen</button>
<button [disabled]="buttonsDisabled" mat-raised-button color="primary" (click)="joinGame()">Spiel beitreten</button>
<button [disabled]="buttonCreateGameDisabled" mat-raised-button color="primary" (click)="getSpielSessions()">Spiel erstellen</button>
<button [disabled]="buttonJoinGameDisabled" mat-raised-button color="primary" (click)="joinGame()">Spiel beitreten</button>
</mat-card-actions>
</mat-card>
</div>
......@@ -9,7 +9,8 @@ import {TabuMiddlewareService} from '../dao/TabuMiddlewareService';
})
export class SelectGameComponent implements OnInit {
buttonsDisabled = true;
buttonCreateGameDisabled = true;
buttonJoinGameDisabled = true;
constructor(private router: Router,
private server: TabuMiddlewareService) { }
......@@ -36,7 +37,23 @@ export class SelectGameComponent implements OnInit {
}
checkSpielname(spielname: string): void {
console.log(spielname)
this.buttonsDisabled = spielname.length === 0;
if (spielname.length === 0) {
this.buttonCreateGameDisabled = true;
this.buttonJoinGameDisabled = true;
return;
} else {
console.log(spielname);
this.server.isSpielSession({"spielname": '' + spielname + ''}).then(value => {
console.log('Response: ', value.status);
const status = JSON.parse(value.status);
if (status) {
this.buttonCreateGameDisabled = true;
this.buttonJoinGameDisabled = false;
} else {
this.buttonCreateGameDisabled = false;
this.buttonJoinGameDisabled = true;
}
});
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment