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

View File

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

możesz usunąć console.log

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

View File

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

możesz usunąć console.log

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