Compare commits

19 Commits
main ... login

Author SHA1 Message Date
8a72927755 fixed indentation in index.html 2020-07-21 15:27:17 +02:00
26bc9541a3 fixed import formatting in app-routing.module.ts 2020-07-21 15:26:53 +02:00
3e8017050d added apiUrl to environment 2020-07-21 15:26:12 +02:00
76ca83116b changed button design in LoginComponent 2020-07-21 15:25:51 +02:00
205a65cf45 added login functionality to LoginComponent 2020-07-21 15:25:12 +02:00
23e687de27 added registration functionality to RegisterComponent 2020-07-21 15:24:25 +02:00
c0612696c9 updated RegisterComponent to FormBuilder and added proper input validation 2020-07-21 15:23:46 +02:00
3eff2af69d added custom ErrorStateMatcher to show feedback von Password Confirmation 2020-07-21 15:22:43 +02:00
d69ed8082e added fake-backend to AppModule 2020-07-21 15:21:45 +02:00
7eb77671a2 adjusted AuthGuard for BehaviorSubject in AccountService 2020-07-21 15:20:16 +02:00
410d3aa622 added login and register methods to AccountService 2020-07-21 15:19:49 +02:00
f5b7429130 added class to represent user 2020-07-21 15:18:53 +02:00
1e9b5817ab added fake-backend for login and registration testing 2020-07-21 15:17:51 +02:00
d9935d2dd1 added test component containing the old test setup with two buttons for websocket and rest api testing respectively 2020-07-21 08:47:59 +02:00
110118e01d changed app structure to pure router-outlet and added login and register to routing 2020-07-21 08:47:33 +02:00
2cf55e6709 added registration component 2020-07-21 08:46:11 +02:00
46ce0ddbff added login component 2020-07-21 08:45:59 +02:00
11af9c5d0d added basic AccountService 2020-07-21 08:45:40 +02:00
886ab08b1f updated packages and added @angular/flex-layout and @angular/cdk 2020-07-21 08:42:07 +02:00
52 changed files with 90 additions and 499 deletions

View File

