Merge branch 'game' into 'main'

Game

Created a GameModule that will contain all the functionality required to play. The routing and imports of AppModule are adjusted accordingly.

See merge request daniel/rona-frontend!2
This commit is contained in:
2020-07-23 14:53:03 +02:00
33 changed files with 187 additions and 13 deletions

View File

@@ -1,15 +1,20 @@
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 { 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: 'register', component: RegisterComponent },
{ path: 'game', loadChildren: gameModule, canActivate: [AuthGuard] },
{ path: '**', redirectTo: '' },
];

View File

@@ -12,22 +12,15 @@ 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 { TestComponent } from './test/test.component';
import { RegisterComponent } from './account/register/register.component';
import { fakeBackendProvider } from './utils/fake-backend';
import { GameModule } from './game/game.module';
@NgModule({
declarations: [
AppComponent,
ChatComponent,
EntryComponent,
InputComponent,
LoginComponent,
TestComponent,
RegisterComponent
],
imports: [
@@ -41,10 +34,13 @@ import { fakeBackendProvider } from './utils/fake-backend';
MatInputModule,
ReactiveFormsModule,
AppRoutingModule,
GameModule,
],
providers: [
fakeBackendProvider,
],
exports: [
],
bootstrap: [AppComponent]
})
export class AppModule { }

View File

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

View File

@@ -1,7 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { Entry } from './entry/entry';
import { Message } from './message';
import {SocketService} from '../socket/socket.service';
import { SocketService } from '../../socket/socket.service';
@Component({
selector: 'app-chat',

View File

@@ -1,7 +1,7 @@
import { Component, OnInit } from '@angular/core';
import {SocketService} from '../../socket/socket.service';
import { Message } from '../message';
import {Events} from '../../socket/events-enum';
import { Events } from '../../../socket/events-enum';
import { SocketService } from '../../../socket/socket.service';
@Component({
selector: 'app-input',

View File

@@ -0,0 +1,18 @@
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

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

View File

@@ -0,0 +1,11 @@
<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

@@ -0,0 +1,25 @@
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

@@ -0,0 +1,15 @@
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

@@ -0,0 +1,35 @@
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 { ChatComponent } from './chat/chat.component';
import { EntryComponent } from './chat/entry/entry.component';
import { InputComponent } from './chat/input/input.component';
import { NavbarComponent } from './navbar/navbar.component';
import { TestComponent } from './test/test.component';
@NgModule({
declarations: [
GameComponent,
NavbarComponent,
ChatComponent,
TestComponent,
EntryComponent,
InputComponent,
],
exports: [
NavbarComponent
],
imports: [
CommonModule,
GameRoutingModule,
FlexModule,
MatCardModule,
]
})
export class GameModule { }

View File

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

View File

@@ -0,0 +1,11 @@
<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

@@ -0,0 +1,25 @@
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

@@ -0,0 +1,15 @@
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,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

@@ -0,0 +1 @@
<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>

After

Width:  |  Height:  |  Size: 602 B