From d353290d874074a6032c98c98f2648254e7eea4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Buczek?= Date: Mon, 3 Feb 2025 19:07:10 +0100 Subject: [PATCH 1/7] feat: #220 added route to /error500 if an internal or unknown error has occured --- src/utils/helpers/errorHandler.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/helpers/errorHandler.ts b/src/utils/helpers/errorHandler.ts index 190c26bb..6df12120 100644 --- a/src/utils/helpers/errorHandler.ts +++ b/src/utils/helpers/errorHandler.ts @@ -2,10 +2,15 @@ import { HttpErrorResponse } from '@angular/common/http'; export function errorHandler(error: HttpErrorResponse): string { let errorMessage = 'An error has occured'; + console.info("error", error) if (error.status === 401) { errorMessage = 'Unauthorized, you have to be logged in'; } else if (error.status === 403) { errorMessage = 'Forbidden, you have no permission to do this operation'; + } else if(error.status === 500 || error.statusText === "Unknown Error") { + if (window.location.pathname !== '/error500') { + window.location.href = '/error500'; + } } else { errorMessage = JSON.parse(error.error)['description']; } From 5940c109ac1acaf60a1348d5d69fdf71a343604e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Buczek?= Date: Mon, 3 Feb 2025 19:10:26 +0100 Subject: [PATCH 2/7] fix: #220 fixed priority of image at error pages + error info update --- .../components/error-pages/error404/error404.page.component.ts | 2 +- .../components/error-pages/error500/error500.page.component.ts | 2 +- src/utils/helpers/errorHandler.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/shared/components/error-pages/error404/error404.page.component.ts b/src/app/shared/components/error-pages/error404/error404.page.component.ts index a33f676d..bbb001e7 100644 --- a/src/app/shared/components/error-pages/error404/error404.page.component.ts +++ b/src/app/shared/components/error-pages/error404/error404.page.component.ts @@ -13,7 +13,7 @@ import { Rag2LogoComponent } from '../../common/rag-2-logo.component';
- +

Unfortunately...

diff --git a/src/app/shared/components/error-pages/error500/error500.page.component.ts b/src/app/shared/components/error-pages/error500/error500.page.component.ts index 8d7d9d28..79ee8099 100644 --- a/src/app/shared/components/error-pages/error500/error500.page.component.ts +++ b/src/app/shared/components/error-pages/error500/error500.page.component.ts @@ -13,7 +13,7 @@ import { Rag2LogoComponent } from '../../common/rag-2-logo.component';
- +

Unfortunately...