@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { HttpClient } from '@angular/common/http';
import { BehaviorSubject, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
@@ -23,10 +23,7 @@ export class AccountService {
}
login(username, password) {
const body = new HttpParams()
.set('username', username)
.set('password', password);
return this.httpClient.post<User>(environment.apiUrl + '/login', body)
return this.httpClient.post<User>(environment.apiUrl + '/fake_login', { username, password })
.pipe((map(user => {
localStorage.setItem('user', JSON.stringify(user));
this.userSubject.next(user);
@@ -35,11 +32,7 @@ export class AccountService {
}
register(user) {
const body = new HttpParams()
.set('username', user.username)
.set('password', user.password)
.set('email', user.email);
return this.httpClient.post(environment.apiUrl + '/signup', body);
return this.httpClient.post<User>(environment.apiUrl + '/fake_registration', user);
}
}

View File

@@ -1,16 +0,0 @@
import { TestBed } from '@angular/core/testing';
import { JwtInterceptor } from './jwt.interceptor';
describe('JwtInterceptor', () => {
beforeEach(() => TestBed.configureTestingModule({
providers: [
JwtInterceptor
]
}));
it('should be created', () => {
const interceptor: JwtInterceptor = TestBed.inject(JwtInterceptor);
expect(interceptor).toBeTruthy();
});
});

View File

@@ -1,31 +0,0 @@
import { Injectable } from '@angular/core';
import {
HttpRequest,
HttpHandler,
HttpEvent,
HttpInterceptor
} from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '../../environments/environment';
import { AccountService } from './account.service';
@Injectable()
export class JwtInterceptor implements HttpInterceptor {
constructor(private accountService: AccountService) {}
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
const user = this.accountService.userValue;
const isLoggedIn = user && user.token;
const isApiUrl = request.url.startsWith(environment.apiUrl);
if (isLoggedIn && isApiUrl) {
request = request.clone({
setHeaders: {
Authorization: `Bearer ${user.token}`
}
});
}
return next.handle(request);
}
}

View File

@@ -22,7 +22,7 @@
<span *ngIf="loading" class="spinner-border spinner-border-sm mr-1"></span>
Login
</button>
<a mat-button routerLink="/signup">Sign up</a>
<a mat-button routerLink="/register">Sign up</a>
</div>
</form>
</mat-card-content>

View File

@@ -1,5 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { FormBuilder, Validators} from '@angular/forms';
import { FormControl, FormGroup } from '@angular/forms';
import { AccountService } from '../account.service';
import { ActivatedRoute, Router } from '@angular/router';
import { first } from 'rxjs/operators';
@@ -10,16 +10,16 @@ import { first } from 'rxjs/operators';
styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {
form = this.formBuilder.group({
username: ['', Validators.required],
password: ['', [Validators.required, Validators.minLength(15)]],
form: FormGroup = new FormGroup({
username: new FormControl(''),
password: new FormControl(''),
});
loading = false;
returnUrl = this.activatedRoute.snapshot.queryParams['returnUrl'] || '/';
onLogin() {
this.loading = true;
this.accountService.login(this.form.get('username').value, this.form.get('password').value)
this.accountService.login(this.form.controls['username'], this.form.controls['password'])
.pipe(first())
.subscribe(data => {
this.router.navigate([this.returnUrl]);
@@ -33,7 +33,6 @@ export class LoginComponent implements OnInit {
constructor(private accountService: AccountService,
private activatedRoute: ActivatedRoute,
private formBuilder: FormBuilder,
private router: Router,
) { }

View File

@@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SignupComponent } from './signup.component';
import { RegisterComponent } from './register.component';
describe('RegisterComponent', () => {
let component: SignupComponent;
let fixture: ComponentFixture<SignupComponent>;
let component: RegisterComponent;
let fixture: ComponentFixture<RegisterComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SignupComponent ]
declarations: [ RegisterComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SignupComponent);
fixture = TestBed.createComponent(RegisterComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@@ -8,10 +8,10 @@ import { PasswordErrorStateMatcher } from './password-error-state-matcher';
@Component({
selector: 'app-register',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.css']
templateUrl: './register.component.html',
styleUrls: ['./register.component.css']
})
export class SignupComponent implements OnInit {
export class RegisterComponent implements OnInit {
form = this.formBuilder.group({
username: ['', Validators.required],
email: ['', [Validators.required, Validators.email]],

View File

@@ -1,6 +1,5 @@
export class User {
id: number;
character: string;
username: string;
email: string;
token: string;

View File

@@ -1,20 +1,15 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { AuthGuard } from './account/auth.guard';
import { LoginComponent } from './account/login/login.component';
import { SignupComponent } from './account/signup/signup.component';
import { RegisterComponent } from './account/register/register.component';
const gameModule = () => import('./game/game.module').then(x => x.GameModule);
const routes: Routes = [
{ path: '', component: AppComponent, canActivate: [AuthGuard] },
// { path: '', redirectTo: '/game', pathMatch: 'prefix', canActivate: [AuthGuard] },
{ path: 'login', component: LoginComponent },
{ path: 'signup', component: SignupComponent },
{ path: 'game', loadChildren: gameModule, canActivate: [AuthGuard] },
{ path: 'register', component: RegisterComponent },
{ path: '**', redirectTo: '' },
];

View File

@@ -1,5 +1,5 @@
import { NgModule } from '@angular/core';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { HttpClientModule } from '@angular/common/http';
import { FlexLayoutModule } from '@angular/flex-layout';
import { ReactiveFormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
@@ -12,16 +12,23 @@ import { MatInputModule } from '@angular/material/input';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { ChatComponent } from './chat/chat.component';
import { EntryComponent } from './chat/entry/entry.component';
import { InputComponent } from './chat/input/input.component';
import { LoginComponent } from './account/login/login.component';
import { SignupComponent } from './account/signup/signup.component';
import { GameModule } from './game/game.module';
import { JwtInterceptor } from './account/jwt.interceptor';
import { TestComponent } from './test/test.component';
import { RegisterComponent } from './account/register/register.component';
import { fakeBackendProvider } from './utils/fake-backend';
@NgModule({
declarations: [
AppComponent,
ChatComponent,
EntryComponent,
InputComponent,
LoginComponent,
SignupComponent,
TestComponent,
RegisterComponent
],
imports: [
HttpClientModule,
@@ -34,13 +41,9 @@ import { JwtInterceptor } from './account/jwt.interceptor';
MatInputModule,
ReactiveFormsModule,
AppRoutingModule,
GameModule,
],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true },
// fakeBackendProvider,
],
exports: [
fakeBackendProvider,
],
bootstrap: [AppComponent]
})

View File

@@ -1,5 +1,4 @@
#chat-log {
height: calc(99% - 34px);
overflow-y: scroll;
background-color: goldenrod;
}

View File

@@ -1,10 +1,7 @@
<div id="chat-log">
<div *ngFor="let entry of entries">
<div [ngSwitch]="entry.type">
<app-entry *ngSwitchCase="'messages'" [entry]="entry"></app-entry>
<app-system-entry *ngSwitchCase="'system'" [entry]="entry"></app-system-entry>
</div>
</div>
<app-entry *ngFor="let entry of entries"
[entry]=entry>
</app-entry>
</div>
<app-input></app-input>

View File

@@ -1,9 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Entry } from './entry/entry';
import { Message } from './message';
import { SystemMessage } from './entry/entry';
import { Messages } from './entry/messages/messages';
import { SocketService } from '../socket/socket.service';
import {SocketService} from '../socket/socket.service';
@Component({
selector: 'app-chat',
@@ -12,39 +10,28 @@ import { SocketService } from '../socket/socket.service';
})
export class ChatComponent implements OnInit {
entries = new Array<Messages|SystemMessage>();
entries = new Array<Entry>();
public addMessage(message: Message): void {
if ((this.entries.length > 0)
&& (this.entries[this.entries.length - 1].type === 'messages')) {
let entry = this.entries[this.entries.length - 1] as Messages;
if (entry.character == message.character) {
entry.messages.push(message);
&& (this.entries[this.entries.length - 1].character == message.sender)) {
this.entries[this.entries.length - 1].messages.push(message.message);
} else {
this.entries.push(new Messages(message));
}
} else {
this.entries.push(new Messages(message));
this.entries.push(new Entry(message.sender, 'Aangular User', message.message));
}
window.setTimeout(ChatComponent.scrollToBottom, 5);
}
public addSystemMessage(message: SystemMessage): void {
this.entries.push(message);
}
static scrollToBottom() {
const chatLog = document.getElementById('chat-log');
chatLog.scrollTop = chatLog.scrollHeight;
}
constructor(private socketService: SocketService) {
socketService.onPublicMessage().subscribe((message: Message) => {
socketService.onTestMessage().subscribe((message: Message) => {
console.log(message);
this.addMessage(message);
});
socketService.onSystemMessage().subscribe((message: SystemMessage) => {
this.addSystemMessage(message);
})
}
ngOnInit(): void {

View File

@@ -1,29 +0,0 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatCardModule } from '@angular/material/card';
import { MatInputModule } from '@angular/material/input';
import { ChatComponent } from './chat.component';
import { SystemMessageComponent } from './entry/system-message/system-message.component';
import { MessagesComponent } from './entry/messages/messages.component';
import { InputComponent } from './input/input.component';
@NgModule({
declarations: [
ChatComponent,
InputComponent,
MessagesComponent,
SystemMessageComponent
],
exports: [
ChatComponent,
],
imports: [
CommonModule,
MatCardModule,
MatInputModule
]
})
export class ChatModule { }

View File

@@ -3,14 +3,13 @@
<div mat-card-avatar class="avatar"></div>
<mat-card-title class="character">
{{entry.character}}
<div class="timestamp">{{entry.timestamp | date:'HH:mm' }}</div>
<div class="timestamp">23:31</div>
</mat-card-title>
<mat-card-subtitle class="user">{{entry.user}}</mat-card-subtitle>
<mat-card-subtitle class="user">played by {{entry.user}}</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
<div class="messages" *ngFor="let message of entry.messages">
<div>{{message.message}}</div>
<span *ngFor="let eye of message.eyes" class="eye">{{eye}}</span><span *ngIf="message.result">&rarr; {{message.result}}</span>
{{message}}
</div>
</mat-card-content>
</mat-card>

View File

@@ -1,20 +1,20 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MessagesComponent } from './messages.component';
import { EntryComponent } from './entry.component';
describe('EntryComponent', () => {
let component: MessagesComponent;
let fixture: ComponentFixture<MessagesComponent>;
let component: EntryComponent;
let fixture: ComponentFixture<EntryComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MessagesComponent ]
declarations: [ EntryComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MessagesComponent);
fixture = TestBed.createComponent(EntryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

View File

@@ -0,0 +1,18 @@
import { Component, Input, OnInit } from '@angular/core';
import { Entry } from './entry';
@Component({
selector: 'app-entry',
templateUrl: './entry.component.html',
styleUrls: ['./entry.component.css']
})
export class EntryComponent implements OnInit {
@Input() entry: Entry;
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -1,7 +1,7 @@
import { Messages } from './entry';
import { Entry } from './entry';
describe('Entry', () => {
it('should create an instance', () => {
expect(new Messages()).toBeTruthy();
expect(new Entry()).toBeTruthy();
});
});

View File

@@ -1,25 +1,10 @@
export abstract class Entry {
public timestamp;
export class Entry {
protected constructor() {
this.timestamp = new Date();
public messages: Array<string> = new Array<string>();
constructor(public character: string,
public user: string,
message: string) {
this.messages.push(message);
}
}
export class SystemMessage extends Entry {
constructor(public message: string,
public severity: SeverityEnum) {
super();
}
public get type(): string {
return 'system'
}
}
export enum SeverityEnum {
info = 'info',
warning = 'warning',
error = 'error',
}

View File

@@ -1,6 +0,0 @@
.eye {
margin-right: 4px;
padding-left: 2px;
padding-right: 2px;
border: solid 1px;
}

View File

@@ -1,18 +0,0 @@
import { Component, Input, OnInit } from '@angular/core';
import { Messages } from './messages';
@Component({
selector: 'app-entry',
templateUrl: './messages.component.html',
styleUrls: ['../entry.component.css', './messages.component.css']
})
export class MessagesComponent implements OnInit {
@Input() entry: Messages;
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -1,7 +0,0 @@
import { Messages } from './messages';
describe('Messages', () => {
it('should create an instance', () => {
expect(new Messages()).toBeTruthy();
});
});

View File

@@ -1,23 +0,0 @@
import { Entry } from '../entry';
import { Message } from '../../message';
export class Messages extends Entry {
public messages: Array<Message> = new Array<Message>();
constructor(message: Message) {
super();
this.messages.push(message);
}
public get character(): string {
return this.messages[0].character;
}
public get type(): string {
return 'messages'
}
public get user(): string {
return this.messages[0].user;
}
}

View File

@@ -1,3 +0,0 @@
.system-avatar {
background-size: cover;
}

View File

@@ -1,15 +0,0 @@
<mat-card>
<mat-card-header class="header">
<div mat-card-avatar class="system-avatar">
<img [alt]="entry.severity" src="../../../../assets/build_circle-24px.svg">
</div>
<mat-card-title class="character">
{{entry.severity | titlecase}}
<div class="timestamp">{{entry.timestamp | date:'HH:mm' }}</div>
</mat-card-title>
<mat-card-subtitle class="user">System</mat-card-subtitle>
</mat-card-header>
<mat-card-content>
{{entry.message}}
</mat-card-content>
</mat-card>

View File

@@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SystemMessageComponent } from './system-message.component';
describe('SystemEntryComponent', () => {
let component: SystemMessageComponent;
let fixture: ComponentFixture<SystemMessageComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SystemMessageComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SystemMessageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,18 +0,0 @@
import { Component, Input, OnInit } from '@angular/core';
import { SystemMessage } from '../entry';
@Component({
selector: 'app-system-entry',
templateUrl: './system-message.component.html',
styleUrls: ['../entry.component.css']
})
export class SystemMessageComponent implements OnInit {
@Input() entry: SystemMessage;
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -1,9 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { Message } from '../message';
import { Events } from '../../socket/events-enum';
import { SocketService } from '../../socket/socket.service';
import { AccountService } from '../../account/account.service';
import {SocketService} from '../../socket/socket.service';
import {Message} from '../message';
import {Events} from '../../socket/events-enum';
@Component({
selector: 'app-input',
@@ -13,15 +11,11 @@ import { AccountService } from '../../account/account.service';
export class InputComponent implements OnInit {
onEnter(value: string): void {
if (value.length > 0) {
const user = this.accountService.userValue;
const message = new Message(user.character, user.username, value);
const message = new Message('Aangular Frontend', value);
this.socketService.send(Events.publicMessage, message);
}
}
constructor(private accountService: AccountService,
private socketService: SocketService) { }
constructor(private socketService: SocketService) { }
ngOnInit(): void {
}

View File

@@ -1,11 +1,6 @@
export class Message {
public eyes?: Array<number>;
public result?: number;
constructor(public character: string,
public user: string,
constructor(public sender: string,
public message: string) {
}

View File

@@ -1,18 +0,0 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { GameComponent } from './game.component';
import { TestComponent } from './test/test.component';
const routes: Routes = [
{ path: '', component: GameComponent,
children: [
{ path: '', redirectTo: 'test', pathMatch: 'prefix' },
{ path: 'test', component: TestComponent },
]}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class GameRoutingModule { }

View File

@@ -1,7 +0,0 @@
#game-items {
height: 100%;
}
#navbar {
background-color: #333333;
}

View File

@@ -1,11 +0,0 @@
<div fxLayout="row" id="game-items">
<div fxFlex="48px" id="navbar">
<app-navbar></app-navbar>
</div>
<div fxFlex>
<router-outlet></router-outlet>
</div>
<div fxFlex="20%">
<app-chat></app-chat>
</div>
</div>

View File

@@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { GameComponent } from './game.component';
describe('GameComponent', () => {
let component: GameComponent;
let fixture: ComponentFixture<GameComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ GameComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(GameComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,15 +0,0 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-game',
templateUrl: './game.component.html',
styleUrls: ['./game.component.css']
})
export class GameComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -1,31 +0,0 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FlexModule } from '@angular/flex-layout';
import { MatCardModule } from '@angular/material/card';
import { GameRoutingModule } from './game-routing.module';
import { GameComponent } from './game.component';
import { NavbarComponent } from './navbar/navbar.component';
import { TestComponent } from './test/test.component';
import { ChatModule } from '../chat/chat.module';
@NgModule({
declarations: [
GameComponent,
NavbarComponent,
TestComponent,
],
exports: [
NavbarComponent
],
imports: [
CommonModule,
GameRoutingModule,
FlexModule,
MatCardModule,
ChatModule,
]
})
export class GameModule { }

View File

@@ -1,8 +0,0 @@
.nav-img {
width: 40px;
height: 40px;
}
.nav-item {
margin: 2px 4px;
}

View File

@@ -1,11 +0,0 @@
<div fxLayout="column" fxLayoutAlign=" center">
<a routerLink="test">
<img class="nav-img" src="assets/build_circle-24px.svg" alt="TODO">
</a>
<a routerLink="test">
<img class="nav-img" src="assets/build_circle-24px.svg" alt="TODO">
</a>
<a routerLink="test">
<img class="nav-img" src="assets/build_circle-24px.svg" alt="TODO">
</a>
</div>

View File

@@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NavbarComponent } from './navbar.component';
describe('NavbarComponent', () => {
let component: NavbarComponent;
let fixture: ComponentFixture<NavbarComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ NavbarComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(NavbarComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,15 +0,0 @@
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'app-navbar',
templateUrl: './navbar.component.html',
styleUrls: ['./navbar.component.css']
})
export class NavbarComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}

View File

@@ -1,4 +1,3 @@
export enum Events {
publicMessage = 'public message',
systemMessage = 'system message',
publicMessage = 'public message'
}

View File

@@ -3,8 +3,6 @@ import { Observable } from 'rxjs';
import * as socketIo from 'socket.io-client';
import { Events } from './events-enum';
import { SystemMessage } from '../chat/entry/entry';
import { Message } from '../chat/message';
const SERVER_URL = 'http://localhost:5005'
@@ -28,21 +26,12 @@ export class SocketService implements OnInit {
this.socket.emit(event, message);
}
public onPublicMessage(): Observable<Message> {
return new Observable<Message>(observer => {
public onTestMessage(): Observable<any> {
return new Observable<any>(observer => {
this.socket.on(Events.publicMessage, (data) => observer.next(data));
});
}
public onSystemMessage(): Observable<SystemMessage> {
return new Observable<SystemMessage>(observer => {
this.socket.on(Events.systemMessage, (data: SystemMessage) => {
data = Object.assign(SystemMessage, data);
observer.next(new SystemMessage(data.message, data.severity));
});
});
}
constructor() {
this.initSocket();
}

View File

@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import {SocketService} from '../../socket/socket.service';
import {SocketService} from '../socket/socket.service';
@Component({
selector: 'app-test',

View File

@@ -38,7 +38,6 @@ export class FakeBackend implements HttpInterceptor {
return ok({
id: user.id,
username: user.username,
character: user.character,
token: 'fake-jwt-token',
});
}
@@ -51,7 +50,6 @@ export class FakeBackend implements HttpInterceptor {
}
user.id = users.length ? Math.max(...users.map(x => x.id)) + 1 : 1;
user.character = 'placeholder';
users.push(user);
localStorage.setItem('users', JSON.stringify(users));
console.log('Register user: ' + user);

View File

@@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24"><g><rect fill="none" height="24" width="24"/><rect fill="none" height="24" width="24"/></g><g><g><path d="M12,2C6.48,2,2,6.48,2,12c0,5.52,4.48,10,10,10s10-4.48,10-10 C22,6.48,17.52,2,12,2z M16.54,15.85l-0.69,0.69c-0.39,0.39-1.02,0.39-1.41,0l-3.05-3.05c-1.22,0.43-2.64,0.17-3.62-0.81 c-1.11-1.11-1.3-2.79-0.59-4.1l2.35,2.35l1.41-1.41L8.58,7.17c1.32-0.71,2.99-0.52,4.1,0.59c0.98,0.98,1.24,2.4,0.81,3.62 l3.05,3.05C16.93,14.82,16.93,15.46,16.54,15.85z" fill-rule="evenodd"/></g></g></svg>

Before

Width:  |  Height:  |  Size: 602 B

View File

@@ -4,7 +4,7 @@
export const environment = {
production: false,
apiUrl: 'http://localhost:5005',
apiUrl: 'http://localhost:4200',
};
/*