mirror of
https://github.com/BrenBroZAYT/gameyfin.git
synced 2026-06-15 08:15:37 +00:00
Added detailed library scan result
Small layout fixes in game detail view
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
import {Observable} from "rxjs";
|
||||
import {HttpResponse} from "@angular/common/http";
|
||||
import {LibraryScanResultDto} from "../models/dtos/LibraryScanResultDto";
|
||||
import {ImageDownloadResultDto} from "../models/dtos/ImageDownloadResultDto";
|
||||
|
||||
export interface LibraryApi {
|
||||
scanLibrary(): Observable<HttpResponse<Response>>;
|
||||
downloadImages(): Observable<HttpResponse<Response>>;
|
||||
scanLibrary(): Observable<LibraryScanResultDto>;
|
||||
|
||||
downloadImages(): Observable<ImageDownloadResultDto>;
|
||||
|
||||
getFiles(): Observable<string[]>;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,11 @@
|
||||
<p>{{game.summary}}</p>
|
||||
</div>
|
||||
|
||||
<div *ngIf="game.companies !== undefined && game.companies.length > 0">
|
||||
<div *ngIf="companiesWithLogo.length > 0">
|
||||
<h2>Developed by</h2>
|
||||
<div fxLayout="row wrap" fxLayoutGap="8px grid">
|
||||
<div *ngFor="let company of game.companies">
|
||||
<img *ngIf="company.logoId !== undefined && company.logoId.length > 0" style="height: 52px;"
|
||||
src="v1/images/{{company.logoId}}" alt="{{company.name}}">
|
||||
<span *ngIf="company.logoId.length > 0">{{company.name}}</span>
|
||||
<div *ngFor="let company of companiesWithLogo">
|
||||
<img style="height: 52px;" src="v1/images/{{company.logoId}}" alt="{{company.name}}" [matTooltip]="company.name">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,6 +2,7 @@ import {Component, HostListener} from '@angular/core';
|
||||
import {ActivatedRoute, Params, Router} from "@angular/router";
|
||||
import {DetectedGameDto} from "../../models/dtos/DetectedGameDto";
|
||||
import {GamesService} from "../../services/games.service";
|
||||
import {CompanyDto} from "../../models/dtos/CompanyDto";
|
||||
|
||||
@Component({
|
||||
selector: 'app-game-detail-view',
|
||||
@@ -12,13 +13,20 @@ export class GameDetailViewComponent {
|
||||
|
||||
game!: DetectedGameDto;
|
||||
|
||||
companiesWithLogo: CompanyDto[]= [];
|
||||
|
||||
gridColumnCount: number;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private gamesService: GamesService) {
|
||||
this.gamesService.getGame(this.route.snapshot.params['slug']).subscribe({
|
||||
next: game => this.game = game,
|
||||
next: game => {
|
||||
this.game = game;
|
||||
if(game.companies !== undefined) {
|
||||
this.companiesWithLogo = game.companies.filter(c => c.logoId !== undefined && c.logoId.length > 0);
|
||||
}
|
||||
},
|
||||
error: error => {
|
||||
if (error.status === 404) {
|
||||
this.router.navigate(['/library']);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {LibraryService} from "../../services/library.service";
|
||||
import {MatSnackBar} from '@angular/material/snack-bar';
|
||||
import {timeInterval} from "rxjs";
|
||||
import {Router} from "@angular/router";
|
||||
import {GamesService} from "../../services/games.service";
|
||||
import {ThemingService} from "../../services/theming.service";
|
||||
@@ -26,11 +25,27 @@ export class HeaderComponent {
|
||||
}
|
||||
|
||||
scanLibrary(): void {
|
||||
this.libraryService.scanLibrary().pipe(timeInterval()).subscribe({
|
||||
next: value => {
|
||||
this.libraryService.scanLibrary().subscribe({
|
||||
next: result => {
|
||||
// Refresh the current page "angular style"
|
||||
this.router.navigate([this.router.url]).then(() =>
|
||||
this.snackBar.open(`Library scan completed in ${Math.trunc(value.interval / 1000)} seconds.`, undefined, {duration: 5000})
|
||||
this.router.navigate([this.router.url]).then(() => {
|
||||
const snackBarDuration: number = 10000;
|
||||
|
||||
let snackbarContent: string = 'Library scan completed in ' + result.scanDuration + ' seconds:\n' +
|
||||
'- ' + result.newGames + ' new games\n' +
|
||||
'- ' + result.deletedGames + ' games removed\n' +
|
||||
'- ' + result.newUnmappableFiles + ' files/folders could not be mapped\n' +
|
||||
'- ' + result.totalGames + ' games currently in your library';
|
||||
|
||||
if (result.companyLogoDownloads !== undefined && result.coverDownloads !== undefined && result.screenshotDownloads !== undefined) {
|
||||
snackbarContent = snackbarContent.concat('\n' +
|
||||
'- ' + result.coverDownloads + ' covers downloaded\n' +
|
||||
'- ' + result.screenshotDownloads + ' screenshots downloaded\n' +
|
||||
'- ' + result.companyLogoDownloads + ' company logos downloaded');
|
||||
}
|
||||
|
||||
this.snackBar.open(snackbarContent, undefined, {duration: snackBarDuration});
|
||||
}
|
||||
)
|
||||
},
|
||||
error: error => this.snackBar.open(`Error while scanning library: ${error.error.message}`, undefined, {duration: 5000})
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
export class ImageDownloadResultDto {
|
||||
coverDownloads!: number;
|
||||
screenshotDownloads!: number;
|
||||
companyLogoDownloads!: number;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export class LibraryScanResultDto {
|
||||
newGames!: number;
|
||||
deletedGames!: number;
|
||||
newUnmappableFiles!: number;
|
||||
totalGames!: number;
|
||||
coverDownloads!: number;
|
||||
screenshotDownloads!: number;
|
||||
companyLogoDownloads!: number;
|
||||
scanDuration!: number;
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient, HttpResponse} from "@angular/common/http";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {Observable} from "rxjs";
|
||||
import {LibraryApi} from "../api/LibraryApi";
|
||||
import {LibraryScanResultDto} from "../models/dtos/LibraryScanResultDto";
|
||||
import {ImageDownloadResultDto} from "../models/dtos/ImageDownloadResultDto";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -13,12 +15,12 @@ export class LibraryService implements LibraryApi {
|
||||
constructor(private http: HttpClient) {
|
||||
}
|
||||
|
||||
scanLibrary(): Observable<HttpResponse<Response>> {
|
||||
return this.http.get<HttpResponse<Response>>(`${this.apiPath}/scan`);
|
||||
scanLibrary(): Observable<LibraryScanResultDto> {
|
||||
return this.http.get<LibraryScanResultDto>(`${this.apiPath}/scan`);
|
||||
}
|
||||
|
||||
downloadImages(): Observable<HttpResponse<Response>> {
|
||||
return this.http.get<HttpResponse<Response>>(`${this.apiPath}/download-images`);
|
||||
downloadImages(): Observable<ImageDownloadResultDto> {
|
||||
return this.http.get<ImageDownloadResultDto>(`${this.apiPath}/download-images`);
|
||||
}
|
||||
|
||||
getFiles(): Observable<string[]> {
|
||||
|
||||
Reference in New Issue
Block a user