SES-145 Tables in GM screen are now connected to backend #67
@ -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())
|
||||||
this.characterStats = characterStats;
|
.subscribe((characterId) => {
|
||||||
}, (error: ErrorResponse | HttpErrorResponse) => {
|
this.characterService
|
||||||
if (error instanceof HttpErrorResponse) {
|
.getCharacterStats(characterId)
|
||||||
error = error.error as ErrorResponse;
|
.pipe(first())
|
||||||
}
|
.subscribe(
|
||||||
console.error(error.message);
|
(characterStats) => {
|
||||||
|
this.characterStats = characterStats;
|
||||||
|
},
|
||||||
|
(error: ErrorResponse | HttpErrorResponse) => {
|
||||||
|
if (error instanceof HttpErrorResponse) {
|
||||||
|
error = error.error as ErrorResponse;
|
||||||
|
}
|
||||||
|
console.error(error.message);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
|||||||
this.dataSource.paginator = this.paginator;
|
this.dataSource.paginator = this.paginator;
|
||||||
this.dataSource.sort = this.sort;
|
this.dataSource.sort = this.sort;
|
||||||
|
@ -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);
|
||||||
s426128
commented
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;
|
||||||
|
Loading…
Reference in New Issue
Block a user
możesz usunąć console.log