-
-
-
-
-
- | Path |
- {{element.path}} |
-
+ 0 || this.mappedGames.length > 0)" fxFlexFill fxLayoutAlign="center start">
+
+
+
+
+ | Path |
+ {{element.path}} |
+
-
- Game |
- {{element.title}} ({{getFullYearFromTimestamp(element.releaseDate)}}) |
-
+
+ Game |
+ {{element.title}} ({{getFullYearFromTimestamp(element.releaseDate)}}
+ )
+ |
+
-
-
-
- |
-
-
-
-
- |
-
+
+
+
+ |
+
+
+
+
+ |
+
-
-
-
-
+
+
+
+
-
-
-
- | Path |
- {{element.path}} |
-
+
+
+
+ | Path |
+ {{element.path}} |
+
-
-
-
- |
-
-
-
- |
-
+
+
+
+ |
+
+
+
+ |
+
-
-
-
-
-
-
+
+
+
+
+
- lock
+
+ lock
+
Please log in to manage your game library
+
+
+
+
north_east
+
Use the library management to scan your file system for games
+
+
+
+ videogame_asset_off
+
Your game library is empty!
+
+
diff --git a/frontend/src/app/components/library-management/library-management.component.scss b/frontend/src/app/components/library-management/library-management.component.scss
index b2493c2..7df5396 100644
--- a/frontend/src/app/components/library-management/library-management.component.scss
+++ b/frontend/src/app/components/library-management/library-management.component.scss
@@ -1,6 +1,7 @@
@use 'sass:map';
@use '@angular/material' as mat;
-@import '../../theme/default-theme';
+@import 'src/app/theme/default-theme';
+@import 'src/app/components/library-overview/library-overview.component';
td, th {
padding: 16px !important;
diff --git a/frontend/src/app/components/library-overview/library-overview.component.ts b/frontend/src/app/components/library-overview/library-overview.component.ts
index 69af14b..43f54c1 100644
--- a/frontend/src/app/components/library-overview/library-overview.component.ts
+++ b/frontend/src/app/components/library-overview/library-overview.component.ts
@@ -1,4 +1,4 @@
-import {AfterViewInit, Component} from '@angular/core';
+import {AfterContentInit, AfterViewInit, Component} from '@angular/core';
import {GamesService} from "../../services/games.service";
import {DetectedGameDto} from "../../models/dtos/DetectedGameDto";
@@ -7,7 +7,7 @@ import {DetectedGameDto} from "../../models/dtos/DetectedGameDto";
templateUrl: './library-overview.component.html',
styleUrls: ['./library-overview.component.scss']
})
-export class LibraryOverviewComponent implements AfterViewInit {
+export class LibraryOverviewComponent implements AfterContentInit {
detectedGames: DetectedGameDto[] = [];
loading: boolean = true;
@@ -15,7 +15,7 @@ export class LibraryOverviewComponent implements AfterViewInit {
constructor(private gameServerService: GamesService) {
}
- ngAfterViewInit(): void {
+ ngAfterContentInit(): void {
this.gameServerService.getAllGames().subscribe(
(detectedGames: DetectedGameDto[]) => {
this.detectedGames = detectedGames;
diff --git a/frontend/src/app/interceptor/error.interceptor.ts b/frontend/src/app/interceptor/error.interceptor.ts
index 528cfe0..11036b5 100644
--- a/frontend/src/app/interceptor/error.interceptor.ts
+++ b/frontend/src/app/interceptor/error.interceptor.ts
@@ -20,17 +20,15 @@ export class ErrorInterceptor implements HttpInterceptor {
this.dialogService.showErrorDialog(err.error.message);
}
break;
- case 401:
- this.dialogService.showErrorDialog(err.error.message);
- break;
case 409:
case 500:
+ case 401:
+ this.dialogService.showErrorDialog(err.error.message);
this.dialogService.showErrorDialog(err.error.message);
break;
case 503:
case 504:
- this.dialogService.showErrorDialog('Can\'t reach the backend at the moment.\n' +
- 'Please ensure that the backend is running and try again');
+ this.dialogService.showErrorDialog(`Can't reach the backend at the moment.
Please ensure that the backend is running and reload this page`);
break;
}
return throwError(err);
diff --git a/frontend/src/app/services/games.service.ts b/frontend/src/app/services/games.service.ts
index 9a82f53..d0388c5 100644
--- a/frontend/src/app/services/games.service.ts
+++ b/frontend/src/app/services/games.service.ts
@@ -12,14 +12,33 @@ export class GamesService implements GamesApi {
private readonly apiPath = '/games';
+ private cache: Map
= new Map();
+
constructor(private http: HttpClient) {
}
- getAllGames(): Observable {
- return this.http.get(this.apiPath).pipe(map(games => games.sort((g1, g2) => g1.title.localeCompare(g2.title))));
+ getAllGames(forceReloadFromServer: boolean = false): Observable {
+
+ if (this.cache.size === 0 || forceReloadFromServer) {
+ let gamesObservable: Observable = this.http.get(this.apiPath).pipe(map(games => games.sort((g1, g2) => g1.title.localeCompare(g2.title))));
+ gamesObservable.subscribe(g => this.cacheGames(g));
+ return gamesObservable;
+ }
+
+ return new Observable(subscriber => {
+ subscriber.next(Array.from(this.cache.values()));
+ subscriber.complete();
+ });
}
- getGame(slug: String): Observable {
+ getGame(slug: string): Observable {
+ if (this.cache.has(slug)) {
+ return new Observable(subscriber => {
+ subscriber.next(this.cache.get(slug));
+ subscriber.complete();
+ });
+ }
+
return this.http.get(`${this.apiPath}/game/${slug}`);
}
@@ -34,4 +53,9 @@ export class GamesService implements GamesApi {
getAllGameMappings(): Observable