Skip to content

Commit

Permalink
Allow to filter for my scores #33
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik.Sigmund committed Oct 19, 2023
1 parent d6260f3 commit 65309e1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/app/changelog/changelog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Component, OnInit } from '@angular/core';
})
export class ChangelogComponent implements OnInit {
changes = [
"1.0.49;Highscores können nun nach Zeiteinheiten gefiltert werden. Standardmäßig werden nur die Highscores der letzten Woche angezeigt.",
"1.0.51;Highscores können nun nach 'meinen' Highscores gefiltert werden.",
"1.0.50;Highscores können nun nach Zeiteinheiten gefiltert werden. Standardmäßig werden nur die Highscores der letzten Woche angezeigt.",
"1.0.48;Eigene Highscores werden markiert, wenn ein Name eingetragen wurde.",
"1.0.47;Ladebalken wird nun angezeigt, wenn Highscores noch nicht geladen wurden",
"1.0.46;Die Eingabe von Namen wurde auf 20 Zeichen beschränkt;Highscorese können nicht mehr mehrfach abgesendet werden;Leere Namen können nicht mehr eingetragen werden",
Expand Down
2 changes: 2 additions & 0 deletions src/app/highscores/highscores.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<h1>HighScores {{filterName}}</h1>
<button mat-raised-button color="primary" [routerLink]="['/spiel']" class="start-button">Spielen!</button>
<br/>
<mat-slide-toggle [checked]="onlyMyScores" color="primary" (change)="showOnlyMyScores()">Nur meine Scores anzeigen</mat-slide-toggle>
<br/>
<mat-button-toggle-group name="filter" aria-label="Filter" [ngModel]="filter" (ngModelChange)="setFilter($event)">
<mat-button-toggle value="all">Alle</mat-button-toggle>
<mat-button-toggle value="year">Jahr</mat-button-toggle>
Expand Down
3 changes: 2 additions & 1 deletion src/app/highscores/highscores.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ em {
.my-score {
background-color: #f57f0b;
}
mat-button-toggle-group {
mat-button-toggle-group,
mat-slide-toggle {
margin: 10px;
}
10 changes: 10 additions & 0 deletions src/app/highscores/highscores.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class HighscoresComponent implements OnInit {
name: string = '';
filter: String = 'week';
filterName: String = 'der Woche';
onlyMyScores: boolean = false;
constructor(
private backend: BackendService,
private highscoreService: HighscoreService,
Expand All @@ -40,6 +41,15 @@ export class HighscoresComponent implements OnInit {
});
}

showOnlyMyScores() {
this.onlyMyScores = !this.onlyMyScores;
if (this.onlyMyScores) {
this.highscores = this.highscores.filter(score => score.username === this.name);
} else {
this.loadHighscores(this.filter);
}
}

ngOnInit(): void {
this.bgm.theme();
}
Expand Down

0 comments on commit 65309e1

Please sign in to comment.