SES-160 shop on gm and player screen #85
29319
SessionCompanion/SessionCompanion.Database/Migrations/20210120183221_shopkeepers-update.Designer.cs
generated
Normal file
29319
SessionCompanion/SessionCompanion.Database/Migrations/20210120183221_shopkeepers-update.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace SessionCompanion.Database.Migrations
|
||||
{
|
||||
public partial class shopkeepersupdate : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Shopkeepers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 3,
|
||||
column: "IsAvailable",
|
||||
value: false);
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Shopkeepers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 5,
|
||||
column: "IsAvailable",
|
||||
value: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Shopkeepers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 3,
|
||||
column: "IsAvailable",
|
||||
value: true);
|
||||
|
||||
migrationBuilder.UpdateData(
|
||||
table: "Shopkeepers",
|
||||
keyColumn: "Id",
|
||||
keyValue: 5,
|
||||
column: "IsAvailable",
|
||||
value: true);
|
||||
}
|
||||
}
|
||||
}
|
@ -21554,7 +21554,7 @@ namespace SessionCompanion.Database.Migrations
|
||||
new
|
||||
{
|
||||
Id = 3,
|
||||
IsAvailable = true,
|
||||
IsAvailable = false,
|
||||
Name = "Bohr Twarda Zbroja"
|
||||
},
|
||||
new
|
||||
@ -21566,7 +21566,7 @@ namespace SessionCompanion.Database.Migrations
|
||||
new
|
||||
{
|
||||
Id = 5,
|
||||
IsAvailable = true,
|
||||
IsAvailable = false,
|
||||
Name = "Zielony spod Gruszkowego Lasu"
|
||||
},
|
||||
new
|
||||
|
@ -863,7 +863,7 @@ namespace SessionCompanion.Database
|
||||
{
|
||||
Id = 3,
|
||||
Name = "Bohr Twarda Zbroja",
|
||||
IsAvailable = true
|
||||
IsAvailable = false
|
||||
},
|
||||
new Shopkeeper
|
||||
{
|
||||
@ -875,7 +875,7 @@ namespace SessionCompanion.Database
|
||||
{
|
||||
Id = 5,
|
||||
Name = "Zielony spod Gruszkowego Lasu",
|
||||
IsAvailable = true
|
||||
IsAvailable = false
|
||||
},
|
||||
new Shopkeeper
|
||||
{
|
||||
|
@ -14,5 +14,6 @@ namespace SessionCompanion.Services.Interfaces
|
||||
public interface IShopkeeperService : IServiceBase<ShopkeeperViewModel, Shopkeeper>
|
||||
{
|
||||
Task<Either<SuccessResponse, ErrorResponse>> CreateNewShopKeeper(ShopkeeperWithItemsViewModel shopkeeperWithItemsViewModel);
|
||||
Task<Either<SuccessResponse, ErrorResponse>> ChangeShopkeeperStatus(int shopkeeperId, bool availability);
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,42 @@ namespace SessionCompanion.Services.Services
|
||||
{
|
||||
public ShopkeeperService(IMapper mapper, IRepository<Shopkeeper> repository) : base(mapper, repository)
|
||||
{ }
|
||||
/// <summary>
|
||||
/// Funkcja zmienia status sprzedawcy
|
||||
/// </summary>
|
||||
/// <param name="shopkeeperId"></param>
|
||||
/// <param name="availability"></param>
|
||||
/// <returns>SuccesResponse/ErrorResponse</returns>
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeShopkeeperStatus(int shopkeeperId, bool availability)
|
||||
{
|
||||
try
|
||||
{
|
||||
var shopkeepers = await Repository.Get().ToListAsync();
|
||||
if (availability)
|
||||
{
|
||||
foreach (var shopkeeper in shopkeepers)
|
||||
{
|
||||
if (shopkeeper.Id.Equals(shopkeeperId))
|
||||
shopkeeper.IsAvailable = true;
|
||||
else
|
||||
shopkeeper.IsAvailable = false;
|
||||
await Repository.Update(shopkeeper);
|
||||
}
|
||||
await Repository.Save();
|
||||
return new SuccessResponse("Shopkeepers updated") { SuccessCode = 200 };
|
||||
}
|
||||
|
||||
var newActiveShopkeeper = shopkeepers.Where(c => c.Id.Equals(shopkeeperId)).Single();
|
||||
newActiveShopkeeper.IsAvailable = false;
|
||||
await Repository.Update(newActiveShopkeeper);
|
||||
await Repository.Save();
|
||||
return new SuccessResponse("Shopkeepers updated") { SuccessCode = 200 };
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ErrorResponse() { StatusCode = 500, Message = e.Message };
|
||||
}
|
||||
}
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> CreateNewShopKeeper(ShopkeeperWithItemsViewModel shopkeeperWithItemsViewModel)
|
||||
{
|
||||
try
|
||||
|
@ -8674,6 +8674,21 @@
|
||||
"integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==",
|
||||
"dev": true
|
||||
},
|
||||
"ng-dynamic-component": {
|
||||
"version": "8.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ng-dynamic-component/-/ng-dynamic-component-8.0.1.tgz",
|
||||
"integrity": "sha512-Ak25QTYmjNVxyZ6ywqRDDjoqAJheFeK0XoHsomwVjdHSiLoQcGfNNj5z51pqoRGpjdDZMSV+J2gaCbRNBeiy3g==",
|
||||
"requires": {
|
||||
"tslib": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.1.0.tgz",
|
||||
"integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"nice-try": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",
|
||||
|
@ -32,6 +32,7 @@
|
||||
"core-js": "^3.3.3",
|
||||
"hammerjs": "^2.0.8",
|
||||
"jquery": "3.4.1",
|
||||
"ng-dynamic-component": "^8.0.1",
|
||||
"oidc-client": "^1.9.1",
|
||||
"popper.js": "^1.16.0",
|
||||
"rpg-awesome": "^0.2.0",
|
||||
|
@ -27,6 +27,7 @@ import {
|
||||
MatSortModule,
|
||||
MatDialogModule,
|
||||
MatTooltipModule,
|
||||
MatSnackBarModule,
|
||||
} from '@angular/material';
|
||||
import { UserService } from '../services/user.service';
|
||||
import { StoreModule } from '@ngrx/store';
|
||||
@ -50,6 +51,10 @@ import { GameMasterMonstersTableComponent } from './components/game-master-monst
|
||||
import { MonsterService } from '../services/monster.service';
|
||||
import { SpellDetailsDialogComponent } from './components/spell-details-dialog/spell-details-dialog.component';
|
||||
import { GameMasterShopkeepersTableComponent } from './components/game-master-shopkeepers-table/game-master-shopkeepers-table.component';
|
||||
import { SendMessageActionComponent } from './components/game-master-character-actions-dialog/actions-components/send-message-action/send-message-action.component';
|
||||
import { DynamicModule } from 'ng-dynamic-component';
|
||||
import { SnackbarComponent } from './shared/snackbar/snackbar.component';
|
||||
import { MessageDialogComponent } from './shared/message-dialog/message-dialog.component';
|
||||
import { GameMasterTurntrackerComponent } from './components/game-master-turntracker/game-master-turntracker.component';
|
||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||
import { ChooseMonsterDialogComponent } from './components/choose-monster-dialog/choose-monster-dialog.component';
|
||||
@ -74,6 +79,9 @@ import { ShopkeeperService } from '../services/shopkeeper.service';
|
||||
GameMasterMonstersTableComponent,
|
||||
SpellDetailsDialogComponent,
|
||||
GameMasterShopkeepersTableComponent,
|
||||
SendMessageActionComponent,
|
||||
SnackbarComponent,
|
||||
MessageDialogComponent,
|
||||
GameMasterTurntrackerComponent,
|
||||
ChooseMonsterDialogComponent,
|
||||
],
|
||||
@ -104,6 +112,8 @@ import { ShopkeeperService } from '../services/shopkeeper.service';
|
||||
MatSortModule,
|
||||
MatTooltipModule,
|
||||
MatRadioModule,
|
||||
DynamicModule,
|
||||
MatSnackBarModule,
|
||||
DragDropModule,
|
||||
],
|
||||
providers: [
|
||||
@ -127,6 +137,9 @@ import { ShopkeeperService } from '../services/shopkeeper.service';
|
||||
ThrowPrimaryAbilityComponent,
|
||||
SpellDetailsDialogComponent,
|
||||
GameMasterShopkeepersTableComponent,
|
||||
SendMessageActionComponent,
|
||||
SnackbarComponent,
|
||||
MessageDialogComponent,
|
||||
GameMasterTurntrackerComponent,
|
||||
ChooseMonsterDialogComponent,
|
||||
],
|
||||
|
@ -0,0 +1,36 @@
|
||||
.send-message-main {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.send-message-main > mat-form-field {
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
width: 80%;
|
||||
}
|
||||
|
||||
.message-textarea {
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
.break {
|
||||
flex-basis: 100%;
|
||||
height: 0;
|
||||
}
|
||||
|
||||
.send-message-actions {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.send-message-actions > button {
|
||||
margin-right: 20px;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.no-focus:focus {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.send-button {
|
||||
color: darkseagreen;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<form class="send-message-main">
|
||||
<mat-form-field>
|
||||
<mat-label>Message</mat-label>
|
||||
<textarea class="message-textarea" matInput #message></textarea>
|
||||
</mat-form-field>
|
||||
<div class="break"></div>
|
||||
<div class="send-message-actions">
|
||||
<button mat-stroked-button color="warn" class="no-focus" (click)="Close()"> Cancel </button>
|
||||
<button mat-stroked-button color="primary" class="no-focus send-button" (click)="SendMessage(message.value)"> Send </button>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,28 @@
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { GMSignalRService } from '../../../../shared/signalR-service/gm-signalR.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-send-message-action',
|
||||
templateUrl: './send-message-action.component.html',
|
||||
styleUrls: ['./send-message-action.component.css'],
|
||||
})
|
||||
export class SendMessageActionComponent implements OnInit {
|
||||
@Input() characterId: any;
|
||||
|
||||
@Output()
|
||||
closeComponent = new EventEmitter<string>();
|
||||
|
||||
constructor(private signalRService: GMSignalRService) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
SendMessage(message: string) {
|
||||
debugger;
|
||||
this.signalRService.SendMessageToPlayer(this.characterId, message);
|
||||
this.Close();
|
||||
}
|
||||
|
||||
Close() {
|
||||
this.closeComponent.emit();
|
||||
}
|
||||
}
|
@ -10,3 +10,8 @@
|
||||
box-shadow: 0 11px 15px -7px rgba(0, 0, 0, 0.2),
|
||||
0 24px 38px 3px rgba(0, 0, 0, 0.14), 0px 5px 20px 4px #d8d8d8;
|
||||
}
|
||||
|
||||
.after-name-divider {
|
||||
border-top-width: 3px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
@ -1,5 +1,16 @@
|
||||
<h1 mat-dialog-title class="character-dialog-title">
|
||||
{{characterName}}
|
||||
</h1>
|
||||
<mat-divider class="after-name-divider"></mat-divider>
|
||||
<div mat-dialog-content>
|
||||
<div *ngIf="actionComponentName == null">
|
||||
<div *ngFor="let action of availableActions">
|
||||
<button mat-flat-button (click)="ChangeActionComponent(action.componentName)">
|
||||
{{action.name}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<ndc-dynamic *ngIf="actionComponentName != null" [ndcDynamicComponent]="actionComponentName" [ndcDynamicInputs]="inputs" [ndcDynamicOutputs]="outputs">
|
||||
|
||||
</ndc-dynamic>
|
||||
</div>
|
||||
|
@ -1,5 +1,6 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { Component, Inject, Injector, OnInit } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
|
||||
import { SendMessageActionComponent } from './actions-components/send-message-action/send-message-action.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-game-master-character-actions-dialog',
|
||||
@ -9,6 +10,17 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
|
||||
export class GameMasterCharacterActionsDialogComponent implements OnInit {
|
||||
characterId: number;
|
||||
characterName: string;
|
||||
actionComponentName;
|
||||
availableActions: { name: string; componentName: string }[] = [
|
||||
{
|
||||
name: 'Send Message',
|
||||
componentName: 'SendMessageActionComponent',
|
||||
},
|
||||
];
|
||||
inputs: { characterId: number };
|
||||
outputs: any = {
|
||||
closeComponent: () => this.ChangeActionComponent(null),
|
||||
};
|
||||
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<GameMasterCharacterActionsDialogComponent>,
|
||||
@ -18,5 +30,17 @@ export class GameMasterCharacterActionsDialogComponent implements OnInit {
|
||||
ngOnInit() {
|
||||
this.characterId = this.data.characterid;
|
||||
this.characterName = this.data.characterName;
|
||||
this.inputs = { characterId: this.characterId };
|
||||
console.log(this.inputs);
|
||||
}
|
||||
|
||||
ChangeActionComponent(componentName: string): void {
|
||||
switch (componentName) {
|
||||
case 'SendMessageActionComponent':
|
||||
this.actionComponentName = SendMessageActionComponent;
|
||||
break;
|
||||
default:
|
||||
this.actionComponentName = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,15 @@ export class GameMasterDashboardComponent implements OnInit, OnDestroy {
|
||||
|
||||
rightSidenavExpanded = false;
|
||||
rightSidenavTextExpanded = false;
|
||||
loggedCharacters: LoggedCharactersViewModel[];
|
||||
loggedCharacters: LoggedCharactersViewModel[] = [
|
||||
{
|
||||
class: 'paladin',
|
||||
id: 2,
|
||||
name: 'Test',
|
||||
currentHealthPoints: 5,
|
||||
level: 1,
|
||||
},
|
||||
];
|
||||
|
||||
constructor(
|
||||
private store: Store<AppState>,
|
||||
|
@ -4,9 +4,11 @@ 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';
|
||||
import {ClearStore, ClearUserId} from '../../store/actions/app.actions';
|
||||
import { ClearStore, ClearUserId } from '../../store/actions/app.actions';
|
||||
import { Router } from '@angular/router';
|
||||
import {ClearCharacterId} from "../../store/actions/player.action";
|
||||
import { ClearCharacterId } from '../../store/actions/player.action';
|
||||
import { MatSnackBar } from '@angular/material';
|
||||
import { SnackbarComponent } from '../../shared/snackbar/snackbar.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-player-dashboard',
|
||||
@ -18,10 +20,19 @@ export class PlayerDashboardComponent implements OnInit {
|
||||
isExpanded = false;
|
||||
selected = false;
|
||||
|
||||
constructor(private signalRService: PlayerSignalRService, private store: Store<AppState>, private router: Router) {}
|
||||
constructor(
|
||||
private signalRService: PlayerSignalRService,
|
||||
private store: Store<AppState>,
|
||||
private router: Router,
|
||||
private _snackBar: MatSnackBar
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.store.select(s => s.playerStore.characterId).pipe(first()).subscribe((id) => {
|
||||
this.store
|
||||
.select((s) => s.playerStore.characterId)
|
||||
.pipe(first())
|
||||
.subscribe((id) => {
|
||||
this.SubscribeToEvents();
|
||||
this.signalRService.Login(id);
|
||||
this.SwitchMiddleComponent('AbilitiesComponent');
|
||||
});
|
||||
@ -43,4 +54,23 @@ export class PlayerDashboardComponent implements OnInit {
|
||||
this.store.dispatch(new ClearStore());
|
||||
this.router.navigate(['/']);
|
||||
}
|
||||
|
||||
private SubscribeToEvents(): void {
|
||||
this.signalRService.runMethod.subscribe(
|
||||
(result: { methodName: string; parameters }) => {
|
||||
switch (result.methodName) {
|
||||
case 'MessageFromGameMaster':
|
||||
this._snackBar.openFromComponent(SnackbarComponent, {
|
||||
horizontalPosition: 'end',
|
||||
verticalPosition: 'top',
|
||||
data: {
|
||||
message: 'New message from GM',
|
||||
methodName: result.methodName,
|
||||
gmMessage: result.parameters.message,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
::ng-deep .mat-dialog-container {
|
||||
background-color: #4a5867;
|
||||
color: whitesmoke;
|
||||
box-shadow: 0 11px 15px -7px rgba(0, 0, 0, 0.2),
|
||||
0 24px 38px 3px rgba(0, 0, 0, 0.14), 0px 5px 20px 4px #d8d8d8;
|
||||
}
|
||||
|
||||
.message-dialog-title {
|
||||
font: 15px/20px Roboto, 'Helvetica Neue', sans-serif;
|
||||
text-align: justify;
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<div mat-dialog-title class="message-dialog-title">
|
||||
{{data.message}}
|
||||
</div>
|
@ -0,0 +1,16 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material';
|
||||
|
||||
@Component({
|
||||
selector: 'app-message-dialog',
|
||||
templateUrl: './message-dialog.component.html',
|
||||
styleUrls: ['./message-dialog.component.css'],
|
||||
})
|
||||
export class MessageDialogComponent implements OnInit {
|
||||
constructor(
|
||||
public dialogRef: MatDialogRef<MessageDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any
|
||||
) {}
|
||||
|
||||
ngOnInit() {}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { SignalRService } from './base/signalR.service';
|
||||
import {Subject} from 'rxjs';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class GMSignalRService {
|
||||
@ -16,11 +16,19 @@ export class GMSignalRService {
|
||||
public Login() {
|
||||
this.signalR.startConnection();
|
||||
|
||||
this.signalR.connectionEstablished$.subscribe(() => {
|
||||
this.signalR.connectionEstablished$
|
||||
.subscribe(() => {
|
||||
if (this.signalR.connectionEstablished$.getValue() === true) {
|
||||
this.signalR.hubConnection.send('GameMasterLogin');
|
||||
}
|
||||
}).unsubscribe();
|
||||
})
|
||||
.unsubscribe();
|
||||
}
|
||||
|
||||
public SendMessageToPlayer(characterId: number, message: string) {
|
||||
this.signalR.hubConnection
|
||||
.send('SendMessageToPlayer', characterId, message)
|
||||
.catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
private registerOnServerEvents(): void {
|
||||
|
@ -1,12 +1,15 @@
|
||||
import { Inject, Injectable } from '@angular/core';
|
||||
import { SignalRService } from './base/signalR.service';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
@Injectable({ providedIn: 'root' })
|
||||
export class PlayerSignalRService {
|
||||
signalR: SignalRService;
|
||||
runMethod: Subject<{ methodName: string; parameters: {} }>;
|
||||
|
||||
constructor(@Inject('BASE_URL') baseUrl: string) {
|
||||
this.signalR = new SignalRService(baseUrl);
|
||||
this.runMethod = new Subject<{ methodName: string; parameters: {} }>();
|
||||
this.registerOnServerEvents();
|
||||
}
|
||||
|
||||
@ -21,5 +24,14 @@ export class PlayerSignalRService {
|
||||
}
|
||||
|
||||
private registerOnServerEvents(): void {
|
||||
this.signalR.hubConnection.on(
|
||||
'MessageFromGameMaster',
|
||||
(message: string) => {
|
||||
this.runMethod.next({
|
||||
methodName: 'MessageFromGameMaster',
|
||||
parameters: { message: message },
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
.flex {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
<div class="flex">
|
||||
<div class="data">{{message}}</div>
|
||||
<div class="dismiss">
|
||||
<button mat-icon-button (click)="ClickAction()">
|
||||
<mat-icon>remove_red_eye</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button (click)="snackBarRef.dismiss()">
|
||||
<mat-icon>close</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,41 @@
|
||||
import { Component, Inject, OnInit } from '@angular/core';
|
||||
import {
|
||||
MAT_SNACK_BAR_DATA,
|
||||
MatDialog,
|
||||
MatSnackBarRef,
|
||||
} from '@angular/material';
|
||||
import { MessageDialogComponent } from '../message-dialog/message-dialog.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-snackbar',
|
||||
templateUrl: './snackbar.component.html',
|
||||
styleUrls: ['./snackbar.component.css'],
|
||||
})
|
||||
export class SnackbarComponent implements OnInit {
|
||||
message: string = '';
|
||||
constructor(
|
||||
public snackBarRef: MatSnackBarRef<SnackbarComponent>,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public data: any,
|
||||
public dialog: MatDialog
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.message = this.data.message;
|
||||
}
|
||||
|
||||
ClickAction() {
|
||||
switch (this.data.methodName) {
|
||||
case 'MessageFromGameMaster':
|
||||
this.ShowMessageFromGM();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ShowMessageFromGM() {
|
||||
this.dialog.open(MessageDialogComponent, {
|
||||
height: '500px',
|
||||
data: { message: this.data.gmMessage },
|
||||
});
|
||||
this.snackBarRef.dismiss();
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ namespace SessionCompanion.Controllers
|
||||
using SessionCompanion.ViewModels.CharacterArmorViewModels;
|
||||
using SessionCompanion.ViewModels.CharacterOtherEquipmentViewModels;
|
||||
using SessionCompanion.ViewModels.CharacterWeaponViewModels;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
[Route("api/character/equipment")]
|
||||
[ApiController]
|
||||
@ -38,7 +39,7 @@ namespace SessionCompanion.Controllers
|
||||
/// <param name="characterId"> Id postaci </param>
|
||||
/// <returns> Lista pozostałego ekwipunku lub błąd </returns>
|
||||
[HttpGet("getOtherEquipment")]
|
||||
public async Task<Either<List<CharacterOtherEquipmentWithDetailsViewModel>, ErrorResponse>> GetCharacterOtherEquipment(int characterId)
|
||||
public async Task<Either<List<CharacterOtherEquipmentWithDetailsViewModel>, ErrorResponse>> GetCharacterOtherEquipment([Required] int characterId)
|
||||
{
|
||||
return await this._characterOtherEquipmentService.GetCharacterOtherEquipmentList(characterId);
|
||||
}
|
||||
@ -49,7 +50,7 @@ namespace SessionCompanion.Controllers
|
||||
/// <param name="characterId"> Id postaci </param>
|
||||
/// <returns> Lista pozostałego ekwipunku lub błąd </returns>
|
||||
[HttpGet("getArmors")]
|
||||
public async Task<Either<List<CharacterArmorViewModelDetails>, ErrorResponse>> GetCharacterArmors(int characterId)
|
||||
public async Task<Either<List<CharacterArmorViewModelDetails>, ErrorResponse>> GetCharacterArmors([Required] int characterId)
|
||||
{
|
||||
return await this._characterArmorService.GetCharacterArmorsTaskList(characterId);
|
||||
}
|
||||
@ -60,7 +61,7 @@ namespace SessionCompanion.Controllers
|
||||
/// <param name="characterId"> Id postaci </param>
|
||||
/// <returns> Lista broni lub błąd </returns>
|
||||
[HttpGet("getWeapons")]
|
||||
public async Task<Either<List<CharacterWeaponWithWeaponDetailsViewModel>, ErrorResponse>> GetCharacterWeapons(int characterId)
|
||||
public async Task<Either<List<CharacterWeaponWithWeaponDetailsViewModel>, ErrorResponse>> GetCharacterWeapons([Required] int characterId)
|
||||
{
|
||||
return await this._characterWeaponService.GetCharacterWeaponsList(characterId);
|
||||
}
|
||||
@ -72,7 +73,7 @@ namespace SessionCompanion.Controllers
|
||||
/// <param name="newArmorId"> Id nowej zbroi </param>
|
||||
/// <returns>SuccessResponse/ErrorResponse</returns>
|
||||
[HttpPut("changeArmor")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterArmor(int characterId, int newArmorId)
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterArmor([Required] int characterId, [Required] int newArmorId)
|
||||
{
|
||||
var response = await _characterArmorService.ChangeCharacterArmor(characterId, newArmorId);
|
||||
return response;
|
||||
@ -84,7 +85,7 @@ namespace SessionCompanion.Controllers
|
||||
/// <param name="characterArmorViewModel"> View model z odpowiednimi parameterami </param>
|
||||
/// <returns>SuccessResponse/ErrorResponse</returns>
|
||||
[HttpPut("addArmor")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterArmor(CharacterArmorViewModel characterArmorViewModel)
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterArmor([Required] CharacterArmorViewModel characterArmorViewModel)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
||||
@ -106,7 +107,7 @@ namespace SessionCompanion.Controllers
|
||||
/// <param name="characterWeaponViewModel"> View model z odpowiednimi parameterami </param>
|
||||
/// <returns>SuccessResponse/ErrorResponse</returns>
|
||||
[HttpPut("addWeapon")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterWeapon(CharacterWeaponViewModel characterWeaponViewModel)
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> AddCharacterWeapon([Required] CharacterWeaponViewModel characterWeaponViewModel)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
||||
@ -127,7 +128,7 @@ namespace SessionCompanion.Controllers
|
||||
/// <param name=characterWeaponViewModel> View model z odpowiednimi parameterami </param>
|
||||
/// <returns>SuccessResponse/ErrorResponse</returns>
|
||||
[HttpPut("changeWeapon")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterWeapon(CharacterWeaponViewModel characterWeaponViewModel)
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeCharacterWeapon([Required] CharacterWeaponViewModel characterWeaponViewModel)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return new ErrorResponse() { StatusCode = 500, Message = "Invalid model!" };
|
||||
|
@ -31,12 +31,16 @@ namespace SessionCompanion.Controllers
|
||||
return _service.Get().ToList();
|
||||
}
|
||||
|
||||
[HttpPost("createNewShopkeeper")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> CreateNewShopKeeper([Required] ShopkeeperWithItemsViewModel shopkeeperWithItemsViewModel)
|
||||
/// <summary>
|
||||
/// Endpoint służacy do zmiany statusu sklepikarza
|
||||
/// </summary>
|
||||
/// <param name="shopkeeperId"></param>
|
||||
/// <param name="availability"></param>
|
||||
/// <returns>SuccesResponse/ErrorResponse</returns>
|
||||
[HttpPut("changeShopkeeperStatus")]
|
||||
public async Task<Either<SuccessResponse, ErrorResponse>> ChangeShopkeeperStatus([Required] int shopkeeperId, [Required] bool availability)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return new ErrorResponse() { StatusCode = 500, Message = "Model is invalid" };
|
||||
return await _service.CreateNewShopKeeper(shopkeeperWithItemsViewModel);
|
||||
return await _service.ChangeShopkeeperStatus(shopkeeperId, availability);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user