SES-116 Database update and icons fix

This commit is contained in:
Łukasz Góreczny 2020-12-28 14:59:42 +01:00
parent 9477b7346b
commit 7b430e05cb
14 changed files with 942 additions and 102 deletions

View File

@ -0,0 +1,838 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SessionCompanion.Database;
namespace SessionCompanion.Database.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20201228114303_Class name fix")]
partial class Classnamefix
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseIdentityColumns()
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.0");
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.HasKey("Id");
b.ToTable("Alignments");
b.HasData(
new
{
Id = 1
},
new
{
Id = 2
},
new
{
Id = 3
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.HasKey("Id");
b.ToTable("Backgrounds");
b.HasData(
new
{
Id = 1
},
new
{
Id = 2
},
new
{
Id = 3
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("AlignmentId")
.HasColumnType("int");
b.Property<int>("BackgroundId")
.HasColumnType("int");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("ClassId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<int>("RaceId")
.HasColumnType("int");
b.Property<string>("Sex")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AlignmentId");
b.HasIndex("BackgroundId");
b.HasIndex("CharacterId")
.IsUnique();
b.HasIndex("ClassId");
b.HasIndex("RaceId");
b.ToTable("Biographies");
b.HasData(
new
{
Id = 1,
AlignmentId = 1,
BackgroundId = 1,
CharacterId = 1,
ClassId = 1,
Name = "Bob",
RaceId = 1,
Sex = "Male"
},
new
{
Id = 2,
AlignmentId = 2,
BackgroundId = 2,
CharacterId = 2,
ClassId = 2,
Name = "Queen Daenerys Stormborn of the House Targaryen, the First of Her Name, Queen of the Andals, the Rhoynar and the First Men, Lady of the Seven Kingdoms and Protector of the Realm, Lady of Dragonstone, Queen of Meereen, Khaleesi of the Great Grass Sea, the Unburnt, Breaker of Chains and Mother of Dragons.",
RaceId = 2,
Sex = "Female"
},
new
{
Id = 3,
AlignmentId = 3,
BackgroundId = 3,
CharacterId = 3,
ClassId = 3,
Name = "Gandalf the White",
RaceId = 3,
Sex = "Both"
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Characters");
b.HasData(
new
{
Id = 1,
UserId = 1
},
new
{
Id = 2,
UserId = 2
},
new
{
Id = 3,
UserId = 3
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Charisma", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<bool>("CanDeception")
.HasColumnType("bit");
b.Property<bool>("CanIntimidation")
.HasColumnType("bit");
b.Property<bool>("CanPerformance")
.HasColumnType("bit");
b.Property<bool>("CanPersuasion")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Deception")
.HasColumnType("int");
b.Property<int>("Intimidation")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Performance")
.HasColumnType("int");
b.Property<int>("Persuasion")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Charismas");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Classes");
b.HasData(
new
{
Id = 1,
Name = "Fighter"
},
new
{
Id = 2,
Name = "Paladin"
},
new
{
Id = 3,
Name = "Cleric"
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Constitution", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Constitutions");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Dexterity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Acrobatics")
.HasColumnType("int");
b.Property<bool>("CanAcrobatics")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<bool>("CanSleightOfHand")
.HasColumnType("bit");
b.Property<bool>("CanStealth")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("SleightOfHand")
.HasColumnType("int");
b.Property<int>("Stealth")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Dexterities");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Intelligence", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Arcana")
.HasColumnType("int");
b.Property<bool>("CanArcana")
.HasColumnType("bit");
b.Property<bool>("CanHistory")
.HasColumnType("bit");
b.Property<bool>("CanInvestigation")
.HasColumnType("bit");
b.Property<bool>("CanNature")
.HasColumnType("bit");
b.Property<bool>("CanReligion")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("History")
.HasColumnType("int");
b.Property<int>("Investigation")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Nature")
.HasColumnType("int");
b.Property<int>("Religion")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Intelligences");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Races");
b.HasData(
new
{
Id = 1,
Name = "Human"
},
new
{
Id = 2,
Name = "Dwarf"
},
new
{
Id = 3,
Name = "Elf"
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("ArmorClass")
.HasColumnType("int");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("CurrentHealthPoints")
.HasColumnType("int");
b.Property<int>("ExperiencePoints")
.HasColumnType("int");
b.Property<int>("HealthPoints")
.HasColumnType("int");
b.Property<int>("Initiative")
.HasColumnType("int");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<int>("Proficiency")
.HasColumnType("int");
b.Property<int>("Speed")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Statistics");
b.HasData(
new
{
Id = 1,
ArmorClass = 9,
CharacterId = 1,
CurrentHealthPoints = 18,
ExperiencePoints = 2,
HealthPoints = 20,
Initiative = 12,
Level = 1,
Proficiency = 1,
Speed = 5
},
new
{
Id = 2,
ArmorClass = 12,
CharacterId = 2,
CurrentHealthPoints = 26,
ExperiencePoints = 0,
HealthPoints = 26,
Initiative = 7,
Level = 1,
Proficiency = 1,
Speed = 10
},
new
{
Id = 3,
ArmorClass = 2,
CharacterId = 3,
CurrentHealthPoints = 7,
ExperiencePoints = 24,
HealthPoints = 7,
Initiative = 18,
Level = 1,
Proficiency = 2,
Speed = 15
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Strength", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Athletics")
.HasColumnType("int");
b.Property<bool>("CanAthletics")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Strengths");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Password")
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
b.HasData(
new
{
Id = 1,
Password = "123",
Username = "Morwiec"
},
new
{
Id = 2,
Password = "123",
Username = "Cichoklepiec"
},
new
{
Id = 3,
Password = "123",
Username = "Ruletka"
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Wisdom", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("AnimalHandling")
.HasColumnType("int");
b.Property<bool>("CanAnimalHandling")
.HasColumnType("bit");
b.Property<bool>("CanInsight")
.HasColumnType("bit");
b.Property<bool>("CanMedicine")
.HasColumnType("bit");
b.Property<bool>("CanPerception")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<bool>("CanSurvival")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Insight")
.HasColumnType("int");
b.Property<int>("Medicine")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Perception")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Survival")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Wisdoms");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Alignment", "Alignment")
.WithMany("Biography")
.HasForeignKey("AlignmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Background", "Background")
.WithMany("Biography")
.HasForeignKey("BackgroundId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Biography")
.HasForeignKey("SessionCompanion.Database.Tables.Biography", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Class", "Class")
.WithMany("Biography")
.HasForeignKey("ClassId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Race", "Race")
.WithMany("Biography")
.HasForeignKey("RaceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Alignment");
b.Navigation("Background");
b.Navigation("Character");
b.Navigation("Class");
b.Navigation("Race");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.HasOne("SessionCompanion.Database.Tables.User", "User")
.WithMany("Character")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Charisma", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Charisma")
.HasForeignKey("SessionCompanion.Database.Tables.Charisma", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Constitution", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Constitution")
.HasForeignKey("SessionCompanion.Database.Tables.Constitution", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Dexterity", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Dexterity")
.HasForeignKey("SessionCompanion.Database.Tables.Dexterity", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Intelligence", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Intelligence")
.HasForeignKey("SessionCompanion.Database.Tables.Intelligence", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Statistics")
.HasForeignKey("SessionCompanion.Database.Tables.Statistics", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Strength", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Strength")
.HasForeignKey("SessionCompanion.Database.Tables.Strength", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Wisdom", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Wisdom")
.HasForeignKey("SessionCompanion.Database.Tables.Wisdom", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.Navigation("Biography");
b.Navigation("Charisma");
b.Navigation("Constitution");
b.Navigation("Dexterity");
b.Navigation("Intelligence");
b.Navigation("Statistics");
b.Navigation("Strength");
b.Navigation("Wisdom");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
{
b.Navigation("Character");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,55 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace SessionCompanion.Database.Migrations
{
public partial class Classnamefix : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Classes",
keyColumn: "Id",
keyValue: 1,
column: "Name",
value: "Fighter");
migrationBuilder.UpdateData(
table: "Classes",
keyColumn: "Id",
keyValue: 2,
column: "Name",
value: "Paladin");
migrationBuilder.UpdateData(
table: "Classes",
keyColumn: "Id",
keyValue: 3,
column: "Name",
value: "Cleric");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "Classes",
keyColumn: "Id",
keyValue: 1,
column: "Name",
value: "Warrior");
migrationBuilder.UpdateData(
table: "Classes",
keyColumn: "Id",
keyValue: 2,
column: "Name",
value: "Knight");
migrationBuilder.UpdateData(
table: "Classes",
keyColumn: "Id",
keyValue: 3,
column: "Name",
value: "Priest");
}
}
}

View File

@ -255,17 +255,17 @@ namespace SessionCompanion.Database.Migrations
new
{
Id = 1,
Name = "Warrior"
Name = "Fighter"
},
new
{
Id = 2,
Name = "Knight"
Name = "Paladin"
},
new
{
Id = 3,
Name = "Priest"
Name = "Cleric"
});
});

View File

@ -66,17 +66,17 @@ namespace SessionCompanion.Database
new Class
{
Id = 1,
Name = "Warrior"
Name = "Fighter"
},
new Class
{
Id = 2,
Name = "Knight"
Name = "Paladin"
},
new Class
{
Id = 3,
Name = "Priest"
Name = "Cleric"
}
};
return classes;

View File

@ -1,9 +1,17 @@
import { Component } from '@angular/core';
import {Component, OnInit} from '@angular/core';
import {SessionCompanionIconsRegistry} from './shared/sc-icons/session-companion-icons-registry.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
export class AppComponent implements OnInit{
title = 'Session Companion';
constructor(private iconService: SessionCompanionIconsRegistry) {
}
ngOnInit() {
this.iconService.registerIcons();
}
}

View File

@ -24,7 +24,6 @@ import {UserService} from '../services/user.service';
import { StoreModule } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import {environment} from '../environments/environment';
import {SessionCompanionIconsModule} from './shared/sc-icons/session-companion-icons.module';
import {reducers} from './store/models/app-state.model';
import {CharacterService} from '../services/character.service';
@ -55,7 +54,6 @@ BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
MatSidenavModule,
MatToolbarModule,
MatListModule,
SessionCompanionIconsModule,
StoreModule.forRoot(reducers),
StoreDevtoolsModule.instrument({
logOnly: environment.production

View File

@ -38,17 +38,9 @@
</div>
<mat-divider></mat-divider>
<mat-nav-list>
<mat-list-item>
<mat-icon mat-list-icon>folder</mat-icon>
<a [@animateText]="rightSidenavTextExpanded ? 'show' : 'hide'" mat-list-item href="#" style="color: white">Link 1</a>
</mat-list-item>
<mat-list-item>
<mat-icon mat-list-icon>folder</mat-icon>
<a [@animateText]="rightSidenavTextExpanded ? 'show' : 'hide'" mat-list-item href="#" style="color: white">Link 2</a>
</mat-list-item>
<mat-list-item>
<mat-icon mat-list-icon>folder</mat-icon>
<a [@animateText]="rightSidenavTextExpanded ? 'show' : 'hide'" mat-list-item href="#" style="color: white">Link 3</a>
<mat-list-item *ngFor="let loggedCharacter of loggedCharacters">
<mat-icon svgIcon="{{loggedCharacter.class.toLowerCase()}}" mat-list-icon></mat-icon>
<a [@animateText]="rightSidenavTextExpanded ? 'show' : 'hide'" mat-list-item href="#" style="color: white">{{(loggedCharacter.name.length>12)? (loggedCharacter.name | slice:0:12)+'..':(loggedCharacter.name)}}</a>
</mat-list-item>
</mat-nav-list>
</mat-sidenav>

View File

@ -5,6 +5,9 @@ import {CharacterService} from '../../../services/character.service';
import {Subscription} from 'rxjs';
import {ErrorResponse} from '../../../types/ErrorResponse';
import {HttpErrorResponse} from '@angular/common/http';
import {LoggedCharactersViewModel} from '../../../types/viewmodels/character-viewmodels/LoggedCharactersViewModel';
import {SessionCompanionIconsRegistry} from '../../shared/sc-icons/session-companion-icons-registry.service';
import { first, take } from 'rxjs/operators';
@Component({
selector: 'app-game-master-dashboard',
@ -19,7 +22,10 @@ export class GameMasterDashboardComponent implements OnInit, OnDestroy {
rightSidenavExpanded = false;
rightSidenavTextExpanded = false;
constructor(private signalRService: GMSignalRService, private characterService: CharacterService) {
loggedCharacters: LoggedCharactersViewModel[];
constructor(private signalRService: GMSignalRService, private characterService: CharacterService,
private iconsRegister: SessionCompanionIconsRegistry) {
this.SubscribeToEvents();
}
@ -45,20 +51,18 @@ export class GameMasterDashboardComponent implements OnInit, OnDestroy {
}
UpdateCharactersList(): void {
this.allSubscriptions.add(
this.characterService.getLoggedCharacters().subscribe((success) => {
console.log(success);
this.characterService.getLoggedCharacters().pipe(first()).subscribe((success) => {
this.loggedCharacters = success;
},
(error: ErrorResponse | HttpErrorResponse) => {
(error: ErrorResponse | HttpErrorResponse) => {
if (error instanceof HttpErrorResponse) {
error = error.error as ErrorResponse;
}
console.error(error.message);
}));
});
}
private SubscribeToEvents(): void {
debugger
this.signalRService.message.subscribe((message: string) => {
if (message === 'New player connected' || message === 'Player disconnected') {
this.UpdateCharactersList();

View File

@ -1,31 +1,19 @@
import {Injectable} from '@angular/core';
import { SessionCompanionIcon } from './icons/sc-icon.model';
import { SessionCompanionIcon, scIcon } from './icons/sc-icon.model';
import {MatIconRegistry} from '@angular/material';
import {DomSanitizer} from '@angular/platform-browser';
@Injectable({
providedIn: 'root'
})
export class SessionCompanionIconsRegistry {
constructor(private registry: MatIconRegistry, private sanitizer: DomSanitizer) {
}
private registry = new Map<string, string>();
public registerIcons(icons: SessionCompanionIcon[]): void {
icons.forEach((icon: SessionCompanionIcon) => {
if (!this.registry.has(icon.name)) {
this.registry.set(icon.name, icon.data);
}
public registerIcons(): void {
const icons = require('./icons/sc-icon.model');
Object.values(icons).forEach((icon: SessionCompanionIcon) => {
this.registry.addSvgIconLiteral(icon.name, this.sanitizer.bypassSecurityTrustHtml(icon.data));
});
}
public registerIcon(icon: SessionCompanionIcon): void {
if (!this.registry.has(icon.name)) {
this.registry.set(icon.name, icon.data);
}
}
public getIcon(iconName: string): string | undefined {
if (!this.registry.has(iconName)) {
console.warn(`We could not find the Icon with the name ${iconName}, did you add it to the Icon registry?`);
}
return this.registry.get(iconName);
}
}

View File

@ -1,36 +0,0 @@
import {ChangeDetectionStrategy, Component, ElementRef, Inject, Input, Optional} from '@angular/core';
import {SessionCompanionIconsRegistry} from './session-companion-icons-registry.service';
import { DOCUMENT } from '@angular/common';
@Component({
selector: 'app-sc-icons',
template: `
<ng-content></ng-content>
`,
styles: [':host::ng-deep svg{width: 50px; height: 50px}'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class SessionCompanionIconsComponent {
private svgIcon: SVGElement;
@Input()
set name(iconName: string) {
if (this.svgIcon) {
this.element.nativeElement.removeChild(this.svgIcon);
}
const svgData = this.scIconRegistry.getIcon(iconName);
this.svgIcon = this.svgElementFromString(svgData);
this.element.nativeElement.appendChild(this.svgIcon);
}
constructor(private element: ElementRef, private scIconRegistry: SessionCompanionIconsRegistry,
@Optional() @Inject(DOCUMENT) private document: any) {
}
private svgElementFromString(svgContent: string): SVGElement {
const div = this.document.createElement('DIV');
div.innerHTML = svgContent;
return div.querySelector('svg') || this.document.createElementNS('http://www.w3.org/2000/svg', 'path');
}
}

View File

@ -1,12 +0,0 @@
import {NgModule} from '@angular/core';
import {SessionCompanionIconsComponent} from './session-companion-icons.component';
@NgModule({
declarations: [SessionCompanionIconsComponent],
imports: [],
exports: [
SessionCompanionIconsComponent
]
})
export class SessionCompanionIconsModule {
}

View File

@ -3,7 +3,7 @@ import {HttpClient} from '@angular/common/http';
import {Observable, of, throwError} from 'rxjs';
import {ErrorResponse} from '../types/ErrorResponse';
import {Either} from '../types/Either';
import {switchMap} from 'rxjs/operators';
import {switchMap, retry} from 'rxjs/operators';
import {LoggedCharactersViewModel} from '../types/viewmodels/character-viewmodels/LoggedCharactersViewModel';
Injectable({
@ -23,7 +23,8 @@ export class CharacterService {
} else {
return throwError(response.right);
}
})
}),
retry(3)
);
}
}

View File

@ -3,4 +3,5 @@ export interface LoggedCharactersViewModel {
name: string;
level: number;
currentHealthPoints: number;
class: string;
}

View File

@ -72,9 +72,12 @@ namespace SessionCompanion.Controllers
public async Task<Either<List<CharacterBasicStatsViewModel>, ErrorResponse>> GetLoggedUsersCharacters()
{
var connectedCharacters = _sessionHubData.ConnectedCharacters_Prop;
connectedCharacters.Add("a", 1);
connectedCharacters.Add("s", 2);
connectedCharacters.Add("d", 3);
if (_sessionHubData.ConnectedCharacters_Prop.Count() == 0)
{
connectedCharacters.Add("a", 1);
connectedCharacters.Add("s", 2);
connectedCharacters.Add("d", 3);
}
var characters = await _service.GetBasicCharactersData(connectedCharacters.Values.ToList());
return characters.ToList();