diff --git a/src/utils/helpers/errorHandler.ts b/src/utils/helpers/errorHandler.ts index 6df12120..b879f26a 100644 --- a/src/utils/helpers/errorHandler.ts +++ b/src/utils/helpers/errorHandler.ts @@ -2,7 +2,6 @@ import { HttpErrorResponse } from '@angular/common/http'; export function errorHandler(error: HttpErrorResponse): string { let errorMessage = 'An error has occured'; - console.info("error", error) if (error.status === 401) { errorMessage = 'Unauthorized, you have to be logged in'; } else if (error.status === 403) { @@ -11,6 +10,7 @@ export function errorHandler(error: HttpErrorResponse): string { if (window.location.pathname !== '/error500') { window.location.href = '/error500'; } + errorMessage = error.message; } else { errorMessage = JSON.parse(error.error)['description']; } From 5c1f1ac85c702bf15fd10fec196c94c666f32d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Buczek?= Date: Mon, 3 Feb 2025 20:04:30 +0100 Subject: [PATCH 3/7] feat: #219 prepared new mode field --- src/app/game/components/console/console.component.ts | 8 ++++++-- src/utils/helpers/errorHandler.ts | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/game/components/console/console.component.ts b/src/app/game/components/console/console.component.ts index a35692c1..76499455 100644 --- a/src/app/game/components/console/console.component.ts +++ b/src/app/game/components/console/console.component.ts @@ -16,7 +16,11 @@ import { ConsoleFieldsetComponent } from './console-fieldset/console-fieldset.co [className]=" consoleClasses['consoleContainer'] + (isConsoleVisible ? ' h-72 py-4' : ' h-0') - "> + "> +
+ External console mode + +
Date: Tue, 4 Feb 2025 19:11:06 +0100 Subject: [PATCH 4/7] feat: #219 opening console's data in new window --- .../components/console/console.component.ts | 61 +++++++++++++------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/src/app/game/components/console/console.component.ts b/src/app/game/components/console/console.component.ts index 76499455..5f43bf16 100644 --- a/src/app/game/components/console/console.component.ts +++ b/src/app/game/components/console/console.component.ts @@ -1,4 +1,4 @@ -import { Component, Input } from '@angular/core'; +import { ApplicationRef, Component, ComponentFactoryResolver, ComponentRef, Injector, Input, OnDestroy } from '@angular/core'; import { TExchangeData } from '@gameModels/exchange-data.type'; import { ExchangeDataPipe } from '@utils/pipes/exchange-data.pipe'; import { ConsoleFieldsetComponent } from './console-fieldset/console-fieldset.component'; @@ -9,40 +9,63 @@ import { ConsoleFieldsetComponent } from './console-fieldset/console-fieldset.co imports: [ExchangeDataPipe, ConsoleFieldsetComponent], template: `
-
-
+ class="relative w-full max-h-96 transition-all ease-in-out duration-700 bg-lightGray overflow-y-scroll z-50 px-5 {{isConsoleVisible ? ' h-72 py-4' : ' h-0'}}"> +
+ + class="items-start gap-y-6 transition-all ease-in-out duration-700 {{isConsoleVisible ? ' p-10' : ' p-0'}}" />
`, }) -export class ConsoleComponent { +export class ConsoleComponent implements OnDestroy{ @Input({ required: true }) public logData: TExchangeData = {}; public isConsoleVisible = false; + + private _newWindow: Window | null = null; + private _componentRef: ComponentRef | null = null; + public constructor( + private _componentFactoryResolver: ComponentFactoryResolver, + private _injector: Injector, + private _appRef: ApplicationRef, + ) {} - public consoleClasses: TExchangeData = { - button: `w-full bg-lightGray tracking-[0.15em] sticky z-50 top-0 transition-all ease-in-out duration-700 border-b-2 - border-mainOrange hover:border-green-500 text-center py-2 uppercase font-bold font-mono text-xl cursor-pointer`, - consoleContainer: `relative w-full max-h-96 transition-all ease-in-out duration-700 bg-lightGray overflow-y-scroll z-50 px-5`, - consoleFieldset: `items-start gap-y-6 transition-all ease-in-out duration-700`, - }; + public ngOnDestroy(): void { + this._newWindow?.close() + } public toggleConsole(): void { this.isConsoleVisible = !this.isConsoleVisible; } + + public externalConsoleMode(): void { + if (this._newWindow && !this._newWindow.closed) { + this._newWindow.focus(); + return; + } + + this._newWindow = window.open('', '_blank', 'width=800,height=600'); + if (this._newWindow) { + this._newWindow.document.body.innerHTML = '
'; + this._newWindow.document.title = 'RAG-2 - External Console Mode'; + + const componentFactory = this._componentFactoryResolver.resolveComponentFactory(ConsoleFieldsetComponent); + this._componentRef = componentFactory.create(this._injector); + + this._componentRef.instance.logData = this.logData; + + this._appRef.attachView(this._componentRef.hostView); + + const hostElement = this._componentRef.location.nativeElement; + this._newWindow.document.getElementById('consoleFieldsetRoot')?.appendChild(hostElement); + } + } } From bc0e0dd79df4082a95eca4ea933bf0150142eca3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Buczek?= Date: Tue, 4 Feb 2025 23:26:38 +0100 Subject: [PATCH 5/7] feat: #219 added styling of external console --- .../console-fieldset.component.ts | 46 +++++++++++++++++-- .../components/console/console.component.ts | 18 +++++++- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/src/app/game/components/console/console-fieldset/console-fieldset.component.ts b/src/app/game/components/console/console-fieldset/console-fieldset.component.ts index c9dad358..1d7f5b99 100644 --- a/src/app/game/components/console/console-fieldset/console-fieldset.component.ts +++ b/src/app/game/components/console/console-fieldset/console-fieldset.component.ts @@ -7,10 +7,50 @@ import { TExchangeData } from '@gameModels/exchange-data.type'; selector: 'app-console-fieldset', standalone: true, imports: [KeyValuePipe, ExchangeDataPipe], + styles: [ + ` + .console-fieldset { + margin-top: 0px; + margin-bottom: 0px; + margin-left: 2rem; + margin-right: 0.5rem; + padding-top: 0.25rem; + padding-bottom: 0.25rem; + padding-left: 0.5rem; + border-left: 1px solid #FF6000; + } + .console-key { + font-weight: 700; + font-size: 1rem; + line-height: 1.5rem; + font-family: monospace; + position: relative; + top: -0.5rem; + } + .console-value { + font-size: 0.875rem; + line-height: 1.25rem; + color: #FFE6C7; + font-family: monospace; + position: relative; + top: -0.5rem; + } + @media (min-width: 1280px) { + .console-value { + font-size: 1rem; + line-height: 1.5rem; + } + .console-key{ + font-size: 1.125rem; + line-height: 1.75rem; + } + } + ` + ], template: ` @for (data of logData | keyvalue; track data.key) { -
- +
+ {{ data.key }}: @@ -18,7 +58,7 @@ import { TExchangeData } from '@gameModels/exchange-data.type'; } @else { - + {{ data.value }} } diff --git a/src/app/game/components/console/console.component.ts b/src/app/game/components/console/console.component.ts index 5f43bf16..2c0afb78 100644 --- a/src/app/game/components/console/console.component.ts +++ b/src/app/game/components/console/console.component.ts @@ -47,16 +47,30 @@ export class ConsoleComponent implements OnDestroy{ } public externalConsoleMode(): void { + this.isConsoleVisible = false; if (this._newWindow && !this._newWindow.closed) { this._newWindow.focus(); return; } - this._newWindow = window.open('', '_blank', 'width=800,height=600'); + this._newWindow = window.open('', '_blank', 'width=1100,height=600'); if (this._newWindow) { - this._newWindow.document.body.innerHTML = '
'; + this._newWindow.document.body.innerHTML = ` +

RAG-2 - External Console Mode

+
+ `; this._newWindow.document.title = 'RAG-2 - External Console Mode'; + const consoleStyles = document.querySelectorAll('style'); + consoleStyles.forEach((style) => { + this._newWindow?.document.head.appendChild(style.cloneNode(true)); + }); + + if (this._newWindow?.document.body) { + this._newWindow.document.body.style.backgroundColor = '#5D5D5D'; + this._newWindow.document.body.style.paddingTop = '1rem'; + } + const componentFactory = this._componentFactoryResolver.resolveComponentFactory(ConsoleFieldsetComponent); this._componentRef = componentFactory.create(this._injector); From 9630746ef19771570c5836b5e5079a97ece5cba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Buczek?= Date: Tue, 4 Feb 2025 23:37:51 +0100 Subject: [PATCH 6/7] feat: #219 external console button changed --- src/app/game/components/console/console.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/game/components/console/console.component.ts b/src/app/game/components/console/console.component.ts index 2c0afb78..05ee1685 100644 --- a/src/app/game/components/console/console.component.ts +++ b/src/app/game/components/console/console.component.ts @@ -15,7 +15,8 @@ import { ConsoleFieldsetComponent } from './console-fieldset/console-fieldset.co
- From 58c932a2f7fad31eb4d26be7fb5cde019bba55e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Buczek?= Date: Tue, 4 Feb 2025 23:41:16 +0100 Subject: [PATCH 7/7] feat: #dev package.json project version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ad52a54..845d484c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rag-2-frontend", - "version": "0.0.0", + "version": "2.1", "scripts": { "ng": "ng", "start": "ng serve",