From 2ecaf2d526f980acc60b7edd83b1569208ce7950 Mon Sep 17 00:00:00 2001 From: Piet Ostendorp Date: Sun, 23 Nov 2025 00:31:31 +0100 Subject: [PATCH] Add smooth scrolling and loading spinner to statistics Introduces smooth scrolling navigation between movie and show statistics sections, updates the header with an icon, and adds loading spinners during data fetch. Also exposes the loading service as public and refactors code for improved readability. --- src/app/statistics/statistics.component.css | 4 + src/app/statistics/statistics.component.html | 138 ++++++++++++------- src/app/statistics/statistics.component.ts | 32 +++-- 3 files changed, 112 insertions(+), 62 deletions(-) diff --git a/src/app/statistics/statistics.component.css b/src/app/statistics/statistics.component.css index 60459a7..a784c2e 100644 --- a/src/app/statistics/statistics.component.css +++ b/src/app/statistics/statistics.component.css @@ -4,3 +4,7 @@ -webkit-background-clip: text; -webkit-text-fill-color: transparent; } + +html { + scroll-behavior: smooth; +} diff --git a/src/app/statistics/statistics.component.html b/src/app/statistics/statistics.component.html index 184d756..b453c6d 100644 --- a/src/app/statistics/statistics.component.html +++ b/src/app/statistics/statistics.component.html @@ -1,9 +1,26 @@ - + -

Movie-Statistiken

+
+

+ Movie-Statistiken +

+ +

+ Show-Statistiken +

+
+ + +
+

+ Movie-Statistiken +

- +
@@ -35,53 +52,76 @@
ID
+ @if (loading.loading$ | async){ +
+ +
+ } + - - -

Show-Statistiken

- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ID{{row.showId}}Kinosaal{{row.showHallName}}Film Name{{row.movieTitle}}Datum{{formatDate(row.showStart)}} - Umsatz - {{(row.earnings/100).toFixed(2)}} € - Gebuchte Tickets - {{row.tickets}}
- +
+

+ Show-Statistiken +

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ID{{row.showId}}Kinosaal{{row.showHallName}}Film Name{{row.movieTitle}}Datum{{formatDate(row.showStart)}} + Umsatz + {{(row.earnings/100).toFixed(2)}} € + Gebuchte Tickets + {{row.tickets}}
+
+ + @if (loading.loading$ | async){ +
+ +
+ } + + +
diff --git a/src/app/statistics/statistics.component.ts b/src/app/statistics/statistics.component.ts index 1745cb4..81b14a0 100644 --- a/src/app/statistics/statistics.component.ts +++ b/src/app/statistics/statistics.component.ts @@ -1,15 +1,11 @@ -import {Component, effect, inject, signal, ViewChild} from '@angular/core'; -import {MatSort, Sort, MatSortModule} from '@angular/material/sort'; -import {HttpService} from '../http.service'; -import { - StatisticsFilm, - StatisticsVorstellung, -} from '@infinimotion/model-frontend'; -import {LoadingService} from '../loading.service'; -import {firstValueFrom} from 'rxjs'; -import {MatTableDataSource} from '@angular/material/table'; -import {MatPaginatorModule} from '@angular/material/paginator'; - +import { Component, inject, signal, ViewChild } from '@angular/core'; +import { MatSort } from '@angular/material/sort'; +import { HttpService } from '../http.service'; +import { StatisticsFilm, StatisticsVorstellung } from '@infinimotion/model-frontend'; +import { LoadingService } from '../loading.service'; +import { firstValueFrom } from 'rxjs'; +import { MatTableDataSource } from '@angular/material/table'; +import { MatPaginatorModule } from '@angular/material/paginator'; @Component({ selector: 'app-statistics', @@ -32,7 +28,7 @@ export class StatisticsComponent { @ViewChild('movieSort') movieSort!: MatSort; @ViewChild('showSort') showSort!: MatSort; - private loading = inject(LoadingService); + public loading = inject(LoadingService); ngOnInit(): void { this.loading.show() @@ -91,4 +87,14 @@ export class StatisticsComponent { } }; } + + scrollTo(id: string) { + const element = document.getElementById(id); + if (element) { + element.scrollIntoView({ behavior: 'smooth', block: 'start' }); + const url = new URL(window.location.href); + url.hash = id; + history.replaceState(null, '', url.toString()); + } + } }