From f24bda4cfeaec621a61aa4e63db6541a7f4b19da Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Mon, 31 Oct 2022 14:59:31 +0300 Subject: [PATCH 1/6] delete obsolete id int field --- src/app/interfaces/game.interface.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/interfaces/game.interface.ts b/src/app/interfaces/game.interface.ts index f8ad7fb..350daf3 100644 --- a/src/app/interfaces/game.interface.ts +++ b/src/app/interfaces/game.interface.ts @@ -1,5 +1,4 @@ export interface Game { - //id: number; //TODO: Заменить на строку gameId: string title: string; image: string; From 4c50f26050bc61573e31ed9c684916403748ad69 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Mon, 31 Oct 2022 21:50:50 +0300 Subject: [PATCH 2/6] create loading screen component --- .../loading-screen.component.html | 1 + .../loading-screen.component.scss | 0 .../loading-screen.component.spec.ts | 23 +++++++++++++++++++ .../loading-screen.component.ts | 14 +++++++++++ 4 files changed, 38 insertions(+) create mode 100644 src/app/components/loading-screen/loading-screen.component.html create mode 100644 src/app/components/loading-screen/loading-screen.component.scss create mode 100644 src/app/components/loading-screen/loading-screen.component.spec.ts create mode 100644 src/app/components/loading-screen/loading-screen.component.ts diff --git a/src/app/components/loading-screen/loading-screen.component.html b/src/app/components/loading-screen/loading-screen.component.html new file mode 100644 index 0000000..a400711 --- /dev/null +++ b/src/app/components/loading-screen/loading-screen.component.html @@ -0,0 +1 @@ +

loading-screen works!

diff --git a/src/app/components/loading-screen/loading-screen.component.scss b/src/app/components/loading-screen/loading-screen.component.scss new file mode 100644 index 0000000..e69de29 diff --git a/src/app/components/loading-screen/loading-screen.component.spec.ts b/src/app/components/loading-screen/loading-screen.component.spec.ts new file mode 100644 index 0000000..3ea00df --- /dev/null +++ b/src/app/components/loading-screen/loading-screen.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { LoadingScreenComponent } from './loading-screen.component'; + +describe('LoadingScreenComponent', () => { + let component: LoadingScreenComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ LoadingScreenComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(LoadingScreenComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/loading-screen/loading-screen.component.ts b/src/app/components/loading-screen/loading-screen.component.ts new file mode 100644 index 0000000..98e6f2f --- /dev/null +++ b/src/app/components/loading-screen/loading-screen.component.ts @@ -0,0 +1,14 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + templateUrl: './loading-screen.component.html', + styleUrls: ['./loading-screen.component.scss'] +}) +export class LoadingScreenComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} From 2049fc88338186114f534ac6ba2a7f09754e2ead Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Mon, 31 Oct 2022 21:51:06 +0300 Subject: [PATCH 3/6] add go method to navigate ng routes --- src/app/services/go.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/app/services/go.ts b/src/app/services/go.ts index 1c85eb2..84fc019 100644 --- a/src/app/services/go.ts +++ b/src/app/services/go.ts @@ -9,13 +9,16 @@ export interface Go extends Window { export interface GoCallback extends Window { SetVersion: (value: string) => void; + GoChangeRoute: (value: string) => void; } let { GoGetGames, GoRunGame, GoGetSessions } = window as unknown as Go; -let { SetVersion } = window as unknown as GoCallback; +let { SetVersion, GoChangeRoute } = window as unknown as GoCallback; let w = window as unknown as GoCallback; + + // var register = function (name: string): void { // const event = new CustomEvent(`${name}_Callback`, { // detail: value @@ -25,11 +28,11 @@ let w = window as unknown as GoCallback; // w.SetVersion = register('SetVersion') -// ((window)).SetVersion = function (value: T): void { -// const event = new CustomEvent('GetVersion_Callback', { -// detail: value, -// }); -// document.dispatchEvent(event); -// }; +((window)).GoChangeRoute = function (value: T): void { + const event = new CustomEvent('GoChangeRoute_Callback', { + detail: value, + }); + document.dispatchEvent(event); +}; -export { GoGetGames, GoGetSessions, SetVersion, GoRunGame }; +export { GoGetGames, GoGetSessions, SetVersion, GoRunGame, GoChangeRoute }; From f79938a76de5d28ae52b3fe3e532e3b4b8311123 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Mon, 31 Oct 2022 21:52:05 +0300 Subject: [PATCH 4/6] set as default route loading screen --- src/app/modules/app-routing.module.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/modules/app-routing.module.ts b/src/app/modules/app-routing.module.ts index d1ee2ce..d468c51 100644 --- a/src/app/modules/app-routing.module.ts +++ b/src/app/modules/app-routing.module.ts @@ -1,5 +1,6 @@ import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; +import { LoadingScreenComponent } from '../components/loading-screen/loading-screen.component'; import { MainRoutingModule } from '../components/main/routing.module'; import { PlaygroundComponent } from '../components/playground/playground.component'; import { SandboxComponent } from '../components/sandbox/sandbox.component'; @@ -11,7 +12,7 @@ const routes: Routes = [ component: PlaygroundComponent, }, { - path: '', + path: 'main', loadChildren: () => MainRoutingModule, }, { @@ -22,6 +23,10 @@ const routes: Routes = [ path: 'sign-in', component: SignInComponent, }, + { + path: '', + component: LoadingScreenComponent, + }, ]; @NgModule({ From 697af174620f89bb4aec26d015f53c877cd31c97 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Mon, 31 Oct 2022 21:52:28 +0300 Subject: [PATCH 5/6] Add callback for ng route commands for go --- src/app/app.component.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 79accdb..395fc07 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,10 +1,20 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { Router, RouterEvent } from '@angular/router'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'], }) -export class AppComponent { + +export class AppComponent implements OnInit{ + constructor(private router: Router){ } + + ngOnInit(){ + document.addEventListener('GoChangeRoute_Callback', (event:any) => { + this.router.navigate([event.detail]) + console.log("here") + }) + } title = 'go-web'; } From 96a81cb5ec8df87f7457532a036e926a10471b30 Mon Sep 17 00:00:00 2001 From: cyber-dream Date: Mon, 31 Oct 2022 21:52:47 +0300 Subject: [PATCH 6/6] import loading screen component --- src/app/app.module.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index ca26181..ce9ca93 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -14,9 +14,10 @@ import { MainModule } from './components/main/main.module'; import { PlaygroundModule } from './components/playground/playground.module'; import { SandboxModule } from './components/sandbox/sandbox.module'; import { SignInModule } from './components/sign-in/sign-in.module'; +import { LoadingScreenComponent } from './components/loading-screen/loading-screen.component'; @NgModule({ - declarations: [AppComponent], + declarations: [AppComponent, LoadingScreenComponent], imports: [ BrowserModule, AppRoutingModule,