SES-145 Tables in GM screen are now connected to backend #67

Merged
s426128 merged 2 commits from SES-145 into dev 2021-01-12 15:55:46 +01:00
3 changed files with 30 additions and 22 deletions
Showing only changes of commit 11b117d85c - Show all commits

View File

@ -1,38 +1,48 @@
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import {CharacterStatsViewModel} from "../../../types/viewmodels/character-viewmodels/CharacterStatsViewModel"; import { CharacterStatsViewModel } from '../../../types/viewmodels/character-viewmodels/CharacterStatsViewModel';
import {Store} from "@ngrx/store"; import { Store } from '@ngrx/store';
import {AppState} from "../../store/models/app-state.model"; import { AppState } from '../../store/models/app-state.model';
import {CharacterService} from "../../../services/character.service"; import { CharacterService } from '../../../services/character.service';
import {first} from "rxjs/operators"; import { first } from 'rxjs/operators';
import {ErrorResponse} from "../../../types/ErrorResponse"; import { ErrorResponse } from '../../../types/ErrorResponse';
import {HttpErrorResponse} from "@angular/common/http"; import { HttpErrorResponse } from '@angular/common/http';
@Component({ @Component({
selector: 'app-abilities', selector: 'app-abilities',
templateUrl: './abilities.component.html', templateUrl: './abilities.component.html',
styleUrls: ['./abilities.component.css'] styleUrls: ['./abilities.component.css'],
}) })
export class AbilitiesComponent implements OnInit { export class AbilitiesComponent implements OnInit {
characterStats: CharacterStatsViewModel[]; characterStats: CharacterStatsViewModel[];
constructor(private store: Store<AppState>, private characterService: CharacterService) {} constructor(
private store: Store<AppState>,
private characterService: CharacterService
) {}
ngOnInit() { ngOnInit() {
this.getCharacterStats(); this.getCharacterStats();
} }
getCharacterStats() { getCharacterStats() {
this.store.select( s => s.playerStore.characterId).pipe(first()).subscribe((characterId) => { this.store
this.characterService.getCharacterStats(characterId).pipe(first()).subscribe((characterStats) => { .select((s) => s.playerStore.characterId)
console.log(characterStats) .pipe(first())
.subscribe((characterId) => {
this.characterService
.getCharacterStats(characterId)
.pipe(first())
.subscribe(
(characterStats) => {
this.characterStats = characterStats; this.characterStats = characterStats;
}, (error: ErrorResponse | HttpErrorResponse) => { },
(error: ErrorResponse | HttpErrorResponse) => {
if (error instanceof HttpErrorResponse) { if (error instanceof HttpErrorResponse) {
error = error.error as ErrorResponse; error = error.error as ErrorResponse;
} }
console.error(error.message); console.error(error.message);
});
})
} }
);
});
}
} }

View File

@ -32,7 +32,6 @@ export class GameMasterArmorsTableComponent implements OnInit {
.pipe(first()) .pipe(first())
.subscribe( .subscribe(
(result) => { (result) => {
console.log(result);
this.dataSource = new MatTableDataSource(result); this.dataSource = new MatTableDataSource(result);
Review

możesz usunąć console.log

możesz usunąć console.log
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;

View File

@ -32,7 +32,6 @@ export class GameMasterWeaponsTableComponent implements OnInit {
.pipe(first()) .pipe(first())
.subscribe( .subscribe(
(result) => { (result) => {
console.log(result);
this.dataSource = new MatTableDataSource(result); this.dataSource = new MatTableDataSource(result);
Review

możesz usunąć console.log

możesz usunąć console.log
this.dataSource.paginator = this.paginator; this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort; this.dataSource.sort = this.sort;