SES-135 abilities card #63
@ -1,6 +1,9 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {AbilitiesComponent} from "../abilities/abilities.component";
|
import { PlayerSignalRService } from "../../shared/signalR-service/player-signalR.service";
|
||||||
|
import { first } from "rxjs/operators";
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
import { AppState } from 'src/app/store/models/app-state.model';
|
||||||
|
import { AbilitiesComponent } from '../abilities/abilities.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-player-dashboard',
|
selector: 'app-player-dashboard',
|
||||||
@ -12,7 +15,12 @@ export class PlayerDashboardComponent implements OnInit {
|
|||||||
isExpanded = false;
|
isExpanded = false;
|
||||||
selected = false;
|
selected = false;
|
||||||
|
|
||||||
|
constructor(private signalRService: PlayerSignalRService, private store: Store<AppState>) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.store.select(s => s.playerStore.characterId).pipe(first()).subscribe((id) => {
|
||||||
|
this.signalRService.Login(id);
|
||||||
|
});
|
||||||
this.SwitchMiddleComponent('AbilitiesComponent');
|
this.SwitchMiddleComponent('AbilitiesComponent');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,5 +34,4 @@ export class PlayerDashboardComponent implements OnInit {
|
|||||||
this.middleComponent = AbilitiesComponent;
|
this.middleComponent = AbilitiesComponent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,9 @@ import { FormGroup, Validators, FormBuilder } from '@angular/forms';
|
|||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import {UserService} from '../../../services/user.service';
|
import {UserService} from '../../../services/user.service';
|
||||||
import {ErrorResponse} from '../../../types/ErrorResponse';
|
import {ErrorResponse} from '../../../types/ErrorResponse';
|
||||||
import {Observable, Subscription} from 'rxjs';
|
import {Subscription} from 'rxjs';
|
||||||
import {HttpErrorResponse} from '@angular/common/http';
|
import {HttpErrorResponse} from '@angular/common/http';
|
||||||
import {AppStoreModel} from '../../store/models/app-store.model';
|
import {Store} from '@ngrx/store';
|
||||||
import {select, Store} from '@ngrx/store';
|
|
||||||
import {AddUserId} from '../../store/actions/app.actions';
|
import {AddUserId} from '../../store/actions/app.actions';
|
||||||
import {AppState} from 'src/app/store/models/app-state.model';
|
import {AppState} from 'src/app/store/models/app-state.model';
|
||||||
import {first} from "rxjs/operators";
|
import {first} from "rxjs/operators";
|
||||||
@ -18,9 +17,6 @@ import {first} from "rxjs/operators";
|
|||||||
})
|
})
|
||||||
export class SignInComponent implements OnDestroy, OnInit {
|
export class SignInComponent implements OnDestroy, OnInit {
|
||||||
allSubscriptions = new Subscription();
|
allSubscriptions = new Subscription();
|
||||||
|
|
||||||
role$: Observable<AppStoreModel>;
|
|
||||||
|
|
||||||
isExpanded = false;
|
isExpanded = false;
|
||||||
apiError = false;
|
apiError = false;
|
||||||
apiErrorMessage = '';
|
apiErrorMessage = '';
|
||||||
@ -39,7 +35,6 @@ export class SignInComponent implements OnDestroy, OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.role$ = this.store.select(s => s.appStore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onLoginButtonClick() {
|
onLoginButtonClick() {
|
||||||
@ -77,10 +72,6 @@ export class SignInComponent implements OnDestroy, OnInit {
|
|||||||
this.router.navigate(['']);
|
this.router.navigate(['']);
|
||||||
}
|
}
|
||||||
|
|
||||||
collapse() {
|
|
||||||
this.isExpanded = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
toggle() {
|
toggle() {
|
||||||
this.isExpanded = !this.isExpanded;
|
this.isExpanded = !this.isExpanded;
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,14 @@ export class PlayerSignalRService {
|
|||||||
constructor(@Inject('BASE_URL') baseUrl: string) {
|
constructor(@Inject('BASE_URL') baseUrl: string) {
|
||||||
this.signalR = new SignalRService(baseUrl);
|
this.signalR = new SignalRService(baseUrl);
|
||||||
this.registerOnServerEvents();
|
this.registerOnServerEvents();
|
||||||
this.signalR.startConnection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Login() {
|
public Login(characterId: number) {
|
||||||
this.signalR.startConnection();
|
this.signalR.startConnection();
|
||||||
|
|
||||||
this.signalR.connectionEstablished$.subscribe(() => {
|
this.signalR.connectionEstablished$.subscribe(() => {
|
||||||
if (this.signalR.connectionEstablished$.getValue() === true) {
|
if (this.signalR.connectionEstablished$.getValue() === true) {
|
||||||
this.signalR.hubConnection.send('GameMasterLogin');
|
this.signalR.hubConnection.send('PlayerCharacterLogin', characterId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user