From 8abef8b818358862d6b320572467030b9084cf78 Mon Sep 17 00:00:00 2001 From: Alexis Leroy Date: Thu, 21 Apr 2022 22:48:15 +0200 Subject: [PATCH] disk space viewer --- src/app/core/http/admin-game-http.service.ts | 4 ++-- .../components/game-show/game-show.component.html | 13 +++++++++++++ .../components/game-show/game-show.component.ts | 6 +++++- src/app/modules/admin/modules/games/game.module.ts | 3 ++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/app/core/http/admin-game-http.service.ts b/src/app/core/http/admin-game-http.service.ts index b6b8426..3652950 100644 --- a/src/app/core/http/admin-game-http.service.ts +++ b/src/app/core/http/admin-game-http.service.ts @@ -48,8 +48,8 @@ export class AdminGameHttpService { ) } - get(slug: string): Observable { - return this.http.get(`${this.apiEndpoint}/admin/games/${slug}`) + get(slug: string): Observable<{ game: Game; free: number; size: number }> { + return this.http.get<{ game: Game; free: number; size: number }>(`${this.apiEndpoint}/admin/games/${slug}`) } uploadMusics(slug: string, files: File[]): Observable> { diff --git a/src/app/modules/admin/modules/games/components/game-show/game-show.component.html b/src/app/modules/admin/modules/games/components/game-show/game-show.component.html index 11765af..660197d 100644 --- a/src/app/modules/admin/modules/games/components/game-show/game-show.component.html +++ b/src/app/modules/admin/modules/games/components/game-show/game-show.component.html @@ -6,6 +6,19 @@ +
+
+ {{ ((size - free) / size) * 100 | number: '1.0-2' }}% +
+

{{ game.name }}

diff --git a/src/app/modules/admin/modules/games/components/game-show/game-show.component.ts b/src/app/modules/admin/modules/games/components/game-show/game-show.component.ts index d08b610..7f12bdb 100644 --- a/src/app/modules/admin/modules/games/components/game-show/game-show.component.ts +++ b/src/app/modules/admin/modules/games/components/game-show/game-show.component.ts @@ -21,6 +21,8 @@ export class GameShowComponent implements OnInit { toggleLoading = false toggleErrorMessage: string fileUploadProgress = 0 + free = 0 + size = 0 get musics(): AbstractControl { return this.musicUploadForm.get('musics') @@ -35,7 +37,9 @@ export class GameShowComponent implements OnInit { ngOnInit(): void { this.loading = true this.adminGameHttpService.get(this.route.snapshot.paramMap.get('slug')).subscribe((res) => { - this.game = res + this.game = res.game + this.free = res.free + this.size = res.size this.loading = false }) this.musicUploadForm = this.formBuilder.group({ diff --git a/src/app/modules/admin/modules/games/game.module.ts b/src/app/modules/admin/modules/games/game.module.ts index b01bc28..e2e8655 100644 --- a/src/app/modules/admin/modules/games/game.module.ts +++ b/src/app/modules/admin/modules/games/game.module.ts @@ -10,6 +10,7 @@ import { ImportGameDialogComponent } from './components/game-search/import-game- import { MatProgressBarModule } from '@angular/material/progress-bar' import {InfiniteScrollModule} from "ngx-infinite-scroll"; import {ScrollingModule} from "@angular/cdk/scrolling"; +import {MatTooltipModule} from "@angular/material/tooltip"; const routes: Routes = [ { @@ -29,6 +30,6 @@ const routes: Routes = [ AlternativeNameRowComponent, ImportGameDialogComponent, ], - imports: [CommonModule, RouterModule.forChild(routes), SharedModule, MatProgressBarModule, InfiniteScrollModule, ScrollingModule], + imports: [CommonModule, RouterModule.forChild(routes), SharedModule, MatProgressBarModule, InfiniteScrollModule, ScrollingModule, MatTooltipModule], }) export class GameModule {